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> |
| 9 #include <stdint.h> |
| 10 |
| 11 #include <unordered_map> |
| 12 |
8 #include "base/macros.h" | 13 #include "base/macros.h" |
9 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
11 #include "media/base/decryptor.h" | 16 #include "media/base/decryptor.h" |
12 #include "media/mojo/interfaces/decryptor.mojom.h" | 17 #include "media/mojo/interfaces/decryptor.mojom.h" |
13 #include "mojo/public/cpp/bindings/binding.h" | 18 #include "mojo/public/cpp/bindings/binding.h" |
14 #include "mojo/public/cpp/bindings/callback.h" | 19 #include "mojo/public/cpp/bindings/callback.h" |
15 #include "mojo/public/cpp/system/data_pipe.h" | 20 #include "mojo/public/cpp/system/data_pipe.h" |
16 | 21 |
17 namespace media { | 22 namespace media { |
(...skipping 28 matching lines...) Expand all Loading... |
46 interfaces::VideoDecoderConfigPtr config, | 51 interfaces::VideoDecoderConfigPtr config, |
47 const InitializeVideoDecoderCallback& callback) final; | 52 const InitializeVideoDecoderCallback& callback) final; |
48 void DecryptAndDecodeAudio( | 53 void DecryptAndDecodeAudio( |
49 interfaces::DecoderBufferPtr encrypted, | 54 interfaces::DecoderBufferPtr encrypted, |
50 const DecryptAndDecodeAudioCallback& callback) final; | 55 const DecryptAndDecodeAudioCallback& callback) final; |
51 void DecryptAndDecodeVideo( | 56 void DecryptAndDecodeVideo( |
52 interfaces::DecoderBufferPtr encrypted, | 57 interfaces::DecoderBufferPtr encrypted, |
53 const DecryptAndDecodeVideoCallback& callback) final; | 58 const DecryptAndDecodeVideoCallback& callback) final; |
54 void ResetDecoder(interfaces::DemuxerStream::Type stream_type) final; | 59 void ResetDecoder(interfaces::DemuxerStream::Type stream_type) final; |
55 void DeinitializeDecoder(interfaces::DemuxerStream::Type stream_type) final; | 60 void DeinitializeDecoder(interfaces::DemuxerStream::Type stream_type) final; |
| 61 void ReleaseSharedBuffer(mojo::ScopedSharedBufferHandle buffer, |
| 62 uint64_t buffer_size) final; |
56 | 63 |
57 private: | 64 private: |
58 // Callback executed once Decrypt() is done. | 65 // Callback executed once Decrypt() is done. |
59 void OnDecryptDone(const DecryptCallback& callback, | 66 void OnDecryptDone(const DecryptCallback& callback, |
60 media::Decryptor::Status status, | 67 media::Decryptor::Status status, |
61 const scoped_refptr<DecoderBuffer>& buffer); | 68 const scoped_refptr<DecoderBuffer>& buffer); |
62 | 69 |
63 // Callbacks executed once decoder initialized. | 70 // Callbacks executed once decoder initialized. |
64 void OnAudioDecoderInitialized(const InitializeAudioDecoderCallback& callback, | 71 void OnAudioDecoderInitialized(const InitializeAudioDecoderCallback& callback, |
65 bool success); | 72 bool success); |
(...skipping 19 matching lines...) Expand all Loading... |
85 | 92 |
86 // DataPipes for serializing the data section of DecoderBuffer into/from. | 93 // DataPipes for serializing the data section of DecoderBuffer into/from. |
87 mojo::ScopedDataPipeProducerHandle producer_handle_; | 94 mojo::ScopedDataPipeProducerHandle producer_handle_; |
88 mojo::ScopedDataPipeConsumerHandle consumer_handle_; | 95 mojo::ScopedDataPipeConsumerHandle consumer_handle_; |
89 | 96 |
90 // Keep ownership of |cdm_| while it is being used. |decryptor_| is the actual | 97 // Keep ownership of |cdm_| while it is being used. |decryptor_| is the actual |
91 // Decryptor referenced by |cdm_|. | 98 // Decryptor referenced by |cdm_|. |
92 scoped_refptr<MediaKeys> cdm_; | 99 scoped_refptr<MediaKeys> cdm_; |
93 media::Decryptor* decryptor_; | 100 media::Decryptor* decryptor_; |
94 | 101 |
| 102 // Keep a reference to VideoFrames until ReleaseSharedBuffer() is called |
| 103 // to release it. |
| 104 std::unordered_map<MojoHandle, scoped_refptr<VideoFrame>> |
| 105 in_use_video_frames_; |
| 106 |
95 base::WeakPtr<MojoDecryptorService> weak_this_; | 107 base::WeakPtr<MojoDecryptorService> weak_this_; |
96 base::WeakPtrFactory<MojoDecryptorService> weak_factory_; | 108 base::WeakPtrFactory<MojoDecryptorService> weak_factory_; |
97 | 109 |
98 DISALLOW_COPY_AND_ASSIGN(MojoDecryptorService); | 110 DISALLOW_COPY_AND_ASSIGN(MojoDecryptorService); |
99 }; | 111 }; |
100 | 112 |
101 } // namespace media | 113 } // namespace media |
102 | 114 |
103 #endif // MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_SERVICE_H_ | 115 #endif // MEDIA_MOJO_SERVICES_MOJO_DECRYPTOR_SERVICE_H_ |
OLD | NEW |