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 "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 #include <string> | 10 #include <string> |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "base/metrics/histogram.h" | 21 #include "base/metrics/histogram.h" |
22 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
23 #include "base/strings/string_number_conversions.h" | 23 #include "base/strings/string_number_conversions.h" |
24 #include "base/task_runner_util.h" | 24 #include "base/task_runner_util.h" |
25 #include "base/threading/thread_task_runner_handle.h" | 25 #include "base/threading/thread_task_runner_handle.h" |
26 #include "base/trace_event/trace_event.h" | 26 #include "base/trace_event/trace_event.h" |
27 #include "build/build_config.h" | 27 #include "build/build_config.h" |
28 #include "cc/blink/web_layer_impl.h" | 28 #include "cc/blink/web_layer_impl.h" |
29 #include "cc/layers/video_layer.h" | 29 #include "cc/layers/video_layer.h" |
30 #include "media/audio/null_audio_sink.h" | 30 #include "media/audio/null_audio_sink.h" |
31 #include "media/base/android/media_url_demuxer.h" | |
31 #include "media/base/bind_to_current_loop.h" | 32 #include "media/base/bind_to_current_loop.h" |
32 #include "media/base/cdm_context.h" | 33 #include "media/base/cdm_context.h" |
33 #include "media/base/limits.h" | 34 #include "media/base/limits.h" |
34 #include "media/base/media_log.h" | 35 #include "media/base/media_log.h" |
35 #include "media/base/media_switches.h" | 36 #include "media/base/media_switches.h" |
36 #include "media/base/text_renderer.h" | 37 #include "media/base/text_renderer.h" |
37 #include "media/base/timestamp_constants.h" | 38 #include "media/base/timestamp_constants.h" |
38 #include "media/base/video_frame.h" | 39 #include "media/base/video_frame.h" |
39 #include "media/blink/texttrack_impl.h" | 40 #include "media/blink/texttrack_impl.h" |
40 #include "media/blink/webaudiosourceprovider_impl.h" | 41 #include "media/blink/webaudiosourceprovider_impl.h" |
41 #include "media/blink/webcontentdecryptionmodule_impl.h" | 42 #include "media/blink/webcontentdecryptionmodule_impl.h" |
42 #include "media/blink/webinbandtexttrack_impl.h" | 43 #include "media/blink/webinbandtexttrack_impl.h" |
43 #include "media/blink/webmediaplayer_delegate.h" | 44 #include "media/blink/webmediaplayer_delegate.h" |
44 #include "media/blink/webmediaplayer_util.h" | 45 #include "media/blink/webmediaplayer_util.h" |
45 #include "media/blink/webmediasource_impl.h" | 46 #include "media/blink/webmediasource_impl.h" |
46 #include "media/filters/chunk_demuxer.h" | 47 #include "media/filters/chunk_demuxer.h" |
47 #include "media/filters/ffmpeg_demuxer.h" | 48 #include "media/filters/ffmpeg_demuxer.h" |
49 #include "media/media_features.h" | |
48 #include "third_party/WebKit/public/platform/WebEncryptedMediaTypes.h" | 50 #include "third_party/WebKit/public/platform/WebEncryptedMediaTypes.h" |
49 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" | 51 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" |
50 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient. h" | 52 #include "third_party/WebKit/public/platform/WebMediaPlayerEncryptedMediaClient. h" |
51 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" | 53 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" |
52 #include "third_party/WebKit/public/platform/WebMediaSource.h" | 54 #include "third_party/WebKit/public/platform/WebMediaSource.h" |
53 #include "third_party/WebKit/public/platform/WebRect.h" | 55 #include "third_party/WebKit/public/platform/WebRect.h" |
54 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 56 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
55 #include "third_party/WebKit/public/platform/WebSize.h" | 57 #include "third_party/WebKit/public/platform/WebSize.h" |
56 #include "third_party/WebKit/public/platform/WebString.h" | 58 #include "third_party/WebKit/public/platform/WebString.h" |
57 #include "third_party/WebKit/public/platform/WebURL.h" | 59 #include "third_party/WebKit/public/platform/WebURL.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 is_cdm_attached_(false), | 202 is_cdm_attached_(false), |
201 #if defined(OS_ANDROID) // WMPI_CAST | 203 #if defined(OS_ANDROID) // WMPI_CAST |
202 cast_impl_(this, client_, params.context_3d_cb()), | 204 cast_impl_(this, client_, params.context_3d_cb()), |
203 #endif | 205 #endif |
204 volume_(1.0), | 206 volume_(1.0), |
205 volume_multiplier_(1.0), | 207 volume_multiplier_(1.0), |
206 renderer_factory_(std::move(renderer_factory)), | 208 renderer_factory_(std::move(renderer_factory)), |
207 surface_manager_(params.surface_manager()), | 209 surface_manager_(params.surface_manager()), |
208 fullscreen_surface_id_(SurfaceManager::kNoSurfaceID), | 210 fullscreen_surface_id_(SurfaceManager::kNoSurfaceID), |
209 suppress_destruction_errors_(false), | 211 suppress_destruction_errors_(false), |
210 can_suspend_state_(CanSuspendState::UNKNOWN) { | 212 can_suspend_state_(CanSuspendState::UNKNOWN), |
213 use_fallback_path_(false) { | |
211 DCHECK(!adjust_allocated_memory_cb_.is_null()); | 214 DCHECK(!adjust_allocated_memory_cb_.is_null()); |
212 DCHECK(renderer_factory_); | 215 DCHECK(renderer_factory_); |
213 DCHECK(client_); | 216 DCHECK(client_); |
214 | 217 |
215 if (delegate_) | 218 if (delegate_) |
216 delegate_id_ = delegate_->AddObserver(this); | 219 delegate_id_ = delegate_->AddObserver(this); |
217 | 220 |
218 media_log_->AddEvent( | 221 media_log_->AddEvent( |
219 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); | 222 media_log_->CreateEvent(MediaLogEvent::WEBMEDIAPLAYER_CREATED)); |
220 | 223 |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1009 if (pipeline_metadata_.video_rotation == VIDEO_ROTATION_90 || | 1012 if (pipeline_metadata_.video_rotation == VIDEO_ROTATION_90 || |
1010 pipeline_metadata_.video_rotation == VIDEO_ROTATION_270) { | 1013 pipeline_metadata_.video_rotation == VIDEO_ROTATION_270) { |
1011 gfx::Size size = pipeline_metadata_.natural_size; | 1014 gfx::Size size = pipeline_metadata_.natural_size; |
1012 pipeline_metadata_.natural_size = gfx::Size(size.height(), size.width()); | 1015 pipeline_metadata_.natural_size = gfx::Size(size.height(), size.width()); |
1013 } | 1016 } |
1014 | 1017 |
1015 if (fullscreen_ && surface_manager_) | 1018 if (fullscreen_ && surface_manager_) |
1016 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); | 1019 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); |
1017 | 1020 |
1018 DCHECK(!video_weblayer_); | 1021 DCHECK(!video_weblayer_); |
1022 | |
1019 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( | 1023 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( |
1020 compositor_, pipeline_metadata_.video_rotation))); | 1024 compositor_, pipeline_metadata_.video_rotation))); |
1025 | |
1021 video_weblayer_->layer()->SetContentsOpaque(opaque_); | 1026 video_weblayer_->layer()->SetContentsOpaque(opaque_); |
1022 video_weblayer_->SetContentsOpaqueIsFixed(true); | 1027 video_weblayer_->SetContentsOpaqueIsFixed(true); |
1023 client_->setWebLayer(video_weblayer_.get()); | 1028 client_->setWebLayer(video_weblayer_.get()); |
1024 } | 1029 } |
1025 | 1030 |
1026 UpdatePlayState(); | 1031 UpdatePlayState(); |
1027 } | 1032 } |
1028 | 1033 |
1029 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) { | 1034 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) { |
1030 DVLOG(1) << __FUNCTION__ << "(" << state << ")"; | 1035 DVLOG(1) << __FUNCTION__ << "(" << state << ")"; |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1243 return video_weblayer_->bounds(); | 1248 return video_weblayer_->bounds(); |
1244 } | 1249 } |
1245 | 1250 |
1246 void WebMediaPlayerImpl::SetDeviceScaleFactor(float scale_factor) { | 1251 void WebMediaPlayerImpl::SetDeviceScaleFactor(float scale_factor) { |
1247 cast_impl_.SetDeviceScaleFactor(scale_factor); | 1252 cast_impl_.SetDeviceScaleFactor(scale_factor); |
1248 } | 1253 } |
1249 | 1254 |
1250 void WebMediaPlayerImpl::setPoster(const blink::WebURL& poster) { | 1255 void WebMediaPlayerImpl::setPoster(const blink::WebURL& poster) { |
1251 cast_impl_.setPoster(poster); | 1256 cast_impl_.setPoster(poster); |
1252 } | 1257 } |
1258 | |
1259 void WebMediaPlayerImpl::EnableFallbackMediaPlayer(GURL url) { | |
1260 fallback_url_ = url; | |
1261 use_fallback_path_ = true; | |
1262 } | |
1253 #endif // defined(OS_ANDROID) // WMPI_CAST | 1263 #endif // defined(OS_ANDROID) // WMPI_CAST |
1254 | 1264 |
1255 void WebMediaPlayerImpl::DataSourceInitialized(bool success) { | 1265 void WebMediaPlayerImpl::DataSourceInitialized(bool success) { |
1256 DVLOG(1) << __FUNCTION__; | 1266 DVLOG(1) << __FUNCTION__; |
1257 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1267 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1258 | 1268 |
1259 #if defined(OS_ANDROID) | 1269 #if defined(OS_ANDROID) |
1260 // We can't play HLS URLs with WebMediaPlayerImpl, so in cases where they are | 1270 // We can't play HLS URLs with WebMediaPlayerImpl, so in cases where they are |
1261 // encountered, instruct the HTML media element to create a new WebMediaPlayer | 1271 // encountered, instruct the HTML media element to create a new WebMediaPlayer |
1262 // instance with the correct URL to trigger WebMediaPlayerAndroid creation. | 1272 // instance with the correct URL to trigger WebMediaPlayerAndroid creation. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1302 fullscreen_surface_id_ = surface_id; | 1312 fullscreen_surface_id_ = surface_id; |
1303 if (!pending_surface_request_cb_.is_null()) | 1313 if (!pending_surface_request_cb_.is_null()) |
1304 base::ResetAndReturn(&pending_surface_request_cb_).Run(surface_id); | 1314 base::ResetAndReturn(&pending_surface_request_cb_).Run(surface_id); |
1305 } | 1315 } |
1306 | 1316 |
1307 // TODO(watk): Move this state management out of WMPI. | 1317 // TODO(watk): Move this state management out of WMPI. |
1308 void WebMediaPlayerImpl::OnSurfaceRequested( | 1318 void WebMediaPlayerImpl::OnSurfaceRequested( |
1309 const SurfaceCreatedCB& surface_created_cb) { | 1319 const SurfaceCreatedCB& surface_created_cb) { |
1310 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1320 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1311 DCHECK(surface_manager_); | 1321 DCHECK(surface_manager_); |
1322 DCHECK(!use_fallback_path_); | |
1312 | 1323 |
1313 // A null callback indicates that the decoder is going away. | 1324 // A null callback indicates that the decoder is going away. |
1314 if (surface_created_cb.is_null()) { | 1325 if (surface_created_cb.is_null()) { |
1315 decoder_requires_restart_for_fullscreen_ = false; | 1326 decoder_requires_restart_for_fullscreen_ = false; |
1316 pending_surface_request_cb_.Reset(); | 1327 pending_surface_request_cb_.Reset(); |
1317 return; | 1328 return; |
1318 } | 1329 } |
1319 | 1330 |
1320 // If we're getting a surface request it means GVD is initializing, so until | 1331 // If we're getting a surface request it means GVD is initializing, so until |
1321 // we get a null surface request, GVD is the active decoder. While that's the | 1332 // we get a null surface request, GVD is the active decoder. While that's the |
(...skipping 24 matching lines...) Expand all Loading... | |
1346 media_task_runner_, worker_task_runner_, audio_source_provider_.get(), | 1357 media_task_runner_, worker_task_runner_, audio_source_provider_.get(), |
1347 compositor_, request_surface_cb); | 1358 compositor_, request_surface_cb); |
1348 } | 1359 } |
1349 | 1360 |
1350 void WebMediaPlayerImpl::StartPipeline() { | 1361 void WebMediaPlayerImpl::StartPipeline() { |
1351 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1362 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1352 | 1363 |
1353 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = | 1364 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb = |
1354 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnEncryptedMediaInitData); | 1365 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnEncryptedMediaInitData); |
1355 | 1366 |
1367 if (use_fallback_path_) { | |
1368 demuxer_.reset(new MediaUrlDemuxer(media_task_runner_, fallback_url_)); | |
1369 pipeline_controller_.Start(demuxer_.get(), this, true, true); | |
1370 return; | |
Julien Isorce Samsung
2016/08/08 12:58:01
Hi, sorry for the short introduction, I was thinki
| |
1371 } | |
1372 | |
1356 // Figure out which demuxer to use. | 1373 // Figure out which demuxer to use. |
1357 if (load_type_ != LoadTypeMediaSource) { | 1374 if (load_type_ != LoadTypeMediaSource) { |
1358 DCHECK(!chunk_demuxer_); | 1375 DCHECK(!chunk_demuxer_); |
1359 DCHECK(data_source_); | 1376 DCHECK(data_source_); |
1360 | 1377 |
1361 #if !defined(MEDIA_DISABLE_FFMPEG) | 1378 #if !defined(MEDIA_DISABLE_FFMPEG) |
1362 Demuxer::MediaTracksUpdatedCB media_tracks_updated_cb = | 1379 Demuxer::MediaTracksUpdatedCB media_tracks_updated_cb = |
1363 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated); | 1380 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnFFmpegMediaTracksUpdated); |
1364 | 1381 |
1365 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(), | 1382 demuxer_.reset(new FFmpegDemuxer(media_task_runner_, data_source_.get(), |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1698 if (isRemote()) | 1715 if (isRemote()) |
1699 return; | 1716 return; |
1700 #endif | 1717 #endif |
1701 | 1718 |
1702 // Idle timeout chosen arbitrarily. | 1719 // Idle timeout chosen arbitrarily. |
1703 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), | 1720 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), |
1704 this, &WebMediaPlayerImpl::OnPause); | 1721 this, &WebMediaPlayerImpl::OnPause); |
1705 } | 1722 } |
1706 | 1723 |
1707 } // namespace media | 1724 } // namespace media |
OLD | NEW |