Skip to content
New issue

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

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

Already on GitHub? # to your account

[DASH] Get start number from muxer. #818

Closed
wants to merge 4 commits into from

Conversation

sr1990
Copy link
Contributor

@sr1990 sr1990 commented Aug 7, 2020

This PR will set the start number in representation to the segment index that is sent by muxer.

@sr1990
Copy link
Contributor Author

sr1990 commented Aug 7, 2020

Have not run clang-format on all files yet.

@sr1990 sr1990 changed the title DASH - Get start number from muxer. [DASH] Get start number from muxer. Aug 7, 2020
Copy link
Contributor

@kqyang kqyang left a comment

Choose a reason for hiding this comment

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

Thanks. Mostly LGTM with some style nits.

@@ -144,13 +147,17 @@ Status ChunkingHandler::OnMediaSample(
return DispatchMediaSample(kStreamIndex, std::move(sample));
}

Status ChunkingHandler::EndSegmentIfStarted() const {
Status ChunkingHandler::EndSegmentIfStarted(bool fromCueEvent) const {
Copy link
Contributor

Choose a reason for hiding this comment

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

from_cue_event

Comment on lines 157 to 159
// If fromCueEvent then current_segment_index_ is already added to the
// number of segments before last cue.
segment_info->segment_index = ((fromCueEvent) ? 0 : current_segment_index_) +
Copy link
Contributor

Choose a reason for hiding this comment

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

A simpler way to handle it is to set current_segment_index_ to 0 in line 79.

// If fromCueEvent then current_segment_index_ is already added to the
// number of segments before last cue.
segment_info->segment_index = ((fromCueEvent) ? 0 : current_segment_index_) +
num_segments_before_last_cue_ - 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be just num_segments_before_last_cue_ without "-1"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am subtracting 1 to send the segment index as 0 based. To remove -1, I can move the lines
|108 current_segment_index_ = segment_index;
|109 // Reset subsegment index.
|110 current_subsegment_index_ = 0;
in ChunkingHandler::OnMediaSample after the call to
|112 RETURN_IF_ERROR(EndSegmentIfStarted());

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think the change you mentioned is needed. current_segment_index_ should also be set to -1 instead of 0 in OnCueEvent.

Here is a simple illustration with segment size of 2.

(| is segment boundary; C is for cue).

_ _ | _ C _ _ | _ _
1   | 2  |  3 | 4

Region 1: current_segment_index_ = 0, num_segments_before_last_cue_ = 0 so segment_info->segment_index = 0
Region 2: current_segment_index_ = 1 => num_segments_before_last_cue_ = 2, current_segment_index_=-1 so segment_info->segment_index = 1
Region 3: current_segment_index_ = 0, num_segments_before_last_cue_ = 2 so segment_info->segment_index = 2
Region 4: current_segment_index_ = 1, num_segments_before_last_cue_ = 2 so segment_info->segment_index = 3

If we don't have unit-tests, we should add unit-tests for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kqyang Thanks for the illustration. I have made this change.
Also looks like there is a unit test for this: ChunkingHandlerTest,CueEvent.

@@ -35,6 +35,7 @@ Status TextChunker::OnFlushRequest(size_t input_stream_index) {
// Keep outputting segments until all the samples leave the system. Calling
// |DispatchSegment| will remove samples over time.
while (samples_in_current_segment_.size()) {
segment_index_++;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have removed it.

Comment on lines 112 to 115
if (((segment_start_ / segment_duration_) + 1) > segment_index_) {
segment_index_ = (segment_start_ / segment_duration_) + 1;
}
info->segment_index = segment_index_ - 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should consider the number of cues too.

I think it can just be:

info->segment_index = segment_start_ / segment_duration_ + num_cues_;

/// @return true on success, false otherwise.
virtual bool NotifyNewSegment(uint32_t container_id,
uint64_t start_time,
uint64_t duration,
uint64_t size) = 0;
uint64_t size,
uint64_t segment_index) = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

alignment

virtual void AddNewSegment(int64_t start_time,
int64_t duration,
uint64_t size);
uint64_t size,
uint64_t segment_index);
Copy link
Contributor

Choose a reason for hiding this comment

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

alignment

EXPECT_THAT(representation_->GetXml().get(),
XmlNodeEqual(ExpectedXml(expected_s_elements)));
XmlNodeEqual(SegmentTimelineTestBase::ExpectedXml(
expected_s_elements, 1372)));
Copy link
Contributor

Choose a reason for hiding this comment

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

where is 1372 from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(kStartTime/kDurationSmaller) + 1

@@ -169,6 +169,8 @@ TEST_F(SimpleMpdNotifierTest, NotifyNewSegment) {
SimpleMpdNotifier notifier(empty_mpd_option_);

const uint32_t kRepresentationId = 447834u;
const uint64_t kSegmentIndex0 = 0u;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can just call it kSegmentIndex

Comment on lines 335 to 340
if (segment_infos_.empty()) {
if (mpd_options_.mpd_params.target_segment_duration > 0) {
// Store segment index as 1 based.
start_number_ = segment_index + 1;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that segment_index or start_segment_index should be added as a member of SegmentInfo. Then we can remove |start_number_|.

Otherwise the code at line 462 is incorrect.

Copy link
Contributor Author

@sr1990 sr1990 Aug 16, 2020

Choose a reason for hiding this comment

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

@kqyang Thanks for the review. Let me try this out. Thinking about how copy constructor changes representation will affect the unit test (RepresentationClone).

Copy link
Contributor Author

@sr1990 sr1990 Aug 16, 2020

Choose a reason for hiding this comment

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

@kqyang For representation_unittest.cc::TEST_P(TimeShiftBufferDepthTest, Generic) as the segment duration changes, segment index is 34 instead of 1002 which it would have been because of increasing |start_number_|. How can this test be changed in order to rely on start_segment_index which is stored in SegmentInfo?

Copy link
Contributor Author

@sr1990 sr1990 Aug 20, 2020

Choose a reason for hiding this comment

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

@kqyang any thoughts? Am I missing anything here? Do you want to move ahead without this change?

Copy link
Contributor

@kqyang kqyang Aug 27, 2020

Choose a reason for hiding this comment

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

Sorry for the late reply. I think it actually surfaces a problem in the unit-test. I think it is better to have your logic here in the test :).

We can define a member variable in SegmentTemplateTest called: start_segment_index_. It is initialized to start_time/duration in AddSegments if not initialized; increment by 1 in for-loop.

 void AddSegments(int64_t start_time,
                   int64_t duration,
                   uint64_t size,
                   int repeat) {
    ...

    if (start_segment_index == -1) 
     start_segment_index = start_time / duration;

    for (int i = 0; i < repeat + 1; ++i) {
      representation_->AddNewSegment(start_time, duration, size, start_segment_index++);
      start_time += duration;
      bandwidth_estimator_.AddBlock(
          size, static_cast<double>(duration) / kDefaultTimeScale);
    }
  }

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added this change.

@sr1990 sr1990 force-pushed the omit_segmentTimeline2 branch from d006e81 to bfd88c0 Compare September 4, 2020 05:53
@sr1990 sr1990 force-pushed the omit_segmentTimeline2 branch from 4cb7f60 to 17a5eb4 Compare September 10, 2020 01:23
@sr1990 sr1990 requested a review from kqyang September 10, 2020 01:23
@sr1990
Copy link
Contributor Author

sr1990 commented Sep 15, 2020

Hi @kqyang, any thoughts on the PR update?

@kqyang
Copy link
Contributor

kqyang commented Sep 15, 2020

Sorry for the late reply. Quite busy these days. I haven't had a chance to look through it. I'll do it some time this week.

@sr1990
Copy link
Contributor Author

sr1990 commented Dec 4, 2020

Ping

@ProIcons
Copy link

bump

@Vinayk93
Copy link

Vinayk93 commented Oct 3, 2022

Any Update on this.

@cosmin
Copy link
Contributor

cosmin commented Feb 15, 2024

replaced by #879

@cosmin cosmin closed this Feb 15, 2024
@github-actions github-actions bot added the status: archived Archived and locked; will not be updated label Apr 15, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
status: archived Archived and locked; will not be updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants