| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "media/base/audio_decoder.h" | 14 #include "media/base/audio_decoder.h" |
| 15 #include "media/mojo/interfaces/audio_decoder.mojom.h" | 15 #include "media/mojo/interfaces/audio_decoder.mojom.h" |
| 16 #include "mojo/public/cpp/bindings/strong_binding.h" | |
| 17 | 16 |
| 18 namespace media { | 17 namespace media { |
| 19 | 18 |
| 20 class MediaKeys; | 19 class MediaKeys; |
| 21 class MojoCdmServiceContext; | 20 class MojoCdmServiceContext; |
| 22 class MojoDecoderBufferReader; | 21 class MojoDecoderBufferReader; |
| 23 | 22 |
| 24 class MojoAudioDecoderService : public mojom::AudioDecoder { | 23 class MojoAudioDecoderService : public mojom::AudioDecoder { |
| 25 public: | 24 public: |
| 26 MojoAudioDecoderService( | 25 MojoAudioDecoderService( |
| 27 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context, | 26 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context, |
| 28 std::unique_ptr<media::AudioDecoder> decoder, | 27 std::unique_ptr<media::AudioDecoder> decoder); |
| 29 mojo::InterfaceRequest<mojom::AudioDecoder> request); | |
| 30 | 28 |
| 31 ~MojoAudioDecoderService() final; | 29 ~MojoAudioDecoderService() final; |
| 32 | 30 |
| 33 // mojom::AudioDecoder implementation | 31 // mojom::AudioDecoder implementation |
| 34 void Initialize(mojom::AudioDecoderClientPtr client, | 32 void Initialize(mojom::AudioDecoderClientPtr client, |
| 35 mojom::AudioDecoderConfigPtr config, | 33 mojom::AudioDecoderConfigPtr config, |
| 36 int32_t cdm_id, | 34 int32_t cdm_id, |
| 37 const InitializeCallback& callback) final; | 35 const InitializeCallback& callback) final; |
| 38 | 36 |
| 39 void SetDataSource(mojo::ScopedDataPipeConsumerHandle receive_pipe) final; | 37 void SetDataSource(mojo::ScopedDataPipeConsumerHandle receive_pipe) final; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 52 // Called by |decoder_| when DecoderBuffer is accepted or rejected. | 50 // Called by |decoder_| when DecoderBuffer is accepted or rejected. |
| 53 void OnDecodeStatus(const DecodeCallback& callback, | 51 void OnDecodeStatus(const DecodeCallback& callback, |
| 54 media::DecodeStatus status); | 52 media::DecodeStatus status); |
| 55 | 53 |
| 56 // Called by |decoder_| when reset sequence is finished. | 54 // Called by |decoder_| when reset sequence is finished. |
| 57 void OnResetDone(const ResetCallback& callback); | 55 void OnResetDone(const ResetCallback& callback); |
| 58 | 56 |
| 59 // Called by |decoder_| for each decoded buffer. | 57 // Called by |decoder_| for each decoded buffer. |
| 60 void OnAudioBufferReady(const scoped_refptr<AudioBuffer>& audio_buffer); | 58 void OnAudioBufferReady(const scoped_refptr<AudioBuffer>& audio_buffer); |
| 61 | 59 |
| 62 // A binding represents the association between the service and the | |
| 63 // communication channel, i.e. the pipe. | |
| 64 mojo::StrongBinding<mojom::AudioDecoder> binding_; | |
| 65 | |
| 66 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; | 60 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; |
| 67 | 61 |
| 68 // A helper object required to get CDM from CDM id. | 62 // A helper object required to get CDM from CDM id. |
| 69 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context_; | 63 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context_; |
| 70 | 64 |
| 71 // The AudioDecoder that does actual decoding work. | 65 // The AudioDecoder that does actual decoding work. |
| 72 std::unique_ptr<media::AudioDecoder> decoder_; | 66 std::unique_ptr<media::AudioDecoder> decoder_; |
| 73 | 67 |
| 74 // The destination for the decoded buffers. | 68 // The destination for the decoded buffers. |
| 75 mojom::AudioDecoderClientPtr client_; | 69 mojom::AudioDecoderClientPtr client_; |
| 76 | 70 |
| 77 // Hold a reference to the CDM to keep it alive for the lifetime of the | 71 // 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_|. | 72 // |decoder_|. The |cdm_| owns the CdmContext which is passed to |decoder_|. |
| 79 scoped_refptr<MediaKeys> cdm_; | 73 scoped_refptr<MediaKeys> cdm_; |
| 80 | 74 |
| 81 base::WeakPtr<MojoAudioDecoderService> weak_this_; | 75 base::WeakPtr<MojoAudioDecoderService> weak_this_; |
| 82 base::WeakPtrFactory<MojoAudioDecoderService> weak_factory_; | 76 base::WeakPtrFactory<MojoAudioDecoderService> weak_factory_; |
| 83 | 77 |
| 84 DISALLOW_COPY_AND_ASSIGN(MojoAudioDecoderService); | 78 DISALLOW_COPY_AND_ASSIGN(MojoAudioDecoderService); |
| 85 }; | 79 }; |
| 86 | 80 |
| 87 } // namespace media | 81 } // namespace media |
| 88 | 82 |
| 89 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_SERVICE_H_ | 83 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_SERVICE_H_ |
| OLD | NEW |