| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ | 5 #ifndef MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ |
| 6 #define MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ | 6 #define MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "media/base/video_renderer.h" | 21 #include "media/base/video_renderer.h" |
| 22 #include "media/filters/video_frame_stream.h" | 22 #include "media/filters/video_frame_stream.h" |
| 23 | 23 |
| 24 namespace base { | 24 namespace base { |
| 25 class MessageLoopProxy; | 25 class MessageLoopProxy; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace media { | 28 namespace media { |
| 29 | 29 |
| 30 class DecryptingDemuxerStream; | 30 class DecryptingDemuxerStream; |
| 31 class VideoDecoderSelector; | |
| 32 | 31 |
| 33 // VideoRendererBase creates its own thread for the sole purpose of timing frame | 32 // VideoRendererBase creates its own thread for the sole purpose of timing frame |
| 34 // presentation. It handles reading from the decoder and stores the results in | 33 // presentation. It handles reading from the decoder and stores the results in |
| 35 // a queue of decoded frames and executing a callback when a frame is ready for | 34 // a queue of decoded frames and executing a callback when a frame is ready for |
| 36 // rendering. | 35 // rendering. |
| 37 class MEDIA_EXPORT VideoRendererBase | 36 class MEDIA_EXPORT VideoRendererBase |
| 38 : public VideoRenderer, | 37 : public VideoRenderer, |
| 39 public base::PlatformThread::Delegate { | 38 public base::PlatformThread::Delegate { |
| 40 public: | 39 public: |
| 41 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> PaintCB; | 40 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> PaintCB; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 59 // Setting |drop_frames_| to true causes the renderer to drop expired frames. | 58 // Setting |drop_frames_| to true causes the renderer to drop expired frames. |
| 60 VideoRendererBase(const scoped_refptr<base::MessageLoopProxy>& message_loop, | 59 VideoRendererBase(const scoped_refptr<base::MessageLoopProxy>& message_loop, |
| 61 ScopedVector<VideoDecoder> decoders, | 60 ScopedVector<VideoDecoder> decoders, |
| 62 const SetDecryptorReadyCB& set_decryptor_ready_cb, | 61 const SetDecryptorReadyCB& set_decryptor_ready_cb, |
| 63 const PaintCB& paint_cb, | 62 const PaintCB& paint_cb, |
| 64 const SetOpaqueCB& set_opaque_cb, | 63 const SetOpaqueCB& set_opaque_cb, |
| 65 bool drop_frames); | 64 bool drop_frames); |
| 66 virtual ~VideoRendererBase(); | 65 virtual ~VideoRendererBase(); |
| 67 | 66 |
| 68 // VideoRenderer implementation. | 67 // VideoRenderer implementation. |
| 69 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, | 68 virtual void Initialize(DemuxerStream* stream, |
| 70 const PipelineStatusCB& init_cb, | 69 const PipelineStatusCB& init_cb, |
| 71 const StatisticsCB& statistics_cb, | 70 const StatisticsCB& statistics_cb, |
| 72 const TimeCB& max_time_cb, | 71 const TimeCB& max_time_cb, |
| 73 const NaturalSizeChangedCB& size_changed_cb, | 72 const NaturalSizeChangedCB& size_changed_cb, |
| 74 const base::Closure& ended_cb, | 73 const base::Closure& ended_cb, |
| 75 const PipelineStatusCB& error_cb, | 74 const PipelineStatusCB& error_cb, |
| 76 const TimeDeltaCB& get_time_cb, | 75 const TimeDeltaCB& get_time_cb, |
| 77 const TimeDeltaCB& get_duration_cb) OVERRIDE; | 76 const TimeDeltaCB& get_duration_cb) OVERRIDE; |
| 78 virtual void Play(const base::Closure& callback) OVERRIDE; | 77 virtual void Play(const base::Closure& callback) OVERRIDE; |
| 79 virtual void Pause(const base::Closure& callback) OVERRIDE; | 78 virtual void Pause(const base::Closure& callback) OVERRIDE; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 133 |
| 135 void ResetDecoder(); | 134 void ResetDecoder(); |
| 136 void StopDecoder(const base::Closure& callback); | 135 void StopDecoder(const base::Closure& callback); |
| 137 | 136 |
| 138 void TransitionToPrerolled_Locked(); | 137 void TransitionToPrerolled_Locked(); |
| 139 | 138 |
| 140 scoped_refptr<base::MessageLoopProxy> message_loop_; | 139 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 141 base::WeakPtrFactory<VideoRendererBase> weak_factory_; | 140 base::WeakPtrFactory<VideoRendererBase> weak_factory_; |
| 142 base::WeakPtr<VideoRendererBase> weak_this_; | 141 base::WeakPtr<VideoRendererBase> weak_this_; |
| 143 | 142 |
| 144 scoped_ptr<VideoDecoderSelector> decoder_selector_; | |
| 145 | |
| 146 // Used for accessing data members. | 143 // Used for accessing data members. |
| 147 base::Lock lock_; | 144 base::Lock lock_; |
| 148 | 145 |
| 149 // Provides video frames to VideoRendererBase. | 146 // Provides video frames to VideoRendererBase. |
| 150 scoped_refptr<VideoFrameStream> video_frame_stream_; | 147 VideoFrameStream video_frame_stream_; |
| 151 | 148 |
| 152 // Queue of incoming frames yet to be painted. | 149 // Queue of incoming frames yet to be painted. |
| 153 typedef std::deque<scoped_refptr<VideoFrame> > VideoFrameQueue; | 150 typedef std::deque<scoped_refptr<VideoFrame> > VideoFrameQueue; |
| 154 VideoFrameQueue ready_frames_; | 151 VideoFrameQueue ready_frames_; |
| 155 | 152 |
| 156 // Keeps track of whether we received the end of stream buffer. | 153 // Keeps track of whether we received the end of stream buffer. |
| 157 bool received_end_of_stream_; | 154 bool received_end_of_stream_; |
| 158 | 155 |
| 159 // Used to signal |thread_| as frames are added to |frames_|. Rule of thumb: | 156 // Used to signal |thread_| as frames are added to |frames_|. Rule of thumb: |
| 160 // always check |state_| to see if it was set to STOPPED after waking up! | 157 // always check |state_| to see if it was set to STOPPED after waking up! |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 // either for calling |paint_cb_| or for dropping. Set to kNoTimestamp() | 244 // either for calling |paint_cb_| or for dropping. Set to kNoTimestamp() |
| 248 // during flushing. | 245 // during flushing. |
| 249 base::TimeDelta last_timestamp_; | 246 base::TimeDelta last_timestamp_; |
| 250 | 247 |
| 251 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); | 248 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); |
| 252 }; | 249 }; |
| 253 | 250 |
| 254 } // namespace media | 251 } // namespace media |
| 255 | 252 |
| 256 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ | 253 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ |
| OLD | NEW |