| 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/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "media/base/decryptor.h" | 10 #include "media/base/decryptor.h" |
| 11 #include "media/base/video_decoder.h" | 11 #include "media/base/video_decoder.h" |
| 12 #include "media/base/video_decoder_config.h" | 12 #include "media/base/video_decoder_config.h" |
| 13 | 13 |
| 14 namespace base { | 14 namespace base { |
| 15 class MessageLoopProxy; | 15 class SingleThreadTaskRunner; |
| 16 } | 16 } |
| 17 | 17 |
| 18 namespace media { | 18 namespace media { |
| 19 | 19 |
| 20 class DecoderBuffer; | 20 class DecoderBuffer; |
| 21 class Decryptor; | 21 class Decryptor; |
| 22 | 22 |
| 23 // Decryptor-based VideoDecoder implementation that can decrypt and decode | 23 // Decryptor-based VideoDecoder implementation that can decrypt and decode |
| 24 // encrypted video buffers and return decrypted and decompressed video frames. | 24 // encrypted video buffers and return decrypted and decompressed video frames. |
| 25 // All public APIs and callbacks are trampolined to the |message_loop_| so | 25 // All public APIs and callbacks are trampolined to the |task_runner_| so |
| 26 // that no locks are required for thread safety. | 26 // that no locks are required for thread safety. |
| 27 class MEDIA_EXPORT DecryptingVideoDecoder : public VideoDecoder { | 27 class MEDIA_EXPORT DecryptingVideoDecoder : public VideoDecoder { |
| 28 public: | 28 public: |
| 29 DecryptingVideoDecoder( | 29 DecryptingVideoDecoder( |
| 30 const scoped_refptr<base::MessageLoopProxy>& message_loop, | 30 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 31 const SetDecryptorReadyCB& set_decryptor_ready_cb); | 31 const SetDecryptorReadyCB& set_decryptor_ready_cb); |
| 32 virtual ~DecryptingVideoDecoder(); | 32 virtual ~DecryptingVideoDecoder(); |
| 33 | 33 |
| 34 // VideoDecoder implementation. | 34 // VideoDecoder implementation. |
| 35 virtual void Initialize(const VideoDecoderConfig& config, | 35 virtual void Initialize(const VideoDecoderConfig& config, |
| 36 const PipelineStatusCB& status_cb) OVERRIDE; | 36 const PipelineStatusCB& status_cb) OVERRIDE; |
| 37 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 37 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| 38 const DecodeCB& decode_cb) OVERRIDE; | 38 const DecodeCB& decode_cb) OVERRIDE; |
| 39 virtual void Reset(const base::Closure& closure) OVERRIDE; | 39 virtual void Reset(const base::Closure& closure) OVERRIDE; |
| 40 virtual void Stop(const base::Closure& closure) OVERRIDE; | 40 virtual void Stop(const base::Closure& closure) OVERRIDE; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 71 // Callback for the |decryptor_| to notify this object that a new key has been | 71 // Callback for the |decryptor_| to notify this object that a new key has been |
| 72 // added. | 72 // added. |
| 73 void OnKeyAdded(); | 73 void OnKeyAdded(); |
| 74 | 74 |
| 75 // Reset decoder and call |reset_cb_|. | 75 // Reset decoder and call |reset_cb_|. |
| 76 void DoReset(); | 76 void DoReset(); |
| 77 | 77 |
| 78 // Free decoder resources and call |stop_cb_|. | 78 // Free decoder resources and call |stop_cb_|. |
| 79 void DoStop(); | 79 void DoStop(); |
| 80 | 80 |
| 81 scoped_refptr<base::MessageLoopProxy> message_loop_; | 81 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 82 base::WeakPtrFactory<DecryptingVideoDecoder> weak_factory_; | 82 base::WeakPtrFactory<DecryptingVideoDecoder> weak_factory_; |
| 83 base::WeakPtr<DecryptingVideoDecoder> weak_this_; | 83 base::WeakPtr<DecryptingVideoDecoder> weak_this_; |
| 84 | 84 |
| 85 State state_; | 85 State state_; |
| 86 | 86 |
| 87 PipelineStatusCB init_cb_; | 87 PipelineStatusCB init_cb_; |
| 88 DecodeCB decode_cb_; | 88 DecodeCB decode_cb_; |
| 89 base::Closure reset_cb_; | 89 base::Closure reset_cb_; |
| 90 | 90 |
| 91 VideoDecoderConfig config_; | 91 VideoDecoderConfig config_; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 108 // A unique ID to trace Decryptor::DecryptAndDecodeVideo() call and the | 108 // A unique ID to trace Decryptor::DecryptAndDecodeVideo() call and the |
| 109 // matching DecryptCB call (in DoDeliverFrame()). | 109 // matching DecryptCB call (in DoDeliverFrame()). |
| 110 uint32 trace_id_; | 110 uint32 trace_id_; |
| 111 | 111 |
| 112 DISALLOW_COPY_AND_ASSIGN(DecryptingVideoDecoder); | 112 DISALLOW_COPY_AND_ASSIGN(DecryptingVideoDecoder); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 } // namespace media | 115 } // namespace media |
| 116 | 116 |
| 117 #endif // MEDIA_FILTERS_DECRYPTING_VIDEO_DECODER_H_ | 117 #endif // MEDIA_FILTERS_DECRYPTING_VIDEO_DECODER_H_ |
| OLD | NEW |