Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: content/renderer/media/android/webmediaplayer_android.cc

Issue 759933003: Move OnNeedKey() to WebMediaPlayerImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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() || init_data_type.empty() ||
ddorwin 2014/12/02 22:06:38 We should log instead of check here too.
xhwang 2014/12/02 22:31:27 Done.
1747 init_data_type == init_data_type_);
1747 if (init_data_type_.empty()) 1748 if (init_data_type_.empty())
1748 init_data_type_ = type; 1749 init_data_type_ = init_data_type;
1749 1750
1750 const uint8* init_data_ptr = init_data.empty() ? NULL : &init_data[0]; 1751 const uint8* init_data_ptr = init_data.empty() ? NULL : &init_data[0];
1751 client_->encrypted( 1752 client_->encrypted(
1752 WebString::fromUTF8(type), init_data_ptr, init_data.size()); 1753 WebString::fromUTF8(init_data_type), init_data_ptr, init_data.size());
1753 } 1754 }
1754 1755
1755 void WebMediaPlayerAndroid::SetDecryptorReadyCB( 1756 void WebMediaPlayerAndroid::SetDecryptorReadyCB(
1756 const media::DecryptorReadyCB& decryptor_ready_cb) { 1757 const media::DecryptorReadyCB& decryptor_ready_cb) {
1757 DCHECK(main_thread_checker_.CalledOnValidThread()); 1758 DCHECK(main_thread_checker_.CalledOnValidThread());
1758 1759
1759 // Cancels the previous decryptor request. 1760 // Cancels the previous decryptor request.
1760 if (decryptor_ready_cb.is_null()) { 1761 if (decryptor_ready_cb.is_null()) {
1761 if (!decryptor_ready_cb_.is_null()) { 1762 if (!decryptor_ready_cb_.is_null()) {
1762 base::ResetAndReturn(&decryptor_ready_cb_) 1763 base::ResetAndReturn(&decryptor_ready_cb_)
(...skipping 26 matching lines...) Expand all
1789 1790
1790 bool WebMediaPlayerAndroid::IsHLSStream() const { 1791 bool WebMediaPlayerAndroid::IsHLSStream() const {
1791 std::string mime; 1792 std::string mime;
1792 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_; 1793 GURL url = redirected_url_.is_empty() ? url_ : redirected_url_;
1793 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime)) 1794 if (!net::GetMimeTypeFromFile(base::FilePath(url.path()), &mime))
1794 return false; 1795 return false;
1795 return !mime.compare("application/x-mpegurl"); 1796 return !mime.compare("application/x-mpegurl");
1796 } 1797 }
1797 1798
1798 } // namespace content 1799 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698