Skip to content

Commit

Permalink
refactor: output DataSize/DataSizeWithSubDescriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
haruyama committed Mar 16, 2023
1 parent 3a7ea8a commit 50d60d9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
1 change: 1 addition & 0 deletions include/shiguredo/mp4/box/esds.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class ESDescriptor : public Descriptor {
};

struct DecoderConfigDescriptorParameters {
const std::uint32_t sub_descriptors_size = 0;
const std::uint8_t object_type_indication;
const std::int8_t stream_type;
const bool upstream = false;
Expand Down
17 changes: 9 additions & 8 deletions src/box/esds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ std::uint64_t ESDescriptor::readData(bitio::Reader* reader) {

std::string ESDescriptor::toString() const {
std::string s = fmt::format(
"{{Tag=ESDescr Size={} ESID={} StreamDependenceFlag={} UrlFlag={} "
"{{Tag=ESDescr DataSize={} DataSizeWithSubDescriptors={} ESID={} StreamDependenceFlag={} UrlFlag={} "
"OcrStreamFlag={} StreamPriority={}",
getDataSizeWithSubDescriptors(), m_ESID, m_stream_dependence_flag, m_url_flag, m_ocr_stream_flag,
getDataSize(), getDataSizeWithSubDescriptors(), m_ESID, m_stream_dependence_flag, m_url_flag, m_ocr_stream_flag,
m_stream_priority);

if (m_stream_dependence_flag) {
Expand All @@ -144,7 +144,8 @@ DecoderConfigDescriptor::DecoderConfigDescriptor() {
}

DecoderConfigDescriptor::DecoderConfigDescriptor(const DecoderConfigDescriptorParameters& params)
: m_object_type_indication(params.object_type_indication),
: m_sub_descriptors_size(params.sub_descriptors_size),
m_object_type_indication(params.object_type_indication),
m_stream_type(params.stream_type),
m_upstream(params.upstream),
m_reserved(params.reserved),
Expand Down Expand Up @@ -199,11 +200,11 @@ std::uint64_t DecoderConfigDescriptor::readData(bitio::Reader* reader) {
}
std::string DecoderConfigDescriptor::toString() const {
return fmt::format(
"{{Tag=DecoderConfigDescr Size={} ObjectTypeIndication={:#x} "
"{{Tag=DecoderConfigDescr DataSize={} DataSizeWithSubDescriptors={} ObjectTypeIndication={:#x} "
"StreamType={} UpStream={} Reserved={} BufferSizeDB={} MaxBitrate={} "
"AvgBitrate={}}}",
getDataSize(), m_object_type_indication, m_stream_type, m_upstream, m_reserved, m_buffer_size_db, m_max_bitrate,
m_avg_bitrate);
getDataSize(), getDataSizeWithSubDescriptors(), m_object_type_indication, m_stream_type, m_upstream, m_reserved,
m_buffer_size_db, m_max_bitrate, m_avg_bitrate);
}

DecSpecificInfo::DecSpecificInfo() {
Expand Down Expand Up @@ -239,7 +240,7 @@ std::uint64_t DecSpecificInfo::readData(bitio::Reader* reader) {
}

std::string DecSpecificInfo::toString() const {
return fmt::format("{{Tag=DecSpecificInfo Size={} Data=[{:#x}]}}", std::size(m_data), fmt::join(m_data, ", "));
return fmt::format("{{Tag=DecSpecificInfo DataSize={} Data=[{:#x}]}}", getDataSize(), fmt::join(m_data, ", "));
}

SLConfigDescr::SLConfigDescr() {
Expand Down Expand Up @@ -275,7 +276,7 @@ std::uint64_t SLConfigDescr::readData(bitio::Reader* reader) {
}

std::string SLConfigDescr::toString() const {
return fmt::format("{{Tag=SLConfigDescr Size={} Data=[{:#x}]}}", std::size(m_data), fmt::join(m_data, ", "));
return fmt::format("{{Tag=SLConfigDescr DataSize={} Data=[{:#x}]}}", getDataSize(), fmt::join(m_data, ", "));
}

BoxType box_type_esds() {
Expand Down
16 changes: 10 additions & 6 deletions test/box_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ BoxTypesTestCase box_test_cases[] = {
.OCRESID = 0})),
std::
shared_ptr<shiguredo::mp4::box::Descriptor>(
new shiguredo::mp4::box::DecoderConfigDescriptor({.object_type_indication = 0x12,
new shiguredo::mp4::box::DecoderConfigDescriptor({.sub_descriptors_size = 8,
.object_type_indication = 0x12,
.stream_type = 0x15,
.upstream = true,
.reserved = false,
Expand All @@ -342,7 +343,7 @@ BoxTypesTestCase box_test_cases[] = {
'e', // urlString
//
0x04, // tag
0x80, 0x80, 0x80, 0x0d, // size (varint)
0x80, 0x80, 0x80, 0x15, // size (varint)
0x12, // objectTypeIndication
0x56, // streamType & upStream & reserved
0x12, 0x34, 0x56, // bufferSizeDB
Expand All @@ -358,20 +359,23 @@ BoxTypesTestCase box_test_cases[] = {
0x11, 0x22, 0x33, 0x44, 0x55, // data
},
"Version=0 Flags=0x000000 Descriptors=[{Tag=ESDescr "
"Size=42 "
"DataSize=15 "
"DataSizeWithSubDescriptors=42 "
"ESID=4660 "
"StreamDependenceFlag=false UrlFlag=true "
"OcrStreamFlag=false "
"StreamPriority=3 URLLength=0xb "
"URLString=\"http://hoge\"}, "
"{Tag=DecoderConfigDescr Size=13 "
"{Tag=DecoderConfigDescr "
"DataSize=13 "
"DataSizeWithSubDescriptors=21 "
"ObjectTypeIndication=0x12 "
"StreamType=21 UpStream=true Reserved=false "
"BufferSizeDB=1193046 "
"MaxBitrate=305419896 AvgBitrate=591751049}, "
"{Tag=DecSpecificInfo "
"Size=3 Data=[0x11, 0x22, 0x33]}, {Tag=SLConfigDescr "
"Size=5 "
"DataSize=3 Data=[0x11, 0x22, 0x33]}, {Tag=SLConfigDescr "
"DataSize=5 "
"Data=[0x11, 0x22, 0x33, 0x44, 0x55]}]",
},
{
Expand Down

0 comments on commit 50d60d9

Please sign in to comment.