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

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

Issue 10800041: Update media duration if data is appended after the previous duration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 DCHECK(!stop_pending_); 88 DCHECK(!stop_pending_);
89 DCHECK(!seek_pending_); 89 DCHECK(!seek_pending_);
90 90
91 media_log_->AddEvent( 91 media_log_->AddEvent(
92 media_log_->CreateEvent(MediaLogEvent::PIPELINE_DESTROYED)); 92 media_log_->CreateEvent(MediaLogEvent::PIPELINE_DESTROYED));
93 } 93 }
94 94
95 void Pipeline::Start(scoped_ptr<FilterCollection> collection, 95 void Pipeline::Start(scoped_ptr<FilterCollection> collection,
96 const PipelineStatusCB& ended_cb, 96 const PipelineStatusCB& ended_cb,
97 const PipelineStatusCB& error_cb, 97 const PipelineStatusCB& error_cb,
98 const PipelineStatusCB& start_cb) { 98 const PipelineStatusCB& start_cb,
99 const base::Closure& new_duration_cb) {
99 base::AutoLock auto_lock(lock_); 100 base::AutoLock auto_lock(lock_);
100 CHECK(!running_) << "Media pipeline is already running"; 101 CHECK(!running_) << "Media pipeline is already running";
101 102
102 running_ = true; 103 running_ = true;
103 message_loop_->PostTask(FROM_HERE, base::Bind( 104 message_loop_->PostTask(FROM_HERE, base::Bind(
104 &Pipeline::StartTask, this, base::Passed(&collection), 105 &Pipeline::StartTask, this, base::Passed(&collection),
105 ended_cb, error_cb, start_cb)); 106 ended_cb, error_cb, start_cb, new_duration_cb));
106 } 107 }
107 108
108 void Pipeline::Stop(const base::Closure& stop_cb) { 109 void Pipeline::Stop(const base::Closure& stop_cb) {
109 base::AutoLock auto_lock(lock_); 110 base::AutoLock auto_lock(lock_);
110 CHECK(running_) << "Media pipeline isn't running"; 111 CHECK(running_) << "Media pipeline isn't running";
111 112
112 // Stop the pipeline, which will set |running_| to false on our behalf. 113 // Stop the pipeline, which will set |running_| to false on our behalf.
113 message_loop_->PostTask(FROM_HERE, base::Bind( 114 message_loop_->PostTask(FROM_HERE, base::Bind(
114 &Pipeline::StopTask, this, stop_cb)); 115 &Pipeline::StopTask, this, stop_cb));
115 } 116 }
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 clock_->SetMaxTime(max_time); 422 clock_->SetMaxTime(max_time);
422 } 423 }
423 424
424 void Pipeline::SetDuration(TimeDelta duration) { 425 void Pipeline::SetDuration(TimeDelta duration) {
425 DCHECK(IsRunning()); 426 DCHECK(IsRunning());
426 media_log_->AddEvent( 427 media_log_->AddEvent(
427 media_log_->CreateTimeEvent( 428 media_log_->CreateTimeEvent(
428 MediaLogEvent::DURATION_SET, "duration", duration)); 429 MediaLogEvent::DURATION_SET, "duration", duration));
429 UMA_HISTOGRAM_LONG_TIMES("Media.Duration", duration); 430 UMA_HISTOGRAM_LONG_TIMES("Media.Duration", duration);
430 431
431 base::AutoLock auto_lock(lock_); 432 base::TimeDelta old_duration;
432 clock_->SetDuration(duration); 433 {
434 base::AutoLock auto_lock(lock_);
435 old_duration = clock_->Duration();
436 clock_->SetDuration(duration);
437 }
438
439 if (old_duration != duration)
440 new_duration_cb_.Run();
433 } 441 }
434 442
435 void Pipeline::SetTotalBytes(int64 total_bytes) { 443 void Pipeline::SetTotalBytes(int64 total_bytes) {
436 DCHECK(IsRunning()); 444 DCHECK(IsRunning());
437 media_log_->AddEvent( 445 media_log_->AddEvent(
438 media_log_->CreateIntegerEvent( 446 media_log_->CreateIntegerEvent(
439 MediaLogEvent::TOTAL_BYTES_SET, "total_bytes", total_bytes)); 447 MediaLogEvent::TOTAL_BYTES_SET, "total_bytes", total_bytes));
440 int64 total_mbytes = total_bytes >> 20; 448 int64 total_mbytes = total_bytes >> 20;
441 if (total_mbytes > kint32max) 449 if (total_mbytes > kint32max)
442 total_mbytes = kint32max; 450 total_mbytes = kint32max;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 base::AutoLock auto_lock(lock_); 545 base::AutoLock auto_lock(lock_);
538 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; 546 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded;
539 statistics_.video_bytes_decoded += stats.video_bytes_decoded; 547 statistics_.video_bytes_decoded += stats.video_bytes_decoded;
540 statistics_.video_frames_decoded += stats.video_frames_decoded; 548 statistics_.video_frames_decoded += stats.video_frames_decoded;
541 statistics_.video_frames_dropped += stats.video_frames_dropped; 549 statistics_.video_frames_dropped += stats.video_frames_dropped;
542 } 550 }
543 551
544 void Pipeline::StartTask(scoped_ptr<FilterCollection> filter_collection, 552 void Pipeline::StartTask(scoped_ptr<FilterCollection> filter_collection,
545 const PipelineStatusCB& ended_cb, 553 const PipelineStatusCB& ended_cb,
546 const PipelineStatusCB& error_cb, 554 const PipelineStatusCB& error_cb,
547 const PipelineStatusCB& start_cb) { 555 const PipelineStatusCB& start_cb,
556 const base::Closure& new_duration_cb) {
548 DCHECK(message_loop_->BelongsToCurrentThread()); 557 DCHECK(message_loop_->BelongsToCurrentThread());
549 DCHECK_EQ(kCreated, state_); 558 DCHECK_EQ(kCreated, state_);
550 filter_collection_ = filter_collection.Pass(); 559 filter_collection_ = filter_collection.Pass();
551 ended_cb_ = ended_cb; 560 ended_cb_ = ended_cb;
552 error_cb_ = error_cb; 561 error_cb_ = error_cb;
553 seek_cb_ = start_cb; 562 seek_cb_ = start_cb;
563 new_duration_cb_ = new_duration_cb;
554 564
555 // Kick off initialization. 565 // Kick off initialization.
556 pipeline_init_state_.reset(new PipelineInitState()); 566 pipeline_init_state_.reset(new PipelineInitState());
557 pipeline_init_state_->composite = new CompositeFilter(message_loop_); 567 pipeline_init_state_->composite = new CompositeFilter(message_loop_);
558 pipeline_init_state_->composite->SetHost(this); 568 pipeline_init_state_->composite->SetHost(this);
559 569
560 SetState(kInitDemuxer); 570 SetState(kInitDemuxer);
561 InitializeDemuxer(); 571 InitializeDemuxer();
562 } 572 }
563 573
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { 1283 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() {
1274 lock_.AssertAcquired(); 1284 lock_.AssertAcquired();
1275 if (!waiting_for_clock_update_) 1285 if (!waiting_for_clock_update_)
1276 return; 1286 return;
1277 1287
1278 waiting_for_clock_update_ = false; 1288 waiting_for_clock_update_ = false;
1279 clock_->Play(); 1289 clock_->Play();
1280 } 1290 }
1281 1291
1282 } // namespace media 1292 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698