| 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" | 16 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 17 #include "mojo/public/cpp/system/data_pipe.h" | |
| 18 | 17 |
| 19 namespace media { | 18 namespace media { |
| 20 | 19 |
| 21 class MediaKeys; | 20 class MediaKeys; |
| 22 class MojoCdmServiceContext; | 21 class MojoCdmServiceContext; |
| 22 class MojoDecoderBufferReader; |
| 23 | 23 |
| 24 class MojoAudioDecoderService : public mojom::AudioDecoder { | 24 class MojoAudioDecoderService : public mojom::AudioDecoder { |
| 25 public: | 25 public: |
| 26 MojoAudioDecoderService( | 26 MojoAudioDecoderService( |
| 27 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context, | 27 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context, |
| 28 std::unique_ptr<media::AudioDecoder> decoder, | 28 std::unique_ptr<media::AudioDecoder> decoder, |
| 29 mojo::InterfaceRequest<mojom::AudioDecoder> request); | 29 mojo::InterfaceRequest<mojom::AudioDecoder> request); |
| 30 | 30 |
| 31 ~MojoAudioDecoderService() final; | 31 ~MojoAudioDecoderService() final; |
| 32 | 32 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 52 // Called by |decoder_| when DecoderBuffer is accepted or rejected. | 52 // Called by |decoder_| when DecoderBuffer is accepted or rejected. |
| 53 void OnDecodeStatus(const DecodeCallback& callback, | 53 void OnDecodeStatus(const DecodeCallback& callback, |
| 54 media::DecodeStatus status); | 54 media::DecodeStatus status); |
| 55 | 55 |
| 56 // Called by |decoder_| when reset sequence is finished. | 56 // Called by |decoder_| when reset sequence is finished. |
| 57 void OnResetDone(const ResetCallback& callback); | 57 void OnResetDone(const ResetCallback& callback); |
| 58 | 58 |
| 59 // Called by |decoder_| for each decoded buffer. | 59 // Called by |decoder_| for each decoded buffer. |
| 60 void OnAudioBufferReady(const scoped_refptr<AudioBuffer>& audio_buffer); | 60 void OnAudioBufferReady(const scoped_refptr<AudioBuffer>& audio_buffer); |
| 61 | 61 |
| 62 // A helper method to read and deserialize DecoderBuffer from data pipe. | |
| 63 // Returns empty scoped_refptr in case of an error. | |
| 64 scoped_refptr<DecoderBuffer> ReadDecoderBuffer( | |
| 65 mojom::DecoderBufferPtr buffer); | |
| 66 | |
| 67 // A binding represents the association between the service and the | 62 // A binding represents the association between the service and the |
| 68 // communication channel, i.e. the pipe. | 63 // communication channel, i.e. the pipe. |
| 69 mojo::StrongBinding<mojom::AudioDecoder> binding_; | 64 mojo::StrongBinding<mojom::AudioDecoder> binding_; |
| 70 | 65 |
| 71 // DataPipe for serializing the data section of DecoderBuffer. | 66 std::unique_ptr<MojoDecoderBufferReader> mojo_decoder_buffer_reader_; |
| 72 mojo::ScopedDataPipeConsumerHandle consumer_handle_; | |
| 73 | 67 |
| 74 // A helper object required to get CDM from CDM id. | 68 // A helper object required to get CDM from CDM id. |
| 75 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context_; | 69 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context_; |
| 76 | 70 |
| 77 // The AudioDecoder that does actual decoding work. | 71 // The AudioDecoder that does actual decoding work. |
| 78 std::unique_ptr<media::AudioDecoder> decoder_; | 72 std::unique_ptr<media::AudioDecoder> decoder_; |
| 79 | 73 |
| 80 // The destination for the decoded buffers. | 74 // The destination for the decoded buffers. |
| 81 mojom::AudioDecoderClientPtr client_; | 75 mojom::AudioDecoderClientPtr client_; |
| 82 | 76 |
| 83 // Hold a reference to the CDM to keep it alive for the lifetime of the | 77 // Hold a reference to the CDM to keep it alive for the lifetime of the |
| 84 // |decoder_|. The |cdm_| owns the CdmContext which is passed to |decoder_|. | 78 // |decoder_|. The |cdm_| owns the CdmContext which is passed to |decoder_|. |
| 85 scoped_refptr<MediaKeys> cdm_; | 79 scoped_refptr<MediaKeys> cdm_; |
| 86 | 80 |
| 87 base::WeakPtr<MojoAudioDecoderService> weak_this_; | 81 base::WeakPtr<MojoAudioDecoderService> weak_this_; |
| 88 base::WeakPtrFactory<MojoAudioDecoderService> weak_factory_; | 82 base::WeakPtrFactory<MojoAudioDecoderService> weak_factory_; |
| 89 | 83 |
| 90 DISALLOW_COPY_AND_ASSIGN(MojoAudioDecoderService); | 84 DISALLOW_COPY_AND_ASSIGN(MojoAudioDecoderService); |
| 91 }; | 85 }; |
| 92 | 86 |
| 93 } // namespace media | 87 } // namespace media |
| 94 | 88 |
| 95 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_SERVICE_H_ | 89 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_SERVICE_H_ |
| OLD | NEW |