| 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_CLIENTS_MOJO_DECRYPTOR_H_ | 5 #ifndef MEDIA_MOJO_CLIENTS_MOJO_DECRYPTOR_H_ |
| 6 #define MEDIA_MOJO_CLIENTS_MOJO_DECRYPTOR_H_ | 6 #define MEDIA_MOJO_CLIENTS_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 "base/threading/thread_checker.h" | 10 #include "base/threading/thread_checker.h" |
| 11 #include "media/base/decryptor.h" | 11 #include "media/base/decryptor.h" |
| 12 #include "media/mojo/interfaces/decryptor.mojom.h" | 12 #include "media/mojo/interfaces/decryptor.mojom.h" |
| 13 #include "mojo/public/cpp/bindings/binding.h" | 13 #include "mojo/public/cpp/bindings/binding.h" |
| 14 #include "mojo/public/cpp/system/data_pipe.h" | |
| 15 | 14 |
| 16 namespace media { | 15 namespace media { |
| 17 | 16 |
| 17 class MojoDecoderBufferReader; |
| 18 class MojoDecoderBufferWriter; |
| 19 |
| 18 // A Decryptor implementation based on mojom::DecryptorPtr. | 20 // A Decryptor implementation based on mojom::DecryptorPtr. |
| 19 // This class is single threaded. The |remote_decryptor| is connected before | 21 // This class is single threaded. The |remote_decryptor| is connected before |
| 20 // being passed to MojoDecryptor, but it is bound to the thread MojoDecryptor | 22 // being passed to MojoDecryptor, but it is bound to the thread MojoDecryptor |
| 21 // lives on the first time it is used in this class. | 23 // lives on the first time it is used in this class. |
| 22 class MojoDecryptor : public Decryptor { | 24 class MojoDecryptor : public Decryptor { |
| 23 public: | 25 public: |
| 24 explicit MojoDecryptor(mojom::DecryptorPtr remote_decryptor); | 26 explicit MojoDecryptor(mojom::DecryptorPtr remote_decryptor); |
| 25 ~MojoDecryptor() final; | 27 ~MojoDecryptor() final; |
| 26 | 28 |
| 27 // Decryptor implementation. | 29 // Decryptor implementation. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 54 mojom::Decryptor::Status status, | 56 mojom::Decryptor::Status status, |
| 55 mojo::Array<mojom::AudioBufferPtr> audio_buffers); | 57 mojo::Array<mojom::AudioBufferPtr> audio_buffers); |
| 56 void OnVideoDecoded(const VideoDecodeCB& video_decode_cb, | 58 void OnVideoDecoded(const VideoDecodeCB& video_decode_cb, |
| 57 mojom::Decryptor::Status status, | 59 mojom::Decryptor::Status status, |
| 58 mojom::VideoFramePtr video_frame); | 60 mojom::VideoFramePtr video_frame); |
| 59 | 61 |
| 60 // Called when done with a VideoFrame in order to reuse the shared memory. | 62 // Called when done with a VideoFrame in order to reuse the shared memory. |
| 61 void ReleaseSharedBuffer(mojo::ScopedSharedBufferHandle buffer, | 63 void ReleaseSharedBuffer(mojo::ScopedSharedBufferHandle buffer, |
| 62 size_t buffer_size); | 64 size_t buffer_size); |
| 63 | 65 |
| 64 // To pass DecoderBuffers to and from the MojoDecryptorService, 2 data pipes | |
| 65 // are required (one each way). At initialization both pipes are created, | |
| 66 // and then the handles are passed to the MojoDecryptorService. | |
| 67 void CreateDataPipes(); | |
| 68 | |
| 69 // Helper functions to write and read a DecoderBuffer. | |
| 70 mojom::DecoderBufferPtr TransferDecoderBuffer( | |
| 71 const scoped_refptr<DecoderBuffer>& buffer); | |
| 72 scoped_refptr<DecoderBuffer> ReadDecoderBuffer( | |
| 73 mojom::DecoderBufferPtr buffer); | |
| 74 | |
| 75 base::ThreadChecker thread_checker_; | 66 base::ThreadChecker thread_checker_; |
| 76 | 67 |
| 77 mojom::DecryptorPtr remote_decryptor_; | 68 mojom::DecryptorPtr remote_decryptor_; |
| 78 | 69 |
| 79 // DataPipes for serializing the data section of DecoderBuffer into/from. | 70 // Helper class to send DecoderBuffer to the |remote_decryptor_| for decrypt |
| 80 mojo::ScopedDataPipeProducerHandle producer_handle_; | 71 // or decrypt-and-decode. |
| 81 mojo::ScopedDataPipeConsumerHandle consumer_handle_; | 72 std::unique_ptr<MojoDecoderBufferWriter> mojo_decoder_buffer_writer_; |
| 73 |
| 74 // Helper class to receive decrypted DecoderBuffer from the |
| 75 // |remote_decryptor_|. |
| 76 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; |
| 82 | 77 |
| 83 NewKeyCB new_audio_key_cb_; | 78 NewKeyCB new_audio_key_cb_; |
| 84 NewKeyCB new_video_key_cb_; | 79 NewKeyCB new_video_key_cb_; |
| 85 | 80 |
| 86 base::WeakPtrFactory<MojoDecryptor> weak_factory_; | 81 base::WeakPtrFactory<MojoDecryptor> weak_factory_; |
| 87 | 82 |
| 88 DISALLOW_COPY_AND_ASSIGN(MojoDecryptor); | 83 DISALLOW_COPY_AND_ASSIGN(MojoDecryptor); |
| 89 }; | 84 }; |
| 90 | 85 |
| 91 } // namespace media | 86 } // namespace media |
| 92 | 87 |
| 93 #endif // MEDIA_MOJO_CLIENTS_MOJO_DECRYPTOR_H_ | 88 #endif // MEDIA_MOJO_CLIENTS_MOJO_DECRYPTOR_H_ |
| OLD | NEW |