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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 virtual bool IsPlayerReady() = 0; | 68 virtual bool IsPlayerReady() = 0; |
69 virtual bool CanPause() = 0; | 69 virtual bool CanPause() = 0; |
70 virtual bool CanSeekForward() = 0; | 70 virtual bool CanSeekForward() = 0; |
71 virtual bool CanSeekBackward() = 0; | 71 virtual bool CanSeekBackward() = 0; |
72 virtual GURL GetUrl(); | 72 virtual GURL GetUrl(); |
73 virtual GURL GetFirstPartyForCookies(); | 73 virtual GURL GetFirstPartyForCookies(); |
74 | 74 |
75 // Associates the |cdm| with this player. | 75 // Associates the |cdm| with this player. |
76 virtual void SetCdm(BrowserCdm* cdm); | 76 virtual void SetCdm(BrowserCdm* cdm); |
77 | 77 |
| 78 int player_id() { return player_id_; } |
| 79 |
| 80 GURL frame_url() { return frame_url_; } |
| 81 |
| 82 protected: |
| 83 MediaPlayerAndroid(int player_id, |
| 84 MediaPlayerManager* manager, |
| 85 const RequestMediaResourcesCB& request_media_resources_cb, |
| 86 const GURL& frame_url); |
| 87 |
78 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to | 88 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to |
79 // media interrupt events. And have a separate child class to listen to all | 89 // media interrupt events. And have a separate child class to listen to all |
80 // the events needed by MediaPlayerBridge. http://crbug.com/422597. | 90 // the events needed by MediaPlayerBridge. http://crbug.com/422597. |
81 // MediaPlayerListener callbacks. | 91 // MediaPlayerListener callbacks. |
82 virtual void OnVideoSizeChanged(int width, int height); | 92 virtual void OnVideoSizeChanged(int width, int height); |
83 virtual void OnMediaError(int error_type); | 93 virtual void OnMediaError(int error_type); |
84 virtual void OnBufferingUpdate(int percent); | 94 virtual void OnBufferingUpdate(int percent); |
85 virtual void OnPlaybackComplete(); | 95 virtual void OnPlaybackComplete(); |
86 virtual void OnMediaInterrupted(); | 96 virtual void OnMediaInterrupted(); |
87 virtual void OnSeekComplete(); | 97 virtual void OnSeekComplete(); |
88 virtual void OnMediaPrepared(); | 98 virtual void OnMediaPrepared(); |
89 | 99 |
90 int player_id() { return player_id_; } | |
91 | |
92 GURL frame_url() { return frame_url_; } | |
93 | |
94 protected: | |
95 MediaPlayerAndroid(int player_id, | |
96 MediaPlayerManager* manager, | |
97 const RequestMediaResourcesCB& request_media_resources_cb, | |
98 const GURL& frame_url); | |
99 | |
100 // Attach/Detaches |listener_| for listening to all the media events. If | 100 // Attach/Detaches |listener_| for listening to all the media events. If |
101 // |j_media_player| is NULL, |listener_| only listens to the system media | 101 // |j_media_player| is NULL, |listener_| only listens to the system media |
102 // events. Otherwise, it also listens to the events from |j_media_player|. | 102 // events. Otherwise, it also listens to the events from |j_media_player|. |
103 void AttachListener(jobject j_media_player); | 103 void AttachListener(jobject j_media_player); |
104 void DetachListener(); | 104 void DetachListener(); |
105 | 105 |
106 MediaPlayerManager* manager() { return manager_; } | 106 MediaPlayerManager* manager() { return manager_; } |
107 | 107 |
108 RequestMediaResourcesCB request_media_resources_cb_; | 108 RequestMediaResourcesCB request_media_resources_cb_; |
109 | 109 |
110 private: | 110 private: |
| 111 friend class MediaPlayerListener; |
| 112 |
111 // Player ID assigned to this player. | 113 // Player ID assigned to this player. |
112 int player_id_; | 114 int player_id_; |
113 | 115 |
114 // Resource manager for all the media players. | 116 // Resource manager for all the media players. |
115 MediaPlayerManager* manager_; | 117 MediaPlayerManager* manager_; |
116 | 118 |
117 // Url for the frame that contains this player. | 119 // Url for the frame that contains this player. |
118 GURL frame_url_; | 120 GURL frame_url_; |
119 | 121 |
120 // Listener object that listens to all the media player events. | 122 // Listener object that listens to all the media player events. |
121 scoped_ptr<MediaPlayerListener> listener_; | 123 scoped_ptr<MediaPlayerListener> listener_; |
122 | 124 |
123 // Weak pointer passed to |listener_| for callbacks. | 125 // Weak pointer passed to |listener_| for callbacks. |
124 // NOTE: Weak pointers must be invalidated before all other member variables. | 126 // NOTE: Weak pointers must be invalidated before all other member variables. |
125 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; | 127 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; |
126 | 128 |
127 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); | 129 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); |
128 }; | 130 }; |
129 | 131 |
130 } // namespace media | 132 } // namespace media |
131 | 133 |
132 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ | 134 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ |
OLD | NEW |