| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_MOJO_SERVICES_MOJO_DECRYPTOR_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_H_ |
| 6 #define MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_H_ | 6 #define MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.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/mojo/interfaces/decryptor.mojom.h" | 11 #include "media/mojo/interfaces/decryptor.mojom.h" |
| 12 #include "mojo/public/cpp/bindings/binding.h" | 12 #include "mojo/public/cpp/bindings/binding.h" |
| 13 #include "mojo/public/cpp/system/data_pipe.h" |
| 13 | 14 |
| 14 namespace media { | 15 namespace media { |
| 15 | 16 |
| 16 class MojoDecryptor : public Decryptor { | 17 class MojoDecryptor : public Decryptor { |
| 17 public: | 18 public: |
| 18 explicit MojoDecryptor(interfaces::DecryptorPtr remote_decryptor); | 19 explicit MojoDecryptor(interfaces::DecryptorPtr remote_decryptor); |
| 19 ~MojoDecryptor() final; | 20 ~MojoDecryptor() final; |
| 20 | 21 |
| 21 // Decryptor implementation. | 22 // Decryptor implementation. |
| 22 void RegisterNewKeyCB(StreamType stream_type, | 23 void RegisterNewKeyCB(StreamType stream_type, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 44 void OnBufferDecrypted(const DecryptCB& decrypt_cb, | 45 void OnBufferDecrypted(const DecryptCB& decrypt_cb, |
| 45 interfaces::Decryptor::Status status, | 46 interfaces::Decryptor::Status status, |
| 46 interfaces::DecoderBufferPtr buffer); | 47 interfaces::DecoderBufferPtr buffer); |
| 47 void OnAudioDecoded(const AudioDecodeCB& audio_decode_cb, | 48 void OnAudioDecoded(const AudioDecodeCB& audio_decode_cb, |
| 48 interfaces::Decryptor::Status status, | 49 interfaces::Decryptor::Status status, |
| 49 mojo::Array<interfaces::AudioBufferPtr> audio_buffers); | 50 mojo::Array<interfaces::AudioBufferPtr> audio_buffers); |
| 50 void OnVideoDecoded(const VideoDecodeCB& video_decode_cb, | 51 void OnVideoDecoded(const VideoDecodeCB& video_decode_cb, |
| 51 interfaces::Decryptor::Status status, | 52 interfaces::Decryptor::Status status, |
| 52 interfaces::VideoFramePtr video_frame); | 53 interfaces::VideoFramePtr video_frame); |
| 53 | 54 |
| 55 // To pass DecoderBuffers to and from the MojoDecryptorService, 2 data pipes |
| 56 // are required (one each way). At initialization both pipes are created, |
| 57 // and then the handles are passed to the MojoDecryptorService. |
| 58 void CreateDataPipes(); |
| 59 |
| 60 // Helper functions to write and read a DecoderBuffer. |
| 61 interfaces::DecoderBufferPtr TransferDecoderBuffer( |
| 62 const scoped_refptr<DecoderBuffer>& buffer); |
| 63 scoped_refptr<DecoderBuffer> ReadDecoderBuffer( |
| 64 interfaces::DecoderBufferPtr buffer); |
| 65 |
| 54 interfaces::DecryptorPtr remote_decryptor_; | 66 interfaces::DecryptorPtr remote_decryptor_; |
| 55 | 67 |
| 68 // DataPipes for serializing the data section of DecoderBuffer into/from. |
| 69 mojo::ScopedDataPipeProducerHandle producer_handle_; |
| 70 mojo::ScopedDataPipeConsumerHandle consumer_handle_; |
| 71 |
| 56 NewKeyCB new_audio_key_cb_; | 72 NewKeyCB new_audio_key_cb_; |
| 57 NewKeyCB new_video_key_cb_; | 73 NewKeyCB new_video_key_cb_; |
| 58 | 74 |
| 59 base::WeakPtrFactory<MojoDecryptor> weak_factory_; | 75 base::WeakPtrFactory<MojoDecryptor> weak_factory_; |
| 60 | 76 |
| 61 DISALLOW_COPY_AND_ASSIGN(MojoDecryptor); | 77 DISALLOW_COPY_AND_ASSIGN(MojoDecryptor); |
| 62 }; | 78 }; |
| 63 | 79 |
| 64 } // namespace media | 80 } // namespace media |
| 65 | 81 |
| 66 #endif // MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_H_ | 82 #endif // MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_H_ |
| OLD | NEW |