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

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

Issue 1128383003: Implementation of MediaCodecPlayer stage 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
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 #include <string> 9 #include <string>
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 virtual GURL GetUrl(); 76 virtual GURL GetUrl();
77 virtual GURL GetFirstPartyForCookies(); 77 virtual GURL GetFirstPartyForCookies();
78 78
79 // Associates the |cdm| with this player. 79 // Associates the |cdm| with this player.
80 virtual void SetCdm(BrowserCdm* cdm); 80 virtual void SetCdm(BrowserCdm* cdm);
81 81
82 int player_id() { return player_id_; } 82 int player_id() { return player_id_; }
83 83
84 GURL frame_url() { return frame_url_; } 84 GURL frame_url() { return frame_url_; }
85 85
86 // Attach/Detaches |listener_| for listening to all the media events. If
87 // |j_media_player| is NULL, |listener_| only listens to the system media
88 // events. Otherwise, it also listens to the events from |j_media_player|.
89 void AttachListener(jobject j_media_player);
90 void DetachListener();
91
86 protected: 92 protected:
87 MediaPlayerAndroid(int player_id, 93 MediaPlayerAndroid(int player_id,
88 MediaPlayerManager* manager, 94 MediaPlayerManager* manager,
89 const RequestMediaResourcesCB& request_media_resources_cb, 95 const RequestMediaResourcesCB& request_media_resources_cb,
90 const GURL& frame_url); 96 const GURL& frame_url);
91 97
92 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to 98 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to
93 // media interrupt events. And have a separate child class to listen to all 99 // media interrupt events. And have a separate child class to listen to all
94 // the events needed by MediaPlayerBridge. http://crbug.com/422597. 100 // the events needed by MediaPlayerBridge. http://crbug.com/422597.
95 // MediaPlayerListener callbacks. 101 // MediaPlayerListener callbacks.
96 virtual void OnVideoSizeChanged(int width, int height); 102 virtual void OnVideoSizeChanged(int width, int height);
97 virtual void OnMediaError(int error_type); 103 virtual void OnMediaError(int error_type);
98 virtual void OnBufferingUpdate(int percent); 104 virtual void OnBufferingUpdate(int percent);
99 virtual void OnPlaybackComplete(); 105 virtual void OnPlaybackComplete();
100 virtual void OnMediaInterrupted(); 106 virtual void OnMediaInterrupted();
101 virtual void OnSeekComplete(); 107 virtual void OnSeekComplete();
102 virtual void OnMediaPrepared(); 108 virtual void OnMediaPrepared();
103 109
104 // Attach/Detaches |listener_| for listening to all the media events. If
105 // |j_media_player| is NULL, |listener_| only listens to the system media
106 // events. Otherwise, it also listens to the events from |j_media_player|.
107 void AttachListener(jobject j_media_player);
108 void DetachListener();
109
110 // When destroying a subclassed object on a non-UI thread 110 // When destroying a subclassed object on a non-UI thread
111 // it is still required to destroy the |listener_| related stuff 111 // it is still required to destroy the |listener_| related stuff
112 // on the UI thread. 112 // on the UI thread.
113 void DestroyListenerOnUIThread(); 113 void DestroyListenerOnUIThread();
114 void SetAudible(bool is_audible); 114 void SetAudible(bool is_audible);
115 115
116 MediaPlayerManager* manager() { return manager_; } 116 MediaPlayerManager* manager() { return manager_; }
117 117
118 base::WeakPtr<MediaPlayerAndroid> weak_ptr_for_ui_thread() {
timav 2015/05/11 23:17:40 I'm not sure about this. I think we need this meth
119 return weak_ptr_for_ui_thread_;
120 }
121
118 RequestMediaResourcesCB request_media_resources_cb_; 122 RequestMediaResourcesCB request_media_resources_cb_;
119 123
120 private: 124 private:
121 friend class MediaPlayerListener; 125 friend class MediaPlayerListener;
122 126
123 // Player ID assigned to this player. 127 // Player ID assigned to this player.
124 int player_id_; 128 int player_id_;
125 129
126 // Resource manager for all the media players. 130 // Resource manager for all the media players.
127 MediaPlayerManager* manager_; 131 MediaPlayerManager* manager_;
128 132
129 // Url for the frame that contains this player. 133 // Url for the frame that contains this player.
130 GURL frame_url_; 134 GURL frame_url_;
131 135
132 // Listener object that listens to all the media player events. 136 // Listener object that listens to all the media player events.
133 scoped_ptr<MediaPlayerListener> listener_; 137 scoped_ptr<MediaPlayerListener> listener_;
134 138
135 // Maintains the audible state of the player, true if it is playing sound. 139 // Maintains the audible state of the player, true if it is playing sound.
136 bool is_audible_; 140 bool is_audible_;
137 141
142 // We use this pointer when we post task from Media thread
143 base::WeakPtr<MediaPlayerAndroid> weak_ptr_for_ui_thread_;
144
138 // Weak pointer passed to |listener_| for callbacks. 145 // Weak pointer passed to |listener_| for callbacks.
139 // NOTE: Weak pointers must be invalidated before all other member variables. 146 // NOTE: Weak pointers must be invalidated before all other member variables.
140 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; 147 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_;
141 148
142 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); 149 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid);
143 }; 150 };
144 151
145 } // namespace media 152 } // namespace media
146 153
147 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ 154 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698