Merge lp:~justinmcp/oxide/mediahub-fixes-1.10 into lp:oxide/1.10

Proposed by Justin McPherson on 2015-09-25
Status: Merged
Merged at revision: 1208
Proposed branch: lp:~justinmcp/oxide/mediahub-fixes-1.10
Merge into: lp:oxide/1.10
Diff against target: 291 lines (+69/-13)
12 files modified
shared/browser/media/mediahub_player_shim.cc (+15/-2)
shared/browser/media/mediahub_player_shim.h (+6/-0)
shared/browser/media/oxide_browser_media_player_manager.cc (+8/-0)
shared/browser/media/oxide_browser_media_player_manager.h (+1/-0)
shared/browser/media/oxide_media_player.h (+2/-0)
shared/browser/media/oxide_media_web_contents_observer.cc (+3/-0)
shared/browser/media/oxide_player_media_hub.cc (+17/-8)
shared/browser/media/oxide_player_media_hub.h (+2/-0)
shared/common/oxide_messages.h (+5/-0)
shared/renderer/media/oxide_renderer_media_player_manager.cc (+4/-0)
shared/renderer/media/oxide_renderer_media_player_manager.h (+2/-0)
shared/renderer/media/oxide_web_media_player.cc (+4/-3)
To merge this branch: bzr merge lp:~justinmcp/oxide/mediahub-fixes-1.10
Reviewer Review Type Date Requested Status
Chris Coulson 2015-09-25 Approve on 2015-10-27
Review via email: mp+272334@code.launchpad.net

Commit message

Small fixes and some changes to increase robustness in MH audio implementation

To post a comment you must log in.
1194. By Justin McPherson on 2015-10-01

Fix reporting of seekable status

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'shared/browser/media/mediahub_player_shim.cc'
2--- shared/browser/media/mediahub_player_shim.cc 2015-02-17 14:22:40 +0000
3+++ shared/browser/media/mediahub_player_shim.cc 2015-10-01 23:59:09 +0000
4@@ -138,9 +138,9 @@
5 try {
6 Player* player = static_cast<Player*>(handle);
7 if (player != 0) {
8- if (player->playback_status().get() == Player::playing);
9+ if (player->playback_status().get() == Player::playing) {
10 player->stop();
11-
12+ }
13 core::ubuntu::media::Player::HeadersType headers;
14 if (!cookies.empty()) {
15 headers["Cookie"] = cookies;
16@@ -334,6 +334,19 @@
17 }
18
19 void
20+mediahub_set_rate(MediaHubClientHandle handle, double rate)
21+{
22+ try {
23+ Player* player = static_cast<Player*>(handle);
24+ if (player) {
25+ player->playback_rate().set(rate);
26+ }
27+ } catch (std::runtime_error& error) {
28+ std::cerr << __PRETTY_FUNCTION__ << " " << error.what() << std::endl;
29+ }
30+}
31+
32+void
33 mediahub_set_player_lifetime(MediaHubClientHandle handle, Lifetime lifetime)
34 {
35 try {
36
37=== modified file 'shared/browser/media/mediahub_player_shim.h'
38--- shared/browser/media/mediahub_player_shim.h 2015-02-17 14:22:40 +0000
39+++ shared/browser/media/mediahub_player_shim.h 2015-10-01 23:59:09 +0000
40@@ -129,6 +129,12 @@
41 void
42 mediahub_set_volume(MediaHubClientHandle, double volume);
43
44+
45+/**
46+ *
47+ */
48+void mediahub_set_rate(MediaHubClientHandle, double rate);
49+
50 /**
51 * Set lifetime of player session.
52 */
53
54=== modified file 'shared/browser/media/oxide_browser_media_player_manager.cc'
55--- shared/browser/media/oxide_browser_media_player_manager.cc 2015-06-29 16:47:46 +0000
56+++ shared/browser/media/oxide_browser_media_player_manager.cc 2015-10-01 23:59:09 +0000
57@@ -72,6 +72,14 @@
58 }
59 }
60
61+void BrowserMediaPlayerManager::OnSetRate(int player_id, double rate) {
62+ MediaPlayer* player = GetPlayer(player_id);
63+
64+ if (player) {
65+ player->SetRate(rate);
66+ }
67+}
68+
69 void BrowserMediaPlayerManager::OnSetPoster(int player_id, const GURL& url) {
70 // To be overridden by subclasses.
71 }
72
73=== modified file 'shared/browser/media/oxide_browser_media_player_manager.h'
74--- shared/browser/media/oxide_browser_media_player_manager.h 2015-06-30 18:35:36 +0000
75+++ shared/browser/media/oxide_browser_media_player_manager.h 2015-10-01 23:59:09 +0000
76@@ -52,6 +52,7 @@
77 void OnSeek(int player_id, const base::TimeDelta& pos);
78 void OnPause(int player_id, bool is_media_related_action);
79 void OnSetVolume(int player_id, double volume);
80+ void OnSetRate(int player_id, double rate);
81 void OnSetPoster(int player_id, const GURL& poster);
82 void OnReleaseResources(int player_id);
83 void OnDestroyPlayer(int player_id);
84
85=== modified file 'shared/browser/media/oxide_media_player.h'
86--- shared/browser/media/oxide_media_player.h 2015-01-06 06:28:47 +0000
87+++ shared/browser/media/oxide_media_player.h 2015-10-01 23:59:09 +0000
88@@ -44,6 +44,8 @@
89
90 // Set the player volume.
91 virtual void SetVolume(double volume) = 0;
92+
93+ virtual void SetRate(double rate) = 0;
94
95 // Get the media information from the player.
96 virtual int GetVideoWidth() = 0;
97
98=== modified file 'shared/browser/media/oxide_media_web_contents_observer.cc'
99--- shared/browser/media/oxide_media_web_contents_observer.cc 2015-01-19 22:49:05 +0000
100+++ shared/browser/media/oxide_media_web_contents_observer.cc 2015-10-01 23:59:09 +0000
101@@ -42,6 +42,9 @@
102 IPC_MESSAGE_FORWARD(OxideHostMsg_MediaPlayer_SetVolume,
103 GetMediaPlayerManager(render_frame_host),
104 BrowserMediaPlayerManager::OnSetVolume)
105+ IPC_MESSAGE_FORWARD(OxideHostMsg_MediaPlayer_SetRate,
106+ GetMediaPlayerManager(render_frame_host),
107+ BrowserMediaPlayerManager::OnSetRate)
108 IPC_MESSAGE_FORWARD(OxideHostMsg_MediaPlayer_SetPoster,
109 GetMediaPlayerManager(render_frame_host),
110 BrowserMediaPlayerManager::OnSetPoster)
111
112=== modified file 'shared/browser/media/oxide_player_media_hub.cc'
113--- shared/browser/media/oxide_player_media_hub.cc 2015-08-25 20:42:44 +0000
114+++ shared/browser/media/oxide_player_media_hub.cc 2015-10-01 23:59:09 +0000
115@@ -32,6 +32,7 @@
116 height_(0),
117 duration_(0),
118 media_hub_client_(0),
119+ status_(MediaHubDelegate::null),
120 weak_factory_(this) {
121
122 const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess();
123@@ -112,11 +113,11 @@
124 }
125
126 base::TimeDelta MediaPlayerMediaHub::GetCurrentTime() {
127- return base::TimeDelta::FromMilliseconds(mediahub_get_position(media_hub_client_));
128+ return base::TimeDelta::FromMicroseconds(mediahub_get_position(media_hub_client_) / 1000);
129 }
130
131 base::TimeDelta MediaPlayerMediaHub::GetDuration() {
132- return base::TimeDelta::FromMilliseconds(mediahub_get_duration(media_hub_client_));
133+ return base::TimeDelta::FromMicroseconds(mediahub_get_duration(media_hub_client_) / 1000);
134 }
135
136 void MediaPlayerMediaHub::Release() {
137@@ -126,6 +127,10 @@
138 mediahub_set_volume(media_hub_client_, volume);
139 }
140
141+void MediaPlayerMediaHub::SetRate(double rate) {
142+ mediahub_set_rate(media_hub_client_, rate);
143+}
144+
145 bool MediaPlayerMediaHub::CanPause() {
146 return mediahub_can_pause(media_hub_client_) != 0;
147 }
148@@ -159,22 +164,26 @@
149 }
150
151 void MediaPlayerMediaHub::playback_status_changed(MediaHubDelegate::Status status) {
152+ if (status == status_) {
153+ return;
154+ }
155+ status_ = status;
156 switch (status) {
157 case null:
158 case ready:
159 manager_->OnMediaMetadataChanged(player_id(),
160- base::TimeDelta::FromMilliseconds(mediahub_get_duration(media_hub_client_)),
161+ base::TimeDelta::FromMicroseconds(mediahub_get_duration(media_hub_client_) / 1000),
162 0, 0, true);
163 break;
164 case playing:
165 manager_->OnMediaMetadataChanged(player_id(),
166- base::TimeDelta::FromMilliseconds(mediahub_get_duration(media_hub_client_)),
167+ base::TimeDelta::FromMicroseconds(mediahub_get_duration(media_hub_client_) / 1000),
168 0, 0, true);
169 manager_->OnPlayerPlay(player_id());
170 break;
171 case paused:
172 manager_->OnMediaMetadataChanged(player_id(),
173- base::TimeDelta::FromMilliseconds(mediahub_get_duration(media_hub_client_)),
174+ base::TimeDelta::FromMicroseconds(mediahub_get_duration(media_hub_client_) / 1000),
175 0, 0, true);
176 manager_->OnPlayerPause(player_id());
177 break;
178@@ -201,14 +210,14 @@
179
180 if (duration != duration_) {
181 manager_->OnMediaMetadataChanged(player_id(),
182- base::TimeDelta::FromMilliseconds(duration),
183+ base::TimeDelta::FromMicroseconds(duration / 1000),
184 0, 0, true);
185 duration_ = duration;
186 }
187
188 manager_->OnTimeUpdate(player_id(),
189- base::TimeDelta::FromMilliseconds(
190- mediahub_get_position(media_hub_client_)));
191+ base::TimeDelta::FromMicroseconds(
192+ mediahub_get_position(media_hub_client_) / 1000));
193 }
194
195 } // namespace media
196
197=== modified file 'shared/browser/media/oxide_player_media_hub.h'
198--- shared/browser/media/oxide_player_media_hub.h 2015-02-17 14:22:40 +0000
199+++ shared/browser/media/oxide_player_media_hub.h 2015-10-01 23:59:09 +0000
200@@ -48,6 +48,7 @@
201 void SeekTo(base::TimeDelta timestamp) override;
202 void Release() override;
203 void SetVolume(double volume) override;
204+ void SetRate(double rate) override;
205 int GetVideoWidth() override;
206 int GetVideoHeight() override;
207 base::TimeDelta GetCurrentTime() override;
208@@ -98,6 +99,7 @@
209 std::string cookies_;
210
211 MediaHubClientHandle media_hub_client_;
212+ MediaHubDelegate::Status status_;
213
214 base::WeakPtrFactory<MediaPlayerMediaHub> weak_factory_;
215
216
217=== modified file 'shared/common/oxide_messages.h'
218--- shared/common/oxide_messages.h 2015-06-29 17:52:40 +0000
219+++ shared/common/oxide_messages.h 2015-10-01 23:59:09 +0000
220@@ -185,6 +185,11 @@
221 int /* player_id */,
222 double /* volume */)
223
224+// Set the rate.
225+IPC_MESSAGE_ROUTED2(OxideHostMsg_MediaPlayer_SetRate,
226+ int /* player_id */,
227+ double /* rate */)
228+
229 // Set the poster image.
230 IPC_MESSAGE_ROUTED2(OxideHostMsg_MediaPlayer_SetPoster,
231 int /* player_id */,
232
233=== modified file 'shared/renderer/media/oxide_renderer_media_player_manager.cc'
234--- shared/renderer/media/oxide_renderer_media_player_manager.cc 2015-01-20 17:26:44 +0000
235+++ shared/renderer/media/oxide_renderer_media_player_manager.cc 2015-10-01 23:59:09 +0000
236@@ -91,6 +91,10 @@
237 Send(new OxideHostMsg_MediaPlayer_SetVolume(routing_id(), player_id, volume));
238 }
239
240+void RendererMediaPlayerManager::SetRate(int player_id, double rate) {
241+ Send(new OxideHostMsg_MediaPlayer_SetRate(routing_id(), player_id, rate));
242+}
243+
244 void RendererMediaPlayerManager::SetPoster(int player_id, const GURL& poster) {
245 Send(new OxideHostMsg_MediaPlayer_SetPoster(routing_id(), player_id, poster));
246 }
247
248=== modified file 'shared/renderer/media/oxide_renderer_media_player_manager.h'
249--- shared/renderer/media/oxide_renderer_media_player_manager.h 2014-12-10 04:14:21 +0000
250+++ shared/renderer/media/oxide_renderer_media_player_manager.h 2015-10-01 23:59:09 +0000
251@@ -56,6 +56,8 @@
252 // Sets the player volume.
253 void SetVolume(int player_id, double volume);
254
255+ void SetRate(int player_id, double rate);
256+
257 // Sets the poster image.
258 void SetPoster(int player_id, const GURL& poster);
259
260
261=== modified file 'shared/renderer/media/oxide_web_media_player.cc'
262--- shared/renderer/media/oxide_web_media_player.cc 2015-08-25 20:42:44 +0000
263+++ shared/renderer/media/oxide_web_media_player.cc 2015-10-01 23:59:09 +0000
264@@ -201,7 +201,7 @@
265 }
266
267 void WebMediaPlayer::seek(double seconds) {
268- NOTIMPLEMENTED();
269+ player_manager_->Seek(player_id_, base::TimeDelta::FromSeconds(seconds));
270 }
271
272 bool WebMediaPlayer::supportsSave() const {
273@@ -209,7 +209,7 @@
274 }
275
276 void WebMediaPlayer::setRate(double rate) {
277- NOTIMPLEMENTED();
278+ player_manager_->SetRate(player_id_, rate);
279 }
280
281 void WebMediaPlayer::setSinkId(
282@@ -325,7 +325,8 @@
283 }
284
285 WebTimeRanges WebMediaPlayer::seekable() const {
286- return buffered_;
287+ const blink::WebTimeRange seekable_range(0.0, duration());
288+ return blink::WebTimeRanges(&seekable_range, 1);
289 }
290
291 double WebMediaPlayer::maxTimeSeekable() const {

Subscribers

People subscribed via source and target branches