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

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

Issue 10535101: Replace Pipeline::SetNetworkActivity() with BufferedDataSource -> WebMediaPlayerImpl callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
« no previous file with comments | « media/base/pipeline.h ('k') | media/base/pipeline_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 NetworkEventCB& network_cb,
99 const PipelineStatusCB& start_cb) { 98 const PipelineStatusCB& start_cb) {
100 base::AutoLock auto_lock(lock_); 99 base::AutoLock auto_lock(lock_);
101 CHECK(!running_) << "Media pipeline is already running"; 100 CHECK(!running_) << "Media pipeline is already running";
102 101
103 running_ = true; 102 running_ = true;
104 message_loop_->PostTask(FROM_HERE, base::Bind( 103 message_loop_->PostTask(FROM_HERE, base::Bind(
105 &Pipeline::StartTask, this, base::Passed(&collection), 104 &Pipeline::StartTask, this, base::Passed(&collection),
106 ended_cb, error_cb, network_cb, start_cb)); 105 ended_cb, error_cb, start_cb));
107 } 106 }
108 107
109 void Pipeline::Stop(const base::Closure& stop_cb) { 108 void Pipeline::Stop(const base::Closure& stop_cb) {
110 base::AutoLock auto_lock(lock_); 109 base::AutoLock auto_lock(lock_);
111 CHECK(running_) << "Media pipeline isn't running"; 110 CHECK(running_) << "Media pipeline isn't running";
112 111
113 // Stop the pipeline, which will set |running_| to false on our behalf. 112 // Stop the pipeline, which will set |running_| to false on our behalf.
114 message_loop_->PostTask(FROM_HERE, base::Bind( 113 message_loop_->PostTask(FROM_HERE, base::Bind(
115 &Pipeline::StopTask, this, stop_cb)); 114 &Pipeline::StopTask, this, stop_cb));
116 } 115 }
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 natural_size_ = size; 466 natural_size_ = size;
468 } 467 }
469 468
470 void Pipeline::NotifyEnded() { 469 void Pipeline::NotifyEnded() {
471 DCHECK(IsRunning()); 470 DCHECK(IsRunning());
472 message_loop_->PostTask(FROM_HERE, base::Bind( 471 message_loop_->PostTask(FROM_HERE, base::Bind(
473 &Pipeline::NotifyEndedTask, this)); 472 &Pipeline::NotifyEndedTask, this));
474 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::ENDED)); 473 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::ENDED));
475 } 474 }
476 475
477 void Pipeline::SetNetworkActivity(bool is_downloading_data) {
478 DCHECK(IsRunning());
479
480 NetworkEvent type = DOWNLOAD_PAUSED;
481 if (is_downloading_data)
482 type = DOWNLOAD_CONTINUED;
483
484 message_loop_->PostTask(FROM_HERE, base::Bind(
485 &Pipeline::NotifyNetworkEventTask, this, type));
486 media_log_->AddEvent(
Ami GONE FROM CHROMIUM 2012/06/10 21:43:46 Oops, forgot to move this to WMPI. New upload has
487 media_log_->CreateBooleanEvent(
488 MediaLogEvent::NETWORK_ACTIVITY_SET,
489 "is_downloading_data", is_downloading_data));
490 }
491
492 void Pipeline::DisableAudioRenderer() { 476 void Pipeline::DisableAudioRenderer() {
493 DCHECK(IsRunning()); 477 DCHECK(IsRunning());
494 478
495 // Disable renderer on the message loop. 479 // Disable renderer on the message loop.
496 message_loop_->PostTask(FROM_HERE, base::Bind( 480 message_loop_->PostTask(FROM_HERE, base::Bind(
497 &Pipeline::DisableAudioRendererTask, this)); 481 &Pipeline::DisableAudioRendererTask, this));
498 media_log_->AddEvent( 482 media_log_->AddEvent(
499 media_log_->CreateEvent(MediaLogEvent::AUDIO_RENDERER_DISABLED)); 483 media_log_->CreateEvent(MediaLogEvent::AUDIO_RENDERER_DISABLED));
500 } 484 }
501 485
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 base::AutoLock auto_lock(lock_); 519 base::AutoLock auto_lock(lock_);
536 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded; 520 statistics_.audio_bytes_decoded += stats.audio_bytes_decoded;
537 statistics_.video_bytes_decoded += stats.video_bytes_decoded; 521 statistics_.video_bytes_decoded += stats.video_bytes_decoded;
538 statistics_.video_frames_decoded += stats.video_frames_decoded; 522 statistics_.video_frames_decoded += stats.video_frames_decoded;
539 statistics_.video_frames_dropped += stats.video_frames_dropped; 523 statistics_.video_frames_dropped += stats.video_frames_dropped;
540 } 524 }
541 525
542 void Pipeline::StartTask(scoped_ptr<FilterCollection> filter_collection, 526 void Pipeline::StartTask(scoped_ptr<FilterCollection> filter_collection,
543 const PipelineStatusCB& ended_cb, 527 const PipelineStatusCB& ended_cb,
544 const PipelineStatusCB& error_cb, 528 const PipelineStatusCB& error_cb,
545 const NetworkEventCB& network_cb,
546 const PipelineStatusCB& start_cb) { 529 const PipelineStatusCB& start_cb) {
547 DCHECK(message_loop_->BelongsToCurrentThread()); 530 DCHECK(message_loop_->BelongsToCurrentThread());
548 DCHECK_EQ(kCreated, state_); 531 DCHECK_EQ(kCreated, state_);
549 filter_collection_ = filter_collection.Pass(); 532 filter_collection_ = filter_collection.Pass();
550 ended_cb_ = ended_cb; 533 ended_cb_ = ended_cb;
551 error_cb_ = error_cb; 534 error_cb_ = error_cb;
552 network_cb_ = network_cb;
553 seek_cb_ = start_cb; 535 seek_cb_ = start_cb;
554 536
555 // Kick off initialization. 537 // Kick off initialization.
556 pipeline_init_state_.reset(new PipelineInitState()); 538 pipeline_init_state_.reset(new PipelineInitState());
557 pipeline_init_state_->composite = new CompositeFilter(message_loop_); 539 pipeline_init_state_->composite = new CompositeFilter(message_loop_);
558 pipeline_init_state_->composite->set_host(this); 540 pipeline_init_state_->composite->set_host(this);
559 541
560 SetState(kInitDemuxer); 542 SetState(kInitDemuxer);
561 InitializeDemuxer(); 543 InitializeDemuxer();
562 } 544 }
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 // Transition to ended, executing the callback if present. 823 // Transition to ended, executing the callback if present.
842 SetState(kEnded); 824 SetState(kEnded);
843 { 825 {
844 base::AutoLock auto_lock(lock_); 826 base::AutoLock auto_lock(lock_);
845 clock_->EndOfStream(); 827 clock_->EndOfStream();
846 } 828 }
847 829
848 ReportStatus(ended_cb_, status_); 830 ReportStatus(ended_cb_, status_);
849 } 831 }
850 832
851 void Pipeline::NotifyNetworkEventTask(NetworkEvent type) {
852 DCHECK(message_loop_->BelongsToCurrentThread());
853 if (!network_cb_.is_null())
854 network_cb_.Run(type);
855 }
856
857 void Pipeline::DisableAudioRendererTask() { 833 void Pipeline::DisableAudioRendererTask() {
858 DCHECK(message_loop_->BelongsToCurrentThread()); 834 DCHECK(message_loop_->BelongsToCurrentThread());
859 835
860 base::AutoLock auto_lock(lock_); 836 base::AutoLock auto_lock(lock_);
861 has_audio_ = false; 837 has_audio_ = false;
862 audio_disabled_ = true; 838 audio_disabled_ = true;
863 839
864 // Notify all filters of disabled audio renderer. If the filter isn't 840 // Notify all filters of disabled audio renderer. If the filter isn't
865 // initialized yet, OnAudioRendererDisabled() will be called when 841 // initialized yet, OnAudioRendererDisabled() will be called when
866 // initialization is complete. 842 // initialization is complete.
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { 1276 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() {
1301 lock_.AssertAcquired(); 1277 lock_.AssertAcquired();
1302 if (!waiting_for_clock_update_) 1278 if (!waiting_for_clock_update_)
1303 return; 1279 return;
1304 1280
1305 waiting_for_clock_update_ = false; 1281 waiting_for_clock_update_ = false;
1306 clock_->Play(); 1282 clock_->Play();
1307 } 1283 }
1308 1284
1309 } // namespace media 1285 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline.h ('k') | media/base/pipeline_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698