| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_AUDIO_DECODER_SERVICE_H_ | 5 #ifndef MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_SERVICE_H_ |
| 6 #define MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_SERVICE_H_ | 6 #define MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_SERVICE_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "media/base/audio_decoder.h" | 11 #include "media/base/audio_decoder.h" |
| 12 #include "media/mojo/interfaces/audio_decoder.mojom.h" | 12 #include "media/mojo/interfaces/audio_decoder.mojom.h" |
| 13 #include "mojo/public/cpp/bindings/strong_binding.h" | 13 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 14 #include "mojo/public/cpp/system/data_pipe.h" | 14 #include "mojo/public/cpp/system/data_pipe.h" |
| 15 | 15 |
| 16 namespace media { | 16 namespace media { |
| 17 | 17 |
| 18 class MediaKeys; |
| 19 class MojoCdmServiceContext; |
| 20 |
| 18 class MojoAudioDecoderService : public interfaces::AudioDecoder { | 21 class MojoAudioDecoderService : public interfaces::AudioDecoder { |
| 19 public: | 22 public: |
| 20 MojoAudioDecoderService( | 23 MojoAudioDecoderService( |
| 24 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context, |
| 21 scoped_ptr<media::AudioDecoder> decoder, | 25 scoped_ptr<media::AudioDecoder> decoder, |
| 22 mojo::InterfaceRequest<interfaces::AudioDecoder> request); | 26 mojo::InterfaceRequest<interfaces::AudioDecoder> request); |
| 23 | 27 |
| 24 ~MojoAudioDecoderService() final; | 28 ~MojoAudioDecoderService() final; |
| 25 | 29 |
| 26 // interfaces::AudioDecoder implementation | 30 // interfaces::AudioDecoder implementation |
| 27 void Initialize(interfaces::AudioDecoderClientPtr client, | 31 void Initialize(interfaces::AudioDecoderClientPtr client, |
| 28 interfaces::AudioDecoderConfigPtr config, | 32 interfaces::AudioDecoderConfigPtr config, |
| 29 int32_t cdm_id, | 33 int32_t cdm_id, |
| 30 const InitializeCallback& callback) final; | 34 const InitializeCallback& callback) final; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 54 scoped_refptr<DecoderBuffer> ReadDecoderBuffer( | 58 scoped_refptr<DecoderBuffer> ReadDecoderBuffer( |
| 55 interfaces::DecoderBufferPtr buffer); | 59 interfaces::DecoderBufferPtr buffer); |
| 56 | 60 |
| 57 // A binding represents the association between the service and the | 61 // A binding represents the association between the service and the |
| 58 // communication channel, i.e. the pipe. | 62 // communication channel, i.e. the pipe. |
| 59 mojo::StrongBinding<interfaces::AudioDecoder> binding_; | 63 mojo::StrongBinding<interfaces::AudioDecoder> binding_; |
| 60 | 64 |
| 61 // DataPipe for serializing the data section of DecoderBuffer. | 65 // DataPipe for serializing the data section of DecoderBuffer. |
| 62 mojo::ScopedDataPipeConsumerHandle consumer_handle_; | 66 mojo::ScopedDataPipeConsumerHandle consumer_handle_; |
| 63 | 67 |
| 68 // A helper object required to get CDM from CDM id. |
| 69 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context_; |
| 70 |
| 64 // The AudioDecoder that does actual decoding work. | 71 // The AudioDecoder that does actual decoding work. |
| 65 scoped_ptr<media::AudioDecoder> decoder_; | 72 scoped_ptr<media::AudioDecoder> decoder_; |
| 66 | 73 |
| 67 // The destination for the decoded buffers. | 74 // The destination for the decoded buffers. |
| 68 interfaces::AudioDecoderClientPtr client_; | 75 interfaces::AudioDecoderClientPtr client_; |
| 69 | 76 |
| 77 // Hold a reference to the CDM to keep it alive for the lifetime of the |
| 78 // |decoder_|. The |cdm_| owns the CdmContext which is passed to |decoder_|. |
| 79 scoped_refptr<MediaKeys> cdm_; |
| 80 |
| 70 base::WeakPtr<MojoAudioDecoderService> weak_this_; | 81 base::WeakPtr<MojoAudioDecoderService> weak_this_; |
| 71 base::WeakPtrFactory<MojoAudioDecoderService> weak_factory_; | 82 base::WeakPtrFactory<MojoAudioDecoderService> weak_factory_; |
| 72 | 83 |
| 73 DISALLOW_COPY_AND_ASSIGN(MojoAudioDecoderService); | 84 DISALLOW_COPY_AND_ASSIGN(MojoAudioDecoderService); |
| 74 }; | 85 }; |
| 75 | 86 |
| 76 } // namespace media | 87 } // namespace media |
| 77 | 88 |
| 78 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_SERVICE_H_ | 89 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_SERVICE_H_ |
| OLD | NEW |