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

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

Issue 1372203002: Throttle media decoding after excessive Android media server crashes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_CODEC_PLAYER_H_ 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_H_
6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_H_ 6 #define MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_H_
7 7
8 #include "base/android/scoped_java_ref.h" 8 #include "base/android/scoped_java_ref.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // For testing only. 160 // For testing only.
161 typedef base::Callback<void(DemuxerStream::Type, 161 typedef base::Callback<void(DemuxerStream::Type,
162 base::TimeDelta, 162 base::TimeDelta,
163 base::TimeDelta)> DecodersTimeCallback; 163 base::TimeDelta)> DecodersTimeCallback;
164 164
165 // For testing only. 165 // For testing only.
166 typedef base::Callback<void(DemuxerStream::Type)> CodecCreatedCallback; 166 typedef base::Callback<void(DemuxerStream::Type)> CodecCreatedCallback;
167 167
168 // Constructs a player with the given ID and demuxer. |manager| must outlive 168 // Constructs a player with the given ID and demuxer. |manager| must outlive
169 // the lifetime of this object. 169 // the lifetime of this object.
170 MediaCodecPlayer(int player_id, 170 MediaCodecPlayer(
171 base::WeakPtr<MediaPlayerManager> manager, 171 int player_id,
172 const RequestMediaResourcesCB& request_media_resources_cb, 172 base::WeakPtr<MediaPlayerManager> manager,
173 scoped_ptr<DemuxerAndroid> demuxer, 173 const OnPlayerReleasedCB& on_player_released_cb,
174 const GURL& frame_url); 174 scoped_ptr<DemuxerAndroid> demuxer,
175 const GURL& frame_url);
175 ~MediaCodecPlayer() override; 176 ~MediaCodecPlayer() override;
176 177
177 // A helper method that performs the media thread part of initialization. 178 // A helper method that performs the media thread part of initialization.
178 void Initialize(); 179 void Initialize();
179 180
180 // MediaPlayerAndroid implementation. 181 // MediaPlayerAndroid implementation.
181 void DeleteOnCorrectThread() override; 182 void DeleteOnCorrectThread() override;
182 void SetVideoSurface(gfx::ScopedJavaSurface surface) override; 183 void SetVideoSurface(gfx::ScopedJavaSurface surface) override;
183 void Start() override; 184 void Start() override;
184 void Pause(bool is_media_related_action) override; 185 void Pause(bool is_media_related_action) override;
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 void OnDecoderDrained(DemuxerStream::Type type); 258 void OnDecoderDrained(DemuxerStream::Type type);
258 void OnStopDone(DemuxerStream::Type type); 259 void OnStopDone(DemuxerStream::Type type);
259 void OnError(); 260 void OnError();
260 void OnStarvation(DemuxerStream::Type stream_type); 261 void OnStarvation(DemuxerStream::Type stream_type);
261 void OnTimeIntervalUpdate(DemuxerStream::Type stream_type, 262 void OnTimeIntervalUpdate(DemuxerStream::Type stream_type,
262 base::TimeDelta now_playing, 263 base::TimeDelta now_playing,
263 base::TimeDelta last_buffered, 264 base::TimeDelta last_buffered,
264 bool postpone); 265 bool postpone);
265 266
266 // Callbacks from video decoder 267 // Callbacks from video decoder
267 void OnVideoCodecCreated();
268 void OnVideoResolutionChanged(const gfx::Size& size); 268 void OnVideoResolutionChanged(const gfx::Size& size);
269 269
270 // Operations called from the state machine. 270 // Operations called from the state machine.
271 void SetState(PlayerState new_state); 271 void SetState(PlayerState new_state);
272 void SetPendingStart(bool need_to_start); 272 void SetPendingStart(bool need_to_start);
273 bool HasPendingStart() const; 273 bool HasPendingStart() const;
274 void SetPendingSeek(base::TimeDelta timestamp); 274 void SetPendingSeek(base::TimeDelta timestamp);
275 base::TimeDelta GetPendingSeek() const; 275 base::TimeDelta GetPendingSeek() const;
276 bool HasVideo() const; 276 bool HasVideo() const;
277 bool HasAudio() const; 277 bool HasAudio() const;
(...skipping 25 matching lines...) Expand all
303 303
304 // Major components: demuxer, audio and video decoders. 304 // Major components: demuxer, audio and video decoders.
305 scoped_ptr<DemuxerAndroid> demuxer_; 305 scoped_ptr<DemuxerAndroid> demuxer_;
306 scoped_ptr<MediaCodecAudioDecoder> audio_decoder_; 306 scoped_ptr<MediaCodecAudioDecoder> audio_decoder_;
307 scoped_ptr<MediaCodecVideoDecoder> video_decoder_; 307 scoped_ptr<MediaCodecVideoDecoder> video_decoder_;
308 308
309 // The state of the state machine. 309 // The state of the state machine.
310 PlayerState state_; 310 PlayerState state_;
311 311
312 // Notification callbacks, they call MediaPlayerManager. 312 // Notification callbacks, they call MediaPlayerManager.
313 base::Closure request_resources_cb_;
314 TimeUpdateCallback time_update_cb_; 313 TimeUpdateCallback time_update_cb_;
315 base::Closure completion_cb_; 314 base::Closure completion_cb_;
316 SeekDoneCallback seek_done_cb_; 315 SeekDoneCallback seek_done_cb_;
317 ErrorCallback error_cb_; 316 ErrorCallback error_cb_;
318 317
319 // A callback that updates metadata cache and calls the manager. 318 // A callback that updates metadata cache and calls the manager.
320 MetadataChangedCallback metadata_changed_cb_; 319 MetadataChangedCallback metadata_changed_cb_;
321 320
322 // We call the base class' AttachListener() and DetachListener() methods on UI 321 // We call the base class' AttachListener() and DetachListener() methods on UI
323 // thread with these callbacks. 322 // thread with these callbacks.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 base::WeakPtr<MediaCodecPlayer> media_weak_this_; 357 base::WeakPtr<MediaCodecPlayer> media_weak_this_;
359 // NOTE: Weak pointers must be invalidated before all other member variables. 358 // NOTE: Weak pointers must be invalidated before all other member variables.
360 base::WeakPtrFactory<MediaCodecPlayer> media_weak_factory_; 359 base::WeakPtrFactory<MediaCodecPlayer> media_weak_factory_;
361 360
362 DISALLOW_COPY_AND_ASSIGN(MediaCodecPlayer); 361 DISALLOW_COPY_AND_ASSIGN(MediaCodecPlayer);
363 }; 362 };
364 363
365 } // namespace media 364 } // namespace media
366 365
367 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_H_ 366 #endif // MEDIA_BASE_ANDROID_MEDIA_CODEC_PLAYER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698