| OLD | NEW |
| 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_PLAYER_ANDROID_H_ | 5 #ifndef MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ |
| 6 #define MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ | 6 #define MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 const gfx::Size& video_size) {} | 101 const gfx::Size& video_size) {} |
| 102 | 102 |
| 103 // Overridden in MediaCodecPlayer to pass data between threads. | 103 // Overridden in MediaCodecPlayer to pass data between threads. |
| 104 virtual void OnTimeUpdate(base::TimeDelta current_timestamp, | 104 virtual void OnTimeUpdate(base::TimeDelta current_timestamp, |
| 105 base::TimeTicks current_time_ticks) {} | 105 base::TimeTicks current_time_ticks) {} |
| 106 | 106 |
| 107 int player_id() { return player_id_; } | 107 int player_id() { return player_id_; } |
| 108 | 108 |
| 109 GURL frame_url() { return frame_url_; } | 109 GURL frame_url() { return frame_url_; } |
| 110 | 110 |
| 111 int media_session_id() { return media_session_id_; } |
| 112 |
| 111 // Attach/Detaches |listener_| for listening to all the media events. If | 113 // Attach/Detaches |listener_| for listening to all the media events. If |
| 112 // |j_media_player| is NULL, |listener_| only listens to the system media | 114 // |j_media_player| is NULL, |listener_| only listens to the system media |
| 113 // events. Otherwise, it also listens to the events from |j_media_player|. | 115 // events. Otherwise, it also listens to the events from |j_media_player|. |
| 114 void AttachListener(jobject j_media_player); | 116 void AttachListener(jobject j_media_player); |
| 115 void DetachListener(); | 117 void DetachListener(); |
| 116 | 118 |
| 117 protected: | 119 protected: |
| 118 MediaPlayerAndroid( | 120 MediaPlayerAndroid( |
| 119 int player_id, | 121 int player_id, |
| 120 MediaPlayerManager* manager, | 122 MediaPlayerManager* manager, |
| 121 const OnDecoderResourcesReleasedCB& on_decoder_resources_released_cb, | 123 const OnDecoderResourcesReleasedCB& on_decoder_resources_released_cb, |
| 122 const GURL& frame_url); | 124 const GURL& frame_url, |
| 125 int media_session_id); |
| 123 | 126 |
| 124 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to | 127 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to |
| 125 // media interrupt events. And have a separate child class to listen to all | 128 // media interrupt events. And have a separate child class to listen to all |
| 126 // the events needed by MediaPlayerBridge. http://crbug.com/422597. | 129 // the events needed by MediaPlayerBridge. http://crbug.com/422597. |
| 127 // MediaPlayerListener callbacks. | 130 // MediaPlayerListener callbacks. |
| 128 virtual void OnVideoSizeChanged(int width, int height); | 131 virtual void OnVideoSizeChanged(int width, int height); |
| 129 virtual void OnMediaError(int error_type); | 132 virtual void OnMediaError(int error_type); |
| 130 virtual void OnBufferingUpdate(int percent); | 133 virtual void OnBufferingUpdate(int percent); |
| 131 virtual void OnPlaybackComplete(); | 134 virtual void OnPlaybackComplete(); |
| 132 virtual void OnMediaInterrupted(); | 135 virtual void OnMediaInterrupted(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 163 // should be a cached version of the MediaSession volume multiplier, | 166 // should be a cached version of the MediaSession volume multiplier, |
| 164 // and should keep updated. | 167 // and should keep updated. |
| 165 double volume_multiplier_; | 168 double volume_multiplier_; |
| 166 | 169 |
| 167 // Resource manager for all the media players. | 170 // Resource manager for all the media players. |
| 168 MediaPlayerManager* manager_; | 171 MediaPlayerManager* manager_; |
| 169 | 172 |
| 170 // Url for the frame that contains this player. | 173 // Url for the frame that contains this player. |
| 171 GURL frame_url_; | 174 GURL frame_url_; |
| 172 | 175 |
| 176 // Media session ID assigned to this player. |
| 177 int media_session_id_; |
| 178 |
| 173 // Listener object that listens to all the media player events. | 179 // Listener object that listens to all the media player events. |
| 174 scoped_ptr<MediaPlayerListener> listener_; | 180 scoped_ptr<MediaPlayerListener> listener_; |
| 175 | 181 |
| 176 // Weak pointer passed to |listener_| for callbacks. | 182 // Weak pointer passed to |listener_| for callbacks. |
| 177 // NOTE: Weak pointers must be invalidated before all other member variables. | 183 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 178 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; | 184 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; |
| 179 | 185 |
| 180 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); | 186 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); |
| 181 }; | 187 }; |
| 182 | 188 |
| 183 } // namespace media | 189 } // namespace media |
| 184 | 190 |
| 185 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ | 191 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ |
| OLD | NEW |