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" |
(...skipping 21 matching lines...) Expand all Loading... |
32 // Wraps a DemuxerStream and a list of VideoDecoders and provides decoded | 32 // Wraps a DemuxerStream and a list of VideoDecoders and provides decoded |
33 // VideoFrames to its client (e.g. VideoRendererBase). | 33 // VideoFrames to its client (e.g. VideoRendererBase). |
34 class MEDIA_EXPORT VideoFrameStream : public DemuxerStream { | 34 class MEDIA_EXPORT VideoFrameStream : public DemuxerStream { |
35 public: | 35 public: |
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 ScopedVector<VideoDecoder> decoders, |
41 const SetDecryptorReadyCB& set_decryptor_ready_cb); | 41 const SetDecryptorReadyCB& set_decryptor_ready_cb); |
| 42 virtual ~VideoFrameStream(); |
42 | 43 |
43 // Initializes the VideoFrameStream and returns the initialization result | 44 // Initializes the VideoFrameStream and returns the initialization result |
44 // through |init_cb|. Note that |init_cb| is always called asynchronously. | 45 // through |init_cb|. Note that |init_cb| is always called asynchronously. |
45 void Initialize(const scoped_refptr<DemuxerStream>& stream, | 46 void Initialize(DemuxerStream* stream, |
46 const StatisticsCB& statistics_cb, | 47 const StatisticsCB& statistics_cb, |
47 const InitCB& init_cb); | 48 const InitCB& init_cb); |
48 | 49 |
49 // Reads a decoded VideoFrame and returns it via the |read_cb|. Note that | 50 // 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 | 51 // |read_cb| is always called asynchronously. This method should only be |
51 // called after initialization has succeeded and must not be called during | 52 // called after initialization has succeeded and must not be called during |
52 // any pending Reset() and/or Stop(). | 53 // any pending Reset() and/or Stop(). |
53 void ReadFrame(const VideoDecoder::ReadCB& read_cb); | 54 void ReadFrame(const VideoDecoder::ReadCB& read_cb); |
54 | 55 |
55 // Resets the decoder, flushes all decoded frames and/or internal buffers, | 56 // Resets the decoder, flushes all decoded frames and/or internal buffers, |
(...skipping 14 matching lines...) Expand all Loading... |
70 // a VideoFrame. | 71 // a VideoFrame. |
71 bool HasOutputFrameAvailable() const; | 72 bool HasOutputFrameAvailable() const; |
72 | 73 |
73 // DemuxerStream implementation. | 74 // DemuxerStream implementation. |
74 virtual void Read(const ReadCB& read_cb) OVERRIDE; | 75 virtual void Read(const ReadCB& read_cb) OVERRIDE; |
75 virtual const AudioDecoderConfig& audio_decoder_config() OVERRIDE; | 76 virtual const AudioDecoderConfig& audio_decoder_config() OVERRIDE; |
76 virtual const VideoDecoderConfig& video_decoder_config() OVERRIDE; | 77 virtual const VideoDecoderConfig& video_decoder_config() OVERRIDE; |
77 virtual Type type() OVERRIDE; | 78 virtual Type type() OVERRIDE; |
78 virtual void EnableBitstreamConverter() OVERRIDE; | 79 virtual void EnableBitstreamConverter() OVERRIDE; |
79 | 80 |
80 protected: | |
81 virtual ~VideoFrameStream(); | |
82 | |
83 private: | 81 private: |
84 enum State { | 82 enum State { |
85 UNINITIALIZED, | 83 UNINITIALIZED, |
86 NORMAL, | 84 NORMAL, |
87 STOPPED | 85 STOPPED |
88 }; | 86 }; |
89 | 87 |
90 // Called when |decoder_selector_| selected the |selected_decoder|. | 88 // Called when |decoder_selector_| selected the |selected_decoder|. |
91 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream | 89 // |decrypting_demuxer_stream| was also populated if a DecryptingDemuxerStream |
92 // is created to help decrypt the encrypted stream. | 90 // is created to help decrypt the encrypted stream. |
93 void OnDecoderSelected( | 91 void OnDecoderSelected( |
94 scoped_ptr<VideoDecoder> selected_decoder, | 92 scoped_ptr<VideoDecoder> selected_decoder, |
95 const scoped_refptr<DecryptingDemuxerStream>& decrypting_demuxer_stream); | 93 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream); |
96 | 94 |
97 // Callback for VideoDecoder::Read(). | 95 // Callback for VideoDecoder::Read(). |
98 void OnFrameRead(const VideoDecoder::Status status, | 96 void OnFrameRead(const VideoDecoder::Status status, |
99 const scoped_refptr<VideoFrame>& frame); | 97 const scoped_refptr<VideoFrame>& frame); |
100 | 98 |
101 void ResetDecoder(); | 99 void ResetDecoder(); |
102 void OnDecoderReset(); | 100 void OnDecoderReset(); |
103 | 101 |
104 void StopDecoder(); | 102 void StopDecoder(); |
105 void OnDecoderStopped(); | 103 void OnDecoderStopped(); |
106 | 104 |
107 scoped_refptr<base::MessageLoopProxy> message_loop_; | 105 scoped_refptr<base::MessageLoopProxy> message_loop_; |
108 base::WeakPtrFactory<VideoFrameStream> weak_factory_; | 106 base::WeakPtrFactory<VideoFrameStream> weak_factory_; |
109 base::WeakPtr<VideoFrameStream> weak_this_; | 107 base::WeakPtr<VideoFrameStream> weak_this_; |
110 | 108 |
111 State state_; | 109 State state_; |
112 | 110 |
113 InitCB init_cb_; | 111 InitCB init_cb_; |
114 VideoDecoder::ReadCB read_cb_; | 112 VideoDecoder::ReadCB read_cb_; |
115 base::Closure reset_cb_; | 113 base::Closure reset_cb_; |
116 base::Closure stop_cb_; | 114 base::Closure stop_cb_; |
117 | 115 |
118 VideoDecoderSelector decoder_selector_; | 116 VideoDecoderSelector decoder_selector_; |
119 | 117 |
120 scoped_refptr<DemuxerStream> stream_; | 118 DemuxerStream* stream_; |
121 | 119 |
122 // These two will be set by VideoDecoderSelector::SelectVideoDecoder(). | 120 // These two will be set by VideoDecoderSelector::SelectVideoDecoder(). |
123 scoped_ptr<VideoDecoder> decoder_; | 121 scoped_ptr<VideoDecoder> decoder_; |
124 scoped_refptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; | 122 scoped_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream_; |
125 | 123 |
126 DISALLOW_COPY_AND_ASSIGN(VideoFrameStream); | 124 DISALLOW_COPY_AND_ASSIGN(VideoFrameStream); |
127 }; | 125 }; |
128 | 126 |
129 } // namespace media | 127 } // namespace media |
130 | 128 |
131 #endif // MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_ | 129 #endif // MEDIA_FILTERS_VIDEO_FRAME_STREAM_H_ |
OLD | NEW |