| 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 "content/renderer/media/webmediaplayer_impl.h" | 5 #include "content/renderer/media/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> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/debug/crash_logging.h" | 15 #include "base/debug/crash_logging.h" |
| 16 #include "base/debug/trace_event.h" | 16 #include "base/debug/trace_event.h" |
| 17 #include "base/message_loop/message_loop_proxy.h" | 17 #include "base/message_loop/message_loop_proxy.h" |
| 18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
| 19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/synchronization/waitable_event.h" | 20 #include "base/synchronization/waitable_event.h" |
| 21 #include "cc/layers/video_layer.h" | 21 #include "cc/layers/video_layer.h" |
| 22 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
| 23 #include "content/renderer/media/buffered_data_source.h" | 23 #include "content/renderer/media/buffered_data_source.h" |
| 24 #include "content/renderer/media/crypto/key_systems.h" | 24 #include "content/renderer/media/crypto/key_systems.h" |
| 25 #include "content/renderer/media/render_media_log.h" | 25 #include "content/renderer/media/render_media_log.h" |
| 26 #include "content/renderer/media/texttrack_impl.h" | 26 #include "content/renderer/media/texttrack_impl.h" |
| 27 #include "content/renderer/media/webaudiosourceprovider_impl.h" | 27 #include "content/renderer/media/webaudiosourceprovider_impl.h" |
| 28 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" |
| 28 #include "content/renderer/media/webinbandtexttrack_impl.h" | 29 #include "content/renderer/media/webinbandtexttrack_impl.h" |
| 29 #include "content/renderer/media/webmediaplayer_delegate.h" | 30 #include "content/renderer/media/webmediaplayer_delegate.h" |
| 30 #include "content/renderer/media/webmediaplayer_params.h" | 31 #include "content/renderer/media/webmediaplayer_params.h" |
| 31 #include "content/renderer/media/webmediaplayer_util.h" | 32 #include "content/renderer/media/webmediaplayer_util.h" |
| 32 #include "content/renderer/media/webmediasource_impl.h" | 33 #include "content/renderer/media/webmediasource_impl.h" |
| 33 #include "content/renderer/pepper/pepper_webplugin_impl.h" | 34 #include "content/renderer/pepper/pepper_webplugin_impl.h" |
| 34 #include "content/renderer/render_thread_impl.h" | 35 #include "content/renderer/render_thread_impl.h" |
| 35 #include "gpu/GLES2/gl2extchromium.h" | 36 #include "gpu/GLES2/gl2extchromium.h" |
| 36 #include "media/audio/null_audio_sink.h" | 37 #include "media/audio/null_audio_sink.h" |
| 37 #include "media/base/bind_to_loop.h" | 38 #include "media/base/bind_to_loop.h" |
| 38 #include "media/base/filter_collection.h" | 39 #include "media/base/filter_collection.h" |
| 39 #include "media/base/limits.h" | 40 #include "media/base/limits.h" |
| 40 #include "media/base/media_log.h" | 41 #include "media/base/media_log.h" |
| 41 #include "media/base/media_switches.h" | 42 #include "media/base/media_switches.h" |
| 42 #include "media/base/pipeline.h" | 43 #include "media/base/pipeline.h" |
| 43 #include "media/base/text_renderer.h" | 44 #include "media/base/text_renderer.h" |
| 44 #include "media/base/video_frame.h" | 45 #include "media/base/video_frame.h" |
| 45 #include "media/filters/audio_renderer_impl.h" | 46 #include "media/filters/audio_renderer_impl.h" |
| 46 #include "media/filters/chunk_demuxer.h" | 47 #include "media/filters/chunk_demuxer.h" |
| 47 #include "media/filters/ffmpeg_audio_decoder.h" | 48 #include "media/filters/ffmpeg_audio_decoder.h" |
| 48 #include "media/filters/ffmpeg_demuxer.h" | 49 #include "media/filters/ffmpeg_demuxer.h" |
| 49 #include "media/filters/ffmpeg_video_decoder.h" | 50 #include "media/filters/ffmpeg_video_decoder.h" |
| 50 #include "media/filters/gpu_video_accelerator_factories.h" | 51 #include "media/filters/gpu_video_accelerator_factories.h" |
| 51 #include "media/filters/gpu_video_decoder.h" | 52 #include "media/filters/gpu_video_decoder.h" |
| 52 #include "media/filters/opus_audio_decoder.h" | 53 #include "media/filters/opus_audio_decoder.h" |
| 53 #include "media/filters/video_renderer_impl.h" | 54 #include "media/filters/video_renderer_impl.h" |
| 54 #include "media/filters/vpx_video_decoder.h" | 55 #include "media/filters/vpx_video_decoder.h" |
| 56 #include "third_party/WebKit/public/platform/WebContentDecryptionModule.h" |
| 55 #include "third_party/WebKit/public/platform/WebMediaSource.h" | 57 #include "third_party/WebKit/public/platform/WebMediaSource.h" |
| 56 #include "third_party/WebKit/public/platform/WebRect.h" | 58 #include "third_party/WebKit/public/platform/WebRect.h" |
| 57 #include "third_party/WebKit/public/platform/WebSize.h" | 59 #include "third_party/WebKit/public/platform/WebSize.h" |
| 58 #include "third_party/WebKit/public/platform/WebString.h" | 60 #include "third_party/WebKit/public/platform/WebString.h" |
| 59 #include "third_party/WebKit/public/platform/WebURL.h" | 61 #include "third_party/WebKit/public/platform/WebURL.h" |
| 60 #include "third_party/WebKit/public/web/WebDocument.h" | 62 #include "third_party/WebKit/public/web/WebDocument.h" |
| 61 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 63 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 62 #include "third_party/WebKit/public/web/WebView.h" | 64 #include "third_party/WebKit/public/web/WebView.h" |
| 63 #include "v8/include/v8.h" | 65 #include "v8/include/v8.h" |
| 64 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" | 66 #include "webkit/renderer/compositor_bindings/web_layer_impl.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 gpu_factories_(RenderThreadImpl::current()->GetGpuFactories()), | 160 gpu_factories_(RenderThreadImpl::current()->GetGpuFactories()), |
| 159 is_local_source_(false), | 161 is_local_source_(false), |
| 160 supports_save_(true), | 162 supports_save_(true), |
| 161 starting_(false), | 163 starting_(false), |
| 162 chunk_demuxer_(NULL), | 164 chunk_demuxer_(NULL), |
| 163 current_frame_painted_(false), | 165 current_frame_painted_(false), |
| 164 frames_dropped_before_paint_(0), | 166 frames_dropped_before_paint_(0), |
| 165 pending_repaint_(false), | 167 pending_repaint_(false), |
| 166 pending_size_change_(false), | 168 pending_size_change_(false), |
| 167 video_frame_provider_client_(NULL), | 169 video_frame_provider_client_(NULL), |
| 168 text_track_index_(0) { | 170 text_track_index_(0), |
| 171 web_cdm_(NULL) { |
| 169 media_log_->AddEvent( | 172 media_log_->AddEvent( |
| 170 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); | 173 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); |
| 171 | 174 |
| 172 pipeline_.reset(new media::Pipeline(media_loop_, media_log_.get())); | 175 pipeline_.reset(new media::Pipeline(media_loop_, media_log_.get())); |
| 173 | 176 |
| 174 // |gpu_factories_| requires that its entry points be called on its | 177 // |gpu_factories_| requires that its entry points be called on its |
| 175 // |GetTaskRunner()|. Since |pipeline_| will own decoders created from the | 178 // |GetTaskRunner()|. Since |pipeline_| will own decoders created from the |
| 176 // factories, require that their message loops are identical. | 179 // factories, require that their message loops are identical. |
| 177 DCHECK(!gpu_factories_ || (gpu_factories_->GetTaskRunner() == media_loop_)); | 180 DCHECK(!gpu_factories_ || (gpu_factories_->GetTaskRunner() == media_loop_)); |
| 178 | 181 |
| (...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 if (!IsConcreteSupportedKeySystem(key_system)) | 852 if (!IsConcreteSupportedKeySystem(key_system)) |
| 850 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; | 853 return WebMediaPlayer::MediaKeyExceptionKeySystemNotSupported; |
| 851 | 854 |
| 852 if (current_key_system_.isEmpty() || key_system != current_key_system_) | 855 if (current_key_system_.isEmpty() || key_system != current_key_system_) |
| 853 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; | 856 return WebMediaPlayer::MediaKeyExceptionInvalidPlayerState; |
| 854 | 857 |
| 855 decryptor_->CancelKeyRequest(session_id.utf8()); | 858 decryptor_->CancelKeyRequest(session_id.utf8()); |
| 856 return WebMediaPlayer::MediaKeyExceptionNoError; | 859 return WebMediaPlayer::MediaKeyExceptionNoError; |
| 857 } | 860 } |
| 858 | 861 |
| 862 void WebMediaPlayerImpl::setContentDecryptionModule( |
| 863 blink::WebContentDecryptionModule* cdm) { |
| 864 web_cdm_ = ToWebContentDecryptionModuleImpl(cdm); |
| 865 // TODO(jrummell): use web_cdm_->getDecryptor() instead of creating |
| 866 // ProxyDecryptor(). |
| 867 } |
| 868 |
| 859 void WebMediaPlayerImpl::OnDestruct() { | 869 void WebMediaPlayerImpl::OnDestruct() { |
| 860 Destroy(); | 870 Destroy(); |
| 861 } | 871 } |
| 862 | 872 |
| 863 void WebMediaPlayerImpl::Repaint() { | 873 void WebMediaPlayerImpl::Repaint() { |
| 864 DCHECK(main_loop_->BelongsToCurrentThread()); | 874 DCHECK(main_loop_->BelongsToCurrentThread()); |
| 865 TRACE_EVENT0("media", "WebMediaPlayerImpl:repaint"); | 875 TRACE_EVENT0("media", "WebMediaPlayerImpl:repaint"); |
| 866 | 876 |
| 867 bool size_changed = false; | 877 bool size_changed = false; |
| 868 { | 878 { |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 // The |current_frame_| wasn't painted, it is being replaced, and we haven't | 1312 // The |current_frame_| wasn't painted, it is being replaced, and we haven't |
| 1303 // even gotten the chance to request a repaint for it yet. Mark it as dropped. | 1313 // even gotten the chance to request a repaint for it yet. Mark it as dropped. |
| 1304 TRACE_EVENT0("media", "WebMediaPlayerImpl:frameDropped"); | 1314 TRACE_EVENT0("media", "WebMediaPlayerImpl:frameDropped"); |
| 1305 DVLOG(1) << "Frame dropped before being painted: " | 1315 DVLOG(1) << "Frame dropped before being painted: " |
| 1306 << current_frame_->GetTimestamp().InSecondsF(); | 1316 << current_frame_->GetTimestamp().InSecondsF(); |
| 1307 if (frames_dropped_before_paint_ < kuint32max) | 1317 if (frames_dropped_before_paint_ < kuint32max) |
| 1308 frames_dropped_before_paint_++; | 1318 frames_dropped_before_paint_++; |
| 1309 } | 1319 } |
| 1310 | 1320 |
| 1311 } // namespace content | 1321 } // namespace content |
| OLD | NEW |