| 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> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 class VideoDecoderJob; | 30 class VideoDecoderJob; |
| 31 class AudioDecoderJob; | 31 class AudioDecoderJob; |
| 32 | 32 |
| 33 // Class for managing all the decoding tasks. Each decoding task will be posted | 33 // Class for managing all the decoding tasks. Each decoding task will be posted |
| 34 // onto the same thread. The thread will be stopped once Stop() is called. | 34 // onto the same thread. The thread will be stopped once Stop() is called. |
| 35 class MediaDecoderJob { | 35 class MediaDecoderJob { |
| 36 public: | 36 public: |
| 37 virtual ~MediaDecoderJob(); | 37 virtual ~MediaDecoderJob(); |
| 38 | 38 |
| 39 // Callback when a decoder job finishes its work. Args: presentation time, | 39 // Callback when a decoder job finishes its work. Args: whether decode |
| 40 // timestamp when the data is rendered, whether decoder is reaching EOS. | 40 // finished successfully, presentation time, timestamp when the data is |
| 41 typedef base::Callback<void(const base::TimeDelta&, const base::Time&, bool)> | 41 // rendered, whether decoder is reaching EOS. |
| 42 DecoderCallback; | 42 typedef base::Callback<void(bool, const base::TimeDelta&, |
| 43 const base::Time&, bool)> DecoderCallback; |
| 43 | 44 |
| 44 // Called by MediaSourcePlayer to decode some data. | 45 // Called by MediaSourcePlayer to decode some data. |
| 45 void Decode( | 46 void Decode( |
| 46 const MediaPlayerHostMsg_ReadFromDemuxerAck_Params::AccessUnit& unit, | 47 const MediaPlayerHostMsg_ReadFromDemuxerAck_Params::AccessUnit& unit, |
| 47 const base::Time& start_wallclock_time, | 48 const base::Time& start_wallclock_time, |
| 48 const base::TimeDelta& start_presentation_timestamp, | 49 const base::TimeDelta& start_presentation_timestamp, |
| 49 const MediaDecoderJob::DecoderCallback& callback); | 50 const MediaDecoderJob::DecoderCallback& callback); |
| 50 | 51 |
| 51 // Flush the decoder. | 52 // Flush the decoder. |
| 52 void Flush(); | 53 void Flush(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 const base::Time& wallclock_time); | 149 const base::Time& wallclock_time); |
| 149 | 150 |
| 150 // Helper function for starting media playback. | 151 // Helper function for starting media playback. |
| 151 void StartInternal(); | 152 void StartInternal(); |
| 152 | 153 |
| 153 // Playback is completed for one channel. | 154 // Playback is completed for one channel. |
| 154 void PlaybackCompleted(bool is_audio); | 155 void PlaybackCompleted(bool is_audio); |
| 155 | 156 |
| 156 // Called when the decoder finishes its task. | 157 // Called when the decoder finishes its task. |
| 157 void MediaDecoderCallback( | 158 void MediaDecoderCallback( |
| 158 bool is_audio, const base::TimeDelta& presentation_timestamp, | 159 bool is_audio, bool decode_succeeded, |
| 160 const base::TimeDelta& presentation_timestamp, |
| 159 const base::Time& wallclock_time, bool end_of_stream); | 161 const base::Time& wallclock_time, bool end_of_stream); |
| 160 | 162 |
| 161 // Handle pending events when all the decoder jobs finished. | 163 // Handle pending events when all the decoder jobs finished. |
| 162 void ProcessPendingEvents(); | 164 void ProcessPendingEvents(); |
| 163 | 165 |
| 164 // Flush the decoders and clean up all the data needs to be decoded. | 166 // Flush the decoders and clean up all the data needs to be decoded. |
| 165 void ClearDecodingData(); | 167 void ClearDecodingData(); |
| 166 | 168 |
| 167 // Called to decoder more data. | 169 // Called to decoder more data. |
| 168 void DecodeMoreAudio(); | 170 void DecodeMoreAudio(); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 228 |
| 227 // Weak pointer passed to media decoder jobs for callbacks. | 229 // Weak pointer passed to media decoder jobs for callbacks. |
| 228 base::WeakPtrFactory<MediaSourcePlayer> weak_this_; | 230 base::WeakPtrFactory<MediaSourcePlayer> weak_this_; |
| 229 | 231 |
| 230 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer); | 232 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer); |
| 231 }; | 233 }; |
| 232 | 234 |
| 233 } // namespace media | 235 } // namespace media |
| 234 | 236 |
| 235 #endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ | 237 #endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ |
| OLD | NEW |