| 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 1713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1724 message.empty() ? NULL : &message[0], | 1724 message.empty() ? NULL : &message[0], |
| 1725 message.size(), | 1725 message.size(), |
| 1726 destination_url); | 1726 destination_url); |
| 1727 } | 1727 } |
| 1728 | 1728 |
| 1729 void WebMediaPlayerAndroid::OnMediaSourceOpened( | 1729 void WebMediaPlayerAndroid::OnMediaSourceOpened( |
| 1730 blink::WebMediaSource* web_media_source) { | 1730 blink::WebMediaSource* web_media_source) { |
| 1731 client_->mediaSourceOpened(web_media_source); | 1731 client_->mediaSourceOpened(web_media_source); |
| 1732 } | 1732 } |
| 1733 | 1733 |
| 1734 void WebMediaPlayerAndroid::OnNeedKey(const std::string& type, | 1734 void WebMediaPlayerAndroid::OnNeedKey(const std::string& init_data_type, |
| 1735 const std::vector<uint8>& init_data) { | 1735 const std::vector<uint8>& init_data) { |
| 1736 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1736 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 1737 | 1737 |
| 1738 // Do not fire NeedKey event if encrypted media is not enabled. | 1738 // Do not fire NeedKey event if encrypted media is not enabled. |
| 1739 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() && | 1739 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() && |
| 1740 !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) { | 1740 !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) { |
| 1741 return; | 1741 return; |
| 1742 } | 1742 } |
| 1743 | 1743 |
| 1744 UMA_HISTOGRAM_COUNTS(kMediaEme + std::string("NeedKey"), 1); | 1744 UMA_HISTOGRAM_COUNTS(kMediaEme + std::string("NeedKey"), 1); |
| 1745 | 1745 |
| 1746 DCHECK(init_data_type_.empty() || type.empty() || type == init_data_type_); | 1746 DCHECK(!init_data_type.empty()); |
| 1747 DLOG_IF(WARNING, |
| 1748 !init_data_type_.empty() && init_data_type != init_data_type_) |
| 1749 << "Mixed init data type not supported. The new type is ignored."; |
| 1747 if (init_data_type_.empty()) | 1750 if (init_data_type_.empty()) |
| 1748 init_data_type_ = type; | 1751 init_data_type_ = init_data_type; |
| 1749 | 1752 |
| 1750 const uint8* init_data_ptr = init_data.empty() ? NULL : &init_data[0]; | 1753 const uint8* init_data_ptr = init_data.empty() ? NULL : &init_data[0]; |
| 1751 client_->encrypted( | 1754 client_->encrypted(WebString::fromUTF8(init_data_type), init_data_ptr, |
| 1752 WebString::fromUTF8(type), init_data_ptr, init_data.size()); | 1755 init_data.size()); |
| 1753 } | 1756 } |
| 1754 | 1757 |
| 1755 void WebMediaPlayerAndroid::SetDecryptorReadyCB( | 1758 void WebMediaPlayerAndroid::SetDecryptorReadyCB( |
| 1756 const media::DecryptorReadyCB& decryptor_ready_cb) { | 1759 const media::DecryptorReadyCB& decryptor_ready_cb) { |
| 1757 DCHECK(main_thread_checker_.CalledOnValidThread()); | 1760 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 1758 | 1761 |
| 1759 // Cancels the previous decryptor request. | 1762 // Cancels the previous decryptor request. |
| 1760 if (decryptor_ready_cb.is_null()) { | 1763 if (decryptor_ready_cb.is_null()) { |
| 1761 if (!decryptor_ready_cb_.is_null()) { | 1764 if (!decryptor_ready_cb_.is_null()) { |
| 1762 base::ResetAndReturn(&decryptor_ready_cb_) | 1765 base::ResetAndReturn(&decryptor_ready_cb_) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1789 | 1792 |
| 1790 bool WebMediaPlayerAndroid::IsHLSStream() const { | 1793 bool WebMediaPlayerAndroid::IsHLSStream() const { |
| 1791 std::string mime; | 1794 std::string mime; |
| 1792 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; | 1795 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; |
| 1793 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) | 1796 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) |
| 1794 return false; | 1797 return false; |
| 1795 return !mime.compare("application/x-mpegurl"); | 1798 return !mime.compare("application/x-mpegurl"); |
| 1796 } | 1799 } |
| 1797 | 1800 |
| 1798 } // namespace content | 1801 } // namespace content |
| OLD | NEW |