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_DECRYPTING_VIDEO_DECODER_H_ | 5 #ifndef MEDIA_FILTERS_DECRYPTING_VIDEO_DECODER_H_ |
6 #define MEDIA_FILTERS_DECRYPTING_VIDEO_DECODER_H_ | 6 #define MEDIA_FILTERS_DECRYPTING_VIDEO_DECODER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "media/base/decryptor.h" | 10 #include "media/base/decryptor.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 virtual void Reset(const base::Closure& closure) OVERRIDE; | 58 virtual void Reset(const base::Closure& closure) OVERRIDE; |
59 virtual void Stop(const base::Closure& closure) OVERRIDE; | 59 virtual void Stop(const base::Closure& closure) OVERRIDE; |
60 | 60 |
61 protected: | 61 protected: |
62 virtual ~DecryptingVideoDecoder(); | 62 virtual ~DecryptingVideoDecoder(); |
63 | 63 |
64 private: | 64 private: |
65 // For a detailed state diagram please see this link: http://goo.gl/8jAok | 65 // For a detailed state diagram please see this link: http://goo.gl/8jAok |
66 // TODO(xhwang): Add a ASCII state diagram in this file after this class | 66 // TODO(xhwang): Add a ASCII state diagram in this file after this class |
67 // stabilizes. | 67 // stabilizes. |
68 enum DecoderState { | 68 enum State { |
69 kUninitialized = 0, | 69 kUninitialized = 0, |
70 kDecryptorRequested, | 70 kDecryptorRequested, |
71 kPendingDecoderInit, | 71 kPendingDecoderInit, |
72 kIdle, | 72 kIdle, |
73 kPendingDemuxerRead, | 73 kPendingDemuxerRead, |
74 kPendingDecode, | 74 kPendingDecode, |
75 kWaitingForKey, | 75 kWaitingForKey, |
76 kDecodeFinished, | 76 kDecodeFinished, |
77 kStopped | 77 kStopped |
78 }; | 78 }; |
(...skipping 28 matching lines...) Expand all Loading... |
107 // Callback for Decryptor::DecryptAndDecodeVideo(). | 107 // Callback for Decryptor::DecryptAndDecodeVideo(). |
108 void DeliverFrame(int buffer_size, | 108 void DeliverFrame(int buffer_size, |
109 Decryptor::Status status, | 109 Decryptor::Status status, |
110 const scoped_refptr<VideoFrame>& frame); | 110 const scoped_refptr<VideoFrame>& frame); |
111 | 111 |
112 // Carries out the frame delivery operation scheduled by DeliverFrame(). | 112 // Carries out the frame delivery operation scheduled by DeliverFrame(). |
113 void DoDeliverFrame(int buffer_size, | 113 void DoDeliverFrame(int buffer_size, |
114 Decryptor::Status status, | 114 Decryptor::Status status, |
115 const scoped_refptr<VideoFrame>& frame); | 115 const scoped_refptr<VideoFrame>& frame); |
116 | 116 |
117 // Callback for the |decryptor_| to notify the DecryptingVideoDecoder that | 117 // Callback for the |decryptor_| to notify this object that a new key has been |
118 // a new key has been added. | 118 // added. |
119 void OnKeyAdded(); | 119 void OnKeyAdded(); |
120 | 120 |
121 // Reset decoder and call |reset_cb_|. | 121 // Reset decoder and call |reset_cb_|. |
122 void DoReset(); | 122 void DoReset(); |
123 | 123 |
124 // Free decoder resources and call |stop_cb_|. | 124 // Free decoder resources and call |stop_cb_|. |
125 void DoStop(); | 125 void DoStop(); |
126 | 126 |
127 // This is !is_null() iff Initialize() hasn't been called. | 127 // This is !is_null() iff Initialize() hasn't been called. |
128 MessageLoopFactoryCB message_loop_factory_cb_; | 128 MessageLoopFactoryCB message_loop_factory_cb_; |
129 | 129 |
130 scoped_refptr<base::MessageLoopProxy> message_loop_; | 130 scoped_refptr<base::MessageLoopProxy> message_loop_; |
131 | 131 |
132 // Current state of the DecryptingVideoDecoder. | 132 State state_; |
133 DecoderState state_; | |
134 | 133 |
135 PipelineStatusCB init_cb_; | 134 PipelineStatusCB init_cb_; |
136 StatisticsCB statistics_cb_; | 135 StatisticsCB statistics_cb_; |
137 ReadCB read_cb_; | 136 ReadCB read_cb_; |
138 base::Closure reset_cb_; | 137 base::Closure reset_cb_; |
139 | 138 |
140 // Pointer to the demuxer stream that will feed us compressed buffers. | 139 // Pointer to the demuxer stream that will feed us compressed buffers. |
141 scoped_refptr<DemuxerStream> demuxer_stream_; | 140 scoped_refptr<DemuxerStream> demuxer_stream_; |
142 | 141 |
143 // Callback to request/cancel decryptor creation notification. | 142 // Callback to request/cancel decryptor creation notification. |
144 RequestDecryptorNotificationCB request_decryptor_notification_cb_; | 143 RequestDecryptorNotificationCB request_decryptor_notification_cb_; |
145 | 144 |
146 Decryptor* decryptor_; | 145 Decryptor* decryptor_; |
147 | 146 |
148 // The buffer returned by the demuxer that needs decrypting/decoding. | 147 // The buffer returned by the demuxer that needs decrypting/decoding. |
149 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decode_; | 148 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decode_; |
150 | 149 |
151 // Indicates the situation where new key is added during pending decode | 150 // Indicates the situation where new key is added during pending decode |
152 // (in other words, this variable can only be set in state kPendingDecode). | 151 // (in other words, this variable can only be set in state kPendingDecode). |
153 // If this variable is true and kNoKey is returned then we need to try | 152 // If this variable is true and kNoKey is returned then we need to try |
154 // decrypting/decoding again in case the newly added key is the correct | 153 // decrypting/decoding again in case the newly added key is the correct |
155 // decryption key. | 154 // decryption key. |
156 bool key_added_while_pending_decode_; | 155 bool key_added_while_decode_pending_; |
157 | 156 |
158 // A unique ID to trace Decryptor::DecryptAndDecodeVideo() call and the | 157 // A unique ID to trace Decryptor::DecryptAndDecodeVideo() call and the |
159 // matching DecryptCB call (in DoDeliverFrame()). | 158 // matching DecryptCB call (in DoDeliverFrame()). |
160 uint32 trace_id_; | 159 uint32 trace_id_; |
161 | 160 |
162 DISALLOW_COPY_AND_ASSIGN(DecryptingVideoDecoder); | 161 DISALLOW_COPY_AND_ASSIGN(DecryptingVideoDecoder); |
163 }; | 162 }; |
164 | 163 |
165 } // namespace media | 164 } // namespace media |
166 | 165 |
167 #endif // MEDIA_FILTERS_DECRYPTING_VIDEO_DECODER_H_ | 166 #endif // MEDIA_FILTERS_DECRYPTING_VIDEO_DECODER_H_ |
OLD | NEW |