-
Notifications
You must be signed in to change notification settings - Fork 511
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
Omit SegmentTimeline completely, with allow_approximate_segment_timel… #747
base: main
Are you sure you want to change the base?
Changes from all commits
e1371d8
e07db24
d76d778
4c6b29e
02c8730
606fd69
33f3a59
07e1e0d
f522c01
d5d376c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,7 +72,7 @@ class ChunkingHandler : public MediaHandler { | |
// Segment and subsegment duration in stream's time scale. | ||
int64_t segment_duration_ = 0; | ||
int64_t subsegment_duration_ = 0; | ||
|
||
int64_t set_segment_index_ = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is already a variable for segment index: current_segment_index_. Why do we need another one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. current_segment_index_ is used to compare with segment index calculated at line: https://github.com/google/shaka-packager/blob/8913dbda85967b26e4968495b1d0ed70fbffe1fd/packager/media/chunking/chunking_handler.cc#L99 and Please let me know what you think. Also I noticed that I made a mistake with isGreaterSegmentIndex method. It should use set_segment_index_ instead of current_segment_index_ (as set_segment_index_ should never be decremented). I will make this change if you think the above explanation is correct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point! I am afraid that won't work though as the increment is undone by the code from line 109 to 113. Since the cue basically resets segment index back to 0 [1], I think we can keep a record of segment count: In Status ChunkingHandler::OnCueEvent(std::shared_ptr<const CueEvent> event) {
...
num_segments_before_last_cue_ = current_segment_index_ + 1;
return Status::OK;
} In Status ChunkingHandler::EndSegmentIfStarted() const {
...
segment_info->segment_index = current_segment_index_ + num_segments_before_last_cue_;
return DispatchSegmentInfo(kStreamIndex, std::move(segment_info));
} [1] See the code at line 106:
|
||
// Current segment index, useful to determine where to do chunking. | ||
int64_t current_segment_index_ = -1; | ||
// Current subsegment index, useful to determine where to do chunking. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -345,7 +345,7 @@ TEST_F(HlsNotifyMuxerListenerTest, OnNewSegmentAndCueEvent) { | |
kSegmentDuration, _, kSegmentSize)); | ||
listener_.OnCueEvent(kCueStartTime, "dummy cue data"); | ||
listener_.OnNewSegment("new_segment_name10.ts", kSegmentStartTime, | ||
kSegmentDuration, kSegmentSize); | ||
kSegmentDuration, kSegmentSize, 10); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer using a named constant to make it easier to readers. For example, can we use kSegmentIndex? Same below |
||
} | ||
|
||
// Verify that the notifier is called for every segment in OnMediaEnd if | ||
|
@@ -363,7 +363,7 @@ TEST_F(HlsNotifyMuxerListenerTest, NoSegmentTemplateOnMediaEnd) { | |
|
||
listener_.OnCueEvent(kCueStartTime, "dummy cue data"); | ||
listener_.OnNewSegment("filename.mp4", kSegmentStartTime, kSegmentDuration, | ||
kSegmentSize); | ||
kSegmentSize, 0); | ||
|
||
EXPECT_CALL(mock_notifier_, NotifyCueEvent(_, kCueStartTime)); | ||
EXPECT_CALL( | ||
|
@@ -393,7 +393,7 @@ TEST_F(HlsNotifyMuxerListenerTest, NoSegmentTemplateOnMediaEndTwice) { | |
listener_.OnMediaStart(muxer_options1, *video_stream_info, 90000, | ||
MuxerListener::kContainerMpeg2ts); | ||
listener_.OnNewSegment("filename1.mp4", kSegmentStartTime, kSegmentDuration, | ||
kSegmentSize); | ||
kSegmentSize, 1); | ||
listener_.OnCueEvent(kCueStartTime, "dummy cue data"); | ||
|
||
EXPECT_CALL(mock_notifier_, NotifyNewStream(_, _, _, _, _)) | ||
|
@@ -410,7 +410,7 @@ TEST_F(HlsNotifyMuxerListenerTest, NoSegmentTemplateOnMediaEndTwice) { | |
listener_.OnMediaStart(muxer_options2, *video_stream_info, 90000, | ||
MuxerListener::kContainerMpeg2ts); | ||
listener_.OnNewSegment("filename2.mp4", kSegmentStartTime + kSegmentDuration, | ||
kSegmentDuration, kSegmentSize); | ||
kSegmentDuration, kSegmentSize, 2); | ||
EXPECT_CALL(mock_notifier_, | ||
NotifyNewSegment(_, StrEq("filename2.mp4"), | ||
kSegmentStartTime + kSegmentDuration, _, _, _)); | ||
|
@@ -436,7 +436,7 @@ TEST_F(HlsNotifyMuxerListenerTest, | |
MuxerListener::kContainerMpeg2ts); | ||
|
||
listener_.OnNewSegment("filename.mp4", kSegmentStartTime, kSegmentDuration, | ||
kSegmentSize); | ||
kSegmentSize, 0); | ||
EXPECT_CALL( | ||
mock_notifier_, | ||
NotifyNewSegment(_, StrEq("filename.mp4"), kSegmentStartTime, | ||
|
@@ -498,7 +498,7 @@ TEST_P(HlsNotifyMuxerListenerKeyFrameTest, NoSegmentTemplate) { | |
listener_.OnKeyFrame(kKeyFrameTimestamp, kKeyFrameStartByteOffset, | ||
kKeyFrameSize); | ||
listener_.OnNewSegment("filename.mp4", kSegmentStartTime, kSegmentDuration, | ||
kSegmentSize); | ||
kSegmentSize, 0); | ||
|
||
EXPECT_CALL(mock_notifier_, | ||
NotifyKeyFrame(_, kKeyFrameTimestamp, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,17 +57,13 @@ void MpdNotifyMuxerListener::OnEncryptionInfoReady( | |
|
||
void MpdNotifyMuxerListener::OnEncryptionStart() {} | ||
|
||
void MpdNotifyMuxerListener::OnMediaStart( | ||
const MuxerOptions& muxer_options, | ||
const StreamInfo& stream_info, | ||
uint32_t time_scale, | ||
ContainerType container_type) { | ||
void MpdNotifyMuxerListener::OnMediaStart(const MuxerOptions& muxer_options, | ||
const StreamInfo& stream_info, | ||
uint32_t time_scale, | ||
ContainerType container_type) { | ||
std::unique_ptr<MediaInfo> media_info(new MediaInfo()); | ||
if (!internal::GenerateMediaInfo(muxer_options, | ||
stream_info, | ||
time_scale, | ||
container_type, | ||
media_info.get())) { | ||
if (!internal::GenerateMediaInfo(muxer_options, stream_info, time_scale, | ||
container_type, media_info.get())) { | ||
LOG(ERROR) << "Failed to generate MediaInfo from input."; | ||
return; | ||
} | ||
|
@@ -79,7 +75,8 @@ void MpdNotifyMuxerListener::OnMediaStart( | |
if (is_encrypted_) { | ||
internal::SetContentProtectionFields(protection_scheme_, default_key_id_, | ||
key_system_info_, media_info.get()); | ||
media_info->mutable_protected_content()->set_include_mspr_pro(mpd_notifier_->include_mspr_pro()); | ||
media_info->mutable_protected_content()->set_include_mspr_pro( | ||
mpd_notifier_->include_mspr_pro()); | ||
} | ||
|
||
// The content may be splitted into multiple files, but their MediaInfo | ||
|
@@ -102,8 +99,7 @@ void MpdNotifyMuxerListener::OnMediaStart( | |
|
||
// Record the sample duration in the media info for VOD so that OnMediaEnd, all | ||
// the information is in the media info. | ||
void MpdNotifyMuxerListener::OnSampleDurationReady( | ||
uint32_t sample_duration) { | ||
void MpdNotifyMuxerListener::OnSampleDurationReady(uint32_t sample_duration) { | ||
if (mpd_notifier_->dash_profile() == DashProfile::kLive) { | ||
mpd_notifier_->NotifySampleDuration(notification_id_.value(), | ||
sample_duration); | ||
|
@@ -157,7 +153,10 @@ void MpdNotifyMuxerListener::OnMediaEnd(const MediaRanges& media_ranges, | |
mpd_notifier_->NotifyNewSegment( | ||
notification_id_.value(), event_info.segment_info.start_time, | ||
event_info.segment_info.duration, | ||
event_info.segment_info.segment_file_size); | ||
event_info.segment_info.segment_file_size, | ||
(event_info.segment_info.start_time / | ||
event_info.segment_info.duration) + | ||
1); | ||
break; | ||
case EventInfoType::kKeyFrame: | ||
// NO-OP for DASH. | ||
|
@@ -175,10 +174,11 @@ void MpdNotifyMuxerListener::OnMediaEnd(const MediaRanges& media_ranges, | |
void MpdNotifyMuxerListener::OnNewSegment(const std::string& file_name, | ||
int64_t start_time, | ||
int64_t duration, | ||
uint64_t segment_file_size) { | ||
uint64_t segment_file_size, | ||
uint64_t segment_index) { | ||
if (mpd_notifier_->dash_profile() == DashProfile::kLive) { | ||
mpd_notifier_->NotifyNewSegment(notification_id_.value(), start_time, | ||
duration, segment_file_size); | ||
duration, segment_file_size, segment_index); | ||
if (mpd_notifier_->mpd_type() == MpdType::kDynamic) | ||
mpd_notifier_->Flush(); | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should save |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there a "+1" in the end? Shouldn't
segment_index
be 0 based?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kqyang
Makes sense. I will divide the pr into
How does that sound?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kqyang Have created 2 PRs for WebM and MPEG2TS changes. Will create a PR for sending segment index and handling when these two are merged. Please review and let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. Thanks a lot for doing that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kqyang Have created 1 PR that sends segment index from (chunking_handler, text_chunker) -> muxer -> segmenters to generate segment with segment name based on segment index -> MpdNotifyMuxerListener -> SimpleMpdNotifier -> Representation which sets the start number based on segment index that it receives.
Please review and let me know. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sr1990 Thanks. Will take a look in the next few days.