OLD | NEW |
---|---|
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
85 DCHECK(!stop_pending_); | 85 DCHECK(!stop_pending_); |
86 DCHECK(!seek_pending_); | 86 DCHECK(!seek_pending_); |
87 | 87 |
88 media_log_->AddEvent( | 88 media_log_->AddEvent( |
89 media_log_->CreateEvent(MediaLogEvent::PIPELINE_DESTROYED)); | 89 media_log_->CreateEvent(MediaLogEvent::PIPELINE_DESTROYED)); |
90 } | 90 } |
91 | 91 |
92 void Pipeline::Start(scoped_ptr<FilterCollection> collection, | 92 void Pipeline::Start(scoped_ptr<FilterCollection> collection, |
93 const PipelineStatusCB& ended_cb, | 93 const PipelineStatusCB& ended_cb, |
94 const PipelineStatusCB& error_cb, | 94 const PipelineStatusCB& error_cb, |
95 const PipelineStatusCB& start_cb) { | 95 const PipelineStatusCB& start_cb, |
96 const base::Closure& new_duration_cb) { | |
96 base::AutoLock auto_lock(lock_); | 97 base::AutoLock auto_lock(lock_); |
97 CHECK(!running_) << "Media pipeline is already running"; | 98 CHECK(!running_) << "Media pipeline is already running"; |
98 | 99 |
99 running_ = true; | 100 running_ = true; |
100 message_loop_->PostTask(FROM_HERE, base::Bind( | 101 message_loop_->PostTask(FROM_HERE, base::Bind( |
101 &Pipeline::StartTask, this, base::Passed(&collection), | 102 &Pipeline::StartTask, this, base::Passed(&collection), |
102 ended_cb, error_cb, start_cb)); | 103 ended_cb, error_cb, start_cb, new_duration_cb)); |
103 } | 104 } |
104 | 105 |
105 void Pipeline::Stop(const base::Closure& stop_cb) { | 106 void Pipeline::Stop(const base::Closure& stop_cb) { |
106 base::AutoLock auto_lock(lock_); | 107 base::AutoLock auto_lock(lock_); |
107 CHECK(running_) << "Media pipeline isn't running"; | 108 CHECK(running_) << "Media pipeline isn't running"; |
108 | 109 |
109 // Stop the pipeline, which will set |running_| to false on our behalf. | 110 // Stop the pipeline, which will set |running_| to false on our behalf. |
110 message_loop_->PostTask(FROM_HERE, base::Bind( | 111 message_loop_->PostTask(FROM_HERE, base::Bind( |
111 &Pipeline::StopTask, this, stop_cb)); | 112 &Pipeline::StopTask, this, stop_cb)); |
112 } | 113 } |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 clock_->SetMaxTime(max_time); | 413 clock_->SetMaxTime(max_time); |
413 } | 414 } |
414 | 415 |
415 void Pipeline::SetDuration(TimeDelta duration) { | 416 void Pipeline::SetDuration(TimeDelta duration) { |
416 DCHECK(IsRunning()); | 417 DCHECK(IsRunning()); |
417 media_log_->AddEvent( | 418 media_log_->AddEvent( |
418 media_log_->CreateTimeEvent( | 419 media_log_->CreateTimeEvent( |
419 MediaLogEvent::DURATION_SET, "duration", duration)); | 420 MediaLogEvent::DURATION_SET, "duration", duration)); |
420 UMA_HISTOGRAM_LONG_TIMES("Media.Duration", duration); | 421 UMA_HISTOGRAM_LONG_TIMES("Media.Duration", duration); |
421 | 422 |
422 base::AutoLock auto_lock(lock_); | 423 base::TimeDelta old_duration; |
423 clock_->SetDuration(duration); | 424 { |
425 base::AutoLock auto_lock(lock_); | |
426 old_duration = clock_->Duration(); | |
acolwell GONE FROM CHROMIUM
2012/07/27 00:03:23
nit: How about just having a duration_changed bool
vrk (LEFT CHROMIUM)
2012/07/28 01:42:05
No longer necessary after getting rid of new_durat
| |
427 clock_->SetDuration(duration); | |
428 } | |
429 | |
430 if (old_duration != duration && !new_duration_cb_.is_null()) | |
431 new_duration_cb_.Run(); | |
424 } | 432 } |
425 | 433 |
426 void Pipeline::SetTotalBytes(int64 total_bytes) { | 434 void Pipeline::SetTotalBytes(int64 total_bytes) { |
427 DCHECK(IsRunning()); | 435 DCHECK(IsRunning()); |
428 media_log_->AddEvent( | 436 media_log_->AddEvent( |
429 media_log_->CreateIntegerEvent( | 437 media_log_->CreateIntegerEvent( |
430 MediaLogEvent::TOTAL_BYTES_SET, "total_bytes", total_bytes)); | 438 MediaLogEvent::TOTAL_BYTES_SET, "total_bytes", total_bytes)); |
431 int64 total_mbytes = total_bytes >> 20; | 439 int64 total_mbytes = total_bytes >> 20; |
432 if (total_mbytes > kint32max) | 440 if (total_mbytes > kint32max) |
433 total_mbytes = kint32max; | 441 total_mbytes = kint32max; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
573 base::AutoLock auto_lock(lock_); | 581 base::AutoLock auto_lock(lock_); |
574 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; | 582 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; |
575 statistics_.video_bytes_decoded += stats.video_bytes_decoded; | 583 statistics_.video_bytes_decoded += stats.video_bytes_decoded; |
576 statistics_.video_frames_decoded += stats.video_frames_decoded; | 584 statistics_.video_frames_decoded += stats.video_frames_decoded; |
577 statistics_.video_frames_dropped += stats.video_frames_dropped; | 585 statistics_.video_frames_dropped += stats.video_frames_dropped; |
578 } | 586 } |
579 | 587 |
580 void Pipeline::StartTask(scoped_ptr<FilterCollection> filter_collection, | 588 void Pipeline::StartTask(scoped_ptr<FilterCollection> filter_collection, |
581 const PipelineStatusCB& ended_cb, | 589 const PipelineStatusCB& ended_cb, |
582 const PipelineStatusCB& error_cb, | 590 const PipelineStatusCB& error_cb, |
583 const PipelineStatusCB& start_cb) { | 591 const PipelineStatusCB& start_cb, |
592 const base::Closure& new_duration_cb) { | |
acolwell GONE FROM CHROMIUM
2012/07/27 00:03:23
WDYT about just having WebMediaPlayerImpl or even
vrk (LEFT CHROMIUM)
2012/07/28 01:42:05
Done (in WebMediaPlayerImpl) and I agree, this is
| |
584 DCHECK(message_loop_->BelongsToCurrentThread()); | 593 DCHECK(message_loop_->BelongsToCurrentThread()); |
585 DCHECK_EQ(kCreated, state_); | 594 DCHECK_EQ(kCreated, state_); |
586 filter_collection_ = filter_collection.Pass(); | 595 filter_collection_ = filter_collection.Pass(); |
587 ended_cb_ = ended_cb; | 596 ended_cb_ = ended_cb; |
588 error_cb_ = error_cb; | 597 error_cb_ = error_cb; |
589 seek_cb_ = start_cb; | 598 seek_cb_ = start_cb; |
599 new_duration_cb_ = new_duration_cb; | |
590 | 600 |
591 // Kick off initialization. | 601 // Kick off initialization. |
592 pipeline_init_state_.reset(new PipelineInitState()); | 602 pipeline_init_state_.reset(new PipelineInitState()); |
593 | 603 |
594 SetState(kInitDemuxer); | 604 SetState(kInitDemuxer); |
595 InitializeDemuxer(); | 605 InitializeDemuxer(); |
596 } | 606 } |
597 | 607 |
598 // Main initialization method called on the pipeline thread. This code attempts | 608 // Main initialization method called on the pipeline thread. This code attempts |
599 // to use the specified filter factory to build a pipeline. | 609 // to use the specified filter factory to build a pipeline. |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1264 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { | 1274 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { |
1265 lock_.AssertAcquired(); | 1275 lock_.AssertAcquired(); |
1266 if (!waiting_for_clock_update_) | 1276 if (!waiting_for_clock_update_) |
1267 return; | 1277 return; |
1268 | 1278 |
1269 waiting_for_clock_update_ = false; | 1279 waiting_for_clock_update_ = false; |
1270 clock_->Play(); | 1280 clock_->Play(); |
1271 } | 1281 } |
1272 | 1282 |
1273 } // namespace media | 1283 } // namespace media |
OLD | NEW |