mirror of
https://github.com/LibreELEC/LibreELEC.tv.git
synced 2025-07-29 21:56:42 +00:00
Merge pull request #7766 from heitbaum/inputstream.adaptive
Inputstream.adaptive: update to 21.1.1-Omega
This commit is contained in:
commit
35cc629970
@ -2,14 +2,14 @@
|
||||
# Copyright (C) 2016-present Team LibreELEC (https://libreelec.tv)
|
||||
|
||||
PKG_NAME="inputstream.adaptive"
|
||||
PKG_VERSION="21.1.0-Omega"
|
||||
PKG_SHA256="1e250d1ae55c0c9d9498ccb97212c55738388b1858cc4db997c05e32ee6b151d"
|
||||
PKG_VERSION="21.1.1-Omega"
|
||||
PKG_SHA256="3002ed760913782a8be4cb37f5f7b7397d1a3edde663c56a088e432ed37ace44"
|
||||
PKG_REV="1"
|
||||
PKG_ARCH="any"
|
||||
PKG_LICENSE="GPL"
|
||||
PKG_SITE="https://github.com/xbmc/inputstream.adaptive"
|
||||
PKG_URL="https://github.com/xbmc/inputstream.adaptive/archive/${PKG_VERSION}.tar.gz"
|
||||
PKG_DEPENDS_TARGET="toolchain kodi-platform bento4 expat nss"
|
||||
PKG_DEPENDS_TARGET="toolchain kodi-platform bento4 expat nss pugixml"
|
||||
PKG_SECTION=""
|
||||
PKG_SHORTDESC="inputstream.adaptive"
|
||||
PKG_LONGDESC="inputstream.adaptive"
|
||||
|
@ -1,111 +0,0 @@
|
||||
From 7b5c284e63c1d6327db7551a0646cffcbaf9410f Mon Sep 17 00:00:00 2001
|
||||
From: Rudi Heitbaum <rudi@heitbaum.com>
|
||||
Date: Wed, 26 Apr 2023 15:47:17 +0000
|
||||
Subject: [PATCH] include missing <cstdint> to support gcc-13
|
||||
|
||||
gcc 13 moved some includes around and as a result <cstdint> is no longer transitively
|
||||
included [1]. Explicitly include it for uint{32,64}_t.
|
||||
|
||||
[1] https://gcc.gnu.org/gcc-13/porting_to.html#header-dep-changes
|
||||
|
||||
Signed-off-by: Rudi Heitbaum <rudi@heitbaum.com>
|
||||
---
|
||||
src/Iaes_decrypter.h | 3 ++-
|
||||
src/SSD_dll.h | 1 +
|
||||
src/utils/FileUtils.h | 1 +
|
||||
src/utils/PropertiesUtils.h | 1 +
|
||||
src/utils/StringUtils.h | 1 +
|
||||
src/utils/Utils.h | 1 +
|
||||
6 files changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/Iaes_decrypter.h b/src/Iaes_decrypter.h
|
||||
index 7fdf6046d..da992be95 100644
|
||||
--- a/src/Iaes_decrypter.h
|
||||
+++ b/src/Iaes_decrypter.h
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <bento4/Ap4Types.h>
|
||||
|
||||
+#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
class IAESDecrypter
|
||||
@@ -31,4 +32,4 @@ class IAESDecrypter
|
||||
|
||||
private:
|
||||
std::string m_licenseKey;
|
||||
-};
|
||||
\ No newline at end of file
|
||||
+};
|
||||
diff --git a/src/SSD_dll.h b/src/SSD_dll.h
|
||||
index 4b2b70c1a..d23fcbe45 100644
|
||||
--- a/src/SSD_dll.h
|
||||
+++ b/src/SSD_dll.h
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
+#include <cstdint>
|
||||
#include <stdarg.h> // va_list, va_start, va_arg, va_end
|
||||
#include <string_view>
|
||||
|
||||
diff --git a/src/utils/FileUtils.h b/src/utils/FileUtils.h
|
||||
index 40745b0d4..0924d8ff7 100644
|
||||
--- a/src/utils/FileUtils.h
|
||||
+++ b/src/utils/FileUtils.h
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
+#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
diff --git a/src/utils/PropertiesUtils.h b/src/utils/PropertiesUtils.h
|
||||
index dee3e0a16..a658b835c 100644
|
||||
--- a/src/utils/PropertiesUtils.h
|
||||
+++ b/src/utils/PropertiesUtils.h
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
+#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
diff --git a/src/utils/StringUtils.h b/src/utils/StringUtils.h
|
||||
index 3f841a274..f209546fa 100644
|
||||
--- a/src/utils/StringUtils.h
|
||||
+++ b/src/utils/StringUtils.h
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
+#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
diff --git a/src/utils/Utils.h b/src/utils/Utils.h
|
||||
index 4966ece63..472a328c4 100644
|
||||
--- a/src/utils/Utils.h
|
||||
+++ b/src/utils/Utils.h
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
+#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
diff --git a/src/common/AdaptiveDecrypter.h b/src/common/AdaptiveDecrypter.h
|
||||
index 4966ece63..472a328c4 100644
|
||||
--- a/src/common/AdaptiveDecrypter.h
|
||||
+++ b/src/common/AdaptiveDecrypter.h
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include "../CryptoMode.h"
|
||||
|
||||
+#include <cstdint>
|
||||
#include <stdexcept>
|
||||
#include <string_view>
|
||||
|
@ -0,0 +1,595 @@
|
||||
From d2a2f40f0724925c8e91d4259a89ea98338b4a6a Mon Sep 17 00:00:00 2001
|
||||
From: Glenn Guy <glennguy@users.noreply.github.com>
|
||||
Date: Mon, 29 May 2023 10:53:46 +1000
|
||||
Subject: [PATCH 1/2] [ADTS] add support for AC3 and E-AC3
|
||||
|
||||
---
|
||||
CMakeLists.txt | 2 +
|
||||
src/ADTSReader.cpp | 149 ++++++++++++++++++------
|
||||
src/ADTSReader.h | 14 ++-
|
||||
src/parser/CodecParser.cpp | 230 +++++++++++++++++++++++++++++++++++++
|
||||
src/parser/CodecParser.h | 60 ++++++++++
|
||||
5 files changed, 417 insertions(+), 38 deletions(-)
|
||||
create mode 100644 src/parser/CodecParser.cpp
|
||||
create mode 100644 src/parser/CodecParser.h
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 6225ef8bd..6601fbbc6 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -37,6 +37,7 @@ set(ADP_SOURCES
|
||||
src/common/Segment.cpp
|
||||
src/common/SegmentList.cpp
|
||||
src/common/SegTemplate.cpp
|
||||
+ src/parser/CodecParser.cpp
|
||||
src/parser/DASHTree.cpp
|
||||
src/parser/HLSTree.cpp
|
||||
src/parser/SmoothTree.cpp
|
||||
@@ -102,6 +103,7 @@ set(ADP_HEADERS
|
||||
src/common/Segment.h
|
||||
src/common/SegmentList.h
|
||||
src/common/SegTemplate.h
|
||||
+ src/parser/CodecParser.h
|
||||
src/parser/DASHTree.h
|
||||
src/parser/HLSTree.h
|
||||
src/parser/SmoothTree.h
|
||||
diff --git a/src/ADTSReader.cpp b/src/ADTSReader.cpp
|
||||
index c0256a63c..58ee74a8b 100644
|
||||
--- a/src/ADTSReader.cpp
|
||||
+++ b/src/ADTSReader.cpp
|
||||
@@ -7,9 +7,15 @@
|
||||
*/
|
||||
|
||||
#include "ADTSReader.h"
|
||||
-#include <bento4/Ap4ByteStream.h>
|
||||
+
|
||||
+#include "parser/CodecParser.h"
|
||||
+#include "utils/log.h"
|
||||
+
|
||||
#include <stdlib.h>
|
||||
|
||||
+#include <bento4/Ap4ByteStream.h>
|
||||
+using namespace adaptive;
|
||||
+
|
||||
uint64_t ID3TAG::getSize(const uint8_t *data, unsigned int len, unsigned int shift)
|
||||
{
|
||||
uint64_t size(0);
|
||||
@@ -73,62 +79,141 @@ ID3TAG::PARSECODE ID3TAG::parse(AP4_ByteStream *stream)
|
||||
|
||||
/**********************************************************************************************************************************/
|
||||
|
||||
-uint64_t ADTSFrame::getBE(const uint8_t *data, unsigned int len)
|
||||
+void ADTSFrame::AdjustStreamForPadding(AP4_ByteStream* stream)
|
||||
{
|
||||
- uint64_t size(0);
|
||||
- const uint8_t *dataE(data + len);
|
||||
- for (; data < dataE; ++data)
|
||||
- size = size << 8 | *data;
|
||||
- return size;
|
||||
-};
|
||||
+ AP4_Position currentPos;
|
||||
+ AP4_Position newPos;
|
||||
+ stream->Tell(currentPos);
|
||||
+ stream->Seek(currentPos + 16);
|
||||
+ stream->Tell(newPos);
|
||||
+ if (newPos - currentPos == 16)
|
||||
+ stream->Seek(currentPos);
|
||||
+}
|
||||
|
||||
-bool ADTSFrame::parse(AP4_ByteStream *stream)
|
||||
+bool ADTSFrame::parse(AP4_ByteStream* stream)
|
||||
{
|
||||
- uint8_t buffer[64];
|
||||
+ AdtsType adtsType = CAdaptiveAdtsHeaderParser::GetAdtsType(stream);
|
||||
+ switch (adtsType)
|
||||
+ {
|
||||
+ case AdtsType::AAC:
|
||||
+ return ParseAac(stream);
|
||||
+ case AdtsType::AC3:
|
||||
+ return ParseAc3(stream);
|
||||
+ case AdtsType::EAC3:
|
||||
+ return ParseEc3(stream);
|
||||
+ case AdtsType::AC4:
|
||||
+ return false;
|
||||
+ default:
|
||||
+ return false;
|
||||
+ }
|
||||
+}
|
||||
|
||||
- static const uint32_t freqTable[13] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350 };
|
||||
+bool ADTSFrame::ParseAac(AP4_ByteStream* stream)
|
||||
+{
|
||||
+ AP4_DataBuffer buffer;
|
||||
+ buffer.SetDataSize(16);
|
||||
|
||||
- if (!AP4_SUCCEEDED(stream->Read(buffer, 2)))
|
||||
+ if (!AP4_SUCCEEDED(stream->Read(buffer.UseData(), AP4_ADTS_HEADER_SIZE)))
|
||||
return false;
|
||||
|
||||
- m_outerHeader = static_cast<uint16_t>(getBE(buffer, 2));
|
||||
- if ((m_outerHeader & 0xFFF6u) != 0xFFF0u)
|
||||
+ CAdaptiveAdtsParser parser;
|
||||
+ AP4_AacFrame frame;
|
||||
+ AP4_Size sz = buffer.GetDataSize();
|
||||
+ parser.Feed(buffer.GetData(), &sz);
|
||||
+ AP4_Result result = parser.FindFrameHeader(frame);
|
||||
+ if (!AP4_SUCCEEDED(result))
|
||||
return false;
|
||||
|
||||
- m_innerHeaderSize = (m_outerHeader & 1) ? 7 : 5; // 16 bit CRC
|
||||
- if (!AP4_SUCCEEDED(stream->Read(buffer, m_innerHeaderSize)))
|
||||
+ m_totalSize = frame.m_Info.m_FrameLength + AP4_ADTS_HEADER_SIZE;
|
||||
+ m_frameCount = 1024;
|
||||
+ m_summedFrameCount += m_frameCount;
|
||||
+ m_sampleRate = frame.m_Info.m_SamplingFrequency;
|
||||
+ m_channelCount = frame.m_Info.m_ChannelConfiguration;
|
||||
+
|
||||
+ // rewind stream to beginning of syncframe
|
||||
+ AP4_Position currentPos;
|
||||
+ stream->Tell(currentPos);
|
||||
+ stream->Seek(currentPos - (AP4_ADTS_HEADER_SIZE));
|
||||
+
|
||||
+ m_dataBuffer.SetDataSize(m_totalSize);
|
||||
+ if (!AP4_SUCCEEDED(stream->Read(m_dataBuffer.UseData(), m_dataBuffer.GetDataSize())))
|
||||
return false;
|
||||
|
||||
- m_innerHeader = getBE(buffer, m_innerHeaderSize);
|
||||
- // add 0 crc to have bits on same place for crc / nocrc
|
||||
- m_innerHeader <<= ((7 - m_innerHeaderSize) * 8);
|
||||
+ AdjustStreamForPadding(stream);
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+bool ADTSFrame::ParseAc3(AP4_ByteStream* stream)
|
||||
+{
|
||||
+ AP4_DataBuffer buffer;
|
||||
+ buffer.SetDataSize(AP4_AC3_HEADER_SIZE);
|
||||
|
||||
- m_totalSize = (m_innerHeader >> 0x1D) & 0x1FFFu;
|
||||
- m_frameCount = ((m_innerHeader >> 0x10) & 0x3u) ? 960 : 1024;
|
||||
+ if (!AP4_SUCCEEDED(stream->Read(buffer.UseData(), AP4_AC3_HEADER_SIZE)))
|
||||
+ return false;
|
||||
+
|
||||
+ CAdaptiveAc3Parser parser;
|
||||
+ AP4_Ac3Frame frame;
|
||||
+ AP4_Size sz = buffer.GetDataSize();
|
||||
+ parser.Feed(buffer.GetData(), &sz);
|
||||
+ AP4_Result result = parser.FindFrameHeader(frame);
|
||||
+ if (!AP4_SUCCEEDED(result))
|
||||
+ return false;
|
||||
+
|
||||
+ m_totalSize = frame.m_Info.m_FrameSize;
|
||||
+ m_sampleRate = frame.m_Info.m_SampleRate;
|
||||
+ m_channelCount = frame.m_Info.m_ChannelCount;
|
||||
+ m_frameCount = 256 * m_channelCount;
|
||||
m_summedFrameCount += m_frameCount;
|
||||
- m_sampleRate = (m_innerHeader >> 0x32) & 0xFu;
|
||||
- m_sampleRate = (m_sampleRate < 13) ? freqTable[m_sampleRate] : 0;
|
||||
- m_channelConfig = (m_innerHeader >> 0x2E) & 0x7u;
|
||||
|
||||
+ // rewind stream to beginning of syncframe
|
||||
AP4_Position currentPos;
|
||||
stream->Tell(currentPos);
|
||||
- stream->Seek(currentPos - (m_innerHeaderSize + 2));
|
||||
+ stream->Seek(currentPos - (AP4_AC3_HEADER_SIZE));
|
||||
|
||||
m_dataBuffer.SetDataSize(m_totalSize);
|
||||
if (!AP4_SUCCEEDED(stream->Read(m_dataBuffer.UseData(), m_dataBuffer.GetDataSize())))
|
||||
return false;
|
||||
|
||||
- //ADTS Streams have padding, at EOF
|
||||
- AP4_Position pos, posNew;
|
||||
- stream->Tell(pos);
|
||||
- stream->Seek(pos + 16);
|
||||
- stream->Tell(posNew);
|
||||
- if (posNew - pos == 16)
|
||||
- stream->Seek(pos);
|
||||
+ AdjustStreamForPadding(stream);
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+bool ADTSFrame::ParseEc3(AP4_ByteStream* stream)
|
||||
+{
|
||||
+ AP4_DataBuffer buffer;
|
||||
+ buffer.SetDataSize(AP4_EAC3_HEADER_SIZE);
|
||||
+
|
||||
+ if (!AP4_SUCCEEDED(stream->Read(buffer.UseData(), AP4_EAC3_HEADER_SIZE)))
|
||||
+ return false;
|
||||
+
|
||||
+ CAdaptiveEac3Parser parser;
|
||||
+ AP4_Eac3Frame frame;
|
||||
+ AP4_Size sz = buffer.GetDataSize();
|
||||
+ parser.Feed(buffer.GetData(), &sz);
|
||||
+ AP4_Result result = parser.FindFrameHeader(frame);
|
||||
+ if (!AP4_SUCCEEDED(result))
|
||||
+ return false;
|
||||
|
||||
+ m_totalSize = frame.m_Info.m_FrameSize;
|
||||
+ m_sampleRate = frame.m_Info.m_SampleRate;
|
||||
+ m_channelCount = frame.m_Info.m_ChannelCount;
|
||||
+ m_frameCount = 256 * m_channelCount;
|
||||
+ m_summedFrameCount += m_frameCount;
|
||||
+
|
||||
+ // rewind stream to beginning of syncframe
|
||||
+ AP4_Position currentPos;
|
||||
+ stream->Tell(currentPos);
|
||||
+ stream->Seek(currentPos - (AP4_EAC3_HEADER_SIZE));
|
||||
+
|
||||
+ m_dataBuffer.SetDataSize(m_totalSize);
|
||||
+ if (!AP4_SUCCEEDED(stream->Read(m_dataBuffer.UseData(), m_dataBuffer.GetDataSize())))
|
||||
+ return false;
|
||||
+
|
||||
+ AdjustStreamForPadding(stream);
|
||||
return true;
|
||||
}
|
||||
|
||||
+
|
||||
/**********************************************************************************************************************************/
|
||||
|
||||
|
||||
diff --git a/src/ADTSReader.h b/src/ADTSReader.h
|
||||
index e5ba05431..8f1af5d95 100644
|
||||
--- a/src/ADTSReader.h
|
||||
+++ b/src/ADTSReader.h
|
||||
@@ -42,7 +42,14 @@ class ATTR_DLL_LOCAL ID3TAG
|
||||
class ATTR_DLL_LOCAL ADTSFrame
|
||||
{
|
||||
public:
|
||||
+ /*! \brief Adjust the stream position to advance over padding if neccessary (end of file)
|
||||
+ * \param stream The stream to check
|
||||
+ */
|
||||
+ void AdjustStreamForPadding(AP4_ByteStream* stream);
|
||||
bool parse(AP4_ByteStream *stream);
|
||||
+ bool ParseAac(AP4_ByteStream* stream);
|
||||
+ bool ParseAc3(AP4_ByteStream* stream);
|
||||
+ bool ParseEc3(AP4_ByteStream* stream);
|
||||
void reset() { m_summedFrameCount = 0; m_frameCount = 0; m_dataBuffer.SetDataSize(0); }
|
||||
void resetFrameCount() { m_summedFrameCount = 0; }
|
||||
uint64_t getPtsOffset() const { return m_sampleRate ? (static_cast<uint64_t>(m_summedFrameCount) * 90000) / m_sampleRate : 0; }
|
||||
@@ -50,16 +57,11 @@ class ATTR_DLL_LOCAL ADTSFrame
|
||||
const AP4_Byte *getData() const { return m_dataBuffer.GetData(); }
|
||||
AP4_Size getDataSize() const { return m_dataBuffer.GetDataSize(); }
|
||||
private:
|
||||
- uint64_t getBE(const uint8_t *data, unsigned int len);
|
||||
- uint16_t m_outerHeader;
|
||||
- uint64_t m_innerHeader;
|
||||
- long m_innerHeaderSize;
|
||||
-
|
||||
uint32_t m_totalSize = 0;
|
||||
uint32_t m_summedFrameCount = 0;
|
||||
uint32_t m_frameCount = 0;
|
||||
uint32_t m_sampleRate = 0;
|
||||
- uint32_t m_channelConfig = 0;
|
||||
+ uint32_t m_channelCount = 0;
|
||||
|
||||
AP4_DataBuffer m_dataBuffer;
|
||||
};
|
||||
diff --git a/src/parser/CodecParser.cpp b/src/parser/CodecParser.cpp
|
||||
new file mode 100644
|
||||
index 000000000..2ee7a6456
|
||||
--- /dev/null
|
||||
+++ b/src/parser/CodecParser.cpp
|
||||
@@ -0,0 +1,230 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2023 Team Kodi
|
||||
+ * This file is part of Kodi - https://kodi.tv
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+ * See LICENSES/README.md for more information.
|
||||
+ */
|
||||
+
|
||||
+#include "CodecParser.h"
|
||||
+
|
||||
+#include <bento4/Ap4Utils.h>
|
||||
+using namespace adaptive;
|
||||
+
|
||||
+AdtsType CAdaptiveAdtsHeaderParser::GetAdtsType(AP4_ByteStream* stream)
|
||||
+{
|
||||
+ AP4_DataBuffer buffer;
|
||||
+ buffer.SetDataSize(AP4_EAC3_HEADER_SIZE); // max header size is 64 (E-AC3)
|
||||
+ AdtsType adtsType = AdtsType::NONE;
|
||||
+
|
||||
+ if (!AP4_SUCCEEDED(stream->Read(buffer.UseData(), AP4_EAC3_HEADER_SIZE)))
|
||||
+ return adtsType;
|
||||
+
|
||||
+ AP4_BitReader bits(buffer.GetData(), AP4_EAC3_HEADER_SIZE);
|
||||
+ AP4_UI32 syncWord = bits.ReadBits(16);
|
||||
+ if ((syncWord & AP4_ADTS_SYNC_MASK) == AP4_ADTS_SYNC_PATTERN)
|
||||
+ {
|
||||
+ adtsType = AdtsType::AAC;
|
||||
+ }
|
||||
+ else if ((syncWord & AP4_AC4_SYNC_MASK) == AP4_AC4_SYNC_PATTERN)
|
||||
+ {
|
||||
+ adtsType = AdtsType::AC4;
|
||||
+ }
|
||||
+ else if (syncWord == AP4_AC3_SYNC_PATTERN)
|
||||
+ {
|
||||
+ bits.SkipBits(24);
|
||||
+ AP4_UI32 bitStreamID = bits.ReadBits(5);
|
||||
+ if ((bitStreamID > 10) && (bitStreamID <= 16))
|
||||
+ {
|
||||
+ adtsType = AdtsType::EAC3;
|
||||
+ }
|
||||
+ else if (bitStreamID <= 10)
|
||||
+ {
|
||||
+ adtsType = AdtsType::AC3;
|
||||
+ }
|
||||
+ }
|
||||
+ AP4_Position currentPos;
|
||||
+ stream->Tell(currentPos);
|
||||
+ stream->Seek(currentPos - (AP4_EAC3_HEADER_SIZE));
|
||||
+ return adtsType;
|
||||
+}
|
||||
+
|
||||
+AP4_Result CAdaptiveAdtsParser::FindFrameHeader(AP4_AacFrame& frame)
|
||||
+{
|
||||
+ unsigned char raw_header[AP4_ADTS_HEADER_SIZE];
|
||||
+ AP4_Result result;
|
||||
+
|
||||
+ /* align to the start of the next byte */
|
||||
+ m_Bits.ByteAlign();
|
||||
+
|
||||
+ /* find a frame header */
|
||||
+ result = FindHeader(raw_header);
|
||||
+ if (AP4_FAILED(result))
|
||||
+ return result;
|
||||
+
|
||||
+ /* parse the header */
|
||||
+ AP4_AdtsHeader adts_header(raw_header);
|
||||
+
|
||||
+ /* check the header */
|
||||
+ result = adts_header.Check();
|
||||
+ if (AP4_FAILED(result))
|
||||
+ return AP4_ERROR_CORRUPTED_BITSTREAM;
|
||||
+
|
||||
+ m_Bits.SkipBytes(AP4_ADTS_HEADER_SIZE);
|
||||
+
|
||||
+ /* fill in the frame info */
|
||||
+ frame.m_Info.m_Standard =
|
||||
+ (adts_header.m_Id == 1 ? AP4_AAC_STANDARD_MPEG2 : AP4_AAC_STANDARD_MPEG4);
|
||||
+ switch (adts_header.m_ProfileObjectType)
|
||||
+ {
|
||||
+ case 0:
|
||||
+ frame.m_Info.m_Profile = AP4_AAC_PROFILE_MAIN;
|
||||
+ break;
|
||||
+
|
||||
+ case 1:
|
||||
+ frame.m_Info.m_Profile = AP4_AAC_PROFILE_LC;
|
||||
+ break;
|
||||
+
|
||||
+ case 2:
|
||||
+ frame.m_Info.m_Profile = AP4_AAC_PROFILE_SSR;
|
||||
+ break;
|
||||
+
|
||||
+ case 3:
|
||||
+ frame.m_Info.m_Profile = AP4_AAC_PROFILE_LTP;
|
||||
+ }
|
||||
+ frame.m_Info.m_FrameLength = adts_header.m_FrameLength - AP4_ADTS_HEADER_SIZE;
|
||||
+ frame.m_Info.m_ChannelConfiguration = adts_header.m_ChannelConfiguration;
|
||||
+ frame.m_Info.m_SamplingFrequencyIndex = adts_header.m_SamplingFrequencyIndex;
|
||||
+ frame.m_Info.m_SamplingFrequency =
|
||||
+ AP4_AdtsSamplingFrequencyTable[adts_header.m_SamplingFrequencyIndex];
|
||||
+
|
||||
+ /* skip crc if present */
|
||||
+ if (adts_header.m_ProtectionAbsent == 0)
|
||||
+ {
|
||||
+ m_Bits.SkipBits(16);
|
||||
+ }
|
||||
+
|
||||
+ /* set the frame source */
|
||||
+ frame.m_Source = &m_Bits;
|
||||
+
|
||||
+ return AP4_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+AP4_Result CAdaptiveAc3Parser::FindFrameHeader(AP4_Ac3Frame& frame)
|
||||
+{
|
||||
+ unsigned char raw_header[AP4_AC3_HEADER_SIZE];
|
||||
+ AP4_Result result;
|
||||
+
|
||||
+ /* align to the start of the next byte */
|
||||
+ m_Bits.ByteAlign();
|
||||
+
|
||||
+ /* find a frame header */
|
||||
+ result = FindHeader(raw_header);
|
||||
+ if (AP4_FAILED(result))
|
||||
+ return result;
|
||||
+
|
||||
+ if (m_LittleEndian)
|
||||
+ {
|
||||
+ AP4_ByteSwap16(raw_header, AP4_AC3_HEADER_SIZE);
|
||||
+ }
|
||||
+
|
||||
+ /* parse the header */
|
||||
+ AP4_Ac3Header ac3_header(raw_header);
|
||||
+
|
||||
+ /* check the header */
|
||||
+ result = ac3_header.Check();
|
||||
+ if (AP4_FAILED(result))
|
||||
+ {
|
||||
+ m_Bits.SkipBytes(2);
|
||||
+ return AP4_ERROR_CORRUPTED_BITSTREAM;
|
||||
+ }
|
||||
+
|
||||
+ frame.m_Info.m_ChannelCount = ac3_header.m_ChannelCount;
|
||||
+ frame.m_Info.m_SampleRate = FSCOD_AC3[ac3_header.m_Fscod];
|
||||
+ frame.m_Info.m_FrameSize = ac3_header.m_FrameSize;
|
||||
+ frame.m_Info.m_Ac3StreamInfo.fscod = ac3_header.m_Fscod;
|
||||
+ frame.m_Info.m_Ac3StreamInfo.bsid = ac3_header.m_Bsid;
|
||||
+ frame.m_Info.m_Ac3StreamInfo.bsmod = ac3_header.m_Bsmod;
|
||||
+ frame.m_Info.m_Ac3StreamInfo.acmod = ac3_header.m_Acmod;
|
||||
+ frame.m_Info.m_Ac3StreamInfo.lfeon = ac3_header.m_Lfeon;
|
||||
+ frame.m_Info.m_Ac3StreamInfo.bit_rate_code = ac3_header.m_Frmsizecod / 2;
|
||||
+
|
||||
+ frame.m_LittleEndian = m_LittleEndian;
|
||||
+
|
||||
+ /* set the frame source */
|
||||
+ frame.m_Source = &m_Bits;
|
||||
+
|
||||
+ return AP4_SUCCESS;
|
||||
+}
|
||||
+
|
||||
+AP4_Result CAdaptiveEac3Parser::FindFrameHeader(AP4_Eac3Frame& frame)
|
||||
+{
|
||||
+ bool dependent_stream_exist = false;
|
||||
+ unsigned int dependent_stream_chan_loc = 0;
|
||||
+ unsigned int dependent_stream_length = 0;
|
||||
+ unsigned int skip_size = 0;
|
||||
+ unsigned char raw_header[AP4_EAC3_HEADER_SIZE];
|
||||
+ AP4_Result result;
|
||||
+
|
||||
+ /* align to the start of the next byte */
|
||||
+ m_Bits.ByteAlign();
|
||||
+
|
||||
+ /* find a frame header */
|
||||
+ result = FindHeader(raw_header, skip_size);
|
||||
+ if (AP4_FAILED(result))
|
||||
+ return result;
|
||||
+
|
||||
+ if (m_LittleEndian)
|
||||
+ {
|
||||
+ AP4_ByteSwap16(raw_header, AP4_EAC3_HEADER_SIZE);
|
||||
+ }
|
||||
+
|
||||
+ /* parse the header */
|
||||
+ AP4_Eac3Header eac3_header(raw_header);
|
||||
+
|
||||
+ /* check the header */
|
||||
+ result = eac3_header.Check();
|
||||
+ if (AP4_FAILED(result))
|
||||
+ return AP4_ERROR_CORRUPTED_BITSTREAM;
|
||||
+
|
||||
+ /* fill in the frame info */
|
||||
+ frame.m_Info.m_ChannelCount = eac3_header.m_ChannelCount;
|
||||
+ if (dependent_stream_exist)
|
||||
+ {
|
||||
+ frame.m_Info.m_FrameSize = eac3_header.m_FrameSize + dependent_stream_length;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ frame.m_Info.m_FrameSize = eac3_header.m_FrameSize;
|
||||
+ }
|
||||
+ frame.m_Info.m_SampleRate = EAC3_SAMPLE_RATE_ARY[eac3_header.m_Fscod];
|
||||
+ frame.m_Info.m_Eac3SubStream.fscod = eac3_header.m_Fscod;
|
||||
+ frame.m_Info.m_Eac3SubStream.bsid = eac3_header.m_Bsid;
|
||||
+ frame.m_Info.m_Eac3SubStream.bsmod = eac3_header.m_Bsmod;
|
||||
+ frame.m_Info.m_Eac3SubStream.acmod = eac3_header.m_Acmod;
|
||||
+ frame.m_Info.m_Eac3SubStream.lfeon = eac3_header.m_Lfeon;
|
||||
+ if (dependent_stream_exist)
|
||||
+ {
|
||||
+ frame.m_Info.m_Eac3SubStream.num_dep_sub = 1;
|
||||
+ frame.m_Info.m_Eac3SubStream.chan_loc = dependent_stream_chan_loc;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ frame.m_Info.m_Eac3SubStream.num_dep_sub = 0;
|
||||
+ frame.m_Info.m_Eac3SubStream.chan_loc = 0;
|
||||
+ }
|
||||
+
|
||||
+ frame.m_Info.complexity_index_type_a = 0;
|
||||
+ if (eac3_header.m_Addbsie && (eac3_header.m_Addbsil == 1) && (eac3_header.m_Addbsi[0] == 0x1))
|
||||
+ {
|
||||
+ frame.m_Info.complexity_index_type_a = eac3_header.m_Addbsi[1];
|
||||
+ }
|
||||
+
|
||||
+ /* set the little endian flag */
|
||||
+ frame.m_LittleEndian = m_LittleEndian;
|
||||
+
|
||||
+ /* set the frame source */
|
||||
+ frame.m_Source = &m_Bits;
|
||||
+
|
||||
+ return AP4_SUCCESS;
|
||||
+}
|
||||
diff --git a/src/parser/CodecParser.h b/src/parser/CodecParser.h
|
||||
new file mode 100644
|
||||
index 000000000..d7e1fbba8
|
||||
--- /dev/null
|
||||
+++ b/src/parser/CodecParser.h
|
||||
@@ -0,0 +1,60 @@
|
||||
+/*
|
||||
+ * Copyright (C) 2023 Team Kodi
|
||||
+ * This file is part of Kodi - https://kodi.tv
|
||||
+ *
|
||||
+ * SPDX-License-Identifier: GPL-2.0-or-later
|
||||
+ * See LICENSES/README.md for more information.
|
||||
+ */
|
||||
+
|
||||
+#include <bento4/Ap4Ac3Parser.h>
|
||||
+#include <bento4/Ap4AdtsParser.h>
|
||||
+#include <bento4/Ap4Eac3Parser.h>
|
||||
+#include <kodi/addon-instance/Inputstream.h>
|
||||
+
|
||||
+namespace adaptive
|
||||
+{
|
||||
+
|
||||
+constexpr AP4_UI32 AP4_ADTS_HEADER_SIZE = 7;
|
||||
+constexpr AP4_UI32 AP4_ADTS_SYNC_MASK = 0xFFF6;
|
||||
+constexpr AP4_UI32 AP4_ADTS_SYNC_PATTERN = 0xFFF0;
|
||||
+constexpr AP4_UI32 AP4_AC3_SYNC_PATTERN = 0x0B77;
|
||||
+constexpr AP4_UI32 AP4_AC4_SYNC_MASK = 0xFFF0;
|
||||
+constexpr AP4_UI32 AP4_AC4_SYNC_PATTERN = 0x0AC40;
|
||||
+
|
||||
+enum class ATTR_DLL_LOCAL AdtsType
|
||||
+{
|
||||
+ NONE,
|
||||
+ AAC,
|
||||
+ AC3,
|
||||
+ EAC3,
|
||||
+ AC4
|
||||
+};
|
||||
+
|
||||
+class ATTR_DLL_LOCAL CAdaptiveAdtsParser : public AP4_AdtsParser
|
||||
+{
|
||||
+public:
|
||||
+ CAdaptiveAdtsParser() {}
|
||||
+ AP4_Result FindFrameHeader(AP4_AacFrame& frame);
|
||||
+};
|
||||
+
|
||||
+class ATTR_DLL_LOCAL CAdaptiveAc3Parser : public AP4_Ac3Parser
|
||||
+{
|
||||
+public:
|
||||
+ CAdaptiveAc3Parser() {}
|
||||
+ AP4_Result FindFrameHeader(AP4_Ac3Frame& frame);
|
||||
+};
|
||||
+
|
||||
+class ATTR_DLL_LOCAL CAdaptiveEac3Parser : public AP4_Eac3Parser
|
||||
+{
|
||||
+public:
|
||||
+ CAdaptiveEac3Parser() {}
|
||||
+ AP4_Result FindFrameHeader(AP4_Eac3Frame& frame);
|
||||
+};
|
||||
+
|
||||
+class ATTR_DLL_LOCAL CAdaptiveAdtsHeaderParser
|
||||
+{
|
||||
+public:
|
||||
+ static AdtsType GetAdtsType(AP4_ByteStream* stream);
|
||||
+};
|
||||
+
|
||||
+} // namespace adaptive
|
||||
|
||||
From fed26ca2307a6587c4e584b63345e1d141b7c320 Mon Sep 17 00:00:00 2001
|
||||
From: Glenn Guy <glennguy@users.noreply.github.com>
|
||||
Date: Thu, 1 Jun 2023 18:54:38 +1000
|
||||
Subject: [PATCH 2/2] Bump Bento4
|
||||
|
||||
---
|
||||
depends/common/bento4/bento4.sha256 | 2 +-
|
||||
depends/common/bento4/bento4.txt | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/depends/common/bento4/bento4.sha256 b/depends/common/bento4/bento4.sha256
|
||||
index 673bab692..04e05c87c 100644
|
||||
--- a/depends/common/bento4/bento4.sha256
|
||||
+++ b/depends/common/bento4/bento4.sha256
|
||||
@@ -1 +1 @@
|
||||
-4464cd47b597e6dedbfc231bb6eb097c45cfe5ee0051082460d9ac53e9d74dc3
|
||||
\ No newline at end of file
|
||||
+d7fc48e52f0037ce977d7f54c49d4f8936cca0e58447c9ce7c55ab64d268e23d
|
||||
\ No newline at end of file
|
||||
diff --git a/depends/common/bento4/bento4.txt b/depends/common/bento4/bento4.txt
|
||||
index d04bc8382..6128dc1a5 100644
|
||||
--- a/depends/common/bento4/bento4.txt
|
||||
+++ b/depends/common/bento4/bento4.txt
|
||||
@@ -1 +1 @@
|
||||
-bento4 https://github.com/xbmc/Bento4/archive/refs/tags/1.6.0-639-7-Omega.tar.gz
|
||||
+bento4 https://github.com/xbmc/Bento4/archive/refs/tags/1.6.0-639-8-Omega.tar.gz
|
@ -0,0 +1,78 @@
|
||||
From c4aeb31d09f5d53e0f29793a5ee295454bcc00ea Mon Sep 17 00:00:00 2001
|
||||
From: CastagnaIT <gottardo.stefano.83@gmail.com>
|
||||
Date: Wed, 31 May 2023 09:34:31 +0200
|
||||
Subject: [PATCH 1/3] [DASHTree] Allow content protection without systemid
|
||||
|
||||
---
|
||||
src/parser/DASHTree.cpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/parser/DASHTree.cpp b/src/parser/DASHTree.cpp
|
||||
index 66cac634..80e8a3c8 100644
|
||||
--- a/src/parser/DASHTree.cpp
|
||||
+++ b/src/parser/DASHTree.cpp
|
||||
@@ -1433,7 +1433,7 @@ bool adaptive::CDashTree::ParseTagContentProtection(pugi::xml_node nodeParent,
|
||||
}
|
||||
}
|
||||
|
||||
- return isUrnSchemeFound;
|
||||
+ return isUrnSchemeFound || isUrnProtectionFound;
|
||||
}
|
||||
|
||||
uint32_t adaptive::CDashTree::ParseAudioChannelConfig(pugi::xml_node node)
|
||||
|
||||
From 58216354739b95ae1e94f2a3aef6f061be415c73 Mon Sep 17 00:00:00 2001
|
||||
From: CastagnaIT <gottardo.stefano.83@gmail.com>
|
||||
Date: Wed, 31 May 2023 14:24:37 +0200
|
||||
Subject: [PATCH 2/3] [DASHTree] Dont overwrite default pssh value when not
|
||||
exist
|
||||
|
||||
---
|
||||
src/parser/DASHTree.cpp | 5 ++---
|
||||
1 file changed, 2 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/parser/DASHTree.cpp b/src/parser/DASHTree.cpp
|
||||
index 80e8a3c8..57b2a215 100644
|
||||
--- a/src/parser/DASHTree.cpp
|
||||
+++ b/src/parser/DASHTree.cpp
|
||||
@@ -1408,15 +1408,14 @@ bool adaptive::CDashTree::ParseTagContentProtection(pugi::xml_node nodeParent,
|
||||
|
||||
if (commonPssh.empty() && !playReadyPro.empty())
|
||||
{
|
||||
- currentPssh = PSSH_FROM_FILE;
|
||||
-
|
||||
PRProtectionParser parser;
|
||||
if (parser.ParseHeader(playReadyPro))
|
||||
currentDefaultKID = parser.GetKID();
|
||||
}
|
||||
else
|
||||
{
|
||||
- currentPssh = commonPssh;
|
||||
+ if (!commonPssh.empty())
|
||||
+ currentPssh = commonPssh;
|
||||
|
||||
if ((isUrnSchemeFound || isUrnProtectionFound) && defaultKID && std::strlen(defaultKID) == 36)
|
||||
{
|
||||
|
||||
From 82a4301277f587632448b2649bdc812488f14f6b Mon Sep 17 00:00:00 2001
|
||||
From: CastagnaIT <gottardo.stefano.83@gmail.com>
|
||||
Date: Wed, 31 May 2023 14:31:43 +0200
|
||||
Subject: [PATCH 3/3] [Session] Replaced FILE pssh with appropriate define
|
||||
|
||||
---
|
||||
src/Session.cpp | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/Session.cpp b/src/Session.cpp
|
||||
index 6c618a47..b064989c 100644
|
||||
--- a/src/Session.cpp
|
||||
+++ b/src/Session.cpp
|
||||
@@ -466,7 +466,7 @@ bool CSession::InitializeDRM(bool addDefaultKID /* = false */)
|
||||
|
||||
CPeriod::PSSHSet& sessionPsshset = m_adaptiveTree->m_currentPeriod->GetPSSHSets()[ses];
|
||||
|
||||
- if (sessionPsshset.pssh_ == "FILE")
|
||||
+ if (sessionPsshset.pssh_ == PSSH_FROM_FILE)
|
||||
{
|
||||
LOG::Log(LOGDEBUG, "Searching PSSH data in FILE");
|
||||
|
@ -2,8 +2,8 @@
|
||||
# Copyright (C) 2021-present Team LibreELEC (https://libreelec.tv)
|
||||
|
||||
PKG_NAME="bento4"
|
||||
PKG_VERSION="1.6.0-639-6-Nexus"
|
||||
PKG_SHA256="8afa4ae07a7629a65e0d5014750960ced33a8771d363652f3913261fb5d0c84f"
|
||||
PKG_VERSION="1.6.0-639-8-Omega"
|
||||
PKG_SHA256="d7fc48e52f0037ce977d7f54c49d4f8936cca0e58447c9ce7c55ab64d268e23d"
|
||||
PKG_LICENSE="GPL"
|
||||
PKG_SITE="https://www.bento4.com"
|
||||
PKG_URL="https://github.com/xbmc/Bento4/archive/refs/tags/${PKG_VERSION}.tar.gz"
|
||||
|
Loading…
x
Reference in New Issue
Block a user