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

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

Issue 11348199: Free (and pause) audio resources when getting a phone call (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@input_color
Patch Set: Created 8 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_PLAYER_BRIDGE_H_ 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_
6 #define MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_ 6 #define MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // Callback when buffering has changed. Args: player ID, percentage 49 // Callback when buffering has changed. Args: player ID, percentage
50 // of the media. 50 // of the media.
51 typedef base::Callback<void(int, int)> BufferingUpdateCB; 51 typedef base::Callback<void(int, int)> BufferingUpdateCB;
52 52
53 // Callback when player got prepared. Args: player ID, duration of the media. 53 // Callback when player got prepared. Args: player ID, duration of the media.
54 typedef base::Callback<void(int, base::TimeDelta)> MediaPreparedCB; 54 typedef base::Callback<void(int, base::TimeDelta)> MediaPreparedCB;
55 55
56 // Callbacks when seek completed. Args: player ID, current time. 56 // Callbacks when seek completed. Args: player ID, current time.
57 typedef base::Callback<void(int, base::TimeDelta)> SeekCompleteCB; 57 typedef base::Callback<void(int, base::TimeDelta)> SeekCompleteCB;
58 58
59 // Callbacks when seek completed. Args: player ID
60 typedef base::Callback<void(int)> MediaInterruptedCB;
61
59 // Callbacks when playback completed. Args: player ID. 62 // Callbacks when playback completed. Args: player ID.
60 typedef base::Callback<void(int)> PlaybackCompleteCB; 63 typedef base::Callback<void(int)> PlaybackCompleteCB;
61 64
62 // Callback when time update messages need to be sent. Args: player ID, 65 // Callback when time update messages need to be sent. Args: player ID,
63 // current time. 66 // current time.
64 typedef base::Callback<void(int, base::TimeDelta)> TimeUpdateCB; 67 typedef base::Callback<void(int, base::TimeDelta)> TimeUpdateCB;
65 68
66 static bool RegisterMediaPlayerBridge(JNIEnv* env); 69 static bool RegisterMediaPlayerBridge(JNIEnv* env);
67 70
68 // Construct a MediaPlayerBridge object with all the needed media player 71 // Construct a MediaPlayerBridge object with all the needed media player
69 // callbacks. This object needs to call |manager|'s RequestMediaResources() 72 // callbacks. This object needs to call |manager|'s RequestMediaResources()
70 // before decoding the media stream. This allows |manager| to track 73 // before decoding the media stream. This allows |manager| to track
71 // unused resources and free them when needed. On the other hand, it needs 74 // unused resources and free them when needed. On the other hand, it needs
72 // to call ReleaseMediaResources() when it is done with decoding. 75 // to call ReleaseMediaResources() when it is done with decoding.
73 MediaPlayerBridge(int player_id, 76 MediaPlayerBridge(int player_id,
74 const std::string& url, 77 const std::string& url,
75 const std::string& first_party_for_cookies, 78 const std::string& first_party_for_cookies,
76 CookieGetter* cookie_getter, 79 CookieGetter* cookie_getter,
77 bool hide_url_log, 80 bool hide_url_log,
78 MediaPlayerBridgeManager* manager, 81 MediaPlayerBridgeManager* manager,
79 const MediaErrorCB& media_error_cb, 82 const MediaErrorCB& media_error_cb,
80 const VideoSizeChangedCB& video_size_changed_cb, 83 const VideoSizeChangedCB& video_size_changed_cb,
81 const BufferingUpdateCB& buffering_update_cb, 84 const BufferingUpdateCB& buffering_update_cb,
82 const MediaPreparedCB& media_prepared_cb, 85 const MediaPreparedCB& media_prepared_cb,
83 const PlaybackCompleteCB& playback_complete_cb, 86 const PlaybackCompleteCB& playback_complete_cb,
84 const SeekCompleteCB& seek_complete_cb, 87 const SeekCompleteCB& seek_complete_cb,
85 const TimeUpdateCB& time_update_cb); 88 const TimeUpdateCB& time_update_cb,
89 const MediaInterruptedCB& media_interrupted_cb);
86 ~MediaPlayerBridge(); 90 ~MediaPlayerBridge();
87 91
88 typedef std::map<std::string, std::string> HeadersMap; 92 typedef std::map<std::string, std::string> HeadersMap;
89 93
90 void SetVideoSurface(jobject surface); 94 void SetVideoSurface(jobject surface);
91 95
92 // Start playing the media. 96 // Start playing the media.
93 void Start(); 97 void Start();
94 98
95 // Pause the media. 99 // Pause the media.
(...skipping 24 matching lines...) Expand all
120 void DoTimeUpdate(); 124 void DoTimeUpdate();
121 125
122 // Called by the MediaPlayerListener and mirrored to corresponding 126 // Called by the MediaPlayerListener and mirrored to corresponding
123 // callbacks. 127 // callbacks.
124 void OnMediaError(int error_type); 128 void OnMediaError(int error_type);
125 void OnVideoSizeChanged(int width, int height); 129 void OnVideoSizeChanged(int width, int height);
126 void OnBufferingUpdate(int percent); 130 void OnBufferingUpdate(int percent);
127 void OnPlaybackComplete(); 131 void OnPlaybackComplete();
128 void OnSeekComplete(); 132 void OnSeekComplete();
129 void OnMediaPrepared(); 133 void OnMediaPrepared();
134 void OnMediaInterrupted();
130 135
131 // Prepare the player for playback, asynchronously. When succeeds, 136 // Prepare the player for playback, asynchronously. When succeeds,
132 // OnMediaPrepared() will be called. Otherwise, OnMediaError() will 137 // OnMediaPrepared() will be called. Otherwise, OnMediaError() will
133 // be called with an error type. 138 // be called with an error type.
134 void Prepare(); 139 void Prepare();
135 140
136 // Callback function passed to |cookies_retriever_|. 141 // Callback function passed to |cookies_retriever_|.
137 void GetCookiesCallback(const std::string& cookies); 142 void GetCookiesCallback(const std::string& cookies);
138 143
139 int player_id() { return player_id_; } 144 int player_id() { return player_id_; }
(...skipping 11 matching lines...) Expand all
151 void PauseInternal(); 156 void PauseInternal();
152 void SeekInternal(base::TimeDelta time); 157 void SeekInternal(base::TimeDelta time);
153 158
154 // Callbacks when events are received. 159 // Callbacks when events are received.
155 MediaErrorCB media_error_cb_; 160 MediaErrorCB media_error_cb_;
156 VideoSizeChangedCB video_size_changed_cb_; 161 VideoSizeChangedCB video_size_changed_cb_;
157 BufferingUpdateCB buffering_update_cb_; 162 BufferingUpdateCB buffering_update_cb_;
158 MediaPreparedCB media_prepared_cb_; 163 MediaPreparedCB media_prepared_cb_;
159 PlaybackCompleteCB playback_complete_cb_; 164 PlaybackCompleteCB playback_complete_cb_;
160 SeekCompleteCB seek_complete_cb_; 165 SeekCompleteCB seek_complete_cb_;
166 MediaInterruptedCB media_interrupted_cb_;
161 167
162 // Callbacks when timer events are received. 168 // Callbacks when timer events are received.
163 TimeUpdateCB time_update_cb_; 169 TimeUpdateCB time_update_cb_;
164 170
165 // Player ID assigned to this player. 171 // Player ID assigned to this player.
166 int player_id_; 172 int player_id_;
167 173
168 // Whether the player is prepared for playback. 174 // Whether the player is prepared for playback.
169 bool prepared_; 175 bool prepared_;
170 176
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 221
216 // Listener object that listens to all the media player events. 222 // Listener object that listens to all the media player events.
217 MediaPlayerListener listener_; 223 MediaPlayerListener listener_;
218 224
219 DISALLOW_COPY_AND_ASSIGN(MediaPlayerBridge); 225 DISALLOW_COPY_AND_ASSIGN(MediaPlayerBridge);
220 }; 226 };
221 227
222 } // namespace media 228 } // namespace media
223 229
224 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_ 230 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_BRIDGE_H_
OLDNEW
« no previous file with comments | « media/base/android/java/src/org/chromium/media/MediaPlayerListener.java ('k') | media/base/android/media_player_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698