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

Side by Side 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, 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "media/base/android/media_source_player_with_dedicated_thread.h"
6
7 #include "base/bind.h"
8 #include "base/lazy_instance.h"
9 #include "base/logging.h"
10 #include "base/threading/thread.h"
11
12 #include "media/base/android/media_player_manager.h"
13 #include "media/base/android/media_source_player_impl.h"
14
15 namespace media {
16
17 class MediaThread : public base::Thread {
18 public:
19 MediaThread() : base::Thread("BrowserMediaThread") {
20 Start();
21 }
22 };
23
24 // Create media thread
25 base::LazyInstance<MediaThread>::Leaky
26 g_media_thread = LAZY_INSTANCE_INITIALIZER;
27
28
29 scoped_refptr<base::SingleThreadTaskRunner> GetMediaTaskRunner() {
30 return g_media_thread.Pointer()->task_runner();
31 }
32
33 MediaSourcePlayerWithDedicatedThread::MediaSourcePlayerWithDedicatedThread(
34 int player_id,
35 MediaPlayerManager* manager,
36 const RequestMediaResourcesCB& request_media_resources_cb,
37 scoped_ptr<DemuxerAndroid> demuxer,
38 const GURL& frame_url)
39 : MediaPlayerAndroid(player_id,
40 manager,
41 request_media_resources_cb,
42 frame_url),
43 weak_factory_(this)
44 {
45 // UI thread
46 DVLOG(1) << "MediaSourcePlayerWithDedicatedThread: player_id:" << player_id;
47
48 impl_ = new MediaSourcePlayerImpl(demuxer.Pass());
49 }
50
51 MediaSourcePlayerWithDedicatedThread::~MediaSourcePlayerWithDedicatedThread()
52 {
53 // UI thread
54 DVLOG(1) << "~MediaSourcePlayerWithDedicatedThread: player_id:"
55 << player_id();
56
57 // Postpone the deletion of |impl_| until it is properly stopped
58 // on the Media thread.
59 GetMediaTaskRunner()->PostTask(
60 FROM_HERE, base::Bind(&MediaSourcePlayerImpl::DestroySelf,
61 base::Unretained(impl_)));
62 }
63
64 // MediaPlayerAndroid implementation.
65 // The methods are called on UI thread
66
67 void MediaSourcePlayerWithDedicatedThread::SetVideoSurface(
68 gfx::ScopedJavaSurface surface) {
69 DVLOG(1) << __FUNCTION__;
70
71 GetMediaTaskRunner()->PostTask(
72 FROM_HERE, base::Bind(&MediaSourcePlayerImpl::SetVideoSurface,
73 base::Unretained(impl_), base::Passed(&surface)));
74 }
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.
75
76 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.
77 DVLOG(1) << __FUNCTION__;
78
79 GetMediaTaskRunner()->PostTask(
80 FROM_HERE,
81 base::Bind(&MediaSourcePlayerImpl::Start, base::Unretained(impl_)));
82 }
83
84 void MediaSourcePlayerWithDedicatedThread::Pause(
85 bool /* is_media_related_action */) {
86 DVLOG(1) << __FUNCTION__;
87
88 GetMediaTaskRunner()->PostTask(
89 FROM_HERE,
90 base::Bind(&MediaSourcePlayerImpl::Pause, base::Unretained(impl_)));
91 }
92
93 void MediaSourcePlayerWithDedicatedThread::SeekTo(base::TimeDelta timestamp) {
94 DVLOG(1) << __FUNCTION__ << " " << timestamp;
95
96 GetMediaTaskRunner()->PostTask(
97 FROM_HERE,
98 base::Bind(&MediaSourcePlayerImpl::SeekTo,
99 base::Unretained(impl_), timestamp));
100 }
101
102 void MediaSourcePlayerWithDedicatedThread::Release() {
103 DVLOG(1) << __FUNCTION__;
104
105 GetMediaTaskRunner()->PostTask(
106 FROM_HERE,
107 base::Bind(&MediaSourcePlayerImpl::Release, base::Unretained(impl_)));
108 }
109
110 void MediaSourcePlayerWithDedicatedThread::SetVolume(double volume) {
111 DVLOG(1) << __FUNCTION__ << " " << volume;
112 GetMediaTaskRunner()->PostTask(
113 FROM_HERE,
114 base::Bind(&MediaSourcePlayerImpl::SetVolume,
115 base::Unretained(impl_), volume));
116 }
117
118 int MediaSourcePlayerWithDedicatedThread::GetVideoWidth() {
119 return impl_->GetVideoWidth();
120 }
121
122 int MediaSourcePlayerWithDedicatedThread::GetVideoHeight() {
123 return impl_->GetVideoHeight();
124 }
125
126 base::TimeDelta MediaSourcePlayerWithDedicatedThread::GetCurrentTime() {
127 return impl_->GetCurrentTime();
128 }
129
130 base::TimeDelta MediaSourcePlayerWithDedicatedThread::GetDuration() {
131 return impl_->GetDuration();
132 }
133
134 bool MediaSourcePlayerWithDedicatedThread::IsPlaying() {
135 return impl_->IsPlaying();
136 }
137
138 bool MediaSourcePlayerWithDedicatedThread::CanPause() {
139 return impl_->CanPause();
140 }
141
142 bool MediaSourcePlayerWithDedicatedThread::CanSeekForward() {
143 return impl_->CanSeekForward();
144 }
145
146 bool MediaSourcePlayerWithDedicatedThread::CanSeekBackward() {
147 return impl_->CanSeekBackward();
148 }
149
150 bool MediaSourcePlayerWithDedicatedThread::IsPlayerReady() {
151 return impl_->IsPlayerReady();
152 }
153
154 void MediaSourcePlayerWithDedicatedThread::SetCdm(BrowserCdm* cdm) {
155 DVLOG(1) << __FUNCTION__;
156 }
157
158 } // namespace media
OLDNEW
« 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