| 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/media/audio_renderer_impl.h" |
| 15 #include "content/renderer/render_audiosourceprovider.h" |
| 14 #include "media/base/composite_data_source_factory.h" | 16 #include "media/base/composite_data_source_factory.h" |
| 15 #include "media/base/filter_collection.h" | 17 #include "media/base/filter_collection.h" |
| 16 #include "media/base/limits.h" | 18 #include "media/base/limits.h" |
| 17 #include "media/base/media_log.h" | 19 #include "media/base/media_log.h" |
| 18 #include "media/base/media_switches.h" | 20 #include "media/base/media_switches.h" |
| 19 #include "media/base/pipeline_impl.h" | 21 #include "media/base/pipeline_impl.h" |
| 20 #include "media/base/video_frame.h" | 22 #include "media/base/video_frame.h" |
| 21 #include "media/filters/chunk_demuxer_factory.h" | 23 #include "media/filters/chunk_demuxer_factory.h" |
| 22 #include "media/filters/dummy_demuxer_factory.h" | 24 #include "media/filters/dummy_demuxer_factory.h" |
| 23 #include "media/filters/ffmpeg_audio_decoder.h" | 25 #include "media/filters/ffmpeg_audio_decoder.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 } | 97 } |
| 96 | 98 |
| 97 } // namespace | 99 } // namespace |
| 98 | 100 |
| 99 namespace webkit_media { | 101 namespace webkit_media { |
| 100 | 102 |
| 101 WebMediaPlayerImpl::WebMediaPlayerImpl( | 103 WebMediaPlayerImpl::WebMediaPlayerImpl( |
| 102 WebKit::WebMediaPlayerClient* client, | 104 WebKit::WebMediaPlayerClient* client, |
| 103 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 105 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
| 104 media::FilterCollection* collection, | 106 media::FilterCollection* collection, |
| 107 bool disable_audio, |
| 105 media::MessageLoopFactory* message_loop_factory, | 108 media::MessageLoopFactory* message_loop_factory, |
| 106 MediaStreamClient* media_stream_client, | 109 MediaStreamClient* media_stream_client, |
| 107 media::MediaLog* media_log) | 110 media::MediaLog* media_log) |
| 108 : network_state_(WebKit::WebMediaPlayer::Empty), | 111 : network_state_(WebKit::WebMediaPlayer::Empty), |
| 109 ready_state_(WebKit::WebMediaPlayer::HaveNothing), | 112 ready_state_(WebKit::WebMediaPlayer::HaveNothing), |
| 110 main_loop_(NULL), | 113 main_loop_(NULL), |
| 111 filter_collection_(collection), | 114 filter_collection_(collection), |
| 112 pipeline_(NULL), | 115 pipeline_(NULL), |
| 113 message_loop_factory_(message_loop_factory), | 116 message_loop_factory_(message_loop_factory), |
| 114 paused_(true), | 117 paused_(true), |
| 115 seeking_(false), | 118 seeking_(false), |
| 116 playback_rate_(0.0f), | 119 playback_rate_(0.0f), |
| 117 pending_seek_(false), | 120 pending_seek_(false), |
| 118 pending_seek_seconds_(0.0f), | 121 pending_seek_seconds_(0.0f), |
| 119 client_(client), | 122 client_(client), |
| 120 proxy_(NULL), | 123 proxy_(NULL), |
| 121 delegate_(delegate), | 124 delegate_(delegate), |
| 122 media_stream_client_(media_stream_client), | 125 media_stream_client_(media_stream_client), |
| 123 media_log_(media_log), | 126 media_log_(media_log), |
| 124 is_accelerated_compositing_active_(false), | 127 is_accelerated_compositing_active_(false), |
| 125 incremented_externally_allocated_memory_(false) { | 128 incremented_externally_allocated_memory_(false) { |
| 129 if (!disable_audio) { |
| 130 // audio_source_provider_ is a "provider" to WebKit, and a sink |
| 131 // from the perspective of the audio renderer. |
| 132 audio_source_provider_ = new RenderAudioSourceProvider(); |
| 133 // Add the chrome specific audio renderer, using audio_source_provider_ |
| 134 // as the sink. |
| 135 AudioRendererImpl* audio_renderer = |
| 136 new AudioRendererImpl(audio_source_provider_.get()); |
| 137 collection->AddAudioRenderer(audio_renderer); |
| 138 } |
| 139 |
| 126 // Saves the current message loop. | 140 // Saves the current message loop. |
| 127 DCHECK(!main_loop_); | 141 DCHECK(!main_loop_); |
| 128 main_loop_ = MessageLoop::current(); | 142 main_loop_ = MessageLoop::current(); |
| 129 media_log_->AddEvent( | 143 media_log_->AddEvent( |
| 130 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); | 144 media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED)); |
| 131 } | 145 } |
| 132 | 146 |
| 133 bool WebMediaPlayerImpl::Initialize( | 147 bool WebMediaPlayerImpl::Initialize( |
| 134 WebKit::WebFrame* frame, | 148 WebKit::WebFrame* frame, |
| 135 bool use_simple_data_source) { | 149 bool use_simple_data_source) { |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 proxy_ = NULL; | 933 proxy_ = NULL; |
| 920 } | 934 } |
| 921 } | 935 } |
| 922 | 936 |
| 923 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { | 937 WebKit::WebMediaPlayerClient* WebMediaPlayerImpl::GetClient() { |
| 924 DCHECK_EQ(main_loop_, MessageLoop::current()); | 938 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 925 DCHECK(client_); | 939 DCHECK(client_); |
| 926 return client_; | 940 return client_; |
| 927 } | 941 } |
| 928 | 942 |
| 943 WebKit::WebAudioSourceProvider* WebMediaPlayerImpl::audioSourceProvider() { |
| 944 return audio_source_provider_; |
| 945 } |
| 946 |
| 929 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { | 947 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { |
| 930 DCHECK_EQ(main_loop_, MessageLoop::current()); | 948 DCHECK_EQ(main_loop_, MessageLoop::current()); |
| 931 incremented_externally_allocated_memory_ = true; | 949 incremented_externally_allocated_memory_ = true; |
| 932 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); | 950 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); |
| 933 } | 951 } |
| 934 | 952 |
| 935 } // namespace webkit_media | 953 } // namespace webkit_media |
| OLD | NEW |