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

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 955993004: Use blink::initDataType and blink::sessionType as enums (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months 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 "media/blink/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 24 matching lines...) Expand all
35 #include "media/blink/encrypted_media_player_support.h" 35 #include "media/blink/encrypted_media_player_support.h"
36 #include "media/blink/texttrack_impl.h" 36 #include "media/blink/texttrack_impl.h"
37 #include "media/blink/webaudiosourceprovider_impl.h" 37 #include "media/blink/webaudiosourceprovider_impl.h"
38 #include "media/blink/webcontentdecryptionmodule_impl.h" 38 #include "media/blink/webcontentdecryptionmodule_impl.h"
39 #include "media/blink/webinbandtexttrack_impl.h" 39 #include "media/blink/webinbandtexttrack_impl.h"
40 #include "media/blink/webmediaplayer_delegate.h" 40 #include "media/blink/webmediaplayer_delegate.h"
41 #include "media/blink/webmediaplayer_util.h" 41 #include "media/blink/webmediaplayer_util.h"
42 #include "media/blink/webmediasource_impl.h" 42 #include "media/blink/webmediasource_impl.h"
43 #include "media/filters/chunk_demuxer.h" 43 #include "media/filters/chunk_demuxer.h"
44 #include "media/filters/ffmpeg_demuxer.h" 44 #include "media/filters/ffmpeg_demuxer.h"
45 #include "third_party/WebKit/public/platform/WebEncryptedMediaTypes.h"
45 #include "third_party/WebKit/public/platform/WebMediaSource.h" 46 #include "third_party/WebKit/public/platform/WebMediaSource.h"
46 #include "third_party/WebKit/public/platform/WebRect.h" 47 #include "third_party/WebKit/public/platform/WebRect.h"
47 #include "third_party/WebKit/public/platform/WebSize.h" 48 #include "third_party/WebKit/public/platform/WebSize.h"
48 #include "third_party/WebKit/public/platform/WebString.h" 49 #include "third_party/WebKit/public/platform/WebString.h"
49 #include "third_party/WebKit/public/platform/WebURL.h" 50 #include "third_party/WebKit/public/platform/WebURL.h"
50 #include "third_party/WebKit/public/web/WebLocalFrame.h" 51 #include "third_party/WebKit/public/web/WebLocalFrame.h"
51 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 52 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
52 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 53 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
53 #include "third_party/WebKit/public/web/WebView.h" 54 #include "third_party/WebKit/public/web/WebView.h"
54 55
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 101
101 #define BIND_TO_RENDER_LOOP1(function, arg1) \ 102 #define BIND_TO_RENDER_LOOP1(function, arg1) \
102 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ 103 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \
103 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1))) 104 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1)))
104 105
105 static void LogMediaSourceError(const scoped_refptr<MediaLog>& media_log, 106 static void LogMediaSourceError(const scoped_refptr<MediaLog>& media_log,
106 const std::string& error) { 107 const std::string& error) {
107 media_log->AddEvent(media_log->CreateMediaSourceErrorEvent(error)); 108 media_log->AddEvent(media_log->CreateMediaSourceErrorEvent(error));
108 } 109 }
109 110
111 static blink::WebEncryptedMediaInitDataType ConvertInitDataType(
112 const std::string& init_data_type) {
113 if (init_data_type == "cenc")
114 return blink::WebEncryptedMediaInitDataType::Cenc;
115 if (init_data_type == "keyids")
116 return blink::WebEncryptedMediaInitDataType::Keyids;
117 if (init_data_type == "webm")
118 return blink::WebEncryptedMediaInitDataType::Webm;
119 NOTREACHED() << "unexpected " << init_data_type;
120 return blink::WebEncryptedMediaInitDataType::Unknown;
121 }
122
110 WebMediaPlayerImpl::WebMediaPlayerImpl( 123 WebMediaPlayerImpl::WebMediaPlayerImpl(
111 blink::WebLocalFrame* frame, 124 blink::WebLocalFrame* frame,
112 blink::WebMediaPlayerClient* client, 125 blink::WebMediaPlayerClient* client,
113 base::WeakPtr<WebMediaPlayerDelegate> delegate, 126 base::WeakPtr<WebMediaPlayerDelegate> delegate,
114 scoped_ptr<RendererFactory> renderer_factory, 127 scoped_ptr<RendererFactory> renderer_factory,
115 scoped_ptr<CdmFactory> cdm_factory, 128 scoped_ptr<CdmFactory> cdm_factory,
116 const WebMediaPlayerParams& params) 129 const WebMediaPlayerParams& params)
117 : frame_(frame), 130 : frame_(frame),
118 network_state_(WebMediaPlayer::NetworkStateEmpty), 131 network_state_(WebMediaPlayer::NetworkStateEmpty),
119 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), 132 ready_state_(WebMediaPlayer::ReadyStateHaveNothing),
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 result.completeWithError( 662 result.completeWithError(
650 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0, 663 blink::WebContentDecryptionModuleExceptionNotSupportedError, 0,
651 "Null MediaKeys object is not supported."); 664 "Null MediaKeys object is not supported.");
652 return; 665 return;
653 } 666 }
654 667
655 SetCdm(ToWebContentDecryptionModuleImpl(cdm)->GetCdmContext(), 668 SetCdm(ToWebContentDecryptionModuleImpl(cdm)->GetCdmContext(),
656 BIND_TO_RENDER_LOOP1(&WebMediaPlayerImpl::OnCdmAttached, result)); 669 BIND_TO_RENDER_LOOP1(&WebMediaPlayerImpl::OnCdmAttached, result));
657 } 670 }
658 671
672 // TODO(jrummell): |init_data_type| should be an enum.
659 void WebMediaPlayerImpl::OnEncryptedMediaInitData( 673 void WebMediaPlayerImpl::OnEncryptedMediaInitData(
660 const std::string& init_data_type, 674 const std::string& init_data_type,
661 const std::vector<uint8>& init_data) { 675 const std::vector<uint8>& init_data) {
662 DCHECK(!init_data_type.empty()); 676 DCHECK(!init_data_type.empty());
663 677
664 // Do not fire "encrypted" event if encrypted media is not enabled. 678 // Do not fire "encrypted" event if encrypted media is not enabled.
665 // TODO(xhwang): Handle this in |client_|. 679 // TODO(xhwang): Handle this in |client_|.
666 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() && 680 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() &&
667 !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) { 681 !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) {
668 return; 682 return;
669 } 683 }
670 684
671 // TODO(xhwang): Update this UMA name. 685 // TODO(xhwang): Update this UMA name.
672 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1); 686 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1);
673 687
674 encrypted_media_support_.SetInitDataType(init_data_type); 688 encrypted_media_support_.SetInitDataType(init_data_type);
675 689
676 const uint8* init_data_ptr = init_data.empty() ? nullptr : &init_data[0]; 690 client_->encrypted(ConvertInitDataType(init_data_type),
677 client_->encrypted(WebString::fromUTF8(init_data_type), init_data_ptr, 691 vector_as_array(&init_data),
678 base::saturated_cast<unsigned int>(init_data.size())); 692 base::saturated_cast<unsigned int>(init_data.size()));
679 } 693 }
680 694
681 void WebMediaPlayerImpl::SetCdm(CdmContext* cdm_context, 695 void WebMediaPlayerImpl::SetCdm(CdmContext* cdm_context,
682 const CdmAttachedCB& cdm_attached_cb) { 696 const CdmAttachedCB& cdm_attached_cb) {
683 pipeline_.SetCdm(cdm_context, cdm_attached_cb); 697 pipeline_.SetCdm(cdm_context, cdm_attached_cb);
684 } 698 }
685 699
686 void WebMediaPlayerImpl::OnCdmAttached( 700 void WebMediaPlayerImpl::OnCdmAttached(
687 blink::WebContentDecryptionModuleResult result, 701 blink::WebContentDecryptionModuleResult result,
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 1013
1000 // pause() may be called after playback has ended and the HTMLMediaElement 1014 // pause() may be called after playback has ended and the HTMLMediaElement
1001 // requires that currentTime() == duration() after ending. We want to ensure 1015 // requires that currentTime() == duration() after ending. We want to ensure
1002 // |paused_time_| matches currentTime() in this case or a future seek() may 1016 // |paused_time_| matches currentTime() in this case or a future seek() may
1003 // incorrectly discard what it thinks is a seek to the existing time. 1017 // incorrectly discard what it thinks is a seek to the existing time.
1004 paused_time_ = 1018 paused_time_ =
1005 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); 1019 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime();
1006 } 1020 }
1007 1021
1008 } // namespace media 1022 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698