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 18 matching lines...) Expand all Loading... |
29 #include "content/renderer/media/crypto/renderer_cdm_manager.h" | 29 #include "content/renderer/media/crypto/renderer_cdm_manager.h" |
30 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" | 30 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" |
31 #include "content/renderer/render_frame_impl.h" | 31 #include "content/renderer/render_frame_impl.h" |
32 #include "content/renderer/render_thread_impl.h" | 32 #include "content/renderer/render_thread_impl.h" |
33 #include "gpu/GLES2/gl2extchromium.h" | 33 #include "gpu/GLES2/gl2extchromium.h" |
34 #include "gpu/command_buffer/client/gles2_interface.h" | 34 #include "gpu/command_buffer/client/gles2_interface.h" |
35 #include "gpu/command_buffer/common/mailbox_holder.h" | 35 #include "gpu/command_buffer/common/mailbox_holder.h" |
36 #include "media/base/android/media_common_android.h" | 36 #include "media/base/android/media_common_android.h" |
37 #include "media/base/android/media_player_android.h" | 37 #include "media/base/android/media_player_android.h" |
38 #include "media/base/bind_to_current_loop.h" | 38 #include "media/base/bind_to_current_loop.h" |
39 // TODO(xhwang): Remove when we remove prefixed EME implementation. | |
40 #include "media/base/media_keys.h" | 39 #include "media/base/media_keys.h" |
41 #include "media/base/media_log.h" | 40 #include "media/base/media_log.h" |
42 #include "media/base/media_switches.h" | 41 #include "media/base/media_switches.h" |
43 #include "media/base/video_frame.h" | 42 #include "media/base/video_frame.h" |
44 #include "media/blink/webmediaplayer_delegate.h" | 43 #include "media/blink/webmediaplayer_delegate.h" |
45 #include "media/blink/webmediaplayer_util.h" | 44 #include "media/blink/webmediaplayer_util.h" |
46 #include "net/base/mime_util.h" | 45 #include "net/base/mime_util.h" |
47 #include "third_party/WebKit/public/platform/Platform.h" | 46 #include "third_party/WebKit/public/platform/Platform.h" |
48 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" | 47 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h" |
49 #include "third_party/WebKit/public/platform/WebGraphicsContext3DProvider.h" | 48 #include "third_party/WebKit/public/platform/WebGraphicsContext3DProvider.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 needs_establish_peer_ = false; | 171 needs_establish_peer_ = false; |
173 current_frame_ = VideoFrame::CreateBlackFrame(gfx::Size(1, 1)); | 172 current_frame_ = VideoFrame::CreateBlackFrame(gfx::Size(1, 1)); |
174 } | 173 } |
175 #endif // defined(VIDEO_HOLE) | 174 #endif // defined(VIDEO_HOLE) |
176 TryCreateStreamTextureProxyIfNeeded(); | 175 TryCreateStreamTextureProxyIfNeeded(); |
177 interpolator_.SetUpperBound(base::TimeDelta()); | 176 interpolator_.SetUpperBound(base::TimeDelta()); |
178 | 177 |
179 // Set the initial CDM, if specified. | 178 // Set the initial CDM, if specified. |
180 if (initial_cdm) { | 179 if (initial_cdm) { |
181 web_cdm_ = ToWebContentDecryptionModuleImpl(initial_cdm); | 180 web_cdm_ = ToWebContentDecryptionModuleImpl(initial_cdm); |
182 if (web_cdm_->GetCdmId() != RendererCdmManager::kInvalidCdmId) | 181 if (web_cdm_->GetCdmId() != media::MediaKeys::kInvalidCdmId) |
183 player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId()); | 182 player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId()); |
184 } | 183 } |
185 } | 184 } |
186 | 185 |
187 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { | 186 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { |
188 DCHECK(main_thread_checker_.CalledOnValidThread()); | 187 DCHECK(main_thread_checker_.CalledOnValidThread()); |
189 SetVideoFrameProviderClient(NULL); | 188 SetVideoFrameProviderClient(NULL); |
190 client_->setWebLayer(NULL); | 189 client_->setWebLayer(NULL); |
191 | 190 |
192 if (player_manager_) { | 191 if (player_manager_) { |
(...skipping 1339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; | 1531 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
1533 } | 1532 } |
1534 | 1533 |
1535 if (!decryptor_ready_cb_.is_null()) { | 1534 if (!decryptor_ready_cb_.is_null()) { |
1536 base::ResetAndReturn(&decryptor_ready_cb_) | 1535 base::ResetAndReturn(&decryptor_ready_cb_) |
1537 .Run(proxy_decryptor_->GetDecryptor(), base::Bind(DoNothing)); | 1536 .Run(proxy_decryptor_->GetDecryptor(), base::Bind(DoNothing)); |
1538 } | 1537 } |
1539 | 1538 |
1540 // Only browser CDMs have CDM ID. Render side CDMs (e.g. ClearKey CDM) do | 1539 // Only browser CDMs have CDM ID. Render side CDMs (e.g. ClearKey CDM) do |
1541 // not have a CDM ID and there is no need to call player_manager_->SetCdm(). | 1540 // not have a CDM ID and there is no need to call player_manager_->SetCdm(). |
1542 if (proxy_decryptor_->GetCdmId() != RendererCdmManager::kInvalidCdmId) | 1541 if (proxy_decryptor_->GetCdmId() != media::MediaKeys::kInvalidCdmId) |
1543 player_manager_->SetCdm(player_id_, proxy_decryptor_->GetCdmId()); | 1542 player_manager_->SetCdm(player_id_, proxy_decryptor_->GetCdmId()); |
1544 | 1543 |
1545 current_key_system_ = key_system; | 1544 current_key_system_ = key_system; |
1546 } else if (key_system != current_key_system_) { | 1545 } else if (key_system != current_key_system_) { |
1547 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; | 1546 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; |
1548 } | 1547 } |
1549 | 1548 |
1550 std::string init_data_type = init_data_type_; | 1549 std::string init_data_type = init_data_type_; |
1551 if (init_data_type.empty()) | 1550 if (init_data_type.empty()) |
1552 init_data_type = GuessInitDataType(init_data, init_data_length); | 1551 init_data_type = GuessInitDataType(init_data, init_data_length); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 | 1650 |
1652 web_cdm_ = ToWebContentDecryptionModuleImpl(cdm); | 1651 web_cdm_ = ToWebContentDecryptionModuleImpl(cdm); |
1653 if (!web_cdm_) | 1652 if (!web_cdm_) |
1654 return; | 1653 return; |
1655 | 1654 |
1656 if (!decryptor_ready_cb_.is_null()) { | 1655 if (!decryptor_ready_cb_.is_null()) { |
1657 base::ResetAndReturn(&decryptor_ready_cb_) | 1656 base::ResetAndReturn(&decryptor_ready_cb_) |
1658 .Run(web_cdm_->GetDecryptor(), base::Bind(DoNothing)); | 1657 .Run(web_cdm_->GetDecryptor(), base::Bind(DoNothing)); |
1659 } | 1658 } |
1660 | 1659 |
1661 if (web_cdm_->GetCdmId() != RendererCdmManager::kInvalidCdmId) | 1660 if (web_cdm_->GetCdmId() != media::MediaKeys::kInvalidCdmId) |
1662 player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId()); | 1661 player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId()); |
1663 } | 1662 } |
1664 | 1663 |
1665 void WebMediaPlayerAndroid::setContentDecryptionModule( | 1664 void WebMediaPlayerAndroid::setContentDecryptionModule( |
1666 blink::WebContentDecryptionModule* cdm, | 1665 blink::WebContentDecryptionModule* cdm, |
1667 blink::WebContentDecryptionModuleResult result) { | 1666 blink::WebContentDecryptionModuleResult result) { |
1668 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1667 DCHECK(main_thread_checker_.CalledOnValidThread()); |
1669 | 1668 |
1670 // TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324 | 1669 // TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324 |
1671 if (!cdm) { | 1670 if (!cdm) { |
(...skipping 13 matching lines...) Expand all Loading... |
1685 media::BindToCurrentLoop( | 1684 media::BindToCurrentLoop( |
1686 base::Bind(&WebMediaPlayerAndroid::ContentDecryptionModuleAttached, | 1685 base::Bind(&WebMediaPlayerAndroid::ContentDecryptionModuleAttached, |
1687 weak_factory_.GetWeakPtr(), | 1686 weak_factory_.GetWeakPtr(), |
1688 result))); | 1687 result))); |
1689 } else { | 1688 } else { |
1690 // No pipeline/decoder connected, so resolve the promise. When something | 1689 // No pipeline/decoder connected, so resolve the promise. When something |
1691 // is connected, setting the CDM will happen in SetDecryptorReadyCB(). | 1690 // is connected, setting the CDM will happen in SetDecryptorReadyCB(). |
1692 ContentDecryptionModuleAttached(result, true); | 1691 ContentDecryptionModuleAttached(result, true); |
1693 } | 1692 } |
1694 | 1693 |
1695 if (web_cdm_->GetCdmId() != RendererCdmManager::kInvalidCdmId) | 1694 if (web_cdm_->GetCdmId() != media::MediaKeys::kInvalidCdmId) |
1696 player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId()); | 1695 player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId()); |
1697 } | 1696 } |
1698 | 1697 |
1699 void WebMediaPlayerAndroid::ContentDecryptionModuleAttached( | 1698 void WebMediaPlayerAndroid::ContentDecryptionModuleAttached( |
1700 blink::WebContentDecryptionModuleResult result, | 1699 blink::WebContentDecryptionModuleResult result, |
1701 bool success) { | 1700 bool success) { |
1702 if (success) { | 1701 if (success) { |
1703 result.complete(); | 1702 result.complete(); |
1704 return; | 1703 return; |
1705 } | 1704 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1828 | 1827 |
1829 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1828 bool WebMediaPlayerAndroid::IsHLSStream() const { |
1830 std::string mime; | 1829 std::string mime; |
1831 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1830 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
1832 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1831 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
1833 return false; | 1832 return false; |
1834 return !mime.compare("application/x-mpegurl"); | 1833 return !mime.compare("application/x-mpegurl"); |
1835 } | 1834 } |
1836 | 1835 |
1837 } // namespace content | 1836 } // namespace content |
OLD | NEW |