xbmc
AEStreamInfo.h
1 /*
2  * Copyright (C) 2010-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 "AEPackIEC61937.h"
12 #include "AEChannelInfo.h"
13 #include <stdint.h>
14 
15 /* ffmpeg re-defines this, so undef it to squash the warning */
16 #undef restrict
17 
18 extern "C" {
19 #include <libavutil/crc.h>
20 }
21 
23 {
24 public:
25  double GetDuration() const;
26  bool operator==(const CAEStreamInfo& info) const;
27 
28  enum DataType
29  {
30  STREAM_TYPE_NULL,
31  STREAM_TYPE_AC3,
32  STREAM_TYPE_DTS_512,
33  STREAM_TYPE_DTS_1024,
34  STREAM_TYPE_DTS_2048,
35  STREAM_TYPE_DTSHD,
36  STREAM_TYPE_DTSHD_CORE,
37  STREAM_TYPE_EAC3,
38  STREAM_TYPE_MLP,
39  STREAM_TYPE_TRUEHD,
40  STREAM_TYPE_DTSHD_MA
41  };
42  DataType m_type = STREAM_TYPE_NULL;
43  unsigned int m_sampleRate;
44  unsigned int m_channels;
45  bool m_dataIsLE = true;
46  unsigned int m_dtsPeriod = 0;
47  unsigned int m_repeat = 0;
48  unsigned int m_ac3FrameSize = 0;
49 };
50 
52 {
53 public:
54 
56  ~CAEStreamParser() = default;
57 
58  int AddData(uint8_t *data, unsigned int size, uint8_t **buffer = NULL, unsigned int *bufferSize = 0);
59 
60  void SetCoreOnly(bool value) { m_coreOnly = value; }
61  unsigned int IsValid() const { return m_hasSync; }
62  unsigned int GetSampleRate() const { return m_info.m_sampleRate; }
63  unsigned int GetChannels() const { return m_info.m_channels; }
64  unsigned int GetFrameSize() const { return m_fsize; }
65  // unsigned int GetDTSBlocks() const { return m_dtsBlocks; }
66  unsigned int GetDTSPeriod() const { return m_info.m_dtsPeriod; }
67  unsigned int GetEAC3BlocksDiv() const { return m_info.m_repeat; }
68  enum CAEStreamInfo::DataType GetDataType() const { return m_info.m_type; }
69  bool IsLittleEndian() const { return m_info.m_dataIsLE; }
70  unsigned int GetBufferSize() const { return m_bufferSize; }
71  CAEStreamInfo& GetStreamInfo() { return m_info; }
72  void Reset();
73 
74 private:
75  uint8_t m_buffer[MAX_IEC61937_PACKET];
76  unsigned int m_bufferSize = 0;
77  unsigned int m_skipBytes = 0;
78 
79  typedef unsigned int (CAEStreamParser::*ParseFunc)(uint8_t *data, unsigned int size);
80 
81  CAEStreamInfo m_info;
82  bool m_coreOnly = false;
83  unsigned int m_needBytes = 0;
84  ParseFunc m_syncFunc;
85  bool m_hasSync = false;
86 
87  unsigned int m_coreSize = 0; /* core size for dtsHD */
88  unsigned int m_dtsBlocks = 0;
89  unsigned int m_fsize = 0;
90  int m_substreams = 0; /* used for TrueHD */
91  AVCRC m_crcTrueHD[1024]; /* TrueHD crc table */
92 
93  void GetPacket(uint8_t **buffer, unsigned int *bufferSize);
94  unsigned int DetectType(uint8_t *data, unsigned int size);
95  bool TrySyncAC3(uint8_t *data, unsigned int size, bool resyncing, bool wantEAC3dependent);
96  unsigned int SyncAC3(uint8_t *data, unsigned int size);
97  unsigned int SyncDTS(uint8_t *data, unsigned int size);
98  unsigned int SyncTrueHD(uint8_t *data, unsigned int size);
99 
100  static unsigned int GetTrueHDChannels(const uint16_t chanmap);
101 };
102 
Definition: AEStreamInfo.h:51
Definition: AEStreamInfo.h:22