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

Side by Side Diff: content/common/gpu/media/gpu_video_encode_accelerator.h

Issue 20632002: Add media::VideoEncodeAccelerator with WebRTC integration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: 9e8f21a0 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_MEDIA_GPU_VIDEO_ENCODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_ENCODE_ACCELERATOR_H_
7
8 #include <vector>
9
10 #include "base/memory/scoped_ptr.h"
11 #include "ipc/ipc_listener.h"
12 #include "media/video/video_encode_accelerator.h"
13 #include "ui/gfx/size.h"
14
15 namespace base {
16
17 class SharedMemory;
18
19 } // namespace base
20
21 namespace content {
22
23 class GpuChannel;
24
25 // This class encapsulates the GPU process view of a VideoEncodeAccelerator,
26 // wrapping the platform-specific VideoEncodeAccelerator instance. It handles
27 // IPC coming in from the renderer and passes it to the underlying VEA.
28 class GpuVideoEncodeAccelerator : public IPC::Listener,
29 public media::VideoEncodeAccelerator::Client {
30 public:
31 GpuVideoEncodeAccelerator(GpuChannel* gpu_channel, int32 route_id);
32 virtual ~GpuVideoEncodeAccelerator();
33
34 // IPC::Listener implementation
35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
36 virtual void OnChannelError() OVERRIDE;
37
38 // media::VideoEncodeAccelerator::Client implementation.
39 virtual void NotifyInitializeDone() OVERRIDE;
40 virtual void RequireBitstreamBuffers(int input_count,
41 const gfx::Size& input_coded_size,
42 size_t output_buffer_size) OVERRIDE;
43 virtual void NotifyInputDone(int32 bitstream_buffer_id) OVERRIDE;
44 virtual void BitstreamBufferReady(int32 bitstream_buffer_id,
45 size_t payload_size,
46 bool key_frame) OVERRIDE;
47 virtual void NotifyError(media::VideoEncodeAccelerator::Error error) OVERRIDE;
48
49 // Static query for supported profiles. This query calls the appropriate
50 // platform-specific version.
51 static std::vector<media::VideoEncodeAccelerator::SupportedProfile>
52 GetSupportedProfiles();
53
54 private:
55 // Create the appropriate platform-specific VEA.
56 void CreateEncoder();
57
58 // IPC handlers, proxying media::VideoEncodeAccelerator for the renderer
59 // process.
60 void OnInitialize(media::VideoFrame::Format input_format,
61 const gfx::Size& input_visible_size,
62 media::VideoCodecProfile output_profile,
63 int32 initial_bitrate);
64 void OnEncode(int32 frame_id,
65 base::SharedMemoryHandle buffer_handle,
66 uint32 buffer_size,
67 bool force_keyframe);
68 void OnUseOutputBitstreamBuffer(int32 buffer_id,
69 base::SharedMemoryHandle buffer_handle,
70 uint32 buffer_size);
71 void OnRequestEncodingParameterChange(int32 bitrate);
72
73 void Send(IPC::Message* message);
74
75 void EncodeFrameFinished(scoped_ptr<base::SharedMemory> shm);
76
77 // The GpuChannel owns this GpuVideoEncodeAccelerator and will outlive |this|.
78 GpuChannel* channel_;
79 const int32 route_id_;
80
81 // Owned pointer to the underlying VideoEncodeAccelerator.
82 scoped_ptr<media::VideoEncodeAccelerator> encoder_;
83
84 // Video encoding parameters.
85 media::VideoFrame::Format input_format_;
86 gfx::Size input_visible_size_;
87 gfx::Size input_coded_size_;
88 size_t output_buffer_size_;
89
90 DISALLOW_COPY_AND_ASSIGN(GpuVideoEncodeAccelerator);
91 };
92
93 } // namespace content
94
95 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_ENCODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698