diff options
Diffstat (limited to 'chromium/content/renderer/media/rtc_video_decoder.h')
-rw-r--r-- | chromium/content/renderer/media/rtc_video_decoder.h | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/chromium/content/renderer/media/rtc_video_decoder.h b/chromium/content/renderer/media/rtc_video_decoder.h index b0f967ab546..d1a04e5cd9b 100644 --- a/chromium/content/renderer/media/rtc_video_decoder.h +++ b/chromium/content/renderer/media/rtc_video_decoder.h @@ -6,6 +6,7 @@ #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ #include <deque> +#include <list> #include <map> #include <set> #include <utility> @@ -13,9 +14,7 @@ #include "base/basictypes.h" #include "base/gtest_prod_util.h" #include "base/memory/weak_ptr.h" -#include "base/message_loop/message_loop.h" #include "base/synchronization/lock.h" -#include "base/synchronization/waitable_event.h" #include "base/threading/thread.h" #include "content/common/content_export.h" #include "media/base/bitstream_buffer.h" @@ -25,6 +24,7 @@ #include "third_party/webrtc/modules/video_coding/codecs/interface/video_codec_interface.h" namespace base { +class WaitableEvent; class MessageLoopProxy; }; @@ -43,8 +43,7 @@ namespace content { // frames are delivered to WebRTC on |vda_message_loop_|. class CONTENT_EXPORT RTCVideoDecoder : NON_EXPORTED_BASE(public webrtc::VideoDecoder), - public media::VideoDecodeAccelerator::Client, - public base::MessageLoop::DestructionObserver { + public media::VideoDecodeAccelerator::Client { public: virtual ~RTCVideoDecoder(); @@ -76,7 +75,6 @@ class CONTENT_EXPORT RTCVideoDecoder virtual int32_t Reset() OVERRIDE; // VideoDecodeAccelerator::Client implementation. - virtual void NotifyInitializeDone() OVERRIDE; virtual void ProvidePictureBuffers(uint32 count, const gfx::Size& size, uint32 texture_target) OVERRIDE; @@ -87,10 +85,6 @@ class CONTENT_EXPORT RTCVideoDecoder virtual void NotifyResetDone() OVERRIDE; virtual void NotifyError(media::VideoDecodeAccelerator::Error error) OVERRIDE; - // base::DestructionObserver implementation. Called when |vda_message_loop_| - // is stopped. - virtual void WillDestroyCurrentMessageLoop() OVERRIDE; - private: class SHMBuffer; // Metadata of a bitstream buffer. @@ -112,12 +106,9 @@ class CONTENT_EXPORT RTCVideoDecoder FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, IsBufferAfterReset); FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, IsFirstBufferAfterReset); - // The meessage loop of |factories| will be saved to |vda_loop_proxy_|. RTCVideoDecoder( const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories); - void Initialize(base::WaitableEvent* waiter); - // Requests a buffer to be decoded by VDA. void RequestBufferDecode(); @@ -155,8 +146,18 @@ class CONTENT_EXPORT RTCVideoDecoder // Resets VDA. void ResetInternal(); + // Static method is to allow it to run even after RVD is deleted. + static void ReleaseMailbox( + base::WeakPtr<RTCVideoDecoder> decoder, + const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories, + int64 picture_buffer_id, + uint32 texture_id, + const std::vector<uint32>& release_sync_points); // Tells VDA that a picture buffer can be recycled. - void ReusePictureBuffer(int64 picture_buffer_id, uint32 sync_point); + void ReusePictureBuffer(int64 picture_buffer_id); + + // Create |vda_| on |vda_loop_proxy_|. + void CreateVDA(media::VideoCodecProfile profile, base::WaitableEvent* waiter); void DestroyTextures(); void DestroyVDA(); @@ -184,6 +185,9 @@ class CONTENT_EXPORT RTCVideoDecoder // Records the result of InitDecode to UMA and returns |status|. int32_t RecordInitDecodeUMA(int32_t status); + // Assert the contract that this class is operated on the right thread. + void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const; + enum State { UNINITIALIZED, // The decoder has not initialized. INITIALIZED, // The decoder has initialized. @@ -201,14 +205,8 @@ class CONTENT_EXPORT RTCVideoDecoder // The size of the incoming video frames. gfx::Size frame_size_; - // Weak pointer to this, which can be dereferenced only on |vda_loop_proxy_|. - base::WeakPtr<RTCVideoDecoder> weak_this_; - scoped_refptr<media::GpuVideoAcceleratorFactories> factories_; - // The message loop to run callbacks on. This is from |factories_|. - scoped_refptr<base::MessageLoopProxy> vda_loop_proxy_; - // The texture target used for decoded pictures. uint32 decoder_texture_target_; @@ -222,13 +220,12 @@ class CONTENT_EXPORT RTCVideoDecoder // A map from picture buffer IDs to texture-backed picture buffers. std::map<int32, media::PictureBuffer> assigned_picture_buffers_; - // Picture buffers that are dismissed but not deleted yet. - std::map<int32, media::PictureBuffer> dismissed_picture_buffers_; - // PictureBuffers given to us by VDA via PictureReady, which we sent forward // as VideoFrames to be rendered via read_cb_, and which will be returned // to us via ReusePictureBuffer. - std::set<int32> picture_buffers_at_display_; + typedef std::map<int32 /* picture_buffer_id */, uint32 /* texture_id */> + PictureBufferTextureMap; + PictureBufferTextureMap picture_buffers_at_display_; // The id that will be given to the next picture buffer. int32 next_picture_buffer_id_; @@ -268,8 +265,8 @@ class CONTENT_EXPORT RTCVideoDecoder // Release has been called. Guarded by |lock_|. int32 reset_bitstream_buffer_id_; - // Factory used to populate |weak_this_|. Must be destroyed, or invalidated, - // on |vda_loop_proxy_|. + // Must be destroyed, or invalidated, on |vda_loop_proxy_| + // NOTE: Weak pointers must be invalidated before all other member variables. base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); |