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

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

Issue 196133020: Reducing the IPC latency for MSE video decoding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix clang warning 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 MediaPlayerManager* manager, 43 MediaPlayerManager* manager,
44 const RequestMediaResourcesCB& request_media_resources_cb, 44 const RequestMediaResourcesCB& request_media_resources_cb,
45 const ReleaseMediaResourcesCB& release_media_resources_cb, 45 const ReleaseMediaResourcesCB& release_media_resources_cb,
46 scoped_ptr<DemuxerAndroid> demuxer); 46 scoped_ptr<DemuxerAndroid> demuxer);
47 virtual ~MediaSourcePlayer(); 47 virtual ~MediaSourcePlayer();
48 48
49 // MediaPlayerAndroid implementation. 49 // MediaPlayerAndroid implementation.
50 virtual void SetVideoSurface(gfx::ScopedJavaSurface surface) OVERRIDE; 50 virtual void SetVideoSurface(gfx::ScopedJavaSurface surface) OVERRIDE;
51 virtual void Start() OVERRIDE; 51 virtual void Start() OVERRIDE;
52 virtual void Pause(bool is_media_related_action ALLOW_UNUSED) OVERRIDE; 52 virtual void Pause(bool is_media_related_action ALLOW_UNUSED) OVERRIDE;
53 virtual void SeekTo(const base::TimeDelta& timestamp) OVERRIDE; 53 virtual void SeekTo(base::TimeDelta timestamp) OVERRIDE;
54 virtual void Release() OVERRIDE; 54 virtual void Release() OVERRIDE;
55 virtual void SetVolume(double volume) OVERRIDE; 55 virtual void SetVolume(double volume) OVERRIDE;
56 virtual int GetVideoWidth() OVERRIDE; 56 virtual int GetVideoWidth() OVERRIDE;
57 virtual int GetVideoHeight() OVERRIDE; 57 virtual int GetVideoHeight() OVERRIDE;
58 virtual base::TimeDelta GetCurrentTime() OVERRIDE; 58 virtual base::TimeDelta GetCurrentTime() OVERRIDE;
59 virtual base::TimeDelta GetDuration() OVERRIDE; 59 virtual base::TimeDelta GetDuration() OVERRIDE;
60 virtual bool IsPlaying() OVERRIDE; 60 virtual bool IsPlaying() OVERRIDE;
61 virtual bool CanPause() OVERRIDE; 61 virtual bool CanPause() OVERRIDE;
62 virtual bool CanSeekForward() OVERRIDE; 62 virtual bool CanSeekForward() OVERRIDE;
63 virtual bool CanSeekBackward() OVERRIDE; 63 virtual bool CanSeekBackward() OVERRIDE;
64 virtual bool IsPlayerReady() OVERRIDE; 64 virtual bool IsPlayerReady() OVERRIDE;
65 virtual void SetDrmBridge(MediaDrmBridge* drm_bridge) OVERRIDE; 65 virtual void SetDrmBridge(MediaDrmBridge* drm_bridge) OVERRIDE;
66 virtual void OnKeyAdded() OVERRIDE; 66 virtual void OnKeyAdded() OVERRIDE;
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 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; 77 friend class MediaSourcePlayerTest;
78 78
79 // Update the current timestamp. 79 // Update the current timestamp.
80 void UpdateTimestamps(const base::TimeDelta& presentation_timestamp, 80 void UpdateTimestamps(base::TimeDelta presentation_timestamp,
81 size_t audio_output_bytes); 81 size_t audio_output_bytes);
82 82
83 // Helper function for starting media playback. 83 // Helper function for starting media playback.
84 void StartInternal(); 84 void StartInternal();
85 85
86 // Playback is completed for one channel. 86 // Playback is completed for one channel.
87 void PlaybackCompleted(bool is_audio); 87 void PlaybackCompleted(bool is_audio);
88 88
89 // Called when the decoder finishes its task. 89 // Called when the decoder finishes its task.
90 void MediaDecoderCallback( 90 void MediaDecoderCallback(
91 bool is_audio, MediaCodecStatus status, 91 bool is_audio, MediaCodecStatus status,
92 const base::TimeDelta& presentation_timestamp, 92 base::TimeDelta presentation_timestamp,
93 size_t audio_output_bytes); 93 size_t audio_output_bytes);
94 94
95 // Gets MediaCrypto object from |drm_bridge_|. 95 // Gets MediaCrypto object from |drm_bridge_|.
96 base::android::ScopedJavaLocalRef<jobject> GetMediaCrypto(); 96 base::android::ScopedJavaLocalRef<jobject> GetMediaCrypto();
97 97
98 // Callback to notify that MediaCrypto is ready in |drm_bridge_|. 98 // Callback to notify that MediaCrypto is ready in |drm_bridge_|.
99 void OnMediaCryptoReady(); 99 void OnMediaCryptoReady();
100 100
101 // Handle pending events if all the decoder jobs are not currently decoding. 101 // Handle pending events if all the decoder jobs are not currently decoding.
102 void ProcessPendingEvents(); 102 void ProcessPendingEvents();
103 103
104 // Helper method to clear any pending |SURFACE_CHANGE_EVENT_PENDING| 104 // Helper method to clear any pending |SURFACE_CHANGE_EVENT_PENDING|
105 // and reset |video_decoder_job_| to null. 105 // and reset |video_decoder_job_| to null.
106 void ResetVideoDecoderJob(); 106 void ResetVideoDecoderJob();
107 void ResetAudioDecoderJob();
107 108
108 // Helper methods to configure the decoder jobs. 109 // Helper methods to configure the decoder jobs.
109 void ConfigureVideoDecoderJob(); 110 void ConfigureVideoDecoderJob();
110 void ConfigureAudioDecoderJob(); 111 void ConfigureAudioDecoderJob();
111 112
112 // Flush the decoders and clean up all the data needs to be decoded. 113 // Flush the decoders and clean up all the data needs to be decoded.
113 void ClearDecodingData(); 114 void ClearDecodingData();
114 115
115 // Called to decode more data. 116 // Called to decode more data.
116 void DecodeMoreAudio(); 117 void DecodeMoreAudio();
(...skipping 11 matching lines...) Expand all
128 // Determine seekability based on duration. 129 // Determine seekability based on duration.
129 bool Seekable(); 130 bool Seekable();
130 131
131 // Called when the |decoder_starvation_callback_| times out. 132 // Called when the |decoder_starvation_callback_| times out.
132 void OnDecoderStarved(); 133 void OnDecoderStarved();
133 134
134 // Starts the |decoder_starvation_callback_| task with the timeout value. 135 // Starts the |decoder_starvation_callback_| task with the timeout value.
135 // |presentation_timestamp| - The presentation timestamp used for starvation 136 // |presentation_timestamp| - The presentation timestamp used for starvation
136 // timeout computations. It represents the timestamp of the last piece of 137 // timeout computations. It represents the timestamp of the last piece of
137 // decoded data. 138 // decoded data.
138 void StartStarvationCallback(const base::TimeDelta& presentation_timestamp); 139 void StartStarvationCallback(base::TimeDelta presentation_timestamp);
139 140
140 // Schedules a seek event in |pending_events_| and calls StopDecode() on all 141 // Schedules a seek event in |pending_events_| and calls StopDecode() on all
141 // the MediaDecoderJobs. Sets clock to |seek_time|, and resets 142 // the MediaDecoderJobs. Sets clock to |seek_time|, and resets
142 // |pending_seek_|. There must not already be a seek event in 143 // |pending_seek_|. There must not already be a seek event in
143 // |pending_events_|. 144 // |pending_events_|.
144 void ScheduleSeekEventAndStopDecoding(const base::TimeDelta& seek_time); 145 void ScheduleSeekEventAndStopDecoding(base::TimeDelta seek_time);
145 146
146 // Schedules a browser seek event. We must not currently be processing any 147 // Schedules a browser seek event. We must not currently be processing any
147 // seek. Note that there is possibility that browser seek of renderer demuxer 148 // seek. Note that there is possibility that browser seek of renderer demuxer
148 // may unexpectedly stall due to lack of buffered data at or after the browser 149 // may unexpectedly stall due to lack of buffered data at or after the browser
149 // seek time. 150 // seek time.
150 // TODO(wolenetz): Instead of doing hack browser seek, replay cached data 151 // TODO(wolenetz): Instead of doing hack browser seek, replay cached data
151 // since last keyframe. See http://crbug.com/304234. 152 // since last keyframe. See http://crbug.com/304234.
152 void BrowserSeekToCurrentTime(); 153 void BrowserSeekToCurrentTime();
153 154
154 // Helper function to set the volume. 155 // Helper function to set the volume.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // the player should pause. When a new key is added (OnKeyAdded()), we should 275 // the player should pause. When a new key is added (OnKeyAdded()), we should
275 // try to start playback again. 276 // try to start playback again.
276 bool is_waiting_for_key_; 277 bool is_waiting_for_key_;
277 278
278 // Test-only callback for hooking the completion of the next decode cycle. 279 // Test-only callback for hooking the completion of the next decode cycle.
279 base::Closure decode_callback_for_testing_; 280 base::Closure decode_callback_for_testing_;
280 281
281 // Whether |surface_| is currently used by the player. 282 // Whether |surface_| is currently used by the player.
282 bool is_surface_in_use_; 283 bool is_surface_in_use_;
283 284
285 // Whether there are pending data requests by the decoder.
286 bool has_pending_audio_data_request_;
287 bool has_pending_video_data_request_;
288
284 // Weak pointer passed to media decoder jobs for callbacks. 289 // Weak pointer passed to media decoder jobs for callbacks.
285 // NOTE: Weak pointers must be invalidated before all other member variables. 290 // NOTE: Weak pointers must be invalidated before all other member variables.
286 base::WeakPtrFactory<MediaSourcePlayer> weak_factory_; 291 base::WeakPtrFactory<MediaSourcePlayer> weak_factory_;
287 292
288 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer); 293 DISALLOW_COPY_AND_ASSIGN(MediaSourcePlayer);
289 }; 294 };
290 295
291 } // namespace media 296 } // namespace media
292 297
293 #endif // MEDIA_BASE_ANDROID_MEDIA_SOURCE_PLAYER_H_ 298 #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