| 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 15 matching lines...) Expand all Loading... |
| 26 #include "content/renderer/media/crypto/render_cdm_factory.h" | 26 #include "content/renderer/media/crypto/render_cdm_factory.h" |
| 27 #include "content/renderer/media/crypto/renderer_cdm_manager.h" | 27 #include "content/renderer/media/crypto/renderer_cdm_manager.h" |
| 28 #include "content/renderer/render_frame_impl.h" | 28 #include "content/renderer/render_frame_impl.h" |
| 29 #include "content/renderer/render_thread_impl.h" | 29 #include "content/renderer/render_thread_impl.h" |
| 30 #include "gpu/GLES2/gl2extchromium.h" | 30 #include "gpu/GLES2/gl2extchromium.h" |
| 31 #include "gpu/command_buffer/client/gles2_interface.h" | 31 #include "gpu/command_buffer/client/gles2_interface.h" |
| 32 #include "gpu/command_buffer/common/mailbox_holder.h" | 32 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 33 #include "media/base/android/media_common_android.h" | 33 #include "media/base/android/media_common_android.h" |
| 34 #include "media/base/android/media_player_android.h" | 34 #include "media/base/android/media_player_android.h" |
| 35 #include "media/base/bind_to_current_loop.h" | 35 #include "media/base/bind_to_current_loop.h" |
| 36 #include "media/base/cdm_context.h" |
| 36 #include "media/base/key_systems.h" | 37 #include "media/base/key_systems.h" |
| 37 #include "media/base/media_keys.h" | 38 #include "media/base/media_keys.h" |
| 38 #include "media/base/media_log.h" | 39 #include "media/base/media_log.h" |
| 39 #include "media/base/media_switches.h" | 40 #include "media/base/media_switches.h" |
| 40 #include "media/base/video_frame.h" | 41 #include "media/base/video_frame.h" |
| 41 #include "media/blink/webcontentdecryptionmodule_impl.h" | 42 #include "media/blink/webcontentdecryptionmodule_impl.h" |
| 42 #include "media/blink/webmediaplayer_delegate.h" | 43 #include "media/blink/webmediaplayer_delegate.h" |
| 43 #include "media/blink/webmediaplayer_util.h" | 44 #include "media/blink/webmediaplayer_util.h" |
| 44 #include "net/base/mime_util.h" | 45 #include "net/base/mime_util.h" |
| 45 #include "third_party/WebKit/public/platform/Platform.h" | 46 #include "third_party/WebKit/public/platform/Platform.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 needs_establish_peer_ = false; | 172 needs_establish_peer_ = false; |
| 172 current_frame_ = VideoFrame::CreateBlackFrame(gfx::Size(1, 1)); | 173 current_frame_ = VideoFrame::CreateBlackFrame(gfx::Size(1, 1)); |
| 173 } | 174 } |
| 174 #endif // defined(VIDEO_HOLE) | 175 #endif // defined(VIDEO_HOLE) |
| 175 TryCreateStreamTextureProxyIfNeeded(); | 176 TryCreateStreamTextureProxyIfNeeded(); |
| 176 interpolator_.SetUpperBound(base::TimeDelta()); | 177 interpolator_.SetUpperBound(base::TimeDelta()); |
| 177 | 178 |
| 178 // Set the initial CDM, if specified. | 179 // Set the initial CDM, if specified. |
| 179 if (initial_cdm) { | 180 if (initial_cdm) { |
| 180 web_cdm_ = media::ToWebContentDecryptionModuleImpl(initial_cdm); | 181 web_cdm_ = media::ToWebContentDecryptionModuleImpl(initial_cdm); |
| 181 if (web_cdm_->GetCdmId() != media::MediaKeys::kInvalidCdmId) | 182 if (web_cdm_->GetCdmId() != media::CdmContext::kInvalidCdmId) |
| 182 player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId()); | 183 player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId()); |
| 183 } | 184 } |
| 184 } | 185 } |
| 185 | 186 |
| 186 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { | 187 WebMediaPlayerAndroid::~WebMediaPlayerAndroid() { |
| 187 DCHECK(main_thread_checker_.CalledOnValidThread()); | 188 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 188 SetVideoFrameProviderClient(NULL); | 189 SetVideoFrameProviderClient(NULL); |
| 189 client_->setWebLayer(NULL); | 190 client_->setWebLayer(NULL); |
| 190 | 191 |
| 191 if (player_manager_) { | 192 if (player_manager_) { |
| (...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1524 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; | 1525 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
| 1525 } | 1526 } |
| 1526 | 1527 |
| 1527 if (!decryptor_ready_cb_.is_null()) { | 1528 if (!decryptor_ready_cb_.is_null()) { |
| 1528 base::ResetAndReturn(&decryptor_ready_cb_) | 1529 base::ResetAndReturn(&decryptor_ready_cb_) |
| 1529 .Run(proxy_decryptor_->GetDecryptor(), base::Bind(DoNothing)); | 1530 .Run(proxy_decryptor_->GetDecryptor(), base::Bind(DoNothing)); |
| 1530 } | 1531 } |
| 1531 | 1532 |
| 1532 // Only browser CDMs have CDM ID. Render side CDMs (e.g. ClearKey CDM) do | 1533 // Only browser CDMs have CDM ID. Render side CDMs (e.g. ClearKey CDM) do |
| 1533 // not have a CDM ID and there is no need to call player_manager_->SetCdm(). | 1534 // not have a CDM ID and there is no need to call player_manager_->SetCdm(). |
| 1534 if (proxy_decryptor_->GetCdmId() != media::MediaKeys::kInvalidCdmId) | 1535 if (proxy_decryptor_->GetCdmId() != media::CdmContext::kInvalidCdmId) |
| 1535 player_manager_->SetCdm(player_id_, proxy_decryptor_->GetCdmId()); | 1536 player_manager_->SetCdm(player_id_, proxy_decryptor_->GetCdmId()); |
| 1536 | 1537 |
| 1537 current_key_system_ = key_system; | 1538 current_key_system_ = key_system; |
| 1538 } else if (key_system != current_key_system_) { | 1539 } else if (key_system != current_key_system_) { |
| 1539 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; | 1540 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; |
| 1540 } | 1541 } |
| 1541 | 1542 |
| 1542 std::string init_data_type = init_data_type_; | 1543 std::string init_data_type = init_data_type_; |
| 1543 if (init_data_type.empty()) | 1544 if (init_data_type.empty()) |
| 1544 init_data_type = GuessInitDataType(init_data, init_data_length); | 1545 init_data_type = GuessInitDataType(init_data, init_data_length); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1643 | 1644 |
| 1644 web_cdm_ = media::ToWebContentDecryptionModuleImpl(cdm); | 1645 web_cdm_ = media::ToWebContentDecryptionModuleImpl(cdm); |
| 1645 if (!web_cdm_) | 1646 if (!web_cdm_) |
| 1646 return; | 1647 return; |
| 1647 | 1648 |
| 1648 if (!decryptor_ready_cb_.is_null()) { | 1649 if (!decryptor_ready_cb_.is_null()) { |
| 1649 base::ResetAndReturn(&decryptor_ready_cb_) | 1650 base::ResetAndReturn(&decryptor_ready_cb_) |
| 1650 .Run(web_cdm_->GetDecryptor(), base::Bind(DoNothing)); | 1651 .Run(web_cdm_->GetDecryptor(), base::Bind(DoNothing)); |
| 1651 } | 1652 } |
| 1652 | 1653 |
| 1653 if (web_cdm_->GetCdmId() != media::MediaKeys::kInvalidCdmId) | 1654 if (web_cdm_->GetCdmId() != media::CdmContext::kInvalidCdmId) |
| 1654 player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId()); | 1655 player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId()); |
| 1655 } | 1656 } |
| 1656 | 1657 |
| 1657 void WebMediaPlayerAndroid::setContentDecryptionModule( | 1658 void WebMediaPlayerAndroid::setContentDecryptionModule( |
| 1658 blink::WebContentDecryptionModule* cdm, | 1659 blink::WebContentDecryptionModule* cdm, |
| 1659 blink::WebContentDecryptionModuleResult result) { | 1660 blink::WebContentDecryptionModuleResult result) { |
| 1660 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1661 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 1661 | 1662 |
| 1662 // TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324 | 1663 // TODO(xhwang): Support setMediaKeys(0) if necessary: http://crbug.com/330324 |
| 1663 if (!cdm) { | 1664 if (!cdm) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1677 media::BindToCurrentLoop( | 1678 media::BindToCurrentLoop( |
| 1678 base::Bind(&WebMediaPlayerAndroid::ContentDecryptionModuleAttached, | 1679 base::Bind(&WebMediaPlayerAndroid::ContentDecryptionModuleAttached, |
| 1679 weak_factory_.GetWeakPtr(), | 1680 weak_factory_.GetWeakPtr(), |
| 1680 result))); | 1681 result))); |
| 1681 } else { | 1682 } else { |
| 1682 // No pipeline/decoder connected, so resolve the promise. When something | 1683 // No pipeline/decoder connected, so resolve the promise. When something |
| 1683 // is connected, setting the CDM will happen in SetDecryptorReadyCB(). | 1684 // is connected, setting the CDM will happen in SetDecryptorReadyCB(). |
| 1684 ContentDecryptionModuleAttached(result, true); | 1685 ContentDecryptionModuleAttached(result, true); |
| 1685 } | 1686 } |
| 1686 | 1687 |
| 1687 if (web_cdm_->GetCdmId() != media::MediaKeys::kInvalidCdmId) | 1688 if (web_cdm_->GetCdmId() != media::CdmContext::kInvalidCdmId) |
| 1688 player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId()); | 1689 player_manager_->SetCdm(player_id_, web_cdm_->GetCdmId()); |
| 1689 } | 1690 } |
| 1690 | 1691 |
| 1691 void WebMediaPlayerAndroid::ContentDecryptionModuleAttached( | 1692 void WebMediaPlayerAndroid::ContentDecryptionModuleAttached( |
| 1692 blink::WebContentDecryptionModuleResult result, | 1693 blink::WebContentDecryptionModuleResult result, |
| 1693 bool success) { | 1694 bool success) { |
| 1694 if (success) { | 1695 if (success) { |
| 1695 result.complete(); | 1696 result.complete(); |
| 1696 return; | 1697 return; |
| 1697 } | 1698 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1815 | 1816 |
| 1816 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1817 bool WebMediaPlayerAndroid::IsHLSStream() const { |
| 1817 std::string mime; | 1818 std::string mime; |
| 1818 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1819 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
| 1819 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1820 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
| 1820 return false; | 1821 return false; |
| 1821 return !mime.compare("application/x-mpegurl"); | 1822 return !mime.compare("application/x-mpegurl"); |
| 1822 } | 1823 } |
| 1823 | 1824 |
| 1824 } // namespace content | 1825 } // namespace content |
| OLD | NEW |