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

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

Issue 2338223003: Unassociating MediaSession from media players (in blink & content) (Closed)
Patch Set: fixed tests Created 4 years, 3 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
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | media/base/android/media_player_android.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_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 9
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 12
13 #include "base/android/scoped_java_ref.h" 13 #include "base/android/scoped_java_ref.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "media/base/android/media_player_listener.h" 18 #include "media/base/android/media_player_listener.h"
19 #include "media/base/media_export.h" 19 #include "media/base/media_export.h"
20 #include "ui/gfx/geometry/size.h" 20 #include "ui/gfx/geometry/size.h"
21 #include "ui/gl/android/scoped_java_surface.h" 21 #include "ui/gl/android/scoped_java_surface.h"
22 #include "url/gurl.h" 22 #include "url/gurl.h"
23 23
24 namespace media { 24 namespace media {
25 25
26 class MediaKeys; 26 class MediaKeys;
27 class MediaPlayerManager; 27 class MediaPlayerManager;
28 28
29 enum {
30 // Id used for players not participating in any media sessions
31 // because of undefined behavior in the specification. When all
32 // media session interactions have been worked out, this id should
33 // no longer be used.
34 kInvalidMediaSessionId = -1,
35
36 // The media session for media elements that don't have an explicit
37 // user created media session set. Must be in-sync with
38 // WebMediaSession::DefaultID in blink.
39 kDefaultMediaSessionId = 0
40 };
41
42 // This class serves as the base class for different media player 29 // This class serves as the base class for different media player
43 // implementations on Android. Subclasses need to provide their own 30 // implementations on Android. Subclasses need to provide their own
44 // MediaPlayerAndroid::Create() implementation. 31 // MediaPlayerAndroid::Create() implementation.
45 class MEDIA_EXPORT MediaPlayerAndroid { 32 class MEDIA_EXPORT MediaPlayerAndroid {
46 public: 33 public:
47 virtual ~MediaPlayerAndroid(); 34 virtual ~MediaPlayerAndroid();
48 35
49 // Error types for MediaErrorCB. 36 // Error types for MediaErrorCB.
50 enum MediaErrorType { 37 enum MediaErrorType {
51 MEDIA_ERROR_FORMAT, 38 MEDIA_ERROR_FORMAT,
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 const gfx::Size& video_size) {} 104 const gfx::Size& video_size) {}
118 105
119 // Overridden in MediaCodecPlayer to pass data between threads. 106 // Overridden in MediaCodecPlayer to pass data between threads.
120 virtual void OnTimeUpdate(base::TimeDelta current_timestamp, 107 virtual void OnTimeUpdate(base::TimeDelta current_timestamp,
121 base::TimeTicks current_time_ticks) {} 108 base::TimeTicks current_time_ticks) {}
122 109
123 int player_id() { return player_id_; } 110 int player_id() { return player_id_; }
124 111
125 GURL frame_url() { return frame_url_; } 112 GURL frame_url() { return frame_url_; }
126 113
127 int media_session_id() { return media_session_id_; }
128
129 // Attach/Detaches |listener_| for listening to all the media events. If 114 // Attach/Detaches |listener_| for listening to all the media events. If
130 // |j_media_player| is NULL, |listener_| only listens to the system media 115 // |j_media_player| is NULL, |listener_| only listens to the system media
131 // events. Otherwise, it also listens to the events from |j_media_player|. 116 // events. Otherwise, it also listens to the events from |j_media_player|.
132 void AttachListener(const base::android::JavaRef<jobject>& j_media_player); 117 void AttachListener(const base::android::JavaRef<jobject>& j_media_player);
133 void DetachListener(); 118 void DetachListener();
134 119
135 protected: 120 protected:
136 MediaPlayerAndroid( 121 MediaPlayerAndroid(
137 int player_id, 122 int player_id,
138 MediaPlayerManager* manager, 123 MediaPlayerManager* manager,
139 const OnDecoderResourcesReleasedCB& on_decoder_resources_released_cb, 124 const OnDecoderResourcesReleasedCB& on_decoder_resources_released_cb,
140 const GURL& frame_url, 125 const GURL& frame_url);
141 int media_session_id);
142 126
143 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to 127 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to
144 // 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
145 // the events needed by MediaPlayerBridge. http://crbug.com/422597. 129 // the events needed by MediaPlayerBridge. http://crbug.com/422597.
146 // MediaPlayerListener callbacks. 130 // MediaPlayerListener callbacks.
147 virtual void OnVideoSizeChanged(int width, int height); 131 virtual void OnVideoSizeChanged(int width, int height);
148 virtual void OnMediaError(int error_type); 132 virtual void OnMediaError(int error_type);
149 virtual void OnBufferingUpdate(int percent); 133 virtual void OnBufferingUpdate(int percent);
150 virtual void OnPlaybackComplete(); 134 virtual void OnPlaybackComplete();
151 virtual void OnMediaInterrupted(); 135 virtual void OnMediaInterrupted();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 169
186 // Resource manager for all the media players. 170 // Resource manager for all the media players.
187 MediaPlayerManager* manager_; 171 MediaPlayerManager* manager_;
188 172
189 // Url for the frame that contains this player. 173 // Url for the frame that contains this player.
190 GURL frame_url_; 174 GURL frame_url_;
191 175
192 // Listener object that listens to all the media player events. 176 // Listener object that listens to all the media player events.
193 std::unique_ptr<MediaPlayerListener> listener_; 177 std::unique_ptr<MediaPlayerListener> listener_;
194 178
195 // Media session ID assigned to this player.
196 int media_session_id_;
197
198 // Weak pointer passed to |listener_| for callbacks. 179 // Weak pointer passed to |listener_| for callbacks.
199 // NOTE: Weak pointers must be invalidated before all other member variables. 180 // NOTE: Weak pointers must be invalidated before all other member variables.
200 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; 181 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_;
201 182
202 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); 183 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid);
203 }; 184 };
204 185
205 } // namespace media 186 } // namespace media
206 187
207 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ 188 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | media/base/android/media_player_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698