| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 DecryptingVideoDecoder( | 34 DecryptingVideoDecoder( |
| 35 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 35 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 36 const scoped_refptr<MediaLog>& media_log, | 36 const scoped_refptr<MediaLog>& media_log, |
| 37 const base::Closure& waiting_for_decryption_key_cb); | 37 const base::Closure& waiting_for_decryption_key_cb); |
| 38 ~DecryptingVideoDecoder() override; | 38 ~DecryptingVideoDecoder() override; |
| 39 | 39 |
| 40 // VideoDecoder implementation. | 40 // VideoDecoder implementation. |
| 41 std::string GetDisplayName() const override; | 41 std::string GetDisplayName() const override; |
| 42 void Initialize(const VideoDecoderConfig& config, | 42 void Initialize(const VideoDecoderConfig& config, |
| 43 bool low_delay, | 43 bool low_delay, |
| 44 const SetCdmReadyCB& set_cdm_ready_cb, | 44 CdmContext* cdm_context, |
| 45 const InitCB& init_cb, | 45 const InitCB& init_cb, |
| 46 const OutputCB& output_cb) override; | 46 const OutputCB& output_cb) override; |
| 47 void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 47 void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| 48 const DecodeCB& decode_cb) override; | 48 const DecodeCB& decode_cb) override; |
| 49 void Reset(const base::Closure& closure) override; | 49 void Reset(const base::Closure& closure) override; |
| 50 | 50 |
| 51 static const char kDecoderName[]; | 51 static const char kDecoderName[]; |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 // For a detailed state diagram please see this link: http://goo.gl/8jAok | 54 // For a detailed state diagram please see this link: http://goo.gl/8jAok |
| 55 // TODO(xhwang): Add a ASCII state diagram in this file after this class | 55 // TODO(xhwang): Add a ASCII state diagram in this file after this class |
| 56 // stabilizes. | 56 // stabilizes. |
| 57 enum State { | 57 enum State { |
| 58 kUninitialized = 0, | 58 kUninitialized = 0, |
| 59 kDecryptorRequested, | |
| 60 kPendingDecoderInit, | 59 kPendingDecoderInit, |
| 61 kIdle, | 60 kIdle, |
| 62 kPendingDecode, | 61 kPendingDecode, |
| 63 kWaitingForKey, | 62 kWaitingForKey, |
| 64 kDecodeFinished, | 63 kDecodeFinished, |
| 65 kError | 64 kError |
| 66 }; | 65 }; |
| 67 | 66 |
| 68 // Callback to set CDM. |cdm_attached_cb| is called when the decryptor in the | |
| 69 // CDM has been completely attached to the pipeline. | |
| 70 void SetCdm(CdmContext* cdm_context, const CdmAttachedCB& cdm_attached_cb); | |
| 71 | |
| 72 // Callback for Decryptor::InitializeVideoDecoder() during initialization. | 67 // Callback for Decryptor::InitializeVideoDecoder() during initialization. |
| 73 void FinishInitialization(bool success); | 68 void FinishInitialization(bool success); |
| 74 | 69 |
| 75 void DecodePendingBuffer(); | 70 void DecodePendingBuffer(); |
| 76 | 71 |
| 77 // Callback for Decryptor::DecryptAndDecodeVideo(). | 72 // Callback for Decryptor::DecryptAndDecodeVideo(). |
| 78 void DeliverFrame(int buffer_size, | 73 void DeliverFrame(int buffer_size, |
| 79 Decryptor::Status status, | 74 Decryptor::Status status, |
| 80 const scoped_refptr<VideoFrame>& frame); | 75 const scoped_refptr<VideoFrame>& frame); |
| 81 | 76 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 93 State state_; | 88 State state_; |
| 94 | 89 |
| 95 InitCB init_cb_; | 90 InitCB init_cb_; |
| 96 OutputCB output_cb_; | 91 OutputCB output_cb_; |
| 97 DecodeCB decode_cb_; | 92 DecodeCB decode_cb_; |
| 98 base::Closure reset_cb_; | 93 base::Closure reset_cb_; |
| 99 base::Closure waiting_for_decryption_key_cb_; | 94 base::Closure waiting_for_decryption_key_cb_; |
| 100 | 95 |
| 101 VideoDecoderConfig config_; | 96 VideoDecoderConfig config_; |
| 102 | 97 |
| 103 // Callback to request/cancel CDM ready notification. | |
| 104 SetCdmReadyCB set_cdm_ready_cb_; | |
| 105 | |
| 106 Decryptor* decryptor_; | 98 Decryptor* decryptor_; |
| 107 | 99 |
| 108 // The buffer that needs decrypting/decoding. | 100 // The buffer that needs decrypting/decoding. |
| 109 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decode_; | 101 scoped_refptr<media::DecoderBuffer> pending_buffer_to_decode_; |
| 110 | 102 |
| 111 // Indicates the situation where new key is added during pending decode | 103 // Indicates the situation where new key is added during pending decode |
| 112 // (in other words, this variable can only be set in state kPendingDecode). | 104 // (in other words, this variable can only be set in state kPendingDecode). |
| 113 // If this variable is true and kNoKey is returned then we need to try | 105 // If this variable is true and kNoKey is returned then we need to try |
| 114 // decrypting/decoding again in case the newly added key is the correct | 106 // decrypting/decoding again in case the newly added key is the correct |
| 115 // decryption key. | 107 // decryption key. |
| 116 bool key_added_while_decode_pending_; | 108 bool key_added_while_decode_pending_; |
| 117 | 109 |
| 118 // A unique ID to trace Decryptor::DecryptAndDecodeVideo() call and the | 110 // A unique ID to trace Decryptor::DecryptAndDecodeVideo() call and the |
| 119 // matching DecryptCB call (in DoDeliverFrame()). | 111 // matching DecryptCB call (in DoDeliverFrame()). |
| 120 uint32_t trace_id_; | 112 uint32_t trace_id_; |
| 121 | 113 |
| 122 base::WeakPtr<DecryptingVideoDecoder> weak_this_; | 114 base::WeakPtr<DecryptingVideoDecoder> weak_this_; |
| 123 base::WeakPtrFactory<DecryptingVideoDecoder> weak_factory_; | 115 base::WeakPtrFactory<DecryptingVideoDecoder> weak_factory_; |
| 124 | 116 |
| 125 DISALLOW_COPY_AND_ASSIGN(DecryptingVideoDecoder); | 117 DISALLOW_COPY_AND_ASSIGN(DecryptingVideoDecoder); |
| 126 }; | 118 }; |
| 127 | 119 |
| 128 } // namespace media | 120 } // namespace media |
| 129 | 121 |
| 130 #endif // MEDIA_FILTERS_DECRYPTING_VIDEO_DECODER_H_ | 122 #endif // MEDIA_FILTERS_DECRYPTING_VIDEO_DECODER_H_ |
| OLD | NEW |