Revert "[M120 Migration]Fix for crash during chrome exit"
[platform/framework/web/chromium-efl.git] / media / filters / passthrough_dts_audio_decoder.h
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.
4
5 #ifndef MEDIA_FILTERS_PASSTHROUGH_DTS_AUDIO_DECODER_H_
6 #define MEDIA_FILTERS_PASSTHROUGH_DTS_AUDIO_DECODER_H_
7
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"
12
13 namespace base {
14 class SequencedTaskRunner;
15 }
16
17 namespace media {
18
19 class DecoderBuffer;
20
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 {
27  public:
28   PassthroughDTSAudioDecoder(
29       const scoped_refptr<base::SequencedTaskRunner>& task_runner,
30       MediaLog* media_log);
31   PassthroughDTSAudioDecoder(const PassthroughDTSAudioDecoder&) = delete;
32   PassthroughDTSAudioDecoder& operator=(const PassthroughDTSAudioDecoder&) =
33       delete;
34   ~PassthroughDTSAudioDecoder() override;
35
36   // AudioDecoder implementation.
37   AudioDecoderType GetDecoderType() const override;
38   void Initialize(const AudioDecoderConfig& config,
39                   CdmContext* cdm_context,
40                   InitCB init_cb,
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;
45
46  private:
47   // Reset decoder and call |reset_cb_|.
48   void DoReset();
49
50   // Process an unencrypted buffer with a DTS audio frame.
51   void ProcessBuffer(const DecoderBuffer& buffer, DecodeCB decode_cb);
52
53   // Encapsulate a DTS audio frame in IEC-61937.
54   void EncapsulateFrame(const DecoderBuffer& buffer);
55
56   scoped_refptr<base::SequencedTaskRunner> task_runner_;
57   SEQUENCE_CHECKER(sequence_checker_);
58
59   OutputCB output_cb_;
60
61   AudioDecoderConfig config_;
62
63   MediaLog* media_log_;
64
65   scoped_refptr<AudioBufferMemoryPool> pool_;
66 };
67
68 }  // namespace media
69
70 #endif  // MEDIA_FILTERS_PASSTHROUGH_DTS_AUDIO_DECODER_H_