| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/base/android/media_source_player.h" | 5 #include "media/base/android/media_source_player.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
| 10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 pending_seek_ = true; | 166 pending_seek_ = true; |
| 167 pending_seek_time_ = timestamp; | 167 pending_seek_time_ = timestamp; |
| 168 return; | 168 return; |
| 169 } | 169 } |
| 170 | 170 |
| 171 doing_browser_seek_ = false; | 171 doing_browser_seek_ = false; |
| 172 ScheduleSeekEventAndStopDecoding(timestamp); | 172 ScheduleSeekEventAndStopDecoding(timestamp); |
| 173 } | 173 } |
| 174 | 174 |
| 175 base::TimeDelta MediaSourcePlayer::GetCurrentTime() { | 175 base::TimeDelta MediaSourcePlayer::GetCurrentTime() { |
| 176 return clock_.Elapsed(); | 176 return std::min(clock_.Elapsed(), duration_); |
| 177 } | 177 } |
| 178 | 178 |
| 179 base::TimeDelta MediaSourcePlayer::GetDuration() { | 179 base::TimeDelta MediaSourcePlayer::GetDuration() { |
| 180 return duration_; | 180 return duration_; |
| 181 } | 181 } |
| 182 | 182 |
| 183 void MediaSourcePlayer::Release() { | 183 void MediaSourcePlayer::Release() { |
| 184 DVLOG(1) << __FUNCTION__; | 184 DVLOG(1) << __FUNCTION__; |
| 185 | 185 |
| 186 is_surface_in_use_ = false; | 186 is_surface_in_use_ = false; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 230 |
| 231 SetPendingEvent(PREFETCH_REQUEST_EVENT_PENDING); | 231 SetPendingEvent(PREFETCH_REQUEST_EVENT_PENDING); |
| 232 ProcessPendingEvents(); | 232 ProcessPendingEvents(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void MediaSourcePlayer::OnDemuxerConfigsAvailable( | 235 void MediaSourcePlayer::OnDemuxerConfigsAvailable( |
| 236 const DemuxerConfigs& configs) { | 236 const DemuxerConfigs& configs) { |
| 237 DVLOG(1) << __FUNCTION__; | 237 DVLOG(1) << __FUNCTION__; |
| 238 DCHECK(!HasAudio() && !HasVideo()); | 238 DCHECK(!HasAudio() && !HasVideo()); |
| 239 duration_ = configs.duration; | 239 duration_ = configs.duration; |
| 240 clock_.SetDuration(duration_); | |
| 241 | 240 |
| 242 audio_decoder_job_->SetDemuxerConfigs(configs); | 241 audio_decoder_job_->SetDemuxerConfigs(configs); |
| 243 video_decoder_job_->SetDemuxerConfigs(configs); | 242 video_decoder_job_->SetDemuxerConfigs(configs); |
| 244 OnDemuxerConfigsChanged(); | 243 OnDemuxerConfigsChanged(); |
| 245 } | 244 } |
| 246 | 245 |
| 247 void MediaSourcePlayer::OnDemuxerDataAvailable(const DemuxerData& data) { | 246 void MediaSourcePlayer::OnDemuxerDataAvailable(const DemuxerData& data) { |
| 248 DVLOG(1) << __FUNCTION__ << "(" << data.type << ")"; | 247 DVLOG(1) << __FUNCTION__ << "(" << data.type << ")"; |
| 249 DCHECK_LT(0u, data.access_units.size()); | 248 DCHECK_LT(0u, data.access_units.size()); |
| 250 CHECK_GE(1u, data.demuxer_configs.size()); | 249 CHECK_GE(1u, data.demuxer_configs.size()); |
| 251 | 250 |
| 252 if (data.type == DemuxerStream::AUDIO) | 251 if (data.type == DemuxerStream::AUDIO) |
| 253 audio_decoder_job_->OnDataReceived(data); | 252 audio_decoder_job_->OnDataReceived(data); |
| 254 else if (data.type == DemuxerStream::VIDEO) | 253 else if (data.type == DemuxerStream::VIDEO) |
| 255 video_decoder_job_->OnDataReceived(data); | 254 video_decoder_job_->OnDataReceived(data); |
| 256 } | 255 } |
| 257 | 256 |
| 258 void MediaSourcePlayer::OnDemuxerDurationChanged(base::TimeDelta duration) { | 257 void MediaSourcePlayer::OnDemuxerDurationChanged(base::TimeDelta duration) { |
| 259 duration_ = duration; | 258 duration_ = duration; |
| 260 clock_.SetDuration(duration_); | |
| 261 } | 259 } |
| 262 | 260 |
| 263 void MediaSourcePlayer::OnMediaCryptoReady() { | 261 void MediaSourcePlayer::OnMediaCryptoReady() { |
| 264 DCHECK(!drm_bridge_->GetMediaCrypto().is_null()); | 262 DCHECK(!drm_bridge_->GetMediaCrypto().is_null()); |
| 265 drm_bridge_->SetMediaCryptoReadyCB(base::Closure()); | 263 drm_bridge_->SetMediaCryptoReadyCB(base::Closure()); |
| 266 | 264 |
| 267 // Retry decoder creation if the decoders are waiting for MediaCrypto. | 265 // Retry decoder creation if the decoders are waiting for MediaCrypto. |
| 268 RetryDecoderCreation(true, true); | 266 RetryDecoderCreation(true, true); |
| 269 } | 267 } |
| 270 | 268 |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 // release MediaDrm when the video is paused, or when the device goes to | 749 // release MediaDrm when the video is paused, or when the device goes to |
| 752 // sleep (see http://crbug.com/272421). | 750 // sleep (see http://crbug.com/272421). |
| 753 NOTREACHED() << "CDM detachment not supported."; | 751 NOTREACHED() << "CDM detachment not supported."; |
| 754 DCHECK(drm_bridge_); | 752 DCHECK(drm_bridge_); |
| 755 audio_decoder_job_->SetDrmBridge(NULL); | 753 audio_decoder_job_->SetDrmBridge(NULL); |
| 756 video_decoder_job_->SetDrmBridge(NULL); | 754 video_decoder_job_->SetDrmBridge(NULL); |
| 757 drm_bridge_ = NULL; | 755 drm_bridge_ = NULL; |
| 758 } | 756 } |
| 759 | 757 |
| 760 } // namespace media | 758 } // namespace media |
| OLD | NEW |