kodi
DVDAudioCodecAndroidMediaCodec.h
1 /*
2  * Copyright (C) 2016 Christian Browet
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 "DVDAudioCodec.h"
12 #include "DVDStreamInfo.h"
13 #include "cores/AudioEngine/Utils/AEAudioFormat.h"
14 
15 #include <memory>
16 #include <queue>
17 #include <vector>
18 
19 class CJNIMediaCodec;
20 class CJNIMediaCrypto;
21 class CJNIMediaFormat;
22 class CJNIByteBuffer;
23 class CProcessInfo;
24 
25 struct DemuxPacket;
26 
28 {
29 public:
32 
33  // registration
34  static std::unique_ptr<CDVDAudioCodec> Create(CProcessInfo& processInfo);
35  static bool Register();
36 
37  // required overrides
38 public:
39  bool Open(CDVDStreamInfo &hints, CDVDCodecOptions &options) override;
40  void Dispose() override;
41  bool AddData(const DemuxPacket &packet) override;
42  void GetData(DVDAudioFrame &frame) override;
43  void Reset() override;
44  AEAudioFormat GetFormat() override;
45  std::string GetName() override;
46 
47 protected:
48  int GetData(uint8_t** dst);
49  int GetChannels() { return m_channels; }
50  int GetEncodedChannels() { return m_channels; }
51  CAEChannelInfo GetChannelMap();
52  int GetSampleRate() { return m_samplerate; }
53  int GetEncodedSampleRate() { return m_samplerate; }
54  enum AEDataFormat GetDataFormat() { return AE_FMT_S16NE; }
55 
56  bool ConfigureMediaCodec(void);
57  void ConfigureOutputFormat(CJNIMediaFormat* mediaformat);
58 
59  CDVDStreamInfo m_hints;
60  std::string m_mime;
61  std::string m_codecname;
62  std::string m_formatname;
63  bool m_opened = false, m_codecIsFed = false;
64  int m_samplerate = 0;
65  int m_channels = 0;
66  uint8_t* m_buffer;
67  int m_bufferSize = 0;
68  int m_bufferUsed = 0;
69  AEAudioFormat m_format;
70  double m_currentPts = DVD_NOPTS_VALUE;
71 
72  std::shared_ptr<CJNIMediaCodec> m_codec;
73  CJNIMediaCrypto* m_crypto = nullptr;
74  std::shared_ptr<CDVDAudioCodec> m_decryptCodec;
75 };
Definition: DVDStreamInfo.h:25
Definition: DVDCodecs.h:23
Definition: DVDAudioCodecAndroidMediaCodec.h:27
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: AEChannelInfo.h:19
Definition: DemuxPacket.h:22
Definition: DVDAudioCodec.h:48