Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(976)

Unified Diff: media/muxers/webm_muxer.cc

Issue 1830383003: WebmMuxer: add Pause()/Resume() methods and internal time-in-pause (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/muxers/webm_muxer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/muxers/webm_muxer.cc
diff --git a/media/muxers/webm_muxer.cc b/media/muxers/webm_muxer.cc
index e00982a759f7e2fee0e853d14443fef936ca5437..729f3485ee5c14be02a0cccdc1b189699a93d68e 100644
--- a/media/muxers/webm_muxer.cc
+++ b/media/muxers/webm_muxer.cc
@@ -147,7 +147,7 @@ void WebmMuxer::OnEncodedVideo(const scoped_refptr<VideoFrame>& video_frame,
void WebmMuxer::OnEncodedAudio(const media::AudioParameters& params,
scoped_ptr<std::string> encoded_data,
base::TimeTicks timestamp) {
- DVLOG(1) << __FUNCTION__ << " - " << encoded_data->size() << "B";
+ DVLOG(2) << __FUNCTION__ << " - " << encoded_data->size() << "B";
DCHECK(thread_checker_.CalledOnValidThread());
if (!audio_track_index_) {
@@ -175,6 +175,22 @@ void WebmMuxer::OnEncodedAudio(const media::AudioParameters& params,
true /* is_key_frame -- always true for audio */);
}
+void WebmMuxer::Pause() {
+ DVLOG(1) << __FUNCTION__;
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (!elapsed_time_in_pause_)
+ elapsed_time_in_pause_.reset(new base::ElapsedTimer());
+}
+
+void WebmMuxer::Resume() {
+ DVLOG(1) << __FUNCTION__;
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (elapsed_time_in_pause_) {
+ total_time_in_pause_ += elapsed_time_in_pause_->Elapsed();
+ elapsed_time_in_pause_.reset();
+ }
+}
+
void WebmMuxer::AddVideoTrack(const gfx::Size& frame_size, double frame_rate) {
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_EQ(0u, video_track_index_)
@@ -204,6 +220,7 @@ void WebmMuxer::AddVideoTrack(const gfx::Size& frame_size, double frame_rate) {
}
void WebmMuxer::AddAudioTrack(const media::AudioParameters& params) {
+ DVLOG(1) << __FUNCTION__ << " " << params.AsHumanReadableString();
DCHECK(thread_checker_.CalledOnValidThread());
DCHECK_EQ(0u, audio_track_index_)
<< "WebmMuxer audio can only be initialised once.";
@@ -270,7 +287,8 @@ void WebmMuxer::AddFrame(scoped_ptr<std::string> encoded_data,
DCHECK(!has_audio_ || audio_track_index_);
most_recent_timestamp_ =
- std::max(most_recent_timestamp_, timestamp - first_frame_timestamp_);
+ std::max(most_recent_timestamp_,
+ timestamp - total_time_in_pause_ - first_frame_timestamp_);
segment_.AddFrame(reinterpret_cast<const uint8_t*>(encoded_data->data()),
encoded_data->size(), track_index,
« no previous file with comments | « media/muxers/webm_muxer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698