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

Side by Side Diff: media/base/android/media_source_player.h

Issue 15499006: Enable seek in fullscreen mode for MSE impl on android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add CancelPendingSeek() Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 virtual void SetVolume(float leftVolume, float rightVolume) OVERRIDE; 124 virtual void SetVolume(float leftVolume, float rightVolume) OVERRIDE;
125 virtual int GetVideoWidth() OVERRIDE; 125 virtual int GetVideoWidth() OVERRIDE;
126 virtual int GetVideoHeight() OVERRIDE; 126 virtual int GetVideoHeight() OVERRIDE;
127 virtual base::TimeDelta GetCurrentTime() OVERRIDE; 127 virtual base::TimeDelta GetCurrentTime() OVERRIDE;
128 virtual base::TimeDelta GetDuration() OVERRIDE; 128 virtual base::TimeDelta GetDuration() OVERRIDE;
129 virtual bool IsPlaying() OVERRIDE; 129 virtual bool IsPlaying() OVERRIDE;
130 virtual bool CanPause() OVERRIDE; 130 virtual bool CanPause() OVERRIDE;
131 virtual bool CanSeekForward() OVERRIDE; 131 virtual bool CanSeekForward() OVERRIDE;
132 virtual bool CanSeekBackward() OVERRIDE; 132 virtual bool CanSeekBackward() OVERRIDE;
133 virtual bool IsPlayerReady() OVERRIDE; 133 virtual bool IsPlayerReady() OVERRIDE;
134 virtual void OnSeekRequestAck() OVERRIDE;
134 135
135 // Called when the demuxer is ready. 136 // Called when the demuxer is ready.
136 virtual void DemuxerReady( 137 virtual void DemuxerReady(
137 const MediaPlayerHostMsg_DemuxerReady_Params& params) OVERRIDE; 138 const MediaPlayerHostMsg_DemuxerReady_Params& params) OVERRIDE;
138 139
139 // Called when the requested data is received from the demuxer. 140 // Called when the requested data is received from the demuxer.
140 virtual void ReadFromDemuxerAck( 141 virtual void ReadFromDemuxerAck(
141 const MediaPlayerHostMsg_ReadFromDemuxerAck_Params& params) OVERRIDE; 142 const MediaPlayerHostMsg_ReadFromDemuxerAck_Params& params) OVERRIDE;
142 143
143 private: 144 private:
144 // Update the timestamps for A/V sync scheduling. |kickoff_time| keeps 145 // Update the timestamps for A/V sync scheduling.
145 // track of when the job is started. We need this to check if a seek is
146 // performed during decoding.
147 void UpdateTimestamps( 146 void UpdateTimestamps(
148 const base::Time& kickoff_time,
149 const base::TimeDelta& presentation_timestamp, 147 const base::TimeDelta& presentation_timestamp,
150 const base::Time& wallclock_time); 148 const base::Time& wallclock_time);
151 149
152 // Helper function for starting media playback. 150 // Helper function for starting media playback.
153 void StartInternal(); 151 void StartInternal();
154 152
155 // Playback is completed for one channel. 153 // Playback is completed for one channel.
156 void PlaybackCompleted(bool is_audio); 154 void PlaybackCompleted(bool is_audio);
157 155
158 // Called when the decoder finishes its task. 156 // Called when the decoder finishes its task.
159 void MediaDecoderCallback( 157 void MediaDecoderCallback(
160 bool is_audio, const base::Time& kickoff_time, 158 bool is_audio, const base::TimeDelta& presentation_timestamp,
161 const base::TimeDelta& presentation_timestamp,
162 const base::Time& wallclock_time, bool end_of_stream); 159 const base::Time& wallclock_time, bool end_of_stream);
163 160
161 // Handle pending events when all the decoder jobs finished.
162 void ProcessPendingEvents();
163
164 // Flush the decoders and clean up all the data needs to be decoded.
165 void ClearDecodingData();
166
164 // Called to decoder more data. 167 // Called to decoder more data.
165 void DecodeMoreAudio(); 168 void DecodeMoreAudio();
166 void DecodeMoreVideo(); 169 void DecodeMoreVideo();
167 170
168 // Functions check whether audio/video is present. 171 // Functions check whether audio/video is present.
169 bool HasVideo(); 172 bool HasVideo();
170 bool HasAudio(); 173 bool HasAudio();
171 174
172 // Pending play event while player is preparing. 175 enum PendingEventFlags {
173 bool pending_play_; 176 NO_EVENT_PENDING = 0,
177 SEEK_EVENT_PENDING = 1 << 0,
178 SURFACE_CHANGE_EVENT_PENDING = 1 << 1,
179 };
180 // Pending event that the player needs to do.
181 unsigned pending_event_;
182
183 // Number of active decoding tasks.
184 int active_decoding_tasks_;
174 185
175 // Stats about the media. 186 // Stats about the media.
176 base::TimeDelta duration_; 187 base::TimeDelta duration_;
177 int width_; 188 int width_;
178 int height_; 189 int height_;
179 AudioCodec audio_codec_; 190 AudioCodec audio_codec_;
180 VideoCodec video_codec_; 191 VideoCodec video_codec_;
181 int num_channels_; 192 int num_channels_;
182 int sampling_rate_; 193 int sampling_rate_;
183 bool seekable_; 194 bool seekable_;
184 base::TimeDelta last_presentation_timestamp_; 195 base::TimeDelta last_presentation_timestamp_;
185 std::vector<uint8> audio_extra_data_; 196 std::vector<uint8> audio_extra_data_;
186 bool audio_finished_; 197 bool audio_finished_;
187 bool video_finished_; 198 bool video_finished_;
188 bool playing_; 199 bool playing_;
189 200
190 // Timestamps for providing simple A/V sync. When start decoding an audio 201 // Timestamps for providing simple A/V sync. When start decoding an audio
191 // chunk, we record its presentation timestamp and the current system time. 202 // chunk, we record its presentation timestamp and the current system time.
192 // Then we use this information to estimate when the next audio/video frame 203 // Then we use this information to estimate when the next audio/video frame
193 // should be rendered. 204 // should be rendered.
194 // TODO(qinmin): Need to fix the problem if audio/video lagged too far behind 205 // TODO(qinmin): Need to fix the problem if audio/video lagged too far behind
195 // due to network or decoding problem. 206 // due to network or decoding problem.
196 base::Time start_wallclock_time_; 207 base::Time start_wallclock_time_;
197 base::TimeDelta start_presentation_timestamp_; 208 base::TimeDelta start_presentation_timestamp_;
198 base::Time last_seek_time_;
199 209
200 // Decoder jobs 210 // Decoder jobs
201 ScopedMediaDecoderJob audio_decoder_job_; 211 ScopedMediaDecoderJob audio_decoder_job_;
202 ScopedMediaDecoderJob video_decoder_job_; 212 ScopedMediaDecoderJob video_decoder_job_;
203 213
204 // These variables keep track of the current decoding data. 214 // These variables keep track of the current decoding data.
205 // TODO(qinmin): remove these variables when we no longer relies on IPC for 215 // TODO(qinmin): remove these variables when we no longer relies on IPC for
206 // data passing. 216 // data passing.
207 size_t audio_access_unit_index_; 217 size_t audio_access_unit_index_;
208 size_t video_access_unit_index_; 218 size_t video_access_unit_index_;
209 bool waiting_for_audio_data_; 219 bool waiting_for_audio_data_;
210 bool waiting_for_video_data_; 220 bool waiting_for_video_data_;
211 MediaPlayerHostMsg_ReadFromDemuxerAck_Params received_audio_; 221 MediaPlayerHostMsg_ReadFromDemuxerAck_Params received_audio_;
212 MediaPlayerHostMsg_ReadFromDemuxerAck_Params received_video_; 222 MediaPlayerHostMsg_ReadFromDemuxerAck_Params received_video_;
213 223
224 // Whether the video decoder need to use anempty surface.
225 bool use_empty_surface_;
226
214 // Weak pointer passed to media decoder jobs for callbacks. 227 // Weak pointer passed to media decoder jobs for callbacks.
215 base::WeakPtrFactory<MediaSourcePlayer> weak_this_; 228 base::WeakPtrFactory<MediaSourcePlayer> weak_this_;
216 229
217 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer); 230 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer);
218 }; 231 };
219 232
220 } // namespace media 233 } // namespace media
221 234
222 #endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ 235 #endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698