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

Side by Side Diff: content/renderer/media/rtc_video_decoder.h

Issue 19534002: Make RendererGpuVideoDecoderFactories live on arbitrary threads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 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
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_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_
6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ 6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 18 matching lines...) Expand all
29 }; 29 };
30 30
31 namespace media { 31 namespace media {
32 class DecoderBuffer; 32 class DecoderBuffer;
33 } 33 }
34 34
35 namespace content { 35 namespace content {
36 36
37 // This class uses hardware accelerated video decoder to decode video for 37 // This class uses hardware accelerated video decoder to decode video for
38 // WebRTC. The message loop of RendererGpuVideoDecoderFactories is stored as 38 // WebRTC. The message loop of RendererGpuVideoDecoderFactories is stored as
39 // |vda_message_loop_|. It is the compositor thread, or the renderer thread if 39 // |vda_message_loop_|. VDA::Client methods run on |vda_message_loop_|.
40 // threaded compositing is disabled. VDA::Client methods run on 40 // webrtc::VideoDecoder methods run on WebRTC DecodingThread or
41 // |vda_message_loop_|. webrtc::VideoDecoder methods run on WebRTC 41 // Chrome_libJingle_WorkerThread, which are trampolined to |vda_message_loop_|.
42 // DecodingThread or Chrome_libJingle_WorkerThread, which are trampolined to 42 // Decode() is non-blocking and queues the buffers. Decoded frames are delivered
43 // |vda_message_loop_|. Decode() is non-blocking and queues the buffers. Decoded 43 // on |vda_message_loop_|.
44 // frames are delivered on |vda_message_loop_|.
45 class CONTENT_EXPORT RTCVideoDecoder 44 class CONTENT_EXPORT RTCVideoDecoder
46 : NON_EXPORTED_BASE(public webrtc::VideoDecoder), 45 : NON_EXPORTED_BASE(public webrtc::VideoDecoder),
47 public media::VideoDecodeAccelerator::Client, 46 public media::VideoDecodeAccelerator::Client,
48 public base::MessageLoop::DestructionObserver { 47 public base::MessageLoop::DestructionObserver {
49 public: 48 public:
50 virtual ~RTCVideoDecoder(); 49 virtual ~RTCVideoDecoder();
51 50
52 // Creates a RTCVideoDecoder. Returns NULL if failed. 51 // Creates a RTCVideoDecoder. Returns NULL if failed.
53 static scoped_ptr<RTCVideoDecoder> Create( 52 static scoped_ptr<RTCVideoDecoder> Create(
53 webrtc::VideoCodecType type,
54 const scoped_refptr<media::GpuVideoDecoder::Factories>& factories); 54 const scoped_refptr<media::GpuVideoDecoder::Factories>& factories);
55 55
56 // webrtc::VideoDecoder implementation. 56 // webrtc::VideoDecoder implementation.
57 // Called on WebRTC DecodingThread. 57 // Called on WebRTC DecodingThread.
58 virtual int32_t InitDecode(const webrtc::VideoCodec* codecSettings, 58 virtual int32_t InitDecode(const webrtc::VideoCodec* codecSettings,
59 int32_t numberOfCores) OVERRIDE; 59 int32_t numberOfCores) OVERRIDE;
60 // Called on WebRTC DecodingThread. 60 // Called on WebRTC DecodingThread.
61 virtual int32_t Decode( 61 virtual int32_t Decode(
62 const webrtc::EncodedImage& inputImage, 62 const webrtc::EncodedImage& inputImage,
63 bool missingFrames, 63 bool missingFrames,
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 scoped_refptr<media::VideoFrame> CreateVideoFrame( 140 scoped_refptr<media::VideoFrame> CreateVideoFrame(
141 const media::Picture& picture, 141 const media::Picture& picture,
142 const media::PictureBuffer& pb, 142 const media::PictureBuffer& pb,
143 uint32_t timestamp, 143 uint32_t timestamp,
144 uint32_t width, 144 uint32_t width,
145 uint32_t height, 145 uint32_t height,
146 size_t size); 146 size_t size);
147 147
148 // Resets VDA. 148 // Resets VDA.
149 void ResetInternal(); 149 void ResetInternal();
150 void ReleaseInternal();
150 151
151 // Tells VDA that a picture buffer can be recycled. 152 // Tells VDA that a picture buffer can be recycled.
152 void ReusePictureBuffer(int64 picture_buffer_id, uint32 sync_point); 153 void ReusePictureBuffer(int64 picture_buffer_id, uint32 sync_point);
153 154
154 void DestroyTextures(); 155 void DestroyTextures();
155 void DestroyVDA(); 156 void DestroyVDA();
156 157
157 // Gets a shared-memory segment of at least |min_size| bytes from 158 // Gets a shared-memory segment of at least |min_size| bytes from
158 // |available_shm_segments_|. Returns NULL if there is no buffer or the 159 // |available_shm_segments_|. Returns NULL if there is no buffer or the
159 // buffer is not big enough. 160 // buffer is not big enough.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // The weak pointer should live and die on the |vda_loop_proxy_|; 195 // The weak pointer should live and die on the |vda_loop_proxy_|;
195 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; 196 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_;
196 base::WeakPtr<RTCVideoDecoder> weak_this_; 197 base::WeakPtr<RTCVideoDecoder> weak_this_;
197 198
198 scoped_refptr<media::GpuVideoDecoder::Factories> factories_; 199 scoped_refptr<media::GpuVideoDecoder::Factories> factories_;
199 200
200 // The message loop to run callbacks on. This is should be the same as the one 201 // The message loop to run callbacks on. This is should be the same as the one
201 // of |factories_|. 202 // of |factories_|.
202 scoped_refptr<base::MessageLoopProxy> vda_loop_proxy_; 203 scoped_refptr<base::MessageLoopProxy> vda_loop_proxy_;
203 204
204 // The thread to create shared memory. Factories::CreateSharedMemory is
205 // trampolined to the child thread. When |vda_loop_proxy_| is the compositor
206 // thread, blocking on the child thread will deadlock. During WebRTC hang up,
207 // the child thread waits for Chrome_libJingle_WorkerThread. libJingle thread
208 // cannot finish when DecodingThread holds a WebRTC lock and blocks on the
209 // child thread. So we need to call CreateSharedMemory asynchronously from a
210 // different thread.
211 base::Thread create_shm_thread_;
212
213 // The texture target used for decoded pictures. 205 // The texture target used for decoded pictures.
214 uint32 decoder_texture_target_; 206 uint32 decoder_texture_target_;
215 207
216 // Metadata of the buffers that have been sent for decode. 208 // Metadata of the buffers that have been sent for decode.
217 std::list<BufferData> input_buffer_data_; 209 std::list<BufferData> input_buffer_data_;
218 210
219 // A map from bitstream buffer IDs to bitstream buffers that are being 211 // A map from bitstream buffer IDs to bitstream buffers that are being
220 // processed by VDA. The map owns SHM buffers. 212 // processed by VDA. The map owns SHM buffers.
221 std::map<int32, SHMBuffer*> bitstream_buffers_in_decoder_; 213 std::map<int32, SHMBuffer*> bitstream_buffers_in_decoder_;
222 214
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // A buffer that has an id less than this should be dropped because Reset or 260 // A buffer that has an id less than this should be dropped because Reset or
269 // Release has been called. Guarded by |lock_|. 261 // Release has been called. Guarded by |lock_|.
270 int32 reset_bitstream_buffer_id_; 262 int32 reset_bitstream_buffer_id_;
271 263
272 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); 264 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder);
273 }; 265 };
274 266
275 } // namespace content 267 } // namespace content
276 268
277 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ 269 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698