| 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 "content/renderer/media/android/webmediaplayer_android.h" | 5 #include "content/renderer/media/android/webmediaplayer_android.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 media_source_delegate_->InitializeMediaSource( | 306 media_source_delegate_->InitializeMediaSource( |
| 307 base::Bind(&WebMediaPlayerAndroid::OnMediaSourceOpened, | 307 base::Bind(&WebMediaPlayerAndroid::OnMediaSourceOpened, |
| 308 weak_factory_.GetWeakPtr()), | 308 weak_factory_.GetWeakPtr()), |
| 309 base::Bind(&WebMediaPlayerAndroid::OnEncryptedMediaInitData, | 309 base::Bind(&WebMediaPlayerAndroid::OnEncryptedMediaInitData, |
| 310 weak_factory_.GetWeakPtr()), | 310 weak_factory_.GetWeakPtr()), |
| 311 base::Bind(&WebMediaPlayerAndroid::SetDecryptorReadyCB, | 311 base::Bind(&WebMediaPlayerAndroid::SetDecryptorReadyCB, |
| 312 weak_factory_.GetWeakPtr()), | 312 weak_factory_.GetWeakPtr()), |
| 313 base::Bind(&WebMediaPlayerAndroid::UpdateNetworkState, | 313 base::Bind(&WebMediaPlayerAndroid::UpdateNetworkState, |
| 314 weak_factory_.GetWeakPtr()), | 314 weak_factory_.GetWeakPtr()), |
| 315 base::Bind(&WebMediaPlayerAndroid::OnDurationChanged, | 315 base::Bind(&WebMediaPlayerAndroid::OnDurationChanged, |
| 316 weak_factory_.GetWeakPtr()), |
| 317 base::Bind(&WebMediaPlayerAndroid::OnWaitingForDecryptionKey, |
| 316 weak_factory_.GetWeakPtr())); | 318 weak_factory_.GetWeakPtr())); |
| 317 InitializePlayer(url_, frame_->document().firstPartyForCookies(), | 319 InitializePlayer(url_, frame_->document().firstPartyForCookies(), |
| 318 true, demuxer_client_id); | 320 true, demuxer_client_id); |
| 319 } | 321 } |
| 320 } else { | 322 } else { |
| 321 info_loader_.reset( | 323 info_loader_.reset( |
| 322 new MediaInfoLoader( | 324 new MediaInfoLoader( |
| 323 url, | 325 url, |
| 324 cors_mode, | 326 cors_mode, |
| 325 base::Bind(&WebMediaPlayerAndroid::DidLoadMediaInfo, | 327 base::Bind(&WebMediaPlayerAndroid::DidLoadMediaInfo, |
| (...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1752 DLOG_IF(WARNING, | 1754 DLOG_IF(WARNING, |
| 1753 !init_data_type_.empty() && init_data_type != init_data_type_) | 1755 !init_data_type_.empty() && init_data_type != init_data_type_) |
| 1754 << "Mixed init data type not supported. The new type is ignored."; | 1756 << "Mixed init data type not supported. The new type is ignored."; |
| 1755 if (init_data_type_.empty()) | 1757 if (init_data_type_.empty()) |
| 1756 init_data_type_ = init_data_type; | 1758 init_data_type_ = init_data_type; |
| 1757 | 1759 |
| 1758 client_->encrypted(ConvertInitDataType(init_data_type), | 1760 client_->encrypted(ConvertInitDataType(init_data_type), |
| 1759 vector_as_array(&init_data), init_data.size()); | 1761 vector_as_array(&init_data), init_data.size()); |
| 1760 } | 1762 } |
| 1761 | 1763 |
| 1764 void WebMediaPlayerAndroid::OnWaitingForDecryptionKey() { |
| 1765 client_->didBlockPlaybackWaitingForKey(); |
| 1766 |
| 1767 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called |
| 1768 // when a key has been successfully added (e.g. OnSessionKeysChange() with |
| 1769 // |has_additional_usable_key| = true). http://crbug.com/461903 |
| 1770 client_->didResumePlaybackBlockedForKey(); |
| 1771 } |
| 1772 |
| 1762 void WebMediaPlayerAndroid::SetCdmInternal( | 1773 void WebMediaPlayerAndroid::SetCdmInternal( |
| 1763 const media::CdmAttachedCB& cdm_attached_cb) { | 1774 const media::CdmAttachedCB& cdm_attached_cb) { |
| 1764 DCHECK(cdm_context_ && is_player_initialized_); | 1775 DCHECK(cdm_context_ && is_player_initialized_); |
| 1765 DCHECK(cdm_context_->GetDecryptor() || | 1776 DCHECK(cdm_context_->GetDecryptor() || |
| 1766 cdm_context_->GetCdmId() != media::CdmContext::kInvalidCdmId) | 1777 cdm_context_->GetCdmId() != media::CdmContext::kInvalidCdmId) |
| 1767 << "CDM should support either a Decryptor or a CDM ID."; | 1778 << "CDM should support either a Decryptor or a CDM ID."; |
| 1768 | 1779 |
| 1769 media::Decryptor* decryptor = cdm_context_->GetDecryptor(); | 1780 media::Decryptor* decryptor = cdm_context_->GetDecryptor(); |
| 1770 | 1781 |
| 1771 // Note: | 1782 // Note: |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1835 | 1846 |
| 1836 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1847 bool WebMediaPlayerAndroid::IsHLSStream() const { |
| 1837 std::string mime; | 1848 std::string mime; |
| 1838 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1849 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
| 1839 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1850 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
| 1840 return false; | 1851 return false; |
| 1841 return !mime.compare("application/x-mpegurl"); | 1852 return !mime.compare("application/x-mpegurl"); |
| 1842 } | 1853 } |
| 1843 | 1854 |
| 1844 } // namespace content | 1855 } // namespace content |
| OLD | NEW |