| 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 #ifndef MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ | 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ |
| 6 #define MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ | 6 #define MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/android/scoped_java_ref.h" | 13 #include "base/android/scoped_java_ref.h" |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/cancelable_callback.h" | 15 #include "base/cancelable_callback.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
| 19 #include "base/time/default_tick_clock.h" | 19 #include "base/time/default_tick_clock.h" |
| 20 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 21 #include "media/base/android/demuxer_android.h" | 21 #include "media/base/android/demuxer_android.h" |
| 22 #include "media/base/android/media_codec_bridge.h" | 22 #include "media/base/android/media_codec_bridge.h" |
| 23 #include "media/base/android/media_decoder_job.h" | 23 #include "media/base/android/media_decoder_job.h" |
| 24 #include "media/base/android/media_drm_bridge.h" | 24 #include "media/base/android/media_drm_bridge.h" |
| 25 #include "media/base/android/media_player_android.h" | 25 #include "media/base/android/media_player_android.h" |
| 26 #include "media/base/clock.h" | |
| 27 #include "media/base/media_export.h" | 26 #include "media/base/media_export.h" |
| 27 #include "media/base/time_delta_interpolator.h" |
| 28 | 28 |
| 29 namespace media { | 29 namespace media { |
| 30 | 30 |
| 31 class AudioDecoderJob; | 31 class AudioDecoderJob; |
| 32 class VideoDecoderJob; | 32 class VideoDecoderJob; |
| 33 | 33 |
| 34 // This class handles media source extensions on Android. It uses Android | 34 // This class handles media source extensions on Android. It uses Android |
| 35 // MediaCodec to decode audio and video streams in two separate threads. | 35 // MediaCodec to decode audio and video streams in two separate threads. |
| 36 class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid, | 36 class MEDIA_EXPORT MediaSourcePlayer : public MediaPlayerAndroid, |
| 37 public DemuxerAndroidClient { | 37 public DemuxerAndroidClient { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 193 |
| 194 scoped_ptr<DemuxerAndroid> demuxer_; | 194 scoped_ptr<DemuxerAndroid> demuxer_; |
| 195 | 195 |
| 196 // Pending event that the player needs to do. | 196 // Pending event that the player needs to do. |
| 197 unsigned pending_event_; | 197 unsigned pending_event_; |
| 198 | 198 |
| 199 // Stats about the media. | 199 // Stats about the media. |
| 200 base::TimeDelta duration_; | 200 base::TimeDelta duration_; |
| 201 bool playing_; | 201 bool playing_; |
| 202 | 202 |
| 203 // base::TickClock used by |clock_|. | 203 // base::TickClock used by |interpolator_|. |
| 204 base::DefaultTickClock default_tick_clock_; | 204 base::DefaultTickClock default_tick_clock_; |
| 205 | 205 |
| 206 // Reference clock. Keeps track of current playback time. | 206 // Tracks the most recent media time update and provides interpolated values |
| 207 Clock clock_; | 207 // as playback progresses. |
| 208 TimeDeltaInterpolator interpolator_; |
| 208 | 209 |
| 209 // Timestamps for providing simple A/V sync. When start decoding an audio | 210 // Timestamps for providing simple A/V sync. When start decoding an audio |
| 210 // chunk, we record its presentation timestamp and the current system time. | 211 // chunk, we record its presentation timestamp and the current system time. |
| 211 // Then we use this information to estimate when the next audio/video frame | 212 // Then we use this information to estimate when the next audio/video frame |
| 212 // should be rendered. | 213 // should be rendered. |
| 213 // TODO(qinmin): Need to fix the problem if audio/video lagged too far behind | 214 // TODO(qinmin): Need to fix the problem if audio/video lagged too far behind |
| 214 // due to network or decoding problem. | 215 // due to network or decoding problem. |
| 215 base::TimeTicks start_time_ticks_; | 216 base::TimeTicks start_time_ticks_; |
| 216 base::TimeDelta start_presentation_timestamp_; | 217 base::TimeDelta start_presentation_timestamp_; |
| 217 | 218 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // NOTE: Weak pointers must be invalidated before all other member variables. | 266 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 266 base::WeakPtrFactory<MediaSourcePlayer> weak_factory_; | 267 base::WeakPtrFactory<MediaSourcePlayer> weak_factory_; |
| 267 base::WeakPtr<MediaSourcePlayer> weak_this_; | 268 base::WeakPtr<MediaSourcePlayer> weak_this_; |
| 268 | 269 |
| 269 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer); | 270 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer); |
| 270 }; | 271 }; |
| 271 | 272 |
| 272 } // namespace media | 273 } // namespace media |
| 273 | 274 |
| 274 #endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ | 275 #endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ |
| OLD | NEW |