kodi
DVDAudioCodec.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include "cores/AudioEngine/Utils/AEAudioFormat.h"
12 #include "cores/VideoPlayer/Interface/DemuxPacket.h"
13 #include "cores/VideoPlayer/Process/ProcessInfo.h"
14 
15 #include <vector>
16 
17 extern "C" {
18 #include <libavcodec/avcodec.h>
19 }
20 
21 struct AVStream;
22 
23 class CDVDStreamInfo;
24 class CDVDCodecOption;
25 class CDVDCodecOptions;
26 
27 typedef struct stDVDAudioFrame
28 {
29  uint8_t* data[16];
30  double pts;
31  bool hasTimestamp;
32  double duration;
33  unsigned int nb_frames;
34  unsigned int framesOut;
35  unsigned int framesize;
36  unsigned int planes;
37 
38  AEAudioFormat format;
39  int bits_per_sample;
40  bool passthrough;
41  enum AVAudioServiceType audio_service_type;
42  enum AVMatrixEncoding matrix_encoding;
43  int profile;
44  bool hasDownmix;
45  double centerMixLevel;
47 
49 {
50 public:
51 
52  explicit CDVDAudioCodec(CProcessInfo &processInfo) : m_processInfo(processInfo) {}
53  virtual ~CDVDAudioCodec() = default;
54 
55  /*
56  * Open the decoder, returns true on success
57  */
58  virtual bool Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) = 0;
59 
60  /*
61  * Dispose, Free all resources
62  */
63  virtual void Dispose() = 0;
64 
65  /*
66  * returns false on error
67  *
68  */
69  virtual bool AddData(const DemuxPacket &packet) = 0;
70 
71  /*
72  * the data is valid until the next call
73  */
74  virtual void GetData(DVDAudioFrame &frame) = 0;
75 
76  /*
77  * resets the decoder
78  */
79  virtual void Reset() = 0;
80 
81  /*
82  * returns the format for the audio stream
83  */
84  virtual AEAudioFormat GetFormat() = 0;
85 
86  /*
87  * should return the average input bit rate
88  */
89  virtual int GetBitRate() { return 0; }
90 
91  /*
92  * returns if the codec requests to use passthrough
93  */
94  virtual bool NeedPassthrough() { return false; }
95 
96  /*
97  * should return codecs name
98  */
99  virtual std::string GetName() = 0;
100 
101  /*
102  * should return amount of data decoded has buffered in preparation for next audio frame
103  */
104  virtual int GetBufferSize() { return 0; }
105 
106  /*
107  * should return the ffmpeg matrix encoding type
108  */
109  virtual enum AVMatrixEncoding GetMatrixEncoding() { return AV_MATRIX_ENCODING_NONE; }
110 
111  /*
112  * should return the ffmpeg audio service type
113  */
114  virtual enum AVAudioServiceType GetAudioServiceType() { return AV_AUDIO_SERVICE_TYPE_MAIN; }
115 
116  /*
117  * should return the ffmpeg profile value
118  */
119  virtual int GetProfile() { return 0; }
120 
121 protected:
122  CProcessInfo &m_processInfo;
123 };
Definition: DVDStreamInfo.h:25
Definition: DVDCodecs.h:23
The audio format structure that fully defines a stream&#39;s audio information.
Definition: AEAudioFormat.h:19
Definition: ProcessInfo.h:26
Definition: DVDAudioCodec.h:27
Definition: DemuxPacket.h:22
Definition: DVDAudioCodec.h:48
Definition: DVDCodecs.h:15