-
Notifications
You must be signed in to change notification settings - Fork 513
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
use second sample in webm and mp4 formats #835
Changes from 2 commits
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 |
---|---|---|
|
@@ -98,7 +98,7 @@ class Segmenter { | |
|
||
/// @return The sample duration in the timescale of the media. | ||
/// Returns 0 if no samples are added yet. | ||
uint32_t sample_duration() const { return sample_duration_; } | ||
uint32_t sample_duration() const { return sample_durations_[1]; } | ||
|
||
protected: | ||
/// Update segmentation progress using ProgressListener. | ||
|
@@ -144,7 +144,8 @@ class Segmenter { | |
ProgressListener* progress_listener_ = nullptr; | ||
uint64_t progress_target_ = 0u; | ||
uint64_t accumulated_progress_ = 0u; | ||
uint32_t sample_duration_ = 0u; | ||
uint32_t sample_durations_[2] = {0, 0}; | ||
uint32_t num_samples_ = 0u; | ||
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. s/uint32_t/size_t/ |
||
std::vector<uint64_t> stream_durations_; | ||
std::vector<KeyFrameInfo> key_frame_infos_; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,11 +161,13 @@ Status Segmenter::Finalize() { | |
Status Segmenter::AddSample(const MediaSample& source_sample) { | ||
std::shared_ptr<MediaSample> sample(source_sample.Clone()); | ||
|
||
if (sample_duration_ == 0) { | ||
first_timestamp_ = sample->pts(); | ||
sample_duration_ = sample->duration(); | ||
if (muxer_listener_) | ||
muxer_listener_->OnSampleDurationReady(sample_duration_); | ||
if (num_samples_ < 2) { | ||
sample_durations_[num_samples_] = sample->duration(); | ||
if (num_samples_ == 0) | ||
first_timestamp_ = sample->pts(); | ||
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. Check |
||
muxer_listener_->OnSampleDurationReady(sample_durations_[num_samples_]); | ||
num_samples_++; | ||
} | ||
|
||
UpdateProgress(sample->duration()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,7 +139,8 @@ class Segmenter { | |
uint64_t progress_target_ = 0; | ||
uint64_t accumulated_progress_ = 0; | ||
uint64_t first_timestamp_ = 0; | ||
int64_t sample_duration_ = 0; | ||
int64_t sample_durations_[2] = {0, 0}; | ||
int64_t num_samples_ = 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. s/int64_t/size_t/ 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. Should num_samples be size_t? I'm assuming only sample_durations_[2] needs to be size_t 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. num_samples_ should be size type, so it should be |
||
// The position (in bytes) of the start of the Segment payload in the init | ||
// file. This is also the size of the header before the SeekHead. | ||
uint64_t segment_payload_pos_ = 0; | ||
|
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.
Can you change uint32_t to int64_t? Same below.