Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Solution for adding startwithSAP/subsegmentstartswithSAP for audio tracks #1055

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packager/mpd/base/adaptation_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,14 @@ base::Optional<xml::XmlNode> AdaptationSet::GetXml() {
return base::nullopt;
}
}
if (subsegment_start_with_sap_ == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add some tests and potentially since this is for spec compliance all the existing golden tests will also be regenrated once you can run those tests as well.

assuming this is for audio only and hence the subsegment check for just value == 1 ?

if (!adaptation_set.SetIntegerAttribute("subsegmentStartsWithSAP", 1))
return base::nullopt;
}
else if (start_with_sap_ == 1) {
if (!adaptation_set.SetIntegerAttribute("startWithSAP", 1))
return base::nullopt;
}

if (video_frame_rates_.size() == 1) {
suppress_representation_frame_rate = true;
Expand Down Expand Up @@ -384,6 +392,14 @@ void AdaptationSet::AddAdaptationSetSwitching(
switchable_adaptation_sets_.push_back(adaptation_set);
}

void AdaptationSet::ForceSubsegmentStartswithSAP(uint32_t sap_value) {
subsegment_start_with_sap_ = sap_value;
}

void AdaptationSet::ForceStartwithSAP(uint32_t sap_value) {
start_with_sap_ = sap_value;
}

// For dynamic MPD, storing all start_time and duration will out-of-memory
// because there's no way of knowing when it will end. Static MPD
// subsegmentAlignment check is *not* done here because it is possible that some
Expand Down
17 changes: 17 additions & 0 deletions packager/mpd/base/adaptation_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ class AdaptationSet {
/// attribute.
virtual void ForceSetSegmentAlignment(bool segment_alignment);

/// Forces the subsegmentStartswithSAP field to be set to @a sap_value.
/// Use this if you are certain with stream access point value of the
/// subsegment.
/// @param sap_value is the value used for subsegmentstartsWithSAP attribute.
virtual void ForceSubsegmentStartswithSAP(uint32_t sap_value);

/// Forces the StartswithSAP field to be set to @a sap_value.
/// Use this if you are certain with stream access point value of the segment.
/// @param sap_value is the value used for startWithSAP attribute.
virtual void ForceStartwithSAP(uint32_t sap_value);

/// Adds the adaptation set this adaptation set can switch to.
/// @param adaptation_set points to the switchable adaptation set.
virtual void AddAdaptationSetSwitching(const AdaptationSet* adaptation_set);
Expand Down Expand Up @@ -299,6 +310,12 @@ class AdaptationSet {
SegmentAligmentStatus segments_aligned_;
bool force_set_segment_alignment_;

// The stream access point for subsegment
uint8_t subsegment_start_with_sap_;

// The stream access point for segment
uint8_t start_with_sap_;

// Keeps track of segment start times of Representations.
// For static MPD, this will not be cleared, all the segment start times are
// stored in this. This should not out-of-memory for a reasonable length
Expand Down
20 changes: 20 additions & 0 deletions packager/mpd/base/period.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,26 @@ bool Period::SetNewAdaptationSetAttributes(
// In practice it doesn't really make sense to adapt between text tracks.
new_adaptation_set->ForceSetSegmentAlignment(true);
}

if (mpd_options_.dash_profile == DashProfile::kLive) {
// According to Dolby Digital Plus and Dolby AC-4 specs, startWithSAP
// attribute shall be set to 1. Other audio codecs do not have
// requirement on this value, we assume them to be 1 as well.
if (GetBaseCodec(media_info) == "mp4a" ||
GetBaseCodec(media_info) == "ac-3" ||
GetBaseCodec(media_info) == "ec-3" ||
GetBaseCodec(media_info) == "ac-4") {
new_adaptation_set->ForceStartwithSAP(1);
}
}
else if (mpd_options_.dash_profile == DashProfile::kOnDemand) {
if (GetBaseCodec(media_info) == "mp4a" ||
GetBaseCodec(media_info) == "ac-3" ||
GetBaseCodec(media_info) == "ec-3" ||
GetBaseCodec(media_info) == "ac-4") {
new_adaptation_set->ForceSubsegmentStartswithSAP(1);
}
}
return true;
}

Expand Down