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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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> WeakPtrForUIThread(); |
| 119 |
118 RequestMediaResourcesCB request_media_resources_cb_; | 120 RequestMediaResourcesCB request_media_resources_cb_; |
119 | 121 |
120 private: | 122 private: |
121 friend class MediaPlayerListener; | 123 friend class MediaPlayerListener; |
122 | 124 |
123 // Player ID assigned to this player. | 125 // Player ID assigned to this player. |
124 int player_id_; | 126 int player_id_; |
125 | 127 |
126 // Resource manager for all the media players. | 128 // Resource manager for all the media players. |
127 MediaPlayerManager* manager_; | 129 MediaPlayerManager* manager_; |
(...skipping 10 matching lines...) Expand all Loading... |
138 // Weak pointer passed to |listener_| for callbacks. | 140 // Weak pointer passed to |listener_| for callbacks. |
139 // NOTE: Weak pointers must be invalidated before all other member variables. | 141 // NOTE: Weak pointers must be invalidated before all other member variables. |
140 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; | 142 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; |
141 | 143 |
142 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); | 144 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); |
143 }; | 145 }; |
144 | 146 |
145 } // namespace media | 147 } // namespace media |
146 | 148 |
147 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ | 149 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ |
OLD | NEW |