| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // TODO(scherkus): clean up PipelineImpl... too many crazy function names, | 5 // TODO(scherkus): clean up PipelineImpl... too many crazy function names, |
| 6 // potential deadlocks, etc... | 6 // potential deadlocks, etc... |
| 7 | 7 |
| 8 #include "media/base/pipeline_impl.h" | 8 #include "media/base/pipeline_impl.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 if (state_ == kEnded || elapsed > duration_) { | 244 if (state_ == kEnded || elapsed > duration_) { |
| 245 return duration_; | 245 return duration_; |
| 246 } | 246 } |
| 247 return elapsed; | 247 return elapsed; |
| 248 } | 248 } |
| 249 | 249 |
| 250 base::TimeDelta PipelineImpl::GetBufferedTime() { | 250 base::TimeDelta PipelineImpl::GetBufferedTime() { |
| 251 base::AutoLock auto_lock(lock_); | 251 base::AutoLock auto_lock(lock_); |
| 252 | 252 |
| 253 // If media is fully loaded, then return duration. | 253 // If media is fully loaded, then return duration. |
| 254 if (loaded_ || total_bytes_ == buffered_bytes_) { | 254 if (local_source_ || total_bytes_ == buffered_bytes_) { |
| 255 max_buffered_time_ = duration_; | 255 max_buffered_time_ = duration_; |
| 256 return duration_; | 256 return duration_; |
| 257 } | 257 } |
| 258 | 258 |
| 259 base::TimeDelta current_time = GetCurrentTime_Locked(); | 259 base::TimeDelta current_time = GetCurrentTime_Locked(); |
| 260 | 260 |
| 261 // If buffered time was set, we report that value directly. | 261 // If buffered time was set, we report that value directly. |
| 262 if (buffered_time_.ToInternalValue() > 0) | 262 if (buffered_time_.ToInternalValue() > 0) |
| 263 return std::max(buffered_time_, current_time); | 263 return std::max(buffered_time_, current_time); |
| 264 | 264 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 base::AutoLock auto_lock(lock_); | 300 base::AutoLock auto_lock(lock_); |
| 301 return total_bytes_; | 301 return total_bytes_; |
| 302 } | 302 } |
| 303 | 303 |
| 304 void PipelineImpl::GetNaturalVideoSize(gfx::Size* out_size) const { | 304 void PipelineImpl::GetNaturalVideoSize(gfx::Size* out_size) const { |
| 305 CHECK(out_size); | 305 CHECK(out_size); |
| 306 base::AutoLock auto_lock(lock_); | 306 base::AutoLock auto_lock(lock_); |
| 307 *out_size = natural_size_; | 307 *out_size = natural_size_; |
| 308 } | 308 } |
| 309 | 309 |
| 310 void PipelineImpl::SetLocalSource(bool local_source) { |
| 311 media_log_->AddEvent( |
| 312 media_log_->CreateBooleanEvent( |
| 313 MediaLogEvent::LOCAL_SOURCE_SET, "local_source", local_source)); |
| 314 |
| 315 base::AutoLock auto_lock(lock_); |
| 316 local_source_ = local_source; |
| 317 download_rate_monitor_.set_local_source(local_source_); |
| 318 } |
| 319 |
| 310 bool PipelineImpl::IsStreaming() const { | 320 bool PipelineImpl::IsStreaming() const { |
| 311 base::AutoLock auto_lock(lock_); | 321 base::AutoLock auto_lock(lock_); |
| 312 return streaming_; | 322 return streaming_; |
| 313 } | 323 } |
| 314 | 324 |
| 315 bool PipelineImpl::IsLoaded() const { | 325 bool PipelineImpl::IsLocalSource() const { |
| 316 base::AutoLock auto_lock(lock_); | 326 base::AutoLock auto_lock(lock_); |
| 317 return loaded_; | 327 return local_source_; |
| 318 } | 328 } |
| 319 | 329 |
| 320 PipelineStatistics PipelineImpl::GetStatistics() const { | 330 PipelineStatistics PipelineImpl::GetStatistics() const { |
| 321 base::AutoLock auto_lock(lock_); | 331 base::AutoLock auto_lock(lock_); |
| 322 return statistics_; | 332 return statistics_; |
| 323 } | 333 } |
| 324 | 334 |
| 325 void PipelineImpl::SetClockForTesting(Clock* clock) { | 335 void PipelineImpl::SetClockForTesting(Clock* clock) { |
| 326 clock_.reset(clock); | 336 clock_.reset(clock); |
| 327 } | 337 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 351 running_ = false; | 361 running_ = false; |
| 352 stop_pending_ = false; | 362 stop_pending_ = false; |
| 353 seek_pending_ = false; | 363 seek_pending_ = false; |
| 354 tearing_down_ = false; | 364 tearing_down_ = false; |
| 355 error_caused_teardown_ = false; | 365 error_caused_teardown_ = false; |
| 356 playback_rate_change_pending_ = false; | 366 playback_rate_change_pending_ = false; |
| 357 duration_ = kZero; | 367 duration_ = kZero; |
| 358 buffered_time_ = kZero; | 368 buffered_time_ = kZero; |
| 359 buffered_bytes_ = 0; | 369 buffered_bytes_ = 0; |
| 360 streaming_ = false; | 370 streaming_ = false; |
| 361 loaded_ = false; | 371 local_source_ = false; |
| 362 total_bytes_ = 0; | 372 total_bytes_ = 0; |
| 363 natural_size_.SetSize(0, 0); | 373 natural_size_.SetSize(0, 0); |
| 364 volume_ = 1.0f; | 374 volume_ = 1.0f; |
| 365 preload_ = AUTO; | 375 preload_ = AUTO; |
| 366 playback_rate_ = 0.0f; | 376 playback_rate_ = 0.0f; |
| 367 pending_playback_rate_ = 0.0f; | 377 pending_playback_rate_ = 0.0f; |
| 368 status_ = PIPELINE_OK; | 378 status_ = PIPELINE_OK; |
| 369 has_audio_ = false; | 379 has_audio_ = false; |
| 370 has_video_ = false; | 380 has_video_ = false; |
| 371 waiting_for_clock_update_ = false; | 381 waiting_for_clock_update_ = false; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 } | 558 } |
| 549 | 559 |
| 550 void PipelineImpl::SetStreaming(bool streaming) { | 560 void PipelineImpl::SetStreaming(bool streaming) { |
| 551 DCHECK(IsRunning()); | 561 DCHECK(IsRunning()); |
| 552 media_log_->AddEvent( | 562 media_log_->AddEvent( |
| 553 media_log_->CreateBooleanEvent( | 563 media_log_->CreateBooleanEvent( |
| 554 MediaLogEvent::STREAMING_SET, "streaming", streaming)); | 564 MediaLogEvent::STREAMING_SET, "streaming", streaming)); |
| 555 | 565 |
| 556 base::AutoLock auto_lock(lock_); | 566 base::AutoLock auto_lock(lock_); |
| 557 streaming_ = streaming; | 567 streaming_ = streaming; |
| 568 download_rate_monitor_.set_streaming(streaming_); |
| 558 } | 569 } |
| 559 | 570 |
| 560 void PipelineImpl::NotifyEnded() { | 571 void PipelineImpl::NotifyEnded() { |
| 561 DCHECK(IsRunning()); | 572 DCHECK(IsRunning()); |
| 562 message_loop_->PostTask(FROM_HERE, | 573 message_loop_->PostTask(FROM_HERE, |
| 563 base::Bind(&PipelineImpl::NotifyEndedTask, this)); | 574 base::Bind(&PipelineImpl::NotifyEndedTask, this)); |
| 564 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::ENDED)); | 575 media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::ENDED)); |
| 565 } | 576 } |
| 566 | 577 |
| 567 void PipelineImpl::SetLoaded(bool loaded) { | 578 void PipelineImpl::SetLocalSourceFromFilter(bool local_source) { |
| 568 DCHECK(IsRunning()); | 579 DCHECK(IsRunning()); |
| 569 media_log_->AddEvent( | 580 SetLocalSource(local_source); |
| 570 media_log_->CreateBooleanEvent( | |
| 571 MediaLogEvent::LOADED_SET, "loaded", loaded)); | |
| 572 | |
| 573 base::AutoLock auto_lock(lock_); | |
| 574 loaded_ = loaded; | |
| 575 download_rate_monitor_.set_loaded(loaded_); | |
| 576 } | 581 } |
| 577 | 582 |
| 578 void PipelineImpl::SetNetworkActivity(bool is_downloading_data) { | 583 void PipelineImpl::SetNetworkActivity(bool is_downloading_data) { |
| 579 DCHECK(IsRunning()); | 584 DCHECK(IsRunning()); |
| 580 | 585 |
| 581 NetworkEvent type = DOWNLOAD_PAUSED; | 586 NetworkEvent type = DOWNLOAD_PAUSED; |
| 582 if (is_downloading_data) | 587 if (is_downloading_data) |
| 583 type = DOWNLOAD_CONTINUED; | 588 type = DOWNLOAD_CONTINUED; |
| 584 | 589 |
| 585 { | 590 { |
| (...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 message_loop_->PostTask(FROM_HERE, | 1436 message_loop_->PostTask(FROM_HERE, |
| 1432 base::Bind(&PipelineImpl::NotifyCanPlayThrough, this)); | 1437 base::Bind(&PipelineImpl::NotifyCanPlayThrough, this)); |
| 1433 } | 1438 } |
| 1434 | 1439 |
| 1435 void PipelineImpl::NotifyCanPlayThrough() { | 1440 void PipelineImpl::NotifyCanPlayThrough() { |
| 1436 DCHECK_EQ(MessageLoop::current(), message_loop_); | 1441 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 1437 NotifyNetworkEventTask(CAN_PLAY_THROUGH); | 1442 NotifyNetworkEventTask(CAN_PLAY_THROUGH); |
| 1438 } | 1443 } |
| 1439 | 1444 |
| 1440 } // namespace media | 1445 } // namespace media |
| OLD | NEW |