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

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

Issue 170843004: Pass Client pointer in Initialize() for VDA/VEA (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 50e826de Rebase. Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_ 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_
6 #define CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_ 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 18 matching lines...) Expand all
29 29
30 class GpuChannelHost; 30 class GpuChannelHost;
31 31
32 // This class is the renderer-side host for the VideoEncodeAccelerator in the 32 // This class is the renderer-side host for the VideoEncodeAccelerator in the
33 // GPU process, coordinated over IPC. 33 // GPU process, coordinated over IPC.
34 class GpuVideoEncodeAcceleratorHost 34 class GpuVideoEncodeAcceleratorHost
35 : public IPC::Listener, 35 : public IPC::Listener,
36 public media::VideoEncodeAccelerator, 36 public media::VideoEncodeAccelerator,
37 public base::SupportsWeakPtr<GpuVideoEncodeAcceleratorHost> { 37 public base::SupportsWeakPtr<GpuVideoEncodeAcceleratorHost> {
38 public: 38 public:
39 // |client| is assumed to outlive this object. Since the GpuChannelHost does 39 // Since the GpuChannelHost does _not_ own this object, a reference to
40 // _not_ own this object, a reference to |gpu_channel_host| is taken. 40 // |gpu_channel_host| is taken.
41 GpuVideoEncodeAcceleratorHost( 41 GpuVideoEncodeAcceleratorHost(
42 media::VideoEncodeAccelerator::Client* client,
43 const scoped_refptr<GpuChannelHost>& gpu_channel_host, 42 const scoped_refptr<GpuChannelHost>& gpu_channel_host,
44 int32 route_id); 43 int32 route_id);
45 virtual ~GpuVideoEncodeAcceleratorHost(); 44 virtual ~GpuVideoEncodeAcceleratorHost();
46 45
47 // Static query for the supported profiles. This query proxies to 46 // Static query for the supported profiles. This query proxies to
48 // GpuVideoEncodeAccelerator::GetSupportedProfiles(). 47 // GpuVideoEncodeAccelerator::GetSupportedProfiles().
49 static std::vector<SupportedProfile> GetSupportedProfiles(); 48 static std::vector<SupportedProfile> GetSupportedProfiles();
50 49
51 // IPC::Listener implementation. 50 // IPC::Listener implementation.
52 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 51 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
53 virtual void OnChannelError() OVERRIDE; 52 virtual void OnChannelError() OVERRIDE;
54 53
55 // media::VideoEncodeAccelerator implementation. 54 // media::VideoEncodeAccelerator implementation.
56 virtual void Initialize(media::VideoFrame::Format format, 55 virtual void Initialize(media::VideoFrame::Format format,
57 const gfx::Size& input_visible_size, 56 const gfx::Size& input_visible_size,
58 media::VideoCodecProfile output_profile, 57 media::VideoCodecProfile output_profile,
59 uint32 initial_bitrate) OVERRIDE; 58 uint32 initial_bitrate,
59 Client* client) OVERRIDE;
60 virtual void Encode(const scoped_refptr<media::VideoFrame>& frame, 60 virtual void Encode(const scoped_refptr<media::VideoFrame>& frame,
61 bool force_keyframe) OVERRIDE; 61 bool force_keyframe) OVERRIDE;
62 virtual void UseOutputBitstreamBuffer( 62 virtual void UseOutputBitstreamBuffer(
63 const media::BitstreamBuffer& buffer) OVERRIDE; 63 const media::BitstreamBuffer& buffer) OVERRIDE;
64 virtual void RequestEncodingParametersChange(uint32 bitrate, 64 virtual void RequestEncodingParametersChange(uint32 bitrate,
65 uint32 framerate_num) OVERRIDE; 65 uint32 framerate_num) OVERRIDE;
66 virtual void Destroy() OVERRIDE; 66 virtual void Destroy() OVERRIDE;
67 67
68 private: 68 private:
69 // Notify |client_| when an error has occured. Used when notifying from 69 // Notify |client_| when an error has occured. Used when notifying from
70 // within a media::VideoEncodeAccelerator entry point, to avoid re-entrancy. 70 // within a media::VideoEncodeAccelerator entry point, to avoid re-entrancy.
71 void NotifyError(Error error); 71 void NotifyError(Error error);
72 72
73 // IPC handlers, proxying media::VideoEncodeAccelerator::Client for the GPU 73 // IPC handlers, proxying media::VideoEncodeAccelerator::Client for the GPU
74 // process. 74 // process.
75 void OnNotifyInitializeDone(); 75 void OnNotifyInitializeDone();
76 void OnRequireBitstreamBuffers(uint32 input_count, 76 void OnRequireBitstreamBuffers(uint32 input_count,
77 const gfx::Size& input_coded_size, 77 const gfx::Size& input_coded_size,
78 uint32 output_buffer_size); 78 uint32 output_buffer_size);
79 void OnNotifyInputDone(int32 frame_id); 79 void OnNotifyInputDone(int32 frame_id);
80 void OnBitstreamBufferReady(int32 bitstream_buffer_id, 80 void OnBitstreamBufferReady(int32 bitstream_buffer_id,
81 uint32 payload_size, 81 uint32 payload_size,
82 bool key_frame); 82 bool key_frame);
83 void OnNotifyError(Error error); 83 void OnNotifyError(Error error);
84 84
85 void Send(IPC::Message* message); 85 void Send(IPC::Message* message);
86 86
87 // Weak pointer for client callbacks on the 87 // Pointer for client callbacks on the media::VideoEncodeAccelerator::Client
88 // media::VideoEncodeAccelerator::Client interface. 88 // interface.
89 media::VideoEncodeAccelerator::Client* client_; 89 Client* client_;
90 // |client_ptr_factory_| is used for callbacks that need to be done through 90 // |client_ptr_factory_| is used for callbacks that need to be done through
91 // a PostTask() to avoid re-entrancy on the client. 91 // a PostTask() to avoid re-entrancy on the client.
92 base::WeakPtrFactory<VideoEncodeAccelerator::Client> client_ptr_factory_; 92 scoped_ptr<base::WeakPtrFactory<Client> > client_ptr_factory_;
93 93
94 // IPC channel and route ID. 94 // IPC channel and route ID.
95 scoped_refptr<GpuChannelHost> channel_; 95 scoped_refptr<GpuChannelHost> channel_;
96 const int32 route_id_; 96 const int32 route_id_;
97 97
98 // media::VideoFrames sent to the encoder. 98 // media::VideoFrames sent to the encoder.
99 // base::IDMap not used here, since that takes pointers, not scoped_refptr. 99 // base::IDMap not used here, since that takes pointers, not scoped_refptr.
100 typedef base::hash_map<int32, scoped_refptr<media::VideoFrame> > FrameMap; 100 typedef base::hash_map<int32, scoped_refptr<media::VideoFrame> > FrameMap;
101 FrameMap frame_map_; 101 FrameMap frame_map_;
102 102
103 // ID serial number for the next frame to send to the GPU process. 103 // ID serial number for the next frame to send to the GPU process.
104 int32 next_frame_id_; 104 int32 next_frame_id_;
105 105
106 DISALLOW_COPY_AND_ASSIGN(GpuVideoEncodeAcceleratorHost); 106 DISALLOW_COPY_AND_ASSIGN(GpuVideoEncodeAcceleratorHost);
107 }; 107 };
108 108
109 } // namespace content 109 } // namespace content
110 110
111 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_ 111 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_ENCODE_ACCELERATOR_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698