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

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: fixed compile error in webmediaplayer_impl 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ 96 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \
97 BindToCurrentLoop(base::Bind(function, AsWeakPtr()))) 97 BindToCurrentLoop(base::Bind(function, AsWeakPtr())))
98 98
99 #define BIND_TO_RENDER_LOOP1(function, arg1) \ 99 #define BIND_TO_RENDER_LOOP1(function, arg1) \
100 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \ 100 (DCHECK(main_task_runner_->BelongsToCurrentThread()), \
101 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1))) 101 BindToCurrentLoop(base::Bind(function, AsWeakPtr(), arg1)))
102 102
103 WebMediaPlayerImpl::WebMediaPlayerImpl( 103 WebMediaPlayerImpl::WebMediaPlayerImpl(
104 blink::WebLocalFrame* frame, 104 blink::WebLocalFrame* frame,
105 blink::WebMediaPlayerClient* client, 105 blink::WebMediaPlayerClient* client,
106 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client,
106 base::WeakPtr<WebMediaPlayerDelegate> delegate, 107 base::WeakPtr<WebMediaPlayerDelegate> delegate,
107 scoped_ptr<RendererFactory> renderer_factory, 108 scoped_ptr<RendererFactory> renderer_factory,
108 CdmFactory* cdm_factory, 109 CdmFactory* cdm_factory,
109 const WebMediaPlayerParams& params) 110 const WebMediaPlayerParams& params)
110 : frame_(frame), 111 : frame_(frame),
111 network_state_(WebMediaPlayer::NetworkStateEmpty), 112 network_state_(WebMediaPlayer::NetworkStateEmpty),
112 ready_state_(WebMediaPlayer::ReadyStateHaveNothing), 113 ready_state_(WebMediaPlayer::ReadyStateHaveNothing),
113 preload_(BufferedDataSource::AUTO), 114 preload_(BufferedDataSource::AUTO),
114 main_task_runner_(base::ThreadTaskRunnerHandle::Get()), 115 main_task_runner_(base::ThreadTaskRunnerHandle::Get()),
115 media_task_runner_(params.media_task_runner()), 116 media_task_runner_(params.media_task_runner()),
116 media_log_(params.media_log()), 117 media_log_(params.media_log()),
117 pipeline_(media_task_runner_, media_log_.get()), 118 pipeline_(media_task_runner_, media_log_.get()),
118 load_type_(LoadTypeURL), 119 load_type_(LoadTypeURL),
119 opaque_(false), 120 opaque_(false),
120 playback_rate_(0.0), 121 playback_rate_(0.0),
121 paused_(true), 122 paused_(true),
122 seeking_(false), 123 seeking_(false),
123 ended_(false), 124 ended_(false),
124 pending_seek_(false), 125 pending_seek_(false),
125 should_notify_time_changed_(false), 126 should_notify_time_changed_(false),
126 client_(client), 127 client_(client),
128 encrypted_client_(encrypted_client),
127 delegate_(delegate), 129 delegate_(delegate),
128 defer_load_cb_(params.defer_load_cb()), 130 defer_load_cb_(params.defer_load_cb()),
129 context_3d_cb_(params.context_3d_cb()), 131 context_3d_cb_(params.context_3d_cb()),
130 supports_save_(true), 132 supports_save_(true),
131 chunk_demuxer_(NULL), 133 chunk_demuxer_(NULL),
132 // Threaded compositing isn't enabled universally yet. 134 // Threaded compositing isn't enabled universally yet.
133 compositor_task_runner_( 135 compositor_task_runner_(
134 params.compositor_task_runner() 136 params.compositor_task_runner()
135 ? params.compositor_task_runner() 137 ? params.compositor_task_runner()
136 : base::MessageLoop::current()->task_runner()), 138 : base::MessageLoop::current()->task_runner()),
137 compositor_(new VideoFrameCompositor( 139 compositor_(new VideoFrameCompositor(
138 compositor_task_runner_, 140 compositor_task_runner_,
139 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNaturalSizeChanged), 141 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnNaturalSizeChanged),
140 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnOpacityChanged))), 142 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnOpacityChanged))),
141 encrypted_media_support_(cdm_factory, 143 encrypted_media_support_(cdm_factory,
142 client, 144 encrypted_client,
143 params.media_permission(), 145 params.media_permission(),
144 base::Bind(&WebMediaPlayerImpl::SetCdm, 146 base::Bind(&WebMediaPlayerImpl::SetCdm,
145 AsWeakPtr(), 147 AsWeakPtr(),
146 base::Bind(&IgnoreCdmAttached))), 148 base::Bind(&IgnoreCdmAttached))),
147 renderer_factory_(renderer_factory.Pass()) { 149 renderer_factory_(renderer_factory.Pass()) {
148 media_log_->AddEvent( 150 media_log_->AddEvent(
149 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); 151 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED));
150 152
151 if (params.initial_cdm()) { 153 if (params.initial_cdm()) {
152 SetCdm(base::Bind(&IgnoreCdmAttached), 154 SetCdm(base::Bind(&IgnoreCdmAttached),
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() && 699 if (!blink::WebRuntimeFeatures::isPrefixedEncryptedMediaEnabled() &&
698 !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) { 700 !blink::WebRuntimeFeatures::isEncryptedMediaEnabled()) {
699 return; 701 return;
700 } 702 }
701 703
702 // TODO(xhwang): Update this UMA name. 704 // TODO(xhwang): Update this UMA name.
703 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1); 705 UMA_HISTOGRAM_COUNTS("Media.EME.NeedKey", 1);
704 706
705 encrypted_media_support_.SetInitDataType(init_data_type); 707 encrypted_media_support_.SetInitDataType(init_data_type);
706 708
707 client_->encrypted(ConvertToWebInitDataType(init_data_type), 709 encrypted_client_->encrypted(
708 vector_as_array(&init_data), 710 ConvertToWebInitDataType(init_data_type), vector_as_array(&init_data),
709 base::saturated_cast<unsigned int>(init_data.size())); 711 base::saturated_cast<unsigned int>(init_data.size()));
710 } 712 }
711 713
712 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() { 714 void WebMediaPlayerImpl::OnWaitingForDecryptionKey() {
713 client_->didBlockPlaybackWaitingForKey(); 715 encrypted_client_->didBlockPlaybackWaitingForKey();
714 716
715 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called 717 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called
716 // when a key has been successfully added (e.g. OnSessionKeysChange() with 718 // when a key has been successfully added (e.g. OnSessionKeysChange() with
717 // |has_additional_usable_key| = true). http://crbug.com/461903 719 // |has_additional_usable_key| = true). http://crbug.com/461903
718 client_->didResumePlaybackBlockedForKey(); 720 encrypted_client_->didResumePlaybackBlockedForKey();
719 } 721 }
720 722
721 void WebMediaPlayerImpl::SetCdm(const CdmAttachedCB& cdm_attached_cb, 723 void WebMediaPlayerImpl::SetCdm(const CdmAttachedCB& cdm_attached_cb,
722 CdmContext* cdm_context) { 724 CdmContext* cdm_context) {
723 // If CDM initialization succeeded, tell the pipeline about it. 725 // If CDM initialization succeeded, tell the pipeline about it.
724 if (cdm_context) 726 if (cdm_context)
725 pipeline_.SetCdm(cdm_context, cdm_attached_cb); 727 pipeline_.SetCdm(cdm_context, cdm_attached_cb);
726 } 728 }
727 729
728 void WebMediaPlayerImpl::OnCdmAttached( 730 void WebMediaPlayerImpl::OnCdmAttached(
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 1033
1032 // pause() may be called after playback has ended and the HTMLMediaElement 1034 // pause() may be called after playback has ended and the HTMLMediaElement
1033 // requires that currentTime() == duration() after ending. We want to ensure 1035 // requires that currentTime() == duration() after ending. We want to ensure
1034 // |paused_time_| matches currentTime() in this case or a future seek() may 1036 // |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. 1037 // incorrectly discard what it thinks is a seek to the existing time.
1036 paused_time_ = 1038 paused_time_ =
1037 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime(); 1039 ended_ ? pipeline_.GetMediaDuration() : pipeline_.GetMediaTime();
1038 } 1040 }
1039 1041
1040 } // namespace media 1042 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698