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

Side by Side Diff: media/mojo/services/mojo_renderer_service.cc

Issue 2240213003: Update media mojom files to use TimeDelta instead of int64 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@OnDurationChanged_CL
Patch Set: Created 4 years, 4 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
« no previous file with comments | « media/mojo/services/mojo_renderer_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "media/mojo/services/mojo_renderer_service.h" 5 #include "media/mojo/services/mojo_renderer_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "media/base/media_keys.h" 10 #include "media/base/media_keys.h"
11 #include "media/base/media_url_demuxer.h" 11 #include "media/base/media_url_demuxer.h"
12 #include "media/base/renderer.h" 12 #include "media/base/renderer.h"
13 #include "media/mojo/services/demuxer_stream_provider_shim.h" 13 #include "media/mojo/services/demuxer_stream_provider_shim.h"
14 #include "media/mojo/services/mojo_cdm_service_context.h" 14 #include "media/mojo/services/mojo_cdm_service_context.h"
15 15
16 namespace media { 16 namespace media {
17 17
18 // Time interval to update media time. 18 // Time interval to update media time.
19 const int kTimeUpdateIntervalMs = 50; 19 const int kTimeUpdateIntervalMs = 50;
20 20
21 MojoRendererService::MojoRendererService( 21 MojoRendererService::MojoRendererService(
22 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context, 22 base::WeakPtr<MojoCdmServiceContext> mojo_cdm_service_context,
23 std::unique_ptr<media::Renderer> renderer, 23 std::unique_ptr<media::Renderer> renderer,
24 mojo::InterfaceRequest<mojom::Renderer> request) 24 mojo::InterfaceRequest<mojom::Renderer> request)
25 : binding_(this, std::move(request)), 25 : binding_(this, std::move(request)),
26 mojo_cdm_service_context_(mojo_cdm_service_context), 26 mojo_cdm_service_context_(mojo_cdm_service_context),
27 state_(STATE_UNINITIALIZED), 27 state_(STATE_UNINITIALIZED),
28 last_media_time_usec_(0),
29 renderer_(std::move(renderer)), 28 renderer_(std::move(renderer)),
30 weak_factory_(this) { 29 weak_factory_(this) {
31 DVLOG(1) << __FUNCTION__; 30 DVLOG(1) << __FUNCTION__;
32 DCHECK(renderer_); 31 DCHECK(renderer_);
33 32
34 weak_this_ = weak_factory_.GetWeakPtr(); 33 weak_this_ = weak_factory_.GetWeakPtr();
35 } 34 }
36 35
37 MojoRendererService::~MojoRendererService() {} 36 MojoRendererService::~MojoRendererService() {}
38 37
(...skipping 27 matching lines...) Expand all
66 void MojoRendererService::Flush(const FlushCallback& callback) { 65 void MojoRendererService::Flush(const FlushCallback& callback) {
67 DVLOG(2) << __FUNCTION__; 66 DVLOG(2) << __FUNCTION__;
68 DCHECK_EQ(state_, STATE_PLAYING); 67 DCHECK_EQ(state_, STATE_PLAYING);
69 68
70 state_ = STATE_FLUSHING; 69 state_ = STATE_FLUSHING;
71 CancelPeriodicMediaTimeUpdates(); 70 CancelPeriodicMediaTimeUpdates();
72 renderer_->Flush( 71 renderer_->Flush(
73 base::Bind(&MojoRendererService::OnFlushCompleted, weak_this_, callback)); 72 base::Bind(&MojoRendererService::OnFlushCompleted, weak_this_, callback));
74 } 73 }
75 74
76 void MojoRendererService::StartPlayingFrom(int64_t time_delta_usec) { 75 void MojoRendererService::StartPlayingFrom(base::TimeDelta time_delta) {
77 DVLOG(2) << __FUNCTION__ << ": " << time_delta_usec; 76 DVLOG(2) << __FUNCTION__ << ": " << time_delta;
78 renderer_->StartPlayingFrom( 77 renderer_->StartPlayingFrom(time_delta);
79 base::TimeDelta::FromMicroseconds(time_delta_usec));
80 SchedulePeriodicMediaTimeUpdates(); 78 SchedulePeriodicMediaTimeUpdates();
81 } 79 }
82 80
83 void MojoRendererService::SetPlaybackRate(double playback_rate) { 81 void MojoRendererService::SetPlaybackRate(double playback_rate) {
84 DVLOG(2) << __FUNCTION__ << ": " << playback_rate; 82 DVLOG(2) << __FUNCTION__ << ": " << playback_rate;
85 DCHECK_EQ(state_, STATE_PLAYING); 83 DCHECK_EQ(state_, STATE_PLAYING);
86 renderer_->SetPlaybackRate(playback_rate); 84 renderer_->SetPlaybackRate(playback_rate);
87 } 85 }
88 86
89 void MojoRendererService::SetVolume(float volume) { 87 void MojoRendererService::SetVolume(float volume) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 DVLOG(1) << __FUNCTION__; 140 DVLOG(1) << __FUNCTION__;
143 client_->OnWaitingForDecryptionKey(); 141 client_->OnWaitingForDecryptionKey();
144 } 142 }
145 143
146 void MojoRendererService::OnVideoNaturalSizeChange(const gfx::Size& size) { 144 void MojoRendererService::OnVideoNaturalSizeChange(const gfx::Size& size) {
147 DVLOG(2) << __FUNCTION__ << "(" << size.ToString() << ")"; 145 DVLOG(2) << __FUNCTION__ << "(" << size.ToString() << ")";
148 client_->OnVideoNaturalSizeChange(size); 146 client_->OnVideoNaturalSizeChange(size);
149 } 147 }
150 148
151 void MojoRendererService::OnDurationChange(base::TimeDelta duration) { 149 void MojoRendererService::OnDurationChange(base::TimeDelta duration) {
152 client_->OnDurationChange(duration.InMicroseconds()); 150 client_->OnDurationChange(duration);
153 } 151 }
154 152
155 void MojoRendererService::OnVideoOpacityChange(bool opaque) { 153 void MojoRendererService::OnVideoOpacityChange(bool opaque) {
156 DVLOG(2) << __FUNCTION__ << "(" << opaque << ")"; 154 DVLOG(2) << __FUNCTION__ << "(" << opaque << ")";
157 client_->OnVideoOpacityChange(opaque); 155 client_->OnVideoOpacityChange(opaque);
158 } 156 }
159 157
160 void MojoRendererService::OnStreamReady( 158 void MojoRendererService::OnStreamReady(
161 const base::Callback<void(bool)>& callback) { 159 const base::Callback<void(bool)>& callback) {
162 DCHECK_EQ(state_, STATE_INITIALIZING); 160 DCHECK_EQ(state_, STATE_INITIALIZING);
(...skipping 14 matching lines...) Expand all
177 state_ = STATE_ERROR; 175 state_ = STATE_ERROR;
178 callback.Run(false); 176 callback.Run(false);
179 return; 177 return;
180 } 178 }
181 179
182 state_ = STATE_PLAYING; 180 state_ = STATE_PLAYING;
183 callback.Run(true); 181 callback.Run(true);
184 } 182 }
185 183
186 void MojoRendererService::UpdateMediaTime(bool force) { 184 void MojoRendererService::UpdateMediaTime(bool force) {
187 const int64_t media_time = renderer_->GetMediaTime().InMicroseconds(); 185 base::TimeDelta media_time = renderer_->GetMediaTime();
188 if (!force && media_time == last_media_time_usec_) 186 if (!force && media_time == last_media_time_)
189 return; 187 return;
190 188
191 client_->OnTimeUpdate(media_time, media_time); 189 client_->OnTimeUpdate(media_time, media_time);
192 last_media_time_usec_ = media_time; 190 last_media_time_ = media_time;
193 } 191 }
194 192
195 void MojoRendererService::CancelPeriodicMediaTimeUpdates() { 193 void MojoRendererService::CancelPeriodicMediaTimeUpdates() {
196 DVLOG(2) << __FUNCTION__; 194 DVLOG(2) << __FUNCTION__;
197 UpdateMediaTime(false); 195 UpdateMediaTime(false);
198 time_update_timer_.Stop(); 196 time_update_timer_.Stop();
199 } 197 }
200 198
201 void MojoRendererService::SchedulePeriodicMediaTimeUpdates() { 199 void MojoRendererService::SchedulePeriodicMediaTimeUpdates() {
202 DVLOG(2) << __FUNCTION__; 200 DVLOG(2) << __FUNCTION__;
(...skipping 17 matching lines...) Expand all
220 bool success) { 218 bool success) {
221 DVLOG(1) << __FUNCTION__ << "(" << success << ")"; 219 DVLOG(1) << __FUNCTION__ << "(" << success << ")";
222 220
223 if (success) 221 if (success)
224 cdm_ = cdm; 222 cdm_ = cdm;
225 223
226 callback.Run(success); 224 callback.Run(success);
227 } 225 }
228 226
229 } // namespace media 227 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_renderer_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698