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 <unordered_map> | 11 #include <unordered_map> |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "media/base/decryptor.h" | 17 #include "media/base/decryptor.h" |
18 #include "media/mojo/interfaces/decryptor.mojom.h" | 18 #include "media/mojo/interfaces/decryptor.mojom.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 MediaKeys; | 24 class ContentDecryptionModule; |
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; | 32 using StreamType = media::Decryptor::StreamType; |
33 using Status = media::Decryptor::Status; | 33 using Status = media::Decryptor::Status; |
34 | 34 |
35 // Constructs a MojoDecryptorService and binds it to the |request|. Keeps a | 35 // Constructs a MojoDecryptorService and binds it to the |request|. Keeps a |
36 // 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. |
37 // |error_handler| will be called if a connection error occurs. | 37 // |error_handler| will be called if a connection error occurs. |
38 MojoDecryptorService(const scoped_refptr<MediaKeys>& cdm, | 38 MojoDecryptorService(const scoped_refptr<ContentDecryptionModule>& cdm, |
39 mojo::InterfaceRequest<mojom::Decryptor> request, | 39 mojo::InterfaceRequest<mojom::Decryptor> request, |
40 const base::Closure& error_handler); | 40 const base::Closure& error_handler); |
41 | 41 |
42 ~MojoDecryptorService() final; | 42 ~MojoDecryptorService() final; |
43 | 43 |
44 // mojom::Decryptor implementation. | 44 // mojom::Decryptor implementation. |
45 void Initialize(mojo::ScopedDataPipeConsumerHandle receive_pipe, | 45 void Initialize(mojo::ScopedDataPipeConsumerHandle receive_pipe, |
46 mojo::ScopedDataPipeProducerHandle transmit_pipe) final; | 46 mojo::ScopedDataPipeProducerHandle transmit_pipe) final; |
47 void Decrypt(StreamType stream_type, | 47 void Decrypt(StreamType stream_type, |
48 mojom::DecoderBufferPtr encrypted, | 48 mojom::DecoderBufferPtr encrypted, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 mojo::Binding<mojom::Decryptor> binding_; | 97 mojo::Binding<mojom::Decryptor> binding_; |
98 | 98 |
99 // Helper class to send decrypted DecoderBuffer to the client. | 99 // Helper class to send decrypted DecoderBuffer to the client. |
100 std::unique_ptr<MojoDecoderBufferWriter> mojo_decoder_buffer_writer_; | 100 std::unique_ptr<MojoDecoderBufferWriter> mojo_decoder_buffer_writer_; |
101 | 101 |
102 // Helper class to receive encrypted DecoderBuffer from the client. | 102 // Helper class to receive encrypted DecoderBuffer from the client. |
103 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; | 103 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; |
104 | 104 |
105 // Keep ownership of |cdm_| while it is being used. |decryptor_| is the actual | 105 // Keep ownership of |cdm_| while it is being used. |decryptor_| is the actual |
106 // Decryptor referenced by |cdm_|. | 106 // Decryptor referenced by |cdm_|. |
107 scoped_refptr<MediaKeys> cdm_; | 107 scoped_refptr<ContentDecryptionModule> cdm_; |
108 media::Decryptor* decryptor_; | 108 media::Decryptor* decryptor_; |
109 | 109 |
110 // Keep a reference to VideoFrames until ReleaseSharedBuffer() is called | 110 // Keep a reference to VideoFrames until ReleaseSharedBuffer() is called |
111 // to release it. | 111 // to release it. |
112 std::unordered_map<MojoHandle, scoped_refptr<VideoFrame>> | 112 std::unordered_map<MojoHandle, scoped_refptr<VideoFrame>> |
113 in_use_video_frames_; | 113 in_use_video_frames_; |
114 | 114 |
115 base::WeakPtr<MojoDecryptorService> weak_this_; | 115 base::WeakPtr<MojoDecryptorService> weak_this_; |
116 base::WeakPtrFactory<MojoDecryptorService> weak_factory_; | 116 base::WeakPtrFactory<MojoDecryptorService> weak_factory_; |
117 | 117 |
118 DISALLOW_COPY_AND_ASSIGN(MojoDecryptorService); | 118 DISALLOW_COPY_AND_ASSIGN(MojoDecryptorService); |
119 }; | 119 }; |
120 | 120 |
121 } // namespace media | 121 } // namespace media |
122 | 122 |
123 #endif // MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_SERVICE_H_ | 123 #endif // MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_SERVICE_H_ |
OLD | NEW |