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 |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "media/base/android/media_player_listener.h" | 15 #include "media/base/android/media_player_listener.h" |
16 #include "media/base/media_export.h" | 16 #include "media/base/media_export.h" |
17 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
18 #include "ui/gl/android/scoped_java_surface.h" | 18 #include "ui/gl/android/scoped_java_surface.h" |
19 #include "url/gurl.h" | 19 #include "url/gurl.h" |
20 | 20 |
21 namespace media { | 21 namespace media { |
22 | 22 |
23 class MediaKeys; | 23 class MediaKeys; |
24 class MediaPlayerManager; | 24 class MediaPlayerManager; |
25 | 25 |
26 // The media session for media elements that don't have an explicit | |
27 // user created media session set. Must be in-sync with | |
28 // WebMediaSession::DefaultID in blink. | |
29 enum { kDefaultMediaSessionID = 0 }; | |
whywhat
2016/03/10 22:34:56
nit: I believe Id is preferred to ID but I don't f
davve
2016/03/11 13:20:29
Done.
| |
30 | |
26 // This class serves as the base class for different media player | 31 // This class serves as the base class for different media player |
27 // implementations on Android. Subclasses need to provide their own | 32 // implementations on Android. Subclasses need to provide their own |
28 // MediaPlayerAndroid::Create() implementation. | 33 // MediaPlayerAndroid::Create() implementation. |
29 class MEDIA_EXPORT MediaPlayerAndroid { | 34 class MEDIA_EXPORT MediaPlayerAndroid { |
30 public: | 35 public: |
31 virtual ~MediaPlayerAndroid(); | 36 virtual ~MediaPlayerAndroid(); |
32 | 37 |
33 // Error types for MediaErrorCB. | 38 // Error types for MediaErrorCB. |
34 enum MediaErrorType { | 39 enum MediaErrorType { |
35 MEDIA_ERROR_FORMAT, | 40 MEDIA_ERROR_FORMAT, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 const gfx::Size& video_size) {} | 106 const gfx::Size& video_size) {} |
102 | 107 |
103 // Overridden in MediaCodecPlayer to pass data between threads. | 108 // Overridden in MediaCodecPlayer to pass data between threads. |
104 virtual void OnTimeUpdate(base::TimeDelta current_timestamp, | 109 virtual void OnTimeUpdate(base::TimeDelta current_timestamp, |
105 base::TimeTicks current_time_ticks) {} | 110 base::TimeTicks current_time_ticks) {} |
106 | 111 |
107 int player_id() { return player_id_; } | 112 int player_id() { return player_id_; } |
108 | 113 |
109 GURL frame_url() { return frame_url_; } | 114 GURL frame_url() { return frame_url_; } |
110 | 115 |
116 int media_session_id() { return media_session_id_; } | |
117 | |
111 // Attach/Detaches |listener_| for listening to all the media events. If | 118 // Attach/Detaches |listener_| for listening to all the media events. If |
112 // |j_media_player| is NULL, |listener_| only listens to the system media | 119 // |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|. | 120 // events. Otherwise, it also listens to the events from |j_media_player|. |
114 void AttachListener(jobject j_media_player); | 121 void AttachListener(jobject j_media_player); |
115 void DetachListener(); | 122 void DetachListener(); |
116 | 123 |
117 protected: | 124 protected: |
118 MediaPlayerAndroid( | 125 MediaPlayerAndroid( |
119 int player_id, | 126 int player_id, |
120 MediaPlayerManager* manager, | 127 MediaPlayerManager* manager, |
121 const OnDecoderResourcesReleasedCB& on_decoder_resources_released_cb, | 128 const OnDecoderResourcesReleasedCB& on_decoder_resources_released_cb, |
122 const GURL& frame_url); | 129 const GURL& frame_url, |
130 int media_session_id); | |
123 | 131 |
124 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to | 132 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to |
125 // media interrupt events. And have a separate child class to listen to all | 133 // media interrupt events. And have a separate child class to listen to all |
126 // the events needed by MediaPlayerBridge. http://crbug.com/422597. | 134 // the events needed by MediaPlayerBridge. http://crbug.com/422597. |
127 // MediaPlayerListener callbacks. | 135 // MediaPlayerListener callbacks. |
128 virtual void OnVideoSizeChanged(int width, int height); | 136 virtual void OnVideoSizeChanged(int width, int height); |
129 virtual void OnMediaError(int error_type); | 137 virtual void OnMediaError(int error_type); |
130 virtual void OnBufferingUpdate(int percent); | 138 virtual void OnBufferingUpdate(int percent); |
131 virtual void OnPlaybackComplete(); | 139 virtual void OnPlaybackComplete(); |
132 virtual void OnMediaInterrupted(); | 140 virtual void OnMediaInterrupted(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 | 174 |
167 // Resource manager for all the media players. | 175 // Resource manager for all the media players. |
168 MediaPlayerManager* manager_; | 176 MediaPlayerManager* manager_; |
169 | 177 |
170 // Url for the frame that contains this player. | 178 // Url for the frame that contains this player. |
171 GURL frame_url_; | 179 GURL frame_url_; |
172 | 180 |
173 // Listener object that listens to all the media player events. | 181 // Listener object that listens to all the media player events. |
174 scoped_ptr<MediaPlayerListener> listener_; | 182 scoped_ptr<MediaPlayerListener> listener_; |
175 | 183 |
184 // Media session ID assigned to this player. | |
185 int media_session_id_; | |
186 | |
176 // Weak pointer passed to |listener_| for callbacks. | 187 // Weak pointer passed to |listener_| for callbacks. |
177 // NOTE: Weak pointers must be invalidated before all other member variables. | 188 // NOTE: Weak pointers must be invalidated before all other member variables. |
178 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; | 189 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; |
179 | 190 |
180 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); | 191 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); |
181 }; | 192 }; |
182 | 193 |
183 } // namespace media | 194 } // namespace media |
184 | 195 |
185 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ | 196 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ |
OLD | NEW |