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

Unified Diff: media/base/android/media_source_player_with_dedicated_thread.cc

Issue 1076013002: Added stub MediaSourcePlayer for developing behind the flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed old and new players, addressed some Xiaohan comments Created 5 years, 8 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 | « media/base/android/media_source_player_with_dedicated_thread.h ('k') | media/base/media_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/android/media_source_player_with_dedicated_thread.cc
diff --git a/media/base/android/media_source_player_with_dedicated_thread.cc b/media/base/android/media_source_player_with_dedicated_thread.cc
new file mode 100644
index 0000000000000000000000000000000000000000..05a9a41e63b45cd7bdfbcf88e9d2a0efd3b35814
--- /dev/null
+++ b/media/base/android/media_source_player_with_dedicated_thread.cc
@@ -0,0 +1,158 @@
+// Copyright 2015 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 "media/base/android/media_source_player_with_dedicated_thread.h"
+
+#include "base/bind.h"
+#include "base/lazy_instance.h"
+#include "base/logging.h"
+#include "base/threading/thread.h"
+
+#include "media/base/android/media_player_manager.h"
+#include "media/base/android/media_source_player_impl.h"
+
+namespace media {
+
+class MediaThread : public base::Thread {
+ public:
+ MediaThread() : base::Thread("BrowserMediaThread") {
+ Start();
+ }
+};
+
+// Create media thread
+base::LazyInstance<MediaThread>::Leaky
+ g_media_thread = LAZY_INSTANCE_INITIALIZER;
+
+
+scoped_refptr<base::SingleThreadTaskRunner> GetMediaTaskRunner() {
+ return g_media_thread.Pointer()->task_runner();
+}
+
+MediaSourcePlayerWithDedicatedThread::MediaSourcePlayerWithDedicatedThread(
+ int player_id,
+ MediaPlayerManager* manager,
+ const RequestMediaResourcesCB& request_media_resources_cb,
+ scoped_ptr<DemuxerAndroid> demuxer,
+ const GURL& frame_url)
+ : MediaPlayerAndroid(player_id,
+ manager,
+ request_media_resources_cb,
+ frame_url),
+ weak_factory_(this)
+{
+ // UI thread
+ DVLOG(1) << "MediaSourcePlayerWithDedicatedThread: player_id:" << player_id;
+
+ impl_ = new MediaSourcePlayerImpl(demuxer.Pass());
+}
+
+MediaSourcePlayerWithDedicatedThread::~MediaSourcePlayerWithDedicatedThread()
+{
+ // UI thread
+ DVLOG(1) << "~MediaSourcePlayerWithDedicatedThread: player_id:"
+ << player_id();
+
+ // Postpone the deletion of |impl_| until it is properly stopped
+ // on the Media thread.
+ GetMediaTaskRunner()->PostTask(
+ FROM_HERE, base::Bind(&MediaSourcePlayerImpl::DestroySelf,
+ base::Unretained(impl_)));
+}
+
+// MediaPlayerAndroid implementation.
+// The methods are called on UI thread
+
+void MediaSourcePlayerWithDedicatedThread::SetVideoSurface(
+ gfx::ScopedJavaSurface surface) {
+ DVLOG(1) << __FUNCTION__;
+
+ GetMediaTaskRunner()->PostTask(
+ FROM_HERE, base::Bind(&MediaSourcePlayerImpl::SetVideoSurface,
+ base::Unretained(impl_), base::Passed(&surface)));
+}
xhwang 2015/05/01 06:55:05 Can you just do something like: void MediaSourceP
timav 2015/05/01 18:14:10 Sorry, I did not understand your point here. The
xhwang 2015/05/01 20:26:35 Sorry for the confusion. I was just proposing to m
timav 2015/05/06 06:46:28 Done.
+
+void MediaSourcePlayerWithDedicatedThread::Start() {
xhwang 2015/05/01 06:55:05 I am not a fan of the name MediaSourcePlayerImpl a
timav 2015/05/01 18:14:10 I completely agree :-) I will get in agreement wit
qinmin 2015/05/01 19:12:14 MediaCodecPlayer sgtm
timav 2015/05/06 06:46:29 Done.
+ DVLOG(1) << __FUNCTION__;
+
+ GetMediaTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&MediaSourcePlayerImpl::Start, base::Unretained(impl_)));
+}
+
+void MediaSourcePlayerWithDedicatedThread::Pause(
+ bool /* is_media_related_action */) {
+ DVLOG(1) << __FUNCTION__;
+
+ GetMediaTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&MediaSourcePlayerImpl::Pause, base::Unretained(impl_)));
+}
+
+void MediaSourcePlayerWithDedicatedThread::SeekTo(base::TimeDelta timestamp) {
+ DVLOG(1) << __FUNCTION__ << " " << timestamp;
+
+ GetMediaTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&MediaSourcePlayerImpl::SeekTo,
+ base::Unretained(impl_), timestamp));
+}
+
+void MediaSourcePlayerWithDedicatedThread::Release() {
+ DVLOG(1) << __FUNCTION__;
+
+ GetMediaTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&MediaSourcePlayerImpl::Release, base::Unretained(impl_)));
+}
+
+void MediaSourcePlayerWithDedicatedThread::SetVolume(double volume) {
+ DVLOG(1) << __FUNCTION__ << " " << volume;
+ GetMediaTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&MediaSourcePlayerImpl::SetVolume,
+ base::Unretained(impl_), volume));
+}
+
+int MediaSourcePlayerWithDedicatedThread::GetVideoWidth() {
+ return impl_->GetVideoWidth();
+}
+
+int MediaSourcePlayerWithDedicatedThread::GetVideoHeight() {
+ return impl_->GetVideoHeight();
+}
+
+base::TimeDelta MediaSourcePlayerWithDedicatedThread::GetCurrentTime() {
+ return impl_->GetCurrentTime();
+}
+
+base::TimeDelta MediaSourcePlayerWithDedicatedThread::GetDuration() {
+ return impl_->GetDuration();
+}
+
+bool MediaSourcePlayerWithDedicatedThread::IsPlaying() {
+ return impl_->IsPlaying();
+}
+
+bool MediaSourcePlayerWithDedicatedThread::CanPause() {
+ return impl_->CanPause();
+}
+
+bool MediaSourcePlayerWithDedicatedThread::CanSeekForward() {
+ return impl_->CanSeekForward();
+}
+
+bool MediaSourcePlayerWithDedicatedThread::CanSeekBackward() {
+ return impl_->CanSeekBackward();
+}
+
+bool MediaSourcePlayerWithDedicatedThread::IsPlayerReady() {
+ return impl_->IsPlayerReady();
+}
+
+void MediaSourcePlayerWithDedicatedThread::SetCdm(BrowserCdm* cdm) {
+ DVLOG(1) << __FUNCTION__;
+}
+
+} // namespace media
« no previous file with comments | « media/base/android/media_source_player_with_dedicated_thread.h ('k') | media/base/media_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698