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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // Overridden in MediaCodecPlayer to pass data between threads. | 91 // Overridden in MediaCodecPlayer to pass data between threads. |
92 virtual void OnMediaMetadataChanged(base::TimeDelta duration, | 92 virtual void OnMediaMetadataChanged(base::TimeDelta duration, |
93 const gfx::Size& video_size) {} | 93 const gfx::Size& video_size) {} |
94 | 94 |
95 // Overridden in MediaCodecPlayer to pass data between threads. | 95 // Overridden in MediaCodecPlayer to pass data between threads. |
96 virtual void OnTimeUpdate(base::TimeDelta current_timestamp, | 96 virtual void OnTimeUpdate(base::TimeDelta current_timestamp, |
97 base::TimeTicks current_time_ticks) {} | 97 base::TimeTicks current_time_ticks) {} |
98 | 98 |
99 int player_id() { return player_id_; } | 99 int player_id() { return player_id_; } |
100 | 100 |
| 101 int session_id() { return session_id_; } |
| 102 |
101 GURL frame_url() { return frame_url_; } | 103 GURL frame_url() { return frame_url_; } |
102 | 104 |
103 // Attach/Detaches |listener_| for listening to all the media events. If | 105 // Attach/Detaches |listener_| for listening to all the media events. If |
104 // |j_media_player| is NULL, |listener_| only listens to the system media | 106 // |j_media_player| is NULL, |listener_| only listens to the system media |
105 // events. Otherwise, it also listens to the events from |j_media_player|. | 107 // events. Otherwise, it also listens to the events from |j_media_player|. |
106 void AttachListener(jobject j_media_player); | 108 void AttachListener(jobject j_media_player); |
107 void DetachListener(); | 109 void DetachListener(); |
108 | 110 |
109 protected: | 111 protected: |
110 MediaPlayerAndroid( | 112 MediaPlayerAndroid( |
111 int player_id, | 113 int player_id, |
112 MediaPlayerManager* manager, | 114 MediaPlayerManager* manager, |
113 const OnDecoderResourcesReleasedCB& on_decoder_resources_released_cb, | 115 const OnDecoderResourcesReleasedCB& on_decoder_resources_released_cb, |
114 const GURL& frame_url); | 116 const GURL& frame_url, |
| 117 int session_id); |
115 | 118 |
116 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to | 119 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to |
117 // media interrupt events. And have a separate child class to listen to all | 120 // media interrupt events. And have a separate child class to listen to all |
118 // the events needed by MediaPlayerBridge. http://crbug.com/422597. | 121 // the events needed by MediaPlayerBridge. http://crbug.com/422597. |
119 // MediaPlayerListener callbacks. | 122 // MediaPlayerListener callbacks. |
120 virtual void OnVideoSizeChanged(int width, int height); | 123 virtual void OnVideoSizeChanged(int width, int height); |
121 virtual void OnMediaError(int error_type); | 124 virtual void OnMediaError(int error_type); |
122 virtual void OnBufferingUpdate(int percent); | 125 virtual void OnBufferingUpdate(int percent); |
123 virtual void OnPlaybackComplete(); | 126 virtual void OnPlaybackComplete(); |
124 virtual void OnMediaInterrupted(); | 127 virtual void OnMediaInterrupted(); |
(...skipping 23 matching lines...) Expand all Loading... |
148 // Url for the frame that contains this player. | 151 // Url for the frame that contains this player. |
149 GURL frame_url_; | 152 GURL frame_url_; |
150 | 153 |
151 // Listener object that listens to all the media player events. | 154 // Listener object that listens to all the media player events. |
152 scoped_ptr<MediaPlayerListener> listener_; | 155 scoped_ptr<MediaPlayerListener> listener_; |
153 | 156 |
154 // Weak pointer passed to |listener_| for callbacks. | 157 // Weak pointer passed to |listener_| for callbacks. |
155 // NOTE: Weak pointers must be invalidated before all other member variables. | 158 // NOTE: Weak pointers must be invalidated before all other member variables. |
156 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; | 159 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; |
157 | 160 |
| 161 // Media session ID assigned to this player |
| 162 int session_id_; |
| 163 |
158 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); | 164 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); |
159 }; | 165 }; |
160 | 166 |
161 } // namespace media | 167 } // namespace media |
162 | 168 |
163 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ | 169 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ |
OLD | NEW |