| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | |
| 10 #include <limits> | 9 #include <limits> |
| 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/android/jni_android.h" | 12 #include "base/android/jni_android.h" |
| 13 #include "base/android/jni_string.h" | 13 #include "base/android/jni_string.h" |
| 14 #include "base/barrier_closure.h" | 14 #include "base/barrier_closure.h" |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/bind_helpers.h" | 16 #include "base/bind_helpers.h" |
| 17 #include "base/callback_helpers.h" | 17 #include "base/callback_helpers.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/trace_event/trace_event.h" | 21 #include "base/trace_event/trace_event.h" |
| 22 #include "media/base/android/audio_decoder_job.h" | 22 #include "media/base/android/audio_decoder_job.h" |
| 23 #include "media/base/android/media_player_manager.h" | 23 #include "media/base/android/media_player_manager.h" |
| 24 #include "media/base/android/video_decoder_job.h" | 24 #include "media/base/android/video_decoder_job.h" |
| 25 #include "media/base/bind_to_current_loop.h" | 25 #include "media/base/bind_to_current_loop.h" |
| 26 #include "media/base/timestamp_constants.h" | 26 #include "media/base/timestamp_constants.h" |
| 27 | 27 |
| 28 namespace media { | 28 namespace media { |
| 29 | 29 |
| 30 MediaSourcePlayer::MediaSourcePlayer( | 30 MediaSourcePlayer::MediaSourcePlayer( |
| 31 int player_id, | 31 int player_id, |
| 32 MediaPlayerManager* manager, | 32 MediaPlayerManager* manager, |
| 33 const OnDecoderResourcesReleasedCB& on_decoder_resources_released_cb, | 33 const OnDecoderResourcesReleasedCB& on_decoder_resources_released_cb, |
| 34 scoped_ptr<DemuxerAndroid> demuxer, | 34 scoped_ptr<DemuxerAndroid> demuxer, |
| 35 const GURL& frame_url) | 35 const GURL& frame_url) |
| 36 : MediaPlayerAndroid(player_id, | 36 : MediaPlayerAndroid(player_id, |
| 37 manager, | 37 manager, |
| 38 on_decoder_resources_released_cb, | 38 on_decoder_resources_released_cb, |
| 39 frame_url), | 39 frame_url), |
| 40 demuxer_(demuxer.Pass()), | 40 demuxer_(std::move(demuxer)), |
| 41 pending_event_(NO_EVENT_PENDING), | 41 pending_event_(NO_EVENT_PENDING), |
| 42 playing_(false), | 42 playing_(false), |
| 43 interpolator_(&default_tick_clock_), | 43 interpolator_(&default_tick_clock_), |
| 44 doing_browser_seek_(false), | 44 doing_browser_seek_(false), |
| 45 pending_seek_(false), | 45 pending_seek_(false), |
| 46 cdm_registration_id_(0), | 46 cdm_registration_id_(0), |
| 47 is_waiting_for_key_(false), | 47 is_waiting_for_key_(false), |
| 48 key_added_while_decode_pending_(false), | 48 key_added_while_decode_pending_(false), |
| 49 is_waiting_for_audio_decoder_(false), | 49 is_waiting_for_audio_decoder_(false), |
| 50 is_waiting_for_video_decoder_(false), | 50 is_waiting_for_video_decoder_(false), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 75 DCHECK_EQ(!cdm_, !cdm_registration_id_); | 75 DCHECK_EQ(!cdm_, !cdm_registration_id_); |
| 76 if (cdm_) { | 76 if (cdm_) { |
| 77 static_cast<MediaDrmBridge*>(cdm_.get()) | 77 static_cast<MediaDrmBridge*>(cdm_.get()) |
| 78 ->UnregisterPlayer(cdm_registration_id_); | 78 ->UnregisterPlayer(cdm_registration_id_); |
| 79 cdm_registration_id_ = 0; | 79 cdm_registration_id_ = 0; |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 void MediaSourcePlayer::SetVideoSurface(gfx::ScopedJavaSurface surface) { | 83 void MediaSourcePlayer::SetVideoSurface(gfx::ScopedJavaSurface surface) { |
| 84 DVLOG(1) << __FUNCTION__; | 84 DVLOG(1) << __FUNCTION__; |
| 85 if (!video_decoder_job_->SetVideoSurface(surface.Pass())) | 85 if (!video_decoder_job_->SetVideoSurface(std::move(surface))) |
| 86 return; | 86 return; |
| 87 // Retry video decoder creation. | 87 // Retry video decoder creation. |
| 88 RetryDecoderCreation(false, true); | 88 RetryDecoderCreation(false, true); |
| 89 } | 89 } |
| 90 | 90 |
| 91 void MediaSourcePlayer::ScheduleSeekEventAndStopDecoding( | 91 void MediaSourcePlayer::ScheduleSeekEventAndStopDecoding( |
| 92 base::TimeDelta seek_time) { | 92 base::TimeDelta seek_time) { |
| 93 DVLOG(1) << __FUNCTION__ << "(" << seek_time.InSecondsF() << ")"; | 93 DVLOG(1) << __FUNCTION__ << "(" << seek_time.InSecondsF() << ")"; |
| 94 DCHECK(!IsEventPending(SEEK_EVENT_PENDING)); | 94 DCHECK(!IsEventPending(SEEK_EVENT_PENDING)); |
| 95 | 95 |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 is_waiting_for_key_ = false; | 848 is_waiting_for_key_ = false; |
| 849 key_added_while_decode_pending_ = false; | 849 key_added_while_decode_pending_ = false; |
| 850 | 850 |
| 851 // StartInternal() will trigger a prefetch, where in most cases we'll just | 851 // StartInternal() will trigger a prefetch, where in most cases we'll just |
| 852 // use previously received data. | 852 // use previously received data. |
| 853 if (playing_) | 853 if (playing_) |
| 854 StartInternal(); | 854 StartInternal(); |
| 855 } | 855 } |
| 856 | 856 |
| 857 } // namespace media | 857 } // namespace media |
| OLD | NEW |