Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: content/common/gpu/client/gpu_video_encode_accelerator_host.h

Issue 20632002: Add media::VideoEncodeAccelerator with WebRTC integration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: fcfd089c More comments addressed. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_
6 #define CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_
7
8 #include <vector>
9
10 #include "base/containers/hash_tables.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "ipc/ipc_listener.h"
14 #include "media/video/video_encode_accelerator.h"
15
16 namespace gfx {
17
18 class Size;
19
20 } // namespace gfx
21
22 namespace media {
23
24 class VideoFrame;
25
26 } // namespace media
27
28 namespace content {
29
30 class GpuChannelHost;
31
32 // This class is the renderer-side host for the VideoEncodeAccelerator in the
33 // GPU process, coordinated over IPC.
34 class GpuVideoEncodeAcceleratorHost
35 : public IPC::Listener,
36 public media::VideoEncodeAccelerator,
37 public base::SupportsWeakPtr<GpuVideoEncodeAcceleratorHost> {
38 public:
39 // |client| is assumed to outlive this object. Since the GpuChannelHost does
40 // _not_ own this object, a reference to |gpu_channel_host| is taken.
41 GpuVideoEncodeAcceleratorHost(
42 media::VideoEncodeAccelerator::Client* client,
43 const scoped_refptr<GpuChannelHost>& gpu_channel_host,
44 int32 route_id);
45 virtual ~GpuVideoEncodeAcceleratorHost();
46
47 // Static query for the supported profiles. This query proxies to
48 // GpuVideoEncodeAccelerator::GetSupportedProfiles().
49 static std::vector<SupportedProfile> GetSupportedProfiles();
50
51 // IPC::Listener implementation.
52 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
53 virtual void OnChannelError() OVERRIDE;
54
55 // media::VideoEncodeAccelerator implementation.
56 virtual void Initialize(media::VideoFrame::Format format,
57 const gfx::Size& input_visible_size,
58 media::VideoCodecProfile output_profile,
59 int32 initial_bitrate) OVERRIDE;
60 virtual void Encode(const scoped_refptr<media::VideoFrame>& frame,
61 bool force_keyframe) OVERRIDE;
62 virtual void UseOutputBitstreamBuffer(
63 const media::BitstreamBuffer& buffer) OVERRIDE;
64 virtual void RequestEncodingParameterChange(int32 bitrate) OVERRIDE;
65 virtual void Destroy() OVERRIDE;
66
67 private:
68 // IPC handlers, proxying media::VideoEncodeAccelerator::Client for the GPU
69 // process.
70 void OnNotifyInitializeDone();
71 void OnRequireBitstreamBuffers(int input_count,
72 const gfx::Size& input_coded_size,
73 uint32 output_buffer_size);
74 void OnNotifyEncodeDone(int32 frame_id);
75 void OnBitstreamBufferReady(int32 bitstream_buffer_id,
76 uint32 payload_size,
77 bool key_frame);
78 void OnNotifyError(Error error);
79
80 void Send(IPC::Message* message);
81
82 // Unowned pointer to the client.
83 media::VideoEncodeAccelerator::Client* client_;
84
85 // IPC channel and route ID.
86 scoped_refptr<GpuChannelHost> channel_;
87 const int32 route_id_;
88
89 // media::VideoFrames sent to the encoder.
90 // base::IDMap not used here, since that takes pointers, not scoped_refptr.
91 typedef base::hash_map<int32, scoped_refptr<media::VideoFrame> > FrameMap;
92 FrameMap frame_map_;
93
94 // ID serial number for the next frame to send to the GPU process.
95 int32 next_frame_id_;
96
97 DISALLOW_COPY_AND_ASSIGN(GpuVideoEncodeAcceleratorHost);
98 };
99
100 } // namespace content
101
102 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698