1 // Copyright 2022 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_FILTERS_PASSTHROUGH_DTS_AUDIO_DECODER_H_
6 #define MEDIA_FILTERS_PASSTHROUGH_DTS_AUDIO_DECODER_H_
8 #include "media/base/audio_buffer.h"
9 #include "media/base/audio_decoder.h"
10 #include "media/base/media_log.h"
11 #include "media/base/sample_format.h"
14 class SequencedTaskRunner;
21 // PassthroughDTSAudioDecoder does not decode DTS audio frames. Instead,
22 // every DTS audio frame is encapsulated in IEC-61937 frame, which is
23 // then pass to a compatible HDMI audio sink for actual decoding.
24 // All public APIs and callbacks are trampolined to the |task_runner_| so
25 // that no locks are required for thread safety.
26 class MEDIA_EXPORT PassthroughDTSAudioDecoder : public AudioDecoder {
28 PassthroughDTSAudioDecoder(
29 const scoped_refptr<base::SequencedTaskRunner>& task_runner,
31 PassthroughDTSAudioDecoder(const PassthroughDTSAudioDecoder&) = delete;
32 PassthroughDTSAudioDecoder& operator=(const PassthroughDTSAudioDecoder&) =
34 ~PassthroughDTSAudioDecoder() override;
36 // AudioDecoder implementation.
37 AudioDecoderType GetDecoderType() const override;
38 void Initialize(const AudioDecoderConfig& config,
39 CdmContext* cdm_context,
41 const OutputCB& output_cb,
42 const WaitingCB& waiting_cb) override;
43 void Decode(scoped_refptr<DecoderBuffer> buffer, DecodeCB decode_cb) override;
44 void Reset(base::OnceClosure closure) override;
47 // Reset decoder and call |reset_cb_|.
50 // Process an unencrypted buffer with a DTS audio frame.
51 void ProcessBuffer(const DecoderBuffer& buffer, DecodeCB decode_cb);
53 // Encapsulate a DTS audio frame in IEC-61937.
54 void EncapsulateFrame(const DecoderBuffer& buffer);
56 scoped_refptr<base::SequencedTaskRunner> task_runner_;
57 SEQUENCE_CHECKER(sequence_checker_);
61 AudioDecoderConfig config_;
65 scoped_refptr<AudioBufferMemoryPool> pool_;
70 #endif // MEDIA_FILTERS_PASSTHROUGH_DTS_AUDIO_DECODER_H_