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

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

Issue 193303002: WeakPtr destruction order cleanup: media edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 9 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
« no previous file with comments | « media/base/android/media_player_bridge.cc ('k') | media/base/android/media_source_player.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 virtual bool IsSurfaceInUse() const OVERRIDE; 67 virtual bool IsSurfaceInUse() const OVERRIDE;
68 68
69 // DemuxerAndroidClient implementation. 69 // DemuxerAndroidClient implementation.
70 virtual void OnDemuxerConfigsAvailable(const DemuxerConfigs& params) OVERRIDE; 70 virtual void OnDemuxerConfigsAvailable(const DemuxerConfigs& params) OVERRIDE;
71 virtual void OnDemuxerDataAvailable(const DemuxerData& params) OVERRIDE; 71 virtual void OnDemuxerDataAvailable(const DemuxerData& params) OVERRIDE;
72 virtual void OnDemuxerSeekDone( 72 virtual void OnDemuxerSeekDone(
73 const base::TimeDelta& actual_browser_seek_time) OVERRIDE; 73 const base::TimeDelta& actual_browser_seek_time) OVERRIDE;
74 virtual void OnDemuxerDurationChanged(base::TimeDelta duration) OVERRIDE; 74 virtual void OnDemuxerDurationChanged(base::TimeDelta duration) OVERRIDE;
75 75
76 private: 76 private:
77 friend class MediaSourcePlayerTest;
78
77 // Update the current timestamp. 79 // Update the current timestamp.
78 void UpdateTimestamps(const base::TimeDelta& presentation_timestamp, 80 void UpdateTimestamps(const base::TimeDelta& presentation_timestamp,
79 size_t audio_output_bytes); 81 size_t audio_output_bytes);
80 82
81 // Helper function for starting media playback. 83 // Helper function for starting media playback.
82 void StartInternal(); 84 void StartInternal();
83 85
84 // Playback is completed for one channel. 86 // Playback is completed for one channel.
85 void PlaybackCompleted(bool is_audio); 87 void PlaybackCompleted(bool is_audio);
86 88
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 base::TimeDelta preroll_timestamp_; 261 base::TimeDelta preroll_timestamp_;
260 262
261 // A cancelable task that is posted when the audio decoder starts requesting 263 // A cancelable task that is posted when the audio decoder starts requesting
262 // new data. This callback runs if no data arrives before the timeout period 264 // new data. This callback runs if no data arrives before the timeout period
263 // elapses. 265 // elapses.
264 base::CancelableClosure decoder_starvation_callback_; 266 base::CancelableClosure decoder_starvation_callback_;
265 267
266 // Object to calculate the current audio timestamp for A/V sync. 268 // Object to calculate the current audio timestamp for A/V sync.
267 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_; 269 scoped_ptr<AudioTimestampHelper> audio_timestamp_helper_;
268 270
269 // Weak pointer passed to media decoder jobs for callbacks.
270 base::WeakPtrFactory<MediaSourcePlayer> weak_this_;
271
272 MediaDrmBridge* drm_bridge_; 271 MediaDrmBridge* drm_bridge_;
273 272
274 // No decryption key available to decrypt the encrypted buffer. In this case, 273 // No decryption key available to decrypt the encrypted buffer. In this case,
275 // the player should pause. When a new key is added (OnKeyAdded()), we should 274 // the player should pause. When a new key is added (OnKeyAdded()), we should
276 // try to start playback again. 275 // try to start playback again.
277 bool is_waiting_for_key_; 276 bool is_waiting_for_key_;
278 277
279 // Test-only callback for hooking the completion of the next decode cycle. 278 // Test-only callback for hooking the completion of the next decode cycle.
280 base::Closure decode_callback_for_testing_; 279 base::Closure decode_callback_for_testing_;
281 280
282 // Whether |surface_| is currently used by the player. 281 // Whether |surface_| is currently used by the player.
283 bool is_surface_in_use_; 282 bool is_surface_in_use_;
284 283
285 friend class MediaSourcePlayerTest; 284 // Weak pointer passed to media decoder jobs for callbacks.
285 // NOTE: Weak pointers must be invalidated before all other member variables.
286 base::WeakPtrFactory<MediaSourcePlayer> weak_factory_;
287
286 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer); 288 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer);
287 }; 289 };
288 290
289 } // namespace media 291 } // namespace media
290 292
291 #endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ 293 #endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_
OLDNEW
« no previous file with comments | « media/base/android/media_player_bridge.cc ('k') | media/base/android/media_source_player.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698