Chromium Code Reviews| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 blink::WebGraphicsContext3D* web_graphics_context_; | 143 blink::WebGraphicsContext3D* web_graphics_context_; |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 } // namespace | 146 } // namespace |
| 147 | 147 |
| 148 namespace content { | 148 namespace content { |
| 149 | 149 |
| 150 WebMediaPlayerAndroid::WebMediaPlayerAndroid( | 150 WebMediaPlayerAndroid::WebMediaPlayerAndroid( |
| 151 blink::WebFrame* frame, | 151 blink::WebFrame* frame, |
| 152 blink::WebMediaPlayerClient* client, | 152 blink::WebMediaPlayerClient* client, |
| 153 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, | |
| 153 base::WeakPtr<media::WebMediaPlayerDelegate> delegate, | 154 base::WeakPtr<media::WebMediaPlayerDelegate> delegate, |
| 154 RendererMediaPlayerManager* player_manager, | 155 RendererMediaPlayerManager* player_manager, |
| 155 media::CdmFactory* cdm_factory, | 156 media::CdmFactory* cdm_factory, |
| 156 media::MediaPermission* media_permission, | 157 media::MediaPermission* media_permission, |
| 157 blink::WebContentDecryptionModule* initial_cdm, | 158 blink::WebContentDecryptionModule* initial_cdm, |
| 158 scoped_refptr<StreamTextureFactory> factory, | 159 scoped_refptr<StreamTextureFactory> factory, |
| 159 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 160 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 160 media::MediaLog* media_log) | 161 media::MediaLog* media_log) |
| 161 : RenderFrameObserver(RenderFrame::FromWebFrame(frame)), | 162 : RenderFrameObserver(RenderFrame::FromWebFrame(frame)), |
| 162 frame_(frame), | 163 frame_(frame), |
| 163 client_(client), | 164 client_(client), |
| 165 encrypted_client_(encrypted_client), | |
| 164 delegate_(delegate), | 166 delegate_(delegate), |
| 165 buffered_(static_cast<size_t>(1)), | 167 buffered_(static_cast<size_t>(1)), |
| 166 media_task_runner_(task_runner), | 168 media_task_runner_(task_runner), |
| 167 ignore_metadata_duration_change_(false), | 169 ignore_metadata_duration_change_(false), |
| 168 pending_seek_(false), | 170 pending_seek_(false), |
| 169 seeking_(false), | 171 seeking_(false), |
| 170 did_loading_progress_(false), | 172 did_loading_progress_(false), |
| 171 player_manager_(player_manager), | 173 player_manager_(player_manager), |
| 172 cdm_factory_(cdm_factory), | 174 cdm_factory_(cdm_factory), |
| 173 media_permission_(media_permission), | 175 media_permission_(media_permission), |
| (...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1690 | 1692 |
| 1691 result.completeWithError( | 1693 result.completeWithError( |
| 1692 blink::WebContentDecryptionModuleExceptionNotSupportedError, | 1694 blink::WebContentDecryptionModuleExceptionNotSupportedError, |
| 1693 0, | 1695 0, |
| 1694 "Unable to set MediaKeys object"); | 1696 "Unable to set MediaKeys object"); |
| 1695 } | 1697 } |
| 1696 | 1698 |
| 1697 void WebMediaPlayerAndroid::OnKeyAdded(const std::string& session_id) { | 1699 void WebMediaPlayerAndroid::OnKeyAdded(const std::string& session_id) { |
| 1698 EmeUMAHistogramCounts(current_key_system_, "KeyAdded", 1); | 1700 EmeUMAHistogramCounts(current_key_system_, "KeyAdded", 1); |
| 1699 | 1701 |
| 1700 client_->keyAdded( | 1702 encrypted_client_->keyAdded( |
|
ddorwin
2015/07/10 17:56:56
Must #include the definition
Srirama
2015/07/10 18:36:03
It is indirectly included from WebMediaPlayerClien
ddorwin
2015/07/10 18:47:43
Yes. Also, IWYU (Include What You Use).
Srirama
2015/07/11 08:44:10
Done.
| |
| 1701 WebString::fromUTF8(media::GetPrefixedKeySystemName(current_key_system_)), | 1703 WebString::fromUTF8(media::GetPrefixedKeySystemName(current_key_system_)), |
| 1702 WebString::fromUTF8(session_id)); | 1704 WebString::fromUTF8(session_id)); |
| 1703 } | 1705 } |
| 1704 | 1706 |
| 1705 void WebMediaPlayerAndroid::OnKeyError(const std::string& session_id, | 1707 void WebMediaPlayerAndroid::OnKeyError(const std::string& session_id, |
| 1706 media::MediaKeys::KeyError error_code, | 1708 media::MediaKeys::KeyError error_code, |
| 1707 uint32 system_code) { | 1709 uint32 system_code) { |
| 1708 EmeUMAHistogramEnumeration(current_key_system_, "KeyError", | 1710 EmeUMAHistogramEnumeration(current_key_system_, "KeyError", |
| 1709 error_code, media::MediaKeys::kMaxKeyError); | 1711 error_code, media::MediaKeys::kMaxKeyError); |
| 1710 | 1712 |
| 1711 unsigned short short_system_code = 0; | 1713 unsigned short short_system_code = 0; |
| 1712 if (system_code > std::numeric_limits<unsigned short>::max()) { | 1714 if (system_code > std::numeric_limits<unsigned short>::max()) { |
| 1713 LOG(WARNING) << "system_code exceeds unsigned short limit."; | 1715 LOG(WARNING) << "system_code exceeds unsigned short limit."; |
| 1714 short_system_code = std::numeric_limits<unsigned short>::max(); | 1716 short_system_code = std::numeric_limits<unsigned short>::max(); |
| 1715 } else { | 1717 } else { |
| 1716 short_system_code = static_cast<unsigned short>(system_code); | 1718 short_system_code = static_cast<unsigned short>(system_code); |
| 1717 } | 1719 } |
| 1718 | 1720 |
| 1719 client_->keyError( | 1721 encrypted_client_->keyError( |
| 1720 WebString::fromUTF8(media::GetPrefixedKeySystemName(current_key_system_)), | 1722 WebString::fromUTF8(media::GetPrefixedKeySystemName(current_key_system_)), |
| 1721 WebString::fromUTF8(session_id), | 1723 WebString::fromUTF8(session_id), |
| 1722 static_cast<blink::WebMediaPlayerClient::MediaKeyErrorCode>(error_code), | 1724 static_cast<blink::WebMediaPlayerClient::MediaKeyErrorCode>(error_code), |
| 1723 short_system_code); | 1725 short_system_code); |
| 1724 } | 1726 } |
| 1725 | 1727 |
| 1726 void WebMediaPlayerAndroid::OnKeyMessage(const std::string& session_id, | 1728 void WebMediaPlayerAndroid::OnKeyMessage(const std::string& session_id, |
| 1727 const std::vector<uint8>& message, | 1729 const std::vector<uint8>& message, |
| 1728 const GURL& destination_url) { | 1730 const GURL& destination_url) { |
| 1729 DCHECK(destination_url.is_empty() || destination_url.is_valid()); | 1731 DCHECK(destination_url.is_empty() || destination_url.is_valid()); |
| 1730 | 1732 |
| 1731 client_->keyMessage( | 1733 encrypted_client_->keyMessage( |
| 1732 WebString::fromUTF8(media::GetPrefixedKeySystemName(current_key_system_)), | 1734 WebString::fromUTF8(media::GetPrefixedKeySystemName(current_key_system_)), |
| 1733 WebString::fromUTF8(session_id), | 1735 WebString::fromUTF8(session_id), message.empty() ? NULL : &message[0], |
| 1734 message.empty() ? NULL : &message[0], | 1736 message.size(), destination_url); |
| 1735 message.size(), | |
| 1736 destination_url); | |
| 1737 } | 1737 } |
| 1738 | 1738 |
| 1739 void WebMediaPlayerAndroid::OnMediaSourceOpened( | 1739 void WebMediaPlayerAndroid::OnMediaSourceOpened( |
| 1740 blink::WebMediaSource* web_media_source) { | 1740 blink::WebMediaSource* web_media_source) { |
| 1741 client_->mediaSourceOpened(web_media_source); | 1741 client_->mediaSourceOpened(web_media_source); |
| 1742 } | 1742 } |
| 1743 | 1743 |
| 1744 void WebMediaPlayerAndroid::OnEncryptedMediaInitData( | 1744 void WebMediaPlayerAndroid::OnEncryptedMediaInitData( |
| 1745 media::EmeInitDataType init_data_type, | 1745 media::EmeInitDataType init_data_type, |
| 1746 const std::vector<uint8>& init_data) { | 1746 const std::vector<uint8>& init_data) { |
| 1747 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1747 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 1748 | 1748 |
| 1749 // Do not fire NeedKey event if encrypted media is not enabled. | 1749 // Do not fire NeedKey event if encrypted media is not enabled. |
| 1750 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() && | 1750 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() && |
| 1751 !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) { | 1751 !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) { |
| 1752 return; | 1752 return; |
| 1753 } | 1753 } |
| 1754 | 1754 |
| 1755 UMA_HISTOGRAM_COUNTS(kMediaEme + std::string("NeedKey"), 1); | 1755 UMA_HISTOGRAM_COUNTS(kMediaEme + std::string("NeedKey"), 1); |
| 1756 | 1756 |
| 1757 DCHECK(init_data_type != media::EmeInitDataType::UNKNOWN); | 1757 DCHECK(init_data_type != media::EmeInitDataType::UNKNOWN); |
| 1758 DLOG_IF(WARNING, init_data_type_ != media::EmeInitDataType::UNKNOWN && | 1758 DLOG_IF(WARNING, init_data_type_ != media::EmeInitDataType::UNKNOWN && |
| 1759 init_data_type != init_data_type_) | 1759 init_data_type != init_data_type_) |
| 1760 << "Mixed init data type not supported. The new type is ignored."; | 1760 << "Mixed init data type not supported. The new type is ignored."; |
| 1761 if (init_data_type_ == media::EmeInitDataType::UNKNOWN) | 1761 if (init_data_type_ == media::EmeInitDataType::UNKNOWN) |
| 1762 init_data_type_ = init_data_type; | 1762 init_data_type_ = init_data_type; |
| 1763 | 1763 |
| 1764 client_->encrypted(ConvertToWebInitDataType(init_data_type), | 1764 encrypted_client_->encrypted(ConvertToWebInitDataType(init_data_type), |
| 1765 vector_as_array(&init_data), init_data.size()); | 1765 vector_as_array(&init_data), init_data.size()); |
| 1766 } | 1766 } |
| 1767 | 1767 |
| 1768 void WebMediaPlayerAndroid::OnWaitingForDecryptionKey() { | 1768 void WebMediaPlayerAndroid::OnWaitingForDecryptionKey() { |
| 1769 client_->didBlockPlaybackWaitingForKey(); | 1769 encrypted_client_->didBlockPlaybackWaitingForKey(); |
| 1770 | 1770 |
| 1771 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called | 1771 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called |
| 1772 // when a key has been successfully added (e.g. OnSessionKeysChange() with | 1772 // when a key has been successfully added (e.g. OnSessionKeysChange() with |
| 1773 // |has_additional_usable_key| = true). http://crbug.com/461903 | 1773 // |has_additional_usable_key| = true). http://crbug.com/461903 |
| 1774 client_->didResumePlaybackBlockedForKey(); | 1774 encrypted_client_->didResumePlaybackBlockedForKey(); |
| 1775 } | 1775 } |
| 1776 | 1776 |
| 1777 void WebMediaPlayerAndroid::OnCdmContextReady(media::CdmContext* cdm_context) { | 1777 void WebMediaPlayerAndroid::OnCdmContextReady(media::CdmContext* cdm_context) { |
| 1778 DCHECK(!cdm_context_); | 1778 DCHECK(!cdm_context_); |
| 1779 | 1779 |
| 1780 if (!cdm_context) { | 1780 if (!cdm_context) { |
| 1781 LOG(ERROR) << "CdmContext not available (e.g. CDM creation failed)."; | 1781 LOG(ERROR) << "CdmContext not available (e.g. CDM creation failed)."; |
| 1782 return; | 1782 return; |
| 1783 } | 1783 } |
| 1784 | 1784 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1865 | 1865 |
| 1866 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1866 bool WebMediaPlayerAndroid::IsHLSStream() const { |
| 1867 std::string mime; | 1867 std::string mime; |
| 1868 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1868 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
| 1869 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1869 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
| 1870 return false; | 1870 return false; |
| 1871 return !mime.compare("application/x-mpegurl"); | 1871 return !mime.compare("application/x-mpegurl"); |
| 1872 } | 1872 } |
| 1873 | 1873 |
| 1874 } // namespace content | 1874 } // namespace content |
| OLD | NEW |