Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(758)

Side by Side Diff: media/mojo/services/mojo_audio_decoder_service.h

Issue 1824763002: Get CdmContext in MojoAudioDecoderService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@spitzer-audio-serialize
Patch Set: Rebased, fixed typo in a comment Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
31 35
32 void SetDataSource(mojo::ScopedDataPipeConsumerHandle receive_pipe) final; 36 void SetDataSource(mojo::ScopedDataPipeConsumerHandle receive_pipe) final;
33 37
34 void Decode(interfaces::DecoderBufferPtr buffer, 38 void Decode(interfaces::DecoderBufferPtr buffer,
35 const DecodeCallback& callback) final; 39 const DecodeCallback& callback) final;
36 40
37 void Reset(const ResetCallback& callback) final; 41 void Reset(const ResetCallback& callback) final;
38 42
39 private: 43 private:
40 // Called by |decoder_| upon finishing initialization. 44 // Called by |decoder_| upon finishing initialization.
41 void OnInitialized(const InitializeCallback& callback, bool success); 45 void OnInitialized(const InitializeCallback& callback,
46 scoped_refptr<MediaKeys> cdm,
47 bool success);
42 48
43 // Called by |decoder_| when DecoderBuffer is accepted or rejected. 49 // Called by |decoder_| when DecoderBuffer is accepted or rejected.
44 void OnDecodeStatus(const DecodeCallback& callback, 50 void OnDecodeStatus(const DecodeCallback& callback,
45 media::AudioDecoder::Status status); 51 media::AudioDecoder::Status status);
46 52
47 // Called by |decoder_| when reset sequence is finished. 53 // Called by |decoder_| when reset sequence is finished.
48 void OnResetDone(const ResetCallback& callback); 54 void OnResetDone(const ResetCallback& callback);
49 55
50 // Called by |decoder_| for each decoded buffer. 56 // Called by |decoder_| for each decoded buffer.
51 void OnAudioBufferReady(const scoped_refptr<AudioBuffer>& audio_buffer); 57 void OnAudioBufferReady(const scoped_refptr<AudioBuffer>& audio_buffer);
52 58
53 // A helper method to read and deserialize DecoderBuffer from data pipe. 59 // A helper method to read and deserialize DecoderBuffer from data pipe.
54 scoped_refptr<DecoderBuffer> ReadDecoderBuffer( 60 scoped_refptr<DecoderBuffer> ReadDecoderBuffer(
55 interfaces::DecoderBufferPtr buffer); 61 interfaces::DecoderBufferPtr buffer);
56 62
57 // A binding represents the association between the service and the 63 // A binding represents the association between the service and the
58 // communication channel, i.e. the pipe. 64 // communication channel, i.e. the pipe.
59 mojo::StrongBinding<interfaces::AudioDecoder> binding_; 65 mojo::StrongBinding<interfaces::AudioDecoder> binding_;
60 66
61 // DataPipe for serializing the data section of DecoderBuffer. 67 // DataPipe for serializing the data section of DecoderBuffer.
62 mojo::ScopedDataPipeConsumerHandle consumer_handle_; 68 mojo::ScopedDataPipeConsumerHandle consumer_handle_;
63 69
70 // A helper object required to get CDM from CDM id.
71 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context_;
72
64 // The AudioDecoder that does actual decoding work. 73 // The AudioDecoder that does actual decoding work.
65 scoped_ptr<media::AudioDecoder> decoder_; 74 scoped_ptr<media::AudioDecoder> decoder_;
66 75
67 // The destination for the decoded buffers. 76 // The destination for the decoded buffers.
68 interfaces::AudioDecoderClientPtr client_; 77 interfaces::AudioDecoderClientPtr client_;
69 78
79 // Hold a reference to the CDM to keep it alive for the lifetime of the
80 // |decoder_|. The |cdm_| owns the CdmContext which is passed to |decoder_|.
81 scoped_refptr<MediaKeys> cdm_;
82
70 base::WeakPtr<MojoAudioDecoderService> weak_this_; 83 base::WeakPtr<MojoAudioDecoderService> weak_this_;
71 base::WeakPtrFactory<MojoAudioDecoderService> weak_factory_; 84 base::WeakPtrFactory<MojoAudioDecoderService> weak_factory_;
72 85
73 DISALLOW_COPY_AND_ASSIGN(MojoAudioDecoderService); 86 DISALLOW_COPY_AND_ASSIGN(MojoAudioDecoderService);
74 }; 87 };
75 88
76 } // namespace media 89 } // namespace media
77 90
78 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_SERVICE_H_ 91 #endif // MEDIA_MOJO_SERVICES_MOJO_AUDIO_DECODER_SERVICE_H_
OLDNEW
« no previous file with comments | « media/mojo/interfaces/audio_decoder.mojom ('k') | media/mojo/services/mojo_audio_decoder_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698