OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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_FRAME_STREAM_H_ | 5 #ifndef MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_ |
6 #define MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_ | 6 #define MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_vector.h" |
14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
15 #include "media/base/decryptor.h" | 16 #include "media/base/decryptor.h" |
16 #include "media/base/demuxer_stream.h" | 17 #include "media/base/demuxer_stream.h" |
17 #include "media/base/media_export.h" | 18 #include "media/base/media_export.h" |
18 #include "media/base/pipeline_status.h" | 19 #include "media/base/pipeline_status.h" |
19 #include "media/base/video_decoder.h" | 20 #include "media/base/video_decoder.h" |
| 21 #include "media/filters/video_decoder_selector.h" |
20 | 22 |
21 namespace base { | 23 namespace base { |
22 class MessageLoopProxy; | 24 class MessageLoopProxy; |
23 } | 25 } |
24 | 26 |
25 namespace media { | 27 namespace media { |
26 | 28 |
27 class DecryptingDemuxerStream; | 29 class DecryptingDemuxerStream; |
28 class VideoDecoderSelector; | 30 class VideoDecoderSelector; |
29 | 31 |
30 // Wraps a DemuxerStream and a list of VideoDecoders and provides decoded | 32 // Wraps a DemuxerStream and a list of VideoDecoders and provides decoded |
31 // VideoFrames to its client (e.g. VideoRendererBase). | 33 // VideoFrames to its client (e.g. VideoRendererBase). |
32 class MEDIA_EXPORT VideoFrameStream : public DemuxerStream { | 34 class MEDIA_EXPORT VideoFrameStream : public DemuxerStream { |
33 public: | 35 public: |
34 typedef std::list<scoped_refptr<VideoDecoder> > VideoDecoderList; | |
35 | |
36 // Indicates completion of VideoFrameStream initialization. | 36 // Indicates completion of VideoFrameStream initialization. |
37 typedef base::Callback<void(bool success, bool has_alpha)> InitCB; | 37 typedef base::Callback<void(bool success, bool has_alpha)> InitCB; |
38 | 38 |
39 VideoFrameStream(const scoped_refptr<base::MessageLoopProxy>& message_loop, | 39 VideoFrameStream(const scoped_refptr<base::MessageLoopProxy>& message_loop, |
| 40 ScopedVector<VideoDecoder> decoders, |
40 const SetDecryptorReadyCB& set_decryptor_ready_cb); | 41 const SetDecryptorReadyCB& set_decryptor_ready_cb); |
41 | 42 |
42 // Initializes the VideoFrameStream and returns the initialization result | 43 // Initializes the VideoFrameStream and returns the initialization result |
43 // through |init_cb|. Note that |init_cb| is always called asynchronously. | 44 // through |init_cb|. Note that |init_cb| is always called asynchronously. |
44 void Initialize(const scoped_refptr<DemuxerStream>& stream, | 45 void Initialize(const scoped_refptr<DemuxerStream>& stream, |
45 const VideoDecoderList& decoders, | |
46 const StatisticsCB& statistics_cb, | 46 const StatisticsCB& statistics_cb, |
47 const InitCB& init_cb); | 47 const InitCB& init_cb); |
48 | 48 |
49 // Reads a decoded VideoFrame and returns it via the |read_cb|. Note that | 49 // Reads a decoded VideoFrame and returns it via the |read_cb|. Note that |
50 // |read_cb| is always called asynchronously. This method should only be | 50 // |read_cb| is always called asynchronously. This method should only be |
51 // called after initialization has succeeded and must not be called during | 51 // called after initialization has succeeded and must not be called during |
52 // any pending Reset() and/or Stop(). | 52 // any pending Reset() and/or Stop(). |
53 void ReadFrame(const VideoDecoder::ReadCB& read_cb); | 53 void ReadFrame(const VideoDecoder::ReadCB& read_cb); |
54 | 54 |
55 // Resets the decoder, flushes all decoded frames and/or internal buffers, | 55 // Resets the decoder, flushes all decoded frames and/or internal buffers, |
(...skipping 27 matching lines...) Expand all Loading... |
83 private: | 83 private: |
84 enum State { | 84 enum State { |
85 UNINITIALIZED, | 85 UNINITIALIZED, |
86 NORMAL, | 86 NORMAL, |
87 STOPPED | 87 STOPPED |
88 }; | 88 }; |
89 | 89 |
90 // Called when |decoder_selector_| selected the |selected_decoder|. | 90 // Called when |decoder_selector_| selected the |selected_decoder|. |
91 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream | 91 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream |
92 // is created to help decrypt the encrypted stream. | 92 // is created to help decrypt the encrypted stream. |
93 // Note: |decoder_selector| is passed here to keep the VideoDecoderSelector | |
94 // alive until OnDecoderSelected() finishes. | |
95 void OnDecoderSelected( | 93 void OnDecoderSelected( |
96 scoped_ptr<VideoDecoderSelector> decoder_selector, | 94 scoped_ptr<VideoDecoder> selected_decoder, |
97 const scoped_refptr<VideoDecoder>& selected_decoder, | |
98 const scoped_refptr<DecryptingDemuxerStream>& decrypting_demuxer_stream); | 95 const scoped_refptr<DecryptingDemuxerStream>& decrypting_demuxer_stream); |
99 | 96 |
100 // Callback for VideoDecoder::Read(). | 97 // Callback for VideoDecoder::Read(). |
101 void OnFrameRead(const VideoDecoder::Status status, | 98 void OnFrameRead(const VideoDecoder::Status status, |
102 const scoped_refptr<VideoFrame>& frame); | 99 const scoped_refptr<VideoFrame>& frame); |
103 | 100 |
104 void ResetDecoder(); | 101 void ResetDecoder(); |
105 void OnDecoderReset(); | 102 void OnDecoderReset(); |
106 | 103 |
107 void StopDecoder(); | 104 void StopDecoder(); |
108 void OnDecoderStopped(); | 105 void OnDecoderStopped(); |
109 | 106 |
110 scoped_refptr<base::MessageLoopProxy> message_loop_; | 107 scoped_refptr<base::MessageLoopProxy> message_loop_; |
111 base::WeakPtrFactory<VideoFrameStream> weak_factory_; | 108 base::WeakPtrFactory<VideoFrameStream> weak_factory_; |
112 base::WeakPtr<VideoFrameStream> weak_this_; | 109 base::WeakPtr<VideoFrameStream> weak_this_; |
113 | 110 |
114 State state_; | 111 State state_; |
115 | 112 |
116 InitCB init_cb_; | 113 InitCB init_cb_; |
117 VideoDecoder::ReadCB read_cb_; | 114 VideoDecoder::ReadCB read_cb_; |
118 base::Closure reset_cb_; | 115 base::Closure reset_cb_; |
119 base::Closure stop_cb_; | 116 base::Closure stop_cb_; |
120 | 117 |
121 SetDecryptorReadyCB set_decryptor_ready_cb_; | 118 VideoDecoderSelector decoder_selector_; |
122 | 119 |
123 scoped_refptr<DemuxerStream> stream_; | 120 scoped_refptr<DemuxerStream> stream_; |
124 | 121 |
125 // These two will be set by VideoDecoderSelector::SelectVideoDecoder(). | 122 // These two will be set by VideoDecoderSelector::SelectVideoDecoder(). |
126 scoped_refptr<VideoDecoder> decoder_; | 123 scoped_ptr<VideoDecoder> decoder_; |
127 scoped_refptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; | 124 scoped_refptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; |
128 | 125 |
129 DISALLOW_COPY_AND_ASSIGN(VideoFrameStream); | 126 DISALLOW_COPY_AND_ASSIGN(VideoFrameStream); |
130 }; | 127 }; |
131 | 128 |
132 } // namespace media | 129 } // namespace media |
133 | 130 |
134 #endif // MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_ | 131 #endif // MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_ |
OLD | NEW |