Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/media/webmediaplayer_impl.h" | 5 #include "webkit/media/webmediaplayer_impl.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "content/renderer/render_audiosourceprovider.h" | |
| 14 #include "media/base/composite_data_source_factory.h" | 15 #include "media/base/composite_data_source_factory.h" |
| 15 #include "media/base/filter_collection.h" | 16 #include "media/base/filter_collection.h" |
| 16 #include "media/base/limits.h" | 17 #include "media/base/limits.h" |
| 17 #include "media/base/media_log.h" | 18 #include "media/base/media_log.h" |
| 18 #include "media/base/media_switches.h" | 19 #include "media/base/media_switches.h" |
| 19 #include "media/base/pipeline_impl.h" | 20 #include "media/base/pipeline_impl.h" |
| 20 #include "media/base/video_frame.h" | 21 #include "media/base/video_frame.h" |
| 21 #include "media/filters/chunk_demuxer_factory.h" | 22 #include "media/filters/chunk_demuxer_factory.h" |
| 22 #include "media/filters/dummy_demuxer_factory.h" | 23 #include "media/filters/dummy_demuxer_factory.h" |
| 23 #include "media/filters/ffmpeg_audio_decoder.h" | 24 #include "media/filters/ffmpeg_audio_decoder.h" |
| 24 #include "media/filters/ffmpeg_demuxer_factory.h" | 25 #include "media/filters/ffmpeg_demuxer_factory.h" |
| 25 #include "media/filters/ffmpeg_video_decoder.h" | 26 #include "media/filters/ffmpeg_video_decoder.h" |
| 26 #include "media/filters/null_audio_renderer.h" | 27 #include "media/filters/null_audio_renderer.h" |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide r.h" | |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAudioSourceProvide rClient.h" | |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVideoFrame.h" | 30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVideoFrame.h" |
| 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 29 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" | 32 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
| 30 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" | 33 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
| 31 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 34 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
| 32 #include "v8/include/v8.h" | 35 #include "v8/include/v8.h" |
| 33 #include "webkit/media/buffered_data_source.h" | 36 #include "webkit/media/buffered_data_source.h" |
| 34 #include "webkit/media/media_stream_client.h" | 37 #include "webkit/media/media_stream_client.h" |
| 35 #include "webkit/media/simple_data_source.h" | 38 #include "webkit/media/simple_data_source.h" |
| 36 #include "webkit/media/video_renderer_impl.h" | 39 #include "webkit/media/video_renderer_impl.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 } | 98 } |
| 96 | 99 |
| 97 } // namespace | 100 } // namespace |
| 98 | 101 |
| 99 namespace webkit_media { | 102 namespace webkit_media { |
| 100 | 103 |
| 101 WebMediaPlayerImpl::WebMediaPlayerImpl( | 104 WebMediaPlayerImpl::WebMediaPlayerImpl( |
| 102 WebKit::WebMediaPlayerClient* client, | 105 WebKit::WebMediaPlayerClient* client, |
| 103 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 106 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
| 104 media::FilterCollection* collection, | 107 media::FilterCollection* collection, |
| 108 media::AudioRendererSink::RenderCallback* render_callback, | |
|
acolwell GONE FROM CHROMIUM
2011/12/19 23:01:49
nit: Consider changing this to WebAudioSourceProvi
Chris Rogers
2011/12/19 23:28:14
Actually, I was hoping to remove this constructor
acolwell GONE FROM CHROMIUM
2011/12/20 01:04:06
I am definitely in favor of doing that in this CL.
Chris Rogers
2011/12/21 01:38:17
Done.
| |
| 105 media::MessageLoopFactory* message_loop_factory, | 109 media::MessageLoopFactory* message_loop_factory, |
| 106 MediaStreamClient* media_stream_client, | 110 MediaStreamClient* media_stream_client, |
| 107 media::MediaLog* media_log) | 111 media::MediaLog* media_log) |
| 108 : network_state_(WebKit::WebMediaPlayer::Empty), | 112 : network_state_(WebKit::WebMediaPlayer::Empty), |
| 109 ready_state_(WebKit::WebMediaPlayer::HaveNothing), | 113 ready_state_(WebKit::WebMediaPlayer::HaveNothing), |
| 110 main_loop_(NULL), | 114 main_loop_(NULL), |
| 111 filter_collection_(collection), | 115 filter_collection_(collection), |
| 112 pipeline_(NULL), | 116 pipeline_(NULL), |
| 113 message_loop_factory_(message_loop_factory), | 117 message_loop_factory_(message_loop_factory), |
| 114 paused_(true), | 118 paused_(true), |
| 115 seeking_(false), | 119 seeking_(false), |
| 116 playback_rate_(0.0f), | 120 playback_rate_(0.0f), |
| 117 pending_seek_(false), | 121 pending_seek_(false), |
| 118 client_(client), | 122 client_(client), |
| 119 proxy_(NULL), | 123 proxy_(NULL), |
| 120 delegate_(delegate), | 124 delegate_(delegate), |
| 121 media_stream_client_(media_stream_client), | 125 media_stream_client_(media_stream_client), |
| 122 media_log_(media_log), | 126 media_log_(media_log), |
| 123 is_accelerated_compositing_active_(false), | 127 is_accelerated_compositing_active_(false), |
| 124 incremented_externally_allocated_memory_(false) { | 128 incremented_externally_allocated_memory_(false), |
| 129 audio_source_provider_(new RenderAudioSourceProvider(render_callback)) { | |
| 125 // Saves the current message loop. | 130 // Saves the current message loop. |
| 126 DCHECK(!main_loop_); | 131 DCHECK(!main_loop_); |
| 127 main_loop_ = MessageLoop::current(); | 132 main_loop_ = MessageLoop::current(); |
| 128 media_log_->AddEvent( | 133 media_log_->AddEvent( |
| 129 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); | 134 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); |
| 130 } | 135 } |
| 131 | 136 |
| 132 bool WebMediaPlayerImpl::Initialize( | 137 bool WebMediaPlayerImpl::Initialize( |
| 133 WebKit::WebFrame* frame, | 138 WebKit::WebFrame* frame, |
| 134 bool use_simple_data_source) { | 139 bool use_simple_data_source) { |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 912 proxy_ = NULL; | 917 proxy_ = NULL; |
| 913 } | 918 } |
| 914 } | 919 } |
| 915 | 920 |
| 916 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | 921 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { |
| 917 DCHECK_EQ(main_loop_, MessageLoop::current()); | 922 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 918 DCHECK(client_); | 923 DCHECK(client_); |
| 919 return client_; | 924 return client_; |
| 920 } | 925 } |
| 921 | 926 |
| 927 WebKit::WebAudioSourceProvider* WebMediaPlayerImpl::audioSourceProvider() { | |
| 928 return audio_source_provider_; | |
| 929 } | |
| 930 | |
| 922 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 931 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
| 923 DCHECK_EQ(main_loop_, MessageLoop::current()); | 932 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 924 incremented_externally_allocated_memory_ = true; | 933 incremented_externally_allocated_memory_ = true; |
| 925 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); | 934 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); |
| 926 } | 935 } |
| 927 | 936 |
| 928 } // namespace webkit_media | 937 } // namespace webkit_media |
| OLD | NEW |