| 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_SERVICE_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_SERVICE_H_ |
| 6 #define MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_SERVICE_H_ | 6 #define MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_SERVICE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "media/base/decryptor.h" | 16 #include "media/base/decryptor.h" |
| 17 #include "media/mojo/interfaces/decryptor.mojom.h" | 17 #include "media/mojo/interfaces/decryptor.mojom.h" |
| 18 #include "media/mojo/services/media_mojo_export.h" | 18 #include "media/mojo/services/media_mojo_export.h" |
| 19 #include "mojo/public/cpp/bindings/binding.h" | 19 #include "mojo/public/cpp/bindings/binding.h" |
| 20 | 20 |
| 21 namespace media { | 21 namespace media { |
| 22 | 22 |
| 23 class DecoderBuffer; | 23 class DecoderBuffer; |
| 24 class ContentDecryptionModule; | |
| 25 class MojoDecoderBufferReader; | 24 class MojoDecoderBufferReader; |
| 26 class MojoDecoderBufferWriter; | 25 class MojoDecoderBufferWriter; |
| 27 | 26 |
| 28 // A mojom::Decryptor implementation. This object is owned by the creator, | 27 // A mojom::Decryptor implementation. This object is owned by the creator, |
| 29 // and uses a weak binding across the mojo interface. | 28 // and uses a weak binding across the mojo interface. |
| 30 class MEDIA_MOJO_EXPORT MojoDecryptorService | 29 class MEDIA_MOJO_EXPORT MojoDecryptorService |
| 31 : NON_EXPORTED_BASE(public mojom::Decryptor) { | 30 : NON_EXPORTED_BASE(public mojom::Decryptor) { |
| 32 public: | 31 public: |
| 33 using StreamType = media::Decryptor::StreamType; | 32 using StreamType = media::Decryptor::StreamType; |
| 34 using Status = media::Decryptor::Status; | 33 using Status = media::Decryptor::Status; |
| 35 | 34 |
| 36 // Constructs a MojoDecryptorService and binds it to the |request|. Keeps a | 35 // Constructs a MojoDecryptorService and binds it to the |request|. |
| 37 // copy of |cdm| to prevent it from being deleted as long as it is needed. | |
| 38 // |error_handler| will be called if a connection error occurs. | 36 // |error_handler| will be called if a connection error occurs. |
| 39 // TODO(jrummell): Ideally this should take a Decryptor instead of |cdm|. | 37 // Caller must ensure that |decryptor| outlives |this|. |
| 40 // The owner of the MojoDecryptorService should control the lifetime of the | 38 MojoDecryptorService(media::Decryptor* decryptor, |
| 41 // CDM. Both this and the CDM are owned by MojoCdmService, so it seems | |
| 42 // possible. http://crbug.com/701107. | |
| 43 MojoDecryptorService(const scoped_refptr<ContentDecryptionModule>& cdm, | |
| 44 mojo::InterfaceRequest<mojom::Decryptor> request, | 39 mojo::InterfaceRequest<mojom::Decryptor> request, |
| 45 const base::Closure& error_handler); | 40 const base::Closure& error_handler); |
| 46 | 41 |
| 47 ~MojoDecryptorService() final; | 42 ~MojoDecryptorService() final; |
| 48 | 43 |
| 49 // mojom::Decryptor implementation. | 44 // mojom::Decryptor implementation. |
| 50 void Initialize(mojo::ScopedDataPipeConsumerHandle receive_pipe, | 45 void Initialize(mojo::ScopedDataPipeConsumerHandle receive_pipe, |
| 51 mojo::ScopedDataPipeProducerHandle transmit_pipe) final; | 46 mojo::ScopedDataPipeProducerHandle transmit_pipe) final; |
| 52 void Decrypt(StreamType stream_type, | 47 void Decrypt(StreamType stream_type, |
| 53 mojom::DecoderBufferPtr encrypted, | 48 mojom::DecoderBufferPtr encrypted, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 94 |
| 100 // A weak binding is used to connect to the MojoDecryptor. | 95 // A weak binding is used to connect to the MojoDecryptor. |
| 101 mojo::Binding<mojom::Decryptor> binding_; | 96 mojo::Binding<mojom::Decryptor> binding_; |
| 102 | 97 |
| 103 // Helper class to send decrypted DecoderBuffer to the client. | 98 // Helper class to send decrypted DecoderBuffer to the client. |
| 104 std::unique_ptr<MojoDecoderBufferWriter> mojo_decoder_buffer_writer_; | 99 std::unique_ptr<MojoDecoderBufferWriter> mojo_decoder_buffer_writer_; |
| 105 | 100 |
| 106 // Helper class to receive encrypted DecoderBuffer from the client. | 101 // Helper class to receive encrypted DecoderBuffer from the client. |
| 107 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; | 102 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; |
| 108 | 103 |
| 109 // Keep ownership of |cdm_| while it is being used. |decryptor_| is the actual | |
| 110 // Decryptor referenced by |cdm_|. | |
| 111 scoped_refptr<ContentDecryptionModule> cdm_; | |
| 112 media::Decryptor* decryptor_; | 104 media::Decryptor* decryptor_; |
| 113 | 105 |
| 114 base::WeakPtr<MojoDecryptorService> weak_this_; | 106 base::WeakPtr<MojoDecryptorService> weak_this_; |
| 115 base::WeakPtrFactory<MojoDecryptorService> weak_factory_; | 107 base::WeakPtrFactory<MojoDecryptorService> weak_factory_; |
| 116 | 108 |
| 117 DISALLOW_COPY_AND_ASSIGN(MojoDecryptorService); | 109 DISALLOW_COPY_AND_ASSIGN(MojoDecryptorService); |
| 118 }; | 110 }; |
| 119 | 111 |
| 120 } // namespace media | 112 } // namespace media |
| 121 | 113 |
| 122 #endif // MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_SERVICE_H_ | 114 #endif // MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_SERVICE_H_ |
| OLD | NEW |