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

Side by Side Diff: media/base/pipeline.cc

Issue 575643002: Initialize media timeline correctly for positive start times. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/pipeline.h" 5 #include "media/base/pipeline.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 return InitializeDemuxer(done_cb); 336 return InitializeDemuxer(done_cb);
337 337
338 case kInitRenderer: 338 case kInitRenderer:
339 return InitializeRenderer(base::Bind(done_cb, PIPELINE_OK)); 339 return InitializeRenderer(base::Bind(done_cb, PIPELINE_OK));
340 340
341 case kPlaying: 341 case kPlaying:
342 // Report metadata the first time we enter the playing state. 342 // Report metadata the first time we enter the playing state.
343 if (!is_initialized_) { 343 if (!is_initialized_) {
344 is_initialized_ = true; 344 is_initialized_ = true;
345 ReportMetadata(); 345 ReportMetadata();
346 start_timestamp_ = demuxer_->GetStartTime();
346 } 347 }
347 348
348 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK); 349 base::ResetAndReturn(&seek_cb_).Run(PIPELINE_OK);
349 350
351 DCHECK(start_timestamp_ >= base::TimeDelta());
scherkus (not reviewing) 2014/09/16 00:16:51 is it actually possible to craft such a file? if s
DaleCurtis 2014/09/16 01:17:46 I don't think it should be a CHECK, just a DCHECK.
350 renderer_->StartPlayingFrom(start_timestamp_); 352 renderer_->StartPlayingFrom(start_timestamp_);
351 353
352 if (text_renderer_) 354 if (text_renderer_)
353 text_renderer_->StartPlaying(); 355 text_renderer_->StartPlaying();
354 356
355 PlaybackRateChangedTask(GetPlaybackRate()); 357 PlaybackRateChangedTask(GetPlaybackRate());
356 VolumeChangedTask(GetVolume()); 358 VolumeChangedTask(GetVolume());
357 return; 359 return;
358 360
359 case kStopping: 361 case kStopping:
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 579
578 // TODO(scherkus): should we run the callback? I'm tempted to say the API 580 // TODO(scherkus): should we run the callback? I'm tempted to say the API
579 // will only execute the first Seek() request. 581 // will only execute the first Seek() request.
580 DVLOG(1) << "Media pipeline has not started, ignoring seek to " 582 DVLOG(1) << "Media pipeline has not started, ignoring seek to "
581 << time.InMicroseconds() << " (current state: " << state_ << ")"; 583 << time.InMicroseconds() << " (current state: " << state_ << ")";
582 return; 584 return;
583 } 585 }
584 586
585 DCHECK(seek_cb_.is_null()); 587 DCHECK(seek_cb_.is_null());
586 588
589 const base::TimeDelta seek_timestamp =
590 std::max(time, demuxer_->GetStartTime());
scherkus (not reviewing) 2014/09/16 00:07:31 do we need to update pipeline_unittest.cc? IIRC we
DaleCurtis 2014/09/16 01:17:46 Done.
591
587 SetState(kSeeking); 592 SetState(kSeeking);
588 seek_cb_ = seek_cb; 593 seek_cb_ = seek_cb;
589 renderer_ended_ = false; 594 renderer_ended_ = false;
590 text_renderer_ended_ = false; 595 text_renderer_ended_ = false;
591 start_timestamp_ = time; 596 start_timestamp_ = seek_timestamp;
592 597
593 DoSeek(time, 598 DoSeek(seek_timestamp,
594 base::Bind(&Pipeline::OnStateTransition, weak_factory_.GetWeakPtr())); 599 base::Bind(&Pipeline::OnStateTransition, weak_factory_.GetWeakPtr()));
595 } 600 }
596 601
597 void Pipeline::OnRendererEnded() { 602 void Pipeline::OnRendererEnded() {
598 DCHECK(task_runner_->BelongsToCurrentThread()); 603 DCHECK(task_runner_->BelongsToCurrentThread());
599 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::ENDED)); 604 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::ENDED));
600 605
601 if (state_ != kPlaying) 606 if (state_ != kPlaying)
602 return; 607 return;
603 608
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 metadata_cb_.Run(metadata); 712 metadata_cb_.Run(metadata);
708 } 713 }
709 714
710 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) { 715 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) {
711 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") "; 716 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") ";
712 DCHECK(task_runner_->BelongsToCurrentThread()); 717 DCHECK(task_runner_->BelongsToCurrentThread());
713 buffering_state_cb_.Run(new_buffering_state); 718 buffering_state_cb_.Run(new_buffering_state);
714 } 719 }
715 720
716 } // namespace media 721 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698