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

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

Issue 1133033003: Eliminate MediaPlayer & MediaPlayerClient abstractions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add new path for createMediaPlayer() Created 5 years, 5 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 <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 20 matching lines...) Expand all
31 #include "media/blink/texttrack_impl.h" 31 #include "media/blink/texttrack_impl.h"
32 #include "media/blink/webaudiosourceprovider_impl.h" 32 #include "media/blink/webaudiosourceprovider_impl.h"
33 #include "media/blink/webcontentdecryptionmodule_impl.h" 33 #include "media/blink/webcontentdecryptionmodule_impl.h"
34 #include "media/blink/webinbandtexttrack_impl.h" 34 #include "media/blink/webinbandtexttrack_impl.h"
35 #include "media/blink/webmediaplayer_delegate.h" 35 #include "media/blink/webmediaplayer_delegate.h"
36 #include "media/blink/webmediaplayer_util.h" 36 #include "media/blink/webmediaplayer_util.h"
37 #include "media/blink/webmediasource_impl.h" 37 #include "media/blink/webmediasource_impl.h"
38 #include "media/filters/chunk_demuxer.h" 38 #include "media/filters/chunk_demuxer.h"
39 #include "media/filters/ffmpeg_demuxer.h" 39 #include "media/filters/ffmpeg_demuxer.h"
40 #include "third_party/WebKit/public/platform/WebEncryptedMediaTypes.h" 40 #include "third_party/WebKit/public/platform/WebEncryptedMediaTypes.h"
41 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h"
41 #include "third_party/WebKit/public/platform/WebMediaSource.h" 42 #include "third_party/WebKit/public/platform/WebMediaSource.h"
42 #include "third_party/WebKit/public/platform/WebRect.h" 43 #include "third_party/WebKit/public/platform/WebRect.h"
43 #include "third_party/WebKit/public/platform/WebSize.h" 44 #include "third_party/WebKit/public/platform/WebSize.h"
44 #include "third_party/WebKit/public/platform/WebString.h" 45 #include "third_party/WebKit/public/platform/WebString.h"
45 #include "third_party/WebKit/public/platform/WebURL.h" 46 #include "third_party/WebKit/public/platform/WebURL.h"
46 #include "third_party/WebKit/public/web/WebDocument.h" 47 #include "third_party/WebKit/public/web/WebDocument.h"
47 #include "third_party/WebKit/public/web/WebFrame.h" 48 #include "third_party/WebKit/public/web/WebFrame.h"
48 #include "third_party/WebKit/public/web/WebLocalFrame.h" 49 #include "third_party/WebKit/public/web/WebLocalFrame.h"
49 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 50 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
50 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" 51 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ 97 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \
97 BindToCurrentLoop(base::Bind(function, AsWeakPtr()))) 98 BindToCurrentLoop(base::Bind(function, AsWeakPtr())))
98 99
99 #define BIND_TO_RENDER_LOOP1(function, arg1) \ 100 #define BIND_TO_RENDER_LOOP1(function, arg1) \
100 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ 101 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \
101 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1))) 102 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1)))
102 103
103 WebMediaPlayerImpl::WebMediaPlayerImpl( 104 WebMediaPlayerImpl::WebMediaPlayerImpl(
104 blink::WebLocalFrame* frame, 105 blink::WebLocalFrame* frame,
105 blink::WebMediaPlayerClient* client, 106 blink::WebMediaPlayerClient* client,
107 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client,
106 base::WeakPtr<WebMediaPlayerDelegate> delegate, 108 base::WeakPtr<WebMediaPlayerDelegate> delegate,
107 scoped_ptr<RendererFactory> renderer_factory, 109 scoped_ptr<RendererFactory> renderer_factory,
108 CdmFactory* cdm_factory, 110 CdmFactory* cdm_factory,
109 const WebMediaPlayerParams& params) 111 const WebMediaPlayerParams& params)
110 : frame_(frame), 112 : frame_(frame),
111 network_state_(WebMediaPlayer::NetworkStateEmpty), 113 network_state_(WebMediaPlayer::NetworkStateEmpty),
112 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), 114 ready_state_(WebMediaPlayer::ReadyStateHaveNothing),
113 preload_(BufferedDataSource::AUTO), 115 preload_(BufferedDataSource::AUTO),
114 main_task_runner_(base::ThreadTaskRunnerHandle::Get()), 116 main_task_runner_(base::ThreadTaskRunnerHandle::Get()),
115 media_task_runner_(params.media_task_runner()), 117 media_task_runner_(params.media_task_runner()),
116 media_log_(params.media_log()), 118 media_log_(params.media_log()),
117 pipeline_(media_task_runner_, media_log_.get()), 119 pipeline_(media_task_runner_, media_log_.get()),
118 load_type_(LoadTypeURL), 120 load_type_(LoadTypeURL),
119 opaque_(false), 121 opaque_(false),
120 playback_rate_(0.0), 122 playback_rate_(0.0),
121 paused_(true), 123 paused_(true),
122 seeking_(false), 124 seeking_(false),
123 ended_(false), 125 ended_(false),
124 pending_seek_(false), 126 pending_seek_(false),
125 should_notify_time_changed_(false), 127 should_notify_time_changed_(false),
126 client_(client), 128 client_(client),
129 encrypted_client_(encrypted_client),
127 delegate_(delegate), 130 delegate_(delegate),
128 defer_load_cb_(params.defer_load_cb()), 131 defer_load_cb_(params.defer_load_cb()),
129 context_3d_cb_(params.context_3d_cb()), 132 context_3d_cb_(params.context_3d_cb()),
130 supports_save_(true), 133 supports_save_(true),
131 chunk_demuxer_(NULL), 134 chunk_demuxer_(NULL),
132 // Threaded compositing isn't enabled universally yet. 135 // Threaded compositing isn't enabled universally yet.
133 compositor_task_runner_( 136 compositor_task_runner_(
134 params.compositor_task_runner() 137 params.compositor_task_runner()
135 ? params.compositor_task_runner() 138 ? params.compositor_task_runner()
136 : base::MessageLoop::current()->task_runner()), 139 : base::MessageLoop::current()->task_runner()),
137 compositor_(new VideoFrameCompositor( 140 compositor_(new VideoFrameCompositor(
138 compositor_task_runner_, 141 compositor_task_runner_,
139 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNaturalSizeChanged), 142 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNaturalSizeChanged),
140 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnOpacityChanged))), 143 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnOpacityChanged))),
141 encrypted_media_support_(cdm_factory, 144 encrypted_media_support_(cdm_factory,
142 client, 145 encrypted_client,
143 params.media_permission(), 146 params.media_permission(),
144 base::Bind(&WebMediaPlayerImpl::SetCdm, 147 base::Bind(&WebMediaPlayerImpl::SetCdm,
145 AsWeakPtr(), 148 AsWeakPtr(),
146 base::Bind(&IgnoreCdmAttached))), 149 base::Bind(&IgnoreCdmAttached))),
147 renderer_factory_(renderer_factory.Pass()) { 150 renderer_factory_(renderer_factory.Pass()) {
148 media_log_->AddEvent( 151 media_log_->AddEvent(
149 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); 152 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED));
150 153
151 if (params.initial_cdm()) { 154 if (params.initial_cdm()) {
152 SetCdm(base::Bind(&IgnoreCdmAttached), 155 SetCdm(base::Bind(&IgnoreCdmAttached),
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() && 700 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() &&
698 !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) { 701 !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) {
699 return; 702 return;
700 } 703 }
701 704
702 // TODO(xhwang): Update this UMA name. 705 // TODO(xhwang): Update this UMA name.
703 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1); 706 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1);
704 707
705 encrypted_media_support_.SetInitDataType(init_data_type); 708 encrypted_media_support_.SetInitDataType(init_data_type);
706 709
707 client_->encrypted(ConvertToWebInitDataType(init_data_type), 710 encrypted_client_->encrypted(
ddorwin 2015/07/10 17:56:56 Must #include the definition
Srirama 2015/07/10 18:36:03 Please refer to my comment in webmediaplayer_andro
Srirama 2015/07/11 08:44:10 Done.
708 vector_as_array(&init_data), 711 ConvertToWebInitDataType(init_data_type), vector_as_array(&init_data),
709 base::saturated_cast<unsigned int>(init_data.size())); 712 base::saturated_cast<unsigned int>(init_data.size()));
710 } 713 }
711 714
712 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() { 715 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() {
713 client_->didBlockPlaybackWaitingForKey(); 716 encrypted_client_->didBlockPlaybackWaitingForKey();
714 717
715 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called 718 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called
716 // when a key has been successfully added (e.g. OnSessionKeysChange() with 719 // when a key has been successfully added (e.g. OnSessionKeysChange() with
717 // |has_additional_usable_key| = true). http://crbug.com/461903 720 // |has_additional_usable_key| = true). http://crbug.com/461903
718 client_->didResumePlaybackBlockedForKey(); 721 encrypted_client_->didResumePlaybackBlockedForKey();
719 } 722 }
720 723
721 void WebMediaPlayerImpl::SetCdm(const CdmAttachedCB& cdm_attached_cb, 724 void WebMediaPlayerImpl::SetCdm(const CdmAttachedCB& cdm_attached_cb,
722 CdmContext* cdm_context) { 725 CdmContext* cdm_context) {
723 // If CDM initialization succeeded, tell the pipeline about it. 726 // If CDM initialization succeeded, tell the pipeline about it.
724 if (cdm_context) 727 if (cdm_context)
725 pipeline_.SetCdm(cdm_context, cdm_attached_cb); 728 pipeline_.SetCdm(cdm_context, cdm_attached_cb);
726 } 729 }
727 730
728 void WebMediaPlayerImpl::OnCdmAttached( 731 void WebMediaPlayerImpl::OnCdmAttached(
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 1034
1032 // pause() may be called after playback has ended and the HTMLMediaElement 1035 // pause() may be called after playback has ended and the HTMLMediaElement
1033 // requires that currentTime() == duration() after ending. We want to ensure 1036 // requires that currentTime() == duration() after ending. We want to ensure
1034 // |paused_time_| matches currentTime() in this case or a future seek() may 1037 // |paused_time_| matches currentTime() in this case or a future seek() may
1035 // incorrectly discard what it thinks is a seek to the existing time. 1038 // incorrectly discard what it thinks is a seek to the existing time.
1036 paused_time_ = 1039 paused_time_ =
1037 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); 1040 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime();
1038 } 1041 }
1039 1042
1040 } // namespace media 1043 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698