| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/blink/buffered_data_source.h" | 5 #include "media/blink/buffered_data_source.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/location.h" | 11 #include "base/location.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "build/build_config.h" |
| 14 #include "media/base/media_log.h" | 15 #include "media/base/media_log.h" |
| 15 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
| 16 | 17 |
| 17 using blink::WebFrame; | 18 using blink::WebFrame; |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 // BufferedDataSource has an intermediate buffer, this value governs the initial | 22 // BufferedDataSource has an intermediate buffer, this value governs the initial |
| 22 // size of that buffer. It is set to 32KB because this is a typical read size | 23 // size of that buffer. It is set to 32KB because this is a typical read size |
| 23 // of FFmpeg. | 24 // of FFmpeg. |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 | 381 |
| 381 bool init_cb_is_null = false; | 382 bool init_cb_is_null = false; |
| 382 { | 383 { |
| 383 base::AutoLock auto_lock(lock_); | 384 base::AutoLock auto_lock(lock_); |
| 384 init_cb_is_null = init_cb_.is_null(); | 385 init_cb_is_null = init_cb_.is_null(); |
| 385 } | 386 } |
| 386 if (init_cb_is_null) { | 387 if (init_cb_is_null) { |
| 387 loader_->Stop(); | 388 loader_->Stop(); |
| 388 return; | 389 return; |
| 389 } | 390 } |
| 391 |
| 390 response_original_url_ = loader_->response_original_url(); | 392 response_original_url_ = loader_->response_original_url(); |
| 393 #if defined(OS_ANDROID) |
| 394 // The response original url is the URL of this resource after following |
| 395 // redirects. Update |url_| to this so that we only follow redirects once. |
| 396 // We do this on Android only to preserve the behavior we had before the |
| 397 // unified media pipeline. This behavior will soon exist on all platforms |
| 398 // as we switch to MultiBufferDataSource (http://crbug.com/514719). |
| 399 // If the response URL is empty (which happens when it's from a Service |
| 400 // Worker), keep the original one. |
| 401 if (!response_original_url_.is_empty()) |
| 402 url_ = response_original_url_; |
| 403 #endif // defined(OS_ANDROID) |
| 391 | 404 |
| 392 // All responses must be successful. Resources that are assumed to be fully | 405 // All responses must be successful. Resources that are assumed to be fully |
| 393 // buffered must have a known content length. | 406 // buffered must have a known content length. |
| 394 bool success = status == BufferedResourceLoader::kOk && | 407 bool success = status == BufferedResourceLoader::kOk && |
| 395 (!assume_fully_buffered() || | 408 (!assume_fully_buffered() || |
| 396 loader_->instance_size() != kPositionNotSpecified); | 409 loader_->instance_size() != kPositionNotSpecified); |
| 397 | 410 |
| 398 if (success) { | 411 if (success) { |
| 399 total_bytes_ = loader_->instance_size(); | 412 total_bytes_ = loader_->instance_size(); |
| 400 streaming_ = | 413 streaming_ = |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 } | 621 } |
| 609 | 622 |
| 610 // If media is currently playing or the page indicated preload=auto or the | 623 // If media is currently playing or the page indicated preload=auto or the |
| 611 // the server does not support the byte range request or we do not want to go | 624 // the server does not support the byte range request or we do not want to go |
| 612 // too far ahead of the read head, use threshold strategy to enable/disable | 625 // too far ahead of the read head, use threshold strategy to enable/disable |
| 613 // deferring when the buffer is full/depleted. | 626 // deferring when the buffer is full/depleted. |
| 614 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); | 627 loader_->UpdateDeferStrategy(BufferedResourceLoader::kCapacityDefer); |
| 615 } | 628 } |
| 616 | 629 |
| 617 } // namespace media | 630 } // namespace media |
| OLD | NEW |