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

Unified Diff: webkit/media/webmediaplayer_ms.cc

Issue 10382048: create WebMediaPlayer based on URL (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webkit/media/webmediaplayer_ms.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/media/webmediaplayer_ms.cc
===================================================================
--- webkit/media/webmediaplayer_ms.cc (revision 0)
+++ webkit/media/webmediaplayer_ms.cc (revision 0)
@@ -0,0 +1,604 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/media/webmediaplayer_ms.h"
+
+#include <limits>
+#include <string>
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/command_line.h"
+#include "base/message_loop_proxy.h"
+#include "base/metrics/histogram.h"
+#include "base/string_number_conversions.h"
+#include "base/synchronization/waitable_event.h"
+#include "media/audio/null_audio_sink.h"
+#include "media/base/filter_collection.h"
+#include "media/base/limits.h"
+#include "media/base/media_log.h"
+#include "media/base/media_switches.h"
+#include "media/base/pipeline.h"
+#include "media/base/video_frame.h"
+#include "media/filters/audio_renderer_impl.h"
+#include "media/filters/video_renderer_base.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebVideoFrame.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
+#include "v8/include/v8.h"
+#include "webkit/media/buffered_data_source.h"
+#include "webkit/media/filter_helpers.h"
+#include "webkit/media/key_systems.h"
+#include "webkit/media/media_stream_client.h"
+#include "webkit/media/video_frame_provider.h"
+#include "webkit/media/webmediaplayer_delegate.h"
+#include "webkit/media/webmediaplayer_proxy.h"
+#include "webkit/media/webmediaplayer_util.h"
+#include "webkit/media/webvideoframe_impl.h"
+
+using WebKit::WebCanvas;
+using WebKit::WebMediaPlayer;
+using WebKit::WebRect;
+using WebKit::WebSize;
+using WebKit::WebString;
+using media::NetworkEvent;
+using media::PipelineStatus;
+
+namespace {
+
+// Helper enum for reporting scheme histograms.
+enum URLSchemeForHistogram {
+ kUnknownURLScheme,
+ kMissingURLScheme,
+ kHttpURLScheme,
+ kHttpsURLScheme,
+ kFtpURLScheme,
+ kChromeExtensionURLScheme,
+ kJavascriptURLScheme,
+ kFileURLScheme,
+ kBlobURLScheme,
+ kDataURLScheme,
+ kFileSystemScheme,
+ kMaxURLScheme = kFileSystemScheme // Must be equal to highest enum value.
+};
+
+URLSchemeForHistogram URLScheme(const GURL& url) {
+ if (!url.has_scheme()) return kMissingURLScheme;
+ if (url.SchemeIs("http")) return kHttpURLScheme;
+ if (url.SchemeIs("https")) return kHttpsURLScheme;
+ if (url.SchemeIs("ftp")) return kFtpURLScheme;
+ if (url.SchemeIs("chrome-extension")) return kChromeExtensionURLScheme;
+ if (url.SchemeIs("javascript")) return kJavascriptURLScheme;
+ if (url.SchemeIs("file")) return kFileURLScheme;
+ if (url.SchemeIs("blob")) return kBlobURLScheme;
+ if (url.SchemeIs("data")) return kDataURLScheme;
+ if (url.SchemeIs("filesystem")) return kFileSystemScheme;
+ return kUnknownURLScheme;
+}
+
+// Amount of extra memory used by each player instance reported to V8.
+// It is not exact number -- first, it differs on different platforms,
+// and second, it is very hard to calculate. Instead, use some arbitrary
+// value that will cause garbage collection from time to time. We don't want
+// it to happen on every allocation, but don't want 5k players to sit in memory
+// either. Looks that chosen constant achieves both goals, at least for audio
+// objects. (Do not worry about video objects yet, JS programs do not create
+// thousands of them...)
+const int kPlayerExtraMemory = 1024 * 1024;
+
+// Limits the range of playback rate.
+//
+// TODO(kylep): Revisit these.
+//
+// Vista has substantially lower performance than XP or Windows7. If you speed
+// up a video too much, it can't keep up, and rendering stops updating except on
+// the time bar. For really high speeds, audio becomes a bottleneck and we just
+// use up the data we have, which may not achieve the speed requested, but will
+// not crash the tab.
+//
+// A very slow speed, ie 0.00000001x, causes the machine to lock up. (It seems
+// like a busy loop). It gets unresponsive, although its not completely dead.
+//
+// Also our timers are not very accurate (especially for ogg), which becomes
+// evident at low speeds and on Vista. Since other speeds are risky and outside
+// the norms, we think 1/16x to 16x is a safe and useful range for now.
+const float kMinRate = 0.0625f;
+const float kMaxRate = 16.0f;
+
+} // namespace
+
+namespace webkit_media {
+
+WebMediaPlayerMSProxy::WebMediaPlayerMSProxy()
+ : render_message_loop_(base::MessageLoopProxy::current()) {
+//LOG(INFO) << "?????WebMediaPlayerMSProxy::WebMediaPlayerMSProxy called, ml = " << render_message_loop_.get();
+}
+
+WebMediaPlayerMSProxy::~WebMediaPlayerMSProxy() {}
+
+void WebMediaPlayerMSProxy::WebMediaPlayerMSProxy::Repaint() {
+ if (!render_message_loop_->BelongsToCurrentThread()) {
+ render_message_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&WebMediaPlayerMSProxy::Repaint, this));
+ return;
+ }
+
+//LOG(INFO) << "?????WebMediaPlayerMSProxy::Repaint called---------";
+ if (listener_)
+ listener_->Repaint();
+}
+
+void WebMediaPlayerMSProxy::Paint(
+ SkCanvas* canvas, const gfx::Rect& dest_rect, uint8_t alpha) {
+}
+
+WebMediaPlayerMS::WebMediaPlayerMS(
+ WebKit::WebFrame* frame,
+ WebKit::WebMediaPlayerClient* client,
+ base::WeakPtr<WebMediaPlayerDelegate> delegate,
+ media::MessageLoopFactory* message_loop_factory,
+ MediaStreamClient* media_stream_client,
+ media::MediaLog* media_log)
+ : frame_(frame),
+ network_state_(WebMediaPlayer::NetworkStateEmpty),
+ ready_state_(WebMediaPlayer::ReadyStateHaveNothing),
+ main_loop_(MessageLoop::current()),
+ message_loop_factory_(message_loop_factory),
+ client_(client),
+ proxy_(new WebMediaPlayerMSProxy()),
+ delegate_(delegate),
+ media_stream_client_(media_stream_client),
+ frame_provider_paused_(true),
+ media_log_(media_log),
+ accelerated_compositing_reported_(false),
+ incremented_externally_allocated_memory_(false) {
+ DCHECK(media_stream_client);
+ media_log_->AddEvent(
+ media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_CREATED));
+ printf("WebMediaPlayerMS::WebMediaPlayerMS, cccccccccreated\n");
+
+ // Let V8 know we started new thread if we did not did it yet.
+ // Made separate task to avoid deletion of player currently being created.
+ // Also, delaying GC until after player starts gets rid of starting lag --
+ // collection happens in parallel with playing.
+ //
+ // TODO(enal): remove when we get rid of per-audio-stream thread.
+ MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&WebMediaPlayerMS::IncrementExternallyAllocatedMemory,
+ AsWeakPtr()));
+
+ // Also we want to be notified of |main_loop_| destruction.
+ main_loop_->AddDestructionObserver(this);
+}
+
+WebMediaPlayerMS::~WebMediaPlayerMS() {
+ printf("WebMediaPlayerMS::~WebMediaPlayerMS, dddddddddddddeleted\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ Destroy();
+ media_log_->AddEvent(
+ media_log_->CreateEvent(media::MediaLogEvent::WEBMEDIAPLAYER_DESTROYED));
+
+ if (delegate_)
+ delegate_->PlayerGone(this);
+
+ // Finally tell the |main_loop_| we don't want to be notified of destruction
+ // event.
+ if (main_loop_) {
+ main_loop_->RemoveDestructionObserver(this);
+ }
+}
+
+void WebMediaPlayerMS::load(const WebKit::WebURL& url) {
+ //printf("WebMediaPlayerMS::load\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+
+ GURL gurl(url);
+
+ SetNetworkState(WebMediaPlayer::NetworkStateLoading);
+ SetReadyState(WebMediaPlayer::ReadyStateHaveNothing);
+ media_log_->AddEvent(media_log_->CreateLoadEvent(url.spec()));
+
+ // Check if this url is media stream.
+ proxy_->SetListener(this);
+ frame_provider_ = media_stream_client_->GetVideoFrameProvider(
+ url, base::Bind(&WebMediaPlayerMSProxy::Repaint, proxy_));
+ if (frame_provider_) {
+ SetNetworkState(WebMediaPlayer::NetworkStateLoaded);
+ client_->sourceOpened();
+ client_->setOpaque(true);
+ SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata);
+ SetReadyState(WebMediaPlayer::ReadyStateHaveEnoughData);
+ }
+}
+
+void WebMediaPlayerMS::cancelLoad() {
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+}
+
+void WebMediaPlayerMS::play() {
+ //printf("WebMediaPlayerMS::play\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ if (frame_provider_) {
+ frame_provider_paused_ = false;
+ frame_provider_->Start();
+ client_->sizeChanged();
+ }
+
+ media_log_->AddEvent(media_log_->CreateEvent(media::MediaLogEvent::PLAY));
+
+ if (delegate_)
+ delegate_->DidPlay(this);
+}
+
+void WebMediaPlayerMS::pause() {
+ //printf("WebMediaPlayerMS::pause\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+
+ frame_provider_paused_ = true;
+
+ media_log_->AddEvent(media_log_->CreateEvent(media::MediaLogEvent::PAUSE));
+
+ if (delegate_)
+ delegate_->DidPause(this);
+}
+
+bool WebMediaPlayerMS::supportsFullscreen() const {
+ //printf("WebMediaPlayerMS::supportsFullscreen\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ return true;
+}
+
+bool WebMediaPlayerMS::supportsSave() const {
+ //printf("WebMediaPlayerMS::supportsSave\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ return true;
+}
+
+void WebMediaPlayerMS::seek(float seconds) {
+ //printf("WebMediaPlayerMS::seek, %f\n", seconds);
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+}
+
+void WebMediaPlayerMS::setEndTime(float seconds) {
+ //printf("WebMediaPlayerMS::setEndTime, %f\n", seconds);
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+}
+
+void WebMediaPlayerMS::setRate(float rate) {
+ //printf("WebMediaPlayerMS::setRate, %f\n", rate);
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+}
+
+void WebMediaPlayerMS::setVolume(float volume) {
+ //printf("WebMediaPlayerMS::setVolume, %f\n", volume);
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+}
+
+void WebMediaPlayerMS::setVisible(bool visible) {
+ //printf("WebMediaPlayerMS::setVisible, %s\n", visible ? "true" : "false");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+}
+
+void WebMediaPlayerMS::setPreload(WebMediaPlayer::Preload preload) {
+ //printf("WebMediaPlayerMS::setPreload, preload=%d\n", preload);
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+}
+
+bool WebMediaPlayerMS::totalBytesKnown() {
+ //printf("WebMediaPlayerMS::totalBytesKnown, false\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+
+ return false;
+}
+
+bool WebMediaPlayerMS::hasVideo() const {
+ //printf("WebMediaPlayerMS::hasVideo, true\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+
+ return true;
+}
+
+bool WebMediaPlayerMS::hasAudio() const {
+ //printf("WebMediaPlayerMS::hasAudio, false\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+
+ return false;
+}
+
+WebKit::WebSize WebMediaPlayerMS::naturalSize() const {
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ gfx::Size size(320, 240);
+ //video_frame_provider_->GetNaturalVideoSize(&size);
+ //printf("WebMediaPlayerMS::naturalSize, (%d, %d)\n", size.width(), size.height());
+ return WebKit::WebSize(size);
+}
+
+bool WebMediaPlayerMS::paused() const {
+ //printf("WebMediaPlayerMS::paused, %s\n", frame_provider_paused_ ? "true" : "false");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+
+ return frame_provider_paused_;
+}
+
+bool WebMediaPlayerMS::seeking() const {
+ //printf("WebMediaPlayerMS::seeking, false\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ return false;
+}
+
+float WebMediaPlayerMS::duration() const {
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ return std::numeric_limits<float>::infinity();
+}
+
+float WebMediaPlayerMS::currentTime() const {
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ return static_cast<float>((base::Time::Now() - base::Time()).InSecondsF());
+}
+
+int WebMediaPlayerMS::dataRate() const {
+ //printf("WebMediaPlayerMS::dataRate\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ return 0;
+}
+
+WebMediaPlayer::NetworkState WebMediaPlayerMS::networkState() const {
+ //printf("WebMediaPlayerMS::networkState, %d\n", network_state_);
+ return network_state_;
+}
+
+WebMediaPlayer::ReadyState WebMediaPlayerMS::readyState() const {
+ //printf("WebMediaPlayerMS::readyState, %d\n", ready_state_);
+ return ready_state_;
+}
+
+const WebKit::WebTimeRanges& WebMediaPlayerMS::buffered() {
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ //printf("WebMediaPlayerMS::buffered, buffered_.size = %d\n", static_cast<int>(buffered_.size()));
+ return buffered_;
+}
+
+float WebMediaPlayerMS::maxTimeSeekable() const {
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ return 0.0f;
+}
+
+unsigned long long WebMediaPlayerMS::bytesLoaded() const {
+ //printf("WebMediaPlayerMS::bytesLoaded, 0\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ return 0;
+}
+
+unsigned long long WebMediaPlayerMS::totalBytes() const {
+ //printf("WebMediaPlayerMS::totalBytes, %d\n", static_cast<int>(pipeline_->GetTotalBytes()));
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ return 0;
+}
+
+void WebMediaPlayerMS::setSize(const WebSize& size) {
+ //printf("WebMediaPlayerMS::setSize\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+
+ // Don't need to do anything as we use the dimensions passed in via paint().
+}
+
+// This variant (without alpha) is just present during staging of this API
+// change. Later we will again only have one virtual paint().
+void WebMediaPlayerMS::paint(WebKit::WebCanvas* canvas,
+ const WebKit::WebRect& rect) {
+ paint(canvas, rect, 0xFF);
+}
+
+void WebMediaPlayerMS::paint(WebCanvas* canvas,
+ const WebRect& rect,
+ uint8_t alpha) {
+ //printf("WebMediaPlayerMS::paint\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ DCHECK(proxy_);
+
+#if WEBKIT_USING_SKIA
+ proxy_->Paint(canvas, rect, alpha);
+#elif WEBKIT_USING_CG
+ // Get the current scaling in X and Y.
+ CGAffineTransform mat = CGContextGetCTM(canvas);
+ float scale_x = sqrt(mat.a * mat.a + mat.b * mat.b);
+ float scale_y = sqrt(mat.c * mat.c + mat.d * mat.d);
+ float inverse_scale_x = SkScalarNearlyZero(scale_x) ? 0.0f : 1.0f / scale_x;
+ float inverse_scale_y = SkScalarNearlyZero(scale_y) ? 0.0f : 1.0f / scale_y;
+ int scaled_width = static_cast<int>(rect.width * fabs(scale_x));
+ int scaled_height = static_cast<int>(rect.height * fabs(scale_y));
+
+ // Make sure we don't create a huge canvas.
+ // TODO(hclam): Respect the aspect ratio.
+ if (scaled_width > static_cast<int>(media::limits::kMaxCanvas))
+ scaled_width = media::limits::kMaxCanvas;
+ if (scaled_height > static_cast<int>(media::limits::kMaxCanvas))
+ scaled_height = media::limits::kMaxCanvas;
+
+ // If there is no preexisting platform canvas, or if the size has
+ // changed, recreate the canvas. This is to avoid recreating the bitmap
+ // buffer over and over for each frame of video.
+ if (!skia_canvas_.get() ||
+ skia_canvas_->getDevice()->width() != scaled_width ||
+ skia_canvas_->getDevice()->height() != scaled_height) {
+ skia_canvas_.reset(
+ new skia::PlatformCanvas(scaled_width, scaled_height, true));
+ }
+
+ // Draw to our temporary skia canvas.
+ gfx::Rect normalized_rect(scaled_width, scaled_height);
+ proxy_->Paint(skia_canvas_.get(), normalized_rect);
+
+ // The mac coordinate system is flipped vertical from the normal skia
+ // coordinates. During painting of the frame, flip the coordinates
+ // system and, for simplicity, also translate the clip rectangle to
+ // start at 0,0.
+ CGContextSaveGState(canvas);
+ CGContextTranslateCTM(canvas, rect.x, rect.height + rect.y);
+ CGContextScaleCTM(canvas, inverse_scale_x, -inverse_scale_y);
+
+ // We need a local variable CGRect version for DrawToContext.
+ CGRect normalized_cgrect =
+ CGRectMake(normalized_rect.x(), normalized_rect.y(),
+ normalized_rect.width(), normalized_rect.height());
+
+ // Copy the frame rendered to our temporary skia canvas onto the passed in
+ // canvas.
+ skia::DrawToNativeContext(skia_canvas_.get(), canvas, 0, 0,
+ &normalized_cgrect);
+
+ CGContextRestoreGState(canvas);
+#else
+ NOTIMPLEMENTED() << "We only support rendering to skia or CG";
+#endif
+}
+
+bool WebMediaPlayerMS::hasSingleSecurityOrigin() const {
+ //printf("WebMediaPlayerMS::hasSingleSecurityOrigin\n");
+ return true;
+}
+
+WebMediaPlayer::MovieLoadType WebMediaPlayerMS::movieLoadType() const {
+ //printf("WebMediaPlayerMS::movieLoadType, %d\n", pipeline_->IsStreaming() ? WebKit::WebMediaPlayer::LiveStream : WebKit::WebMediaPlayer::Unknown);
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ return WebMediaPlayer::MovieLoadTypeUnknown;
+}
+
+float WebMediaPlayerMS::mediaTimeForTimeValue(float timeValue) const {
+ //printf("WebMediaPlayerMS::mediaTimeForTimeValue, %f\n", ConvertSecondsToTimestamp(timeValue).InSecondsF());
+ return ConvertSecondsToTimestamp(timeValue).InSecondsF();
+}
+
+unsigned WebMediaPlayerMS::decodedFrameCount() const {
+ //printf("WebMediaPlayerMS::decodedFrameCount, %d\n", static_cast<int>(pipeline_->GetStatistics().video_frames_decoded));
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+unsigned WebMediaPlayerMS::droppedFrameCount() const {
+ //printf("WebMediaPlayerMS::droppedFrameCount\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+unsigned WebMediaPlayerMS::audioDecodedByteCount() const {
+ //printf("WebMediaPlayerMS::audioDecodedByteCount\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+unsigned WebMediaPlayerMS::videoDecodedByteCount() const {
+ //printf("WebMediaPlayerMS::videoDecodedByteCount\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ NOTIMPLEMENTED();
+ return 0;
+}
+
+WebKit::WebVideoFrame* WebMediaPlayerMS::getCurrentFrame() {
+ ////printf("WebMediaPlayerMS::getCurrentFrame\n");
+ scoped_refptr<media::VideoFrame> video_frame;
+ frame_provider_->GetCurrentFrame(&video_frame);
+ if (video_frame.get())
+ return new webkit_media::WebVideoFrameImpl(video_frame);
+ return NULL;
+}
+
+void WebMediaPlayerMS::putCurrentFrame(
+ WebKit::WebVideoFrame* web_video_frame) {
+ //printf("WebMediaPlayerMS::putCurrentFrame\n");
+ if (!accelerated_compositing_reported_) {
+ accelerated_compositing_reported_ = true;
+ UMA_HISTOGRAM_BOOLEAN("Media.AcceleratedCompositingActive",
+ frame_->view()->isAcceleratedCompositingActive());
+ }
+ if (web_video_frame) {
+ scoped_refptr<media::VideoFrame> video_frame(
+ WebVideoFrameImpl::toVideoFrame(web_video_frame));
+ frame_provider_->PutCurrentFrame(video_frame);
+ delete web_video_frame;
+ } else {
+ frame_provider_->PutCurrentFrame(NULL);
+ }
+}
+
+void WebMediaPlayerMS::WillDestroyCurrentMessageLoop() {
+ //printf("WebMediaPlayerMS::WillDestroyCurrentMessageLoop\n");
+ Destroy();
+ main_loop_ = NULL;
+}
+
+void WebMediaPlayerMS::Repaint() {
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ //printf("WebMediaPlayerMS::Repaint: call client repaint()\n");
+ GetClient()->repaint();
+}
+
+void WebMediaPlayerMS::SetNetworkState(WebMediaPlayer::NetworkState state) {
+ //printf("WebMediaPlayerMS::SetNetworkState, calling client networkStateChanged, state=%d\n", state);
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ DVLOG(1) << "SetNetworkState: " << state;
+ network_state_ = state;
+ // Always notify to ensure client has the latest value.
+ GetClient()->networkStateChanged();
+}
+
+void WebMediaPlayerMS::SetReadyState(WebMediaPlayer::ReadyState state) {
+ //printf("WebMediaPlayerMS::SetReadyState, calling client readyStateChanged, state=%d\n", state);
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ DVLOG(1) << "SetReadyState: " << state;
+ ready_state_ = state;
+ // Always notify to ensure client has the latest value.
+ GetClient()->readyStateChanged();
+}
+
+void WebMediaPlayerMS::Destroy() {
+ printf("WebMediaPlayerMS::Destroy\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+
+ // Tell the data source to abort any pending reads so that the pipeline is
+ // not blocked when issuing stop commands to the other filters.
+ if (proxy_) {
+ proxy_->SetListener(NULL);
+ proxy_ = NULL;
+ }
+
+ if (frame_provider_) {
+ base::WaitableEvent event(false, false);
+ frame_provider_->Stop(base::Bind(&base::WaitableEvent::Signal,
+ base::Unretained(&event)));
+ event.Wait();
+ }
+
+ // Let V8 know we are not using extra resources anymore.
+ if (incremented_externally_allocated_memory_) {
+ v8::V8::AdjustAmountOfExternalAllocatedMemory(-kPlayerExtraMemory);
+ incremented_externally_allocated_memory_ = false;
+ }
+
+ message_loop_factory_.reset();
+}
+
+WebKit::WebMediaPlayerClient* WebMediaPlayerMS::GetClient() {
+ //printf("WebMediaPlayerMS::GetClient\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ DCHECK(client_);
+ return client_;
+}
+
+void WebMediaPlayerMS::IncrementExternallyAllocatedMemory() {
+ printf("WebMediaPlayerMS::IncrementExternallyAllocatedMemory\n");
+ DCHECK_EQ(main_loop_, MessageLoop::current());
+ incremented_externally_allocated_memory_ = true;
+ v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory);
+}
+
+} // namespace webkit_media
Property changes on: webkit/media/webmediaplayer_ms.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « webkit/media/webmediaplayer_ms.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698