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 |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 class DecoderBuffer; | 23 class DecoderBuffer; |
24 class MediaKeys; | 24 class MediaKeys; |
25 class MojoDecoderBufferReader; | 25 class MojoDecoderBufferReader; |
26 class MojoDecoderBufferWriter; | 26 class MojoDecoderBufferWriter; |
27 | 27 |
28 // A mojom::Decryptor implementation. This object is owned by the creator, | 28 // A mojom::Decryptor implementation. This object is owned by the creator, |
29 // and uses a weak binding across the mojo interface. | 29 // and uses a weak binding across the mojo interface. |
30 class MojoDecryptorService : public mojom::Decryptor { | 30 class MojoDecryptorService : public mojom::Decryptor { |
31 public: | 31 public: |
| 32 using StreamType = media::Decryptor::StreamType; |
| 33 using Status = media::Decryptor::Status; |
| 34 |
32 // Constructs a MojoDecryptorService and binds it to the |request|. Keeps a | 35 // Constructs a MojoDecryptorService and binds it to the |request|. Keeps a |
33 // copy of |cdm| to prevent it from being deleted as long as it is needed. | 36 // copy of |cdm| to prevent it from being deleted as long as it is needed. |
34 // |error_handler| will be called if a connection error occurs. | 37 // |error_handler| will be called if a connection error occurs. |
35 MojoDecryptorService(const scoped_refptr<MediaKeys>& cdm, | 38 MojoDecryptorService(const scoped_refptr<MediaKeys>& cdm, |
36 mojo::InterfaceRequest<mojom::Decryptor> request, | 39 mojo::InterfaceRequest<mojom::Decryptor> request, |
37 const base::Closure& error_handler); | 40 const base::Closure& error_handler); |
38 | 41 |
39 ~MojoDecryptorService() final; | 42 ~MojoDecryptorService() final; |
40 | 43 |
41 // mojom::Decryptor implementation. | 44 // mojom::Decryptor implementation. |
42 void Initialize(mojo::ScopedDataPipeConsumerHandle receive_pipe, | 45 void Initialize(mojo::ScopedDataPipeConsumerHandle receive_pipe, |
43 mojo::ScopedDataPipeProducerHandle transmit_pipe) final; | 46 mojo::ScopedDataPipeProducerHandle transmit_pipe) final; |
44 void Decrypt(mojom::DemuxerStream::Type stream_type, | 47 void Decrypt(StreamType stream_type, |
45 mojom::DecoderBufferPtr encrypted, | 48 mojom::DecoderBufferPtr encrypted, |
46 const DecryptCallback& callback) final; | 49 const DecryptCallback& callback) final; |
47 void CancelDecrypt(mojom::DemuxerStream::Type stream_type) final; | 50 void CancelDecrypt(StreamType stream_type) final; |
48 void InitializeAudioDecoder( | 51 void InitializeAudioDecoder( |
49 mojom::AudioDecoderConfigPtr config, | 52 mojom::AudioDecoderConfigPtr config, |
50 const InitializeAudioDecoderCallback& callback) final; | 53 const InitializeAudioDecoderCallback& callback) final; |
51 void InitializeVideoDecoder( | 54 void InitializeVideoDecoder( |
52 mojom::VideoDecoderConfigPtr config, | 55 mojom::VideoDecoderConfigPtr config, |
53 const InitializeVideoDecoderCallback& callback) final; | 56 const InitializeVideoDecoderCallback& callback) final; |
54 void DecryptAndDecodeAudio( | 57 void DecryptAndDecodeAudio( |
55 mojom::DecoderBufferPtr encrypted, | 58 mojom::DecoderBufferPtr encrypted, |
56 const DecryptAndDecodeAudioCallback& callback) final; | 59 const DecryptAndDecodeAudioCallback& callback) final; |
57 void DecryptAndDecodeVideo( | 60 void DecryptAndDecodeVideo( |
58 mojom::DecoderBufferPtr encrypted, | 61 mojom::DecoderBufferPtr encrypted, |
59 const DecryptAndDecodeVideoCallback& callback) final; | 62 const DecryptAndDecodeVideoCallback& callback) final; |
60 void ResetDecoder(mojom::DemuxerStream::Type stream_type) final; | 63 void ResetDecoder(StreamType stream_type) final; |
61 void DeinitializeDecoder(mojom::DemuxerStream::Type stream_type) final; | 64 void DeinitializeDecoder(StreamType stream_type) final; |
62 void ReleaseSharedBuffer(mojo::ScopedSharedBufferHandle buffer, | 65 void ReleaseSharedBuffer(mojo::ScopedSharedBufferHandle buffer, |
63 uint64_t buffer_size) final; | 66 uint64_t buffer_size) final; |
64 | 67 |
65 private: | 68 private: |
66 // Callback executed once Decrypt() is done. | 69 // Callback executed once Decrypt() is done. |
67 void OnDecryptDone(const DecryptCallback& callback, | 70 void OnDecryptDone(const DecryptCallback& callback, |
68 media::Decryptor::Status status, | 71 Status status, |
69 const scoped_refptr<DecoderBuffer>& buffer); | 72 const scoped_refptr<DecoderBuffer>& buffer); |
70 | 73 |
71 // Callbacks executed once decoder initialized. | 74 // Callbacks executed once decoder initialized. |
72 void OnAudioDecoderInitialized(const InitializeAudioDecoderCallback& callback, | 75 void OnAudioDecoderInitialized(const InitializeAudioDecoderCallback& callback, |
73 bool success); | 76 bool success); |
74 void OnVideoDecoderInitialized(const InitializeVideoDecoderCallback& callback, | 77 void OnVideoDecoderInitialized(const InitializeVideoDecoderCallback& callback, |
75 bool success); | 78 bool success); |
76 | 79 |
77 // Callbacks executed when DecryptAndDecode are done. | 80 // Callbacks executed when DecryptAndDecode are done. |
78 void OnAudioDecoded(const DecryptAndDecodeAudioCallback& callback, | 81 void OnAudioDecoded(const DecryptAndDecodeAudioCallback& callback, |
79 media::Decryptor::Status status, | 82 Status status, |
80 const media::Decryptor::AudioFrames& frames); | 83 const media::Decryptor::AudioFrames& frames); |
81 void OnVideoDecoded(const DecryptAndDecodeVideoCallback& callback, | 84 void OnVideoDecoded(const DecryptAndDecodeVideoCallback& callback, |
82 media::Decryptor::Status status, | 85 Status status, |
83 const scoped_refptr<VideoFrame>& frame); | 86 const scoped_refptr<VideoFrame>& frame); |
84 | 87 |
85 // A weak binding is used to connect to the MojoDecryptor. | 88 // A weak binding is used to connect to the MojoDecryptor. |
86 mojo::Binding<mojom::Decryptor> binding_; | 89 mojo::Binding<mojom::Decryptor> binding_; |
87 | 90 |
88 // Helper class to send decrypted DecoderBuffer to the client. | 91 // Helper class to send decrypted DecoderBuffer to the client. |
89 std::unique_ptr<MojoDecoderBufferWriter> mojo_decoder_buffer_writer_; | 92 std::unique_ptr<MojoDecoderBufferWriter> mojo_decoder_buffer_writer_; |
90 | 93 |
91 // Helper class to receive encrypted DecoderBuffer from the client. | 94 // Helper class to receive encrypted DecoderBuffer from the client. |
92 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; | 95 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; |
(...skipping 10 matching lines...) Expand all Loading... |
103 | 106 |
104 base::WeakPtr<MojoDecryptorService> weak_this_; | 107 base::WeakPtr<MojoDecryptorService> weak_this_; |
105 base::WeakPtrFactory<MojoDecryptorService> weak_factory_; | 108 base::WeakPtrFactory<MojoDecryptorService> weak_factory_; |
106 | 109 |
107 DISALLOW_COPY_AND_ASSIGN(MojoDecryptorService); | 110 DISALLOW_COPY_AND_ASSIGN(MojoDecryptorService); |
108 }; | 111 }; |
109 | 112 |
110 } // namespace media | 113 } // namespace media |
111 | 114 |
112 #endif // MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_SERVICE_H_ | 115 #endif // MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_SERVICE_H_ |
OLD | NEW |