| 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/memory/weak_ptr.h" |
| 12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "media/base/android/media_player_listener.h" |
| 13 #include "media/base/media_export.h" | 15 #include "media/base/media_export.h" |
| 14 #include "ui/gl/android/scoped_java_surface.h" | 16 #include "ui/gl/android/scoped_java_surface.h" |
| 15 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 16 | 18 |
| 17 namespace media { | 19 namespace media { |
| 18 | 20 |
| 19 class BrowserCdm; | 21 class BrowserCdm; |
| 20 class MediaPlayerManager; | 22 class MediaPlayerManager; |
| 21 | 23 |
| 22 // This class serves as the base class for different media player | 24 // This class serves as the base class for different media player |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 int player_id() { return player_id_; } | 78 int player_id() { return player_id_; } |
| 77 | 79 |
| 78 GURL frame_url() { return frame_url_; } | 80 GURL frame_url() { return frame_url_; } |
| 79 | 81 |
| 80 protected: | 82 protected: |
| 81 MediaPlayerAndroid(int player_id, | 83 MediaPlayerAndroid(int player_id, |
| 82 MediaPlayerManager* manager, | 84 MediaPlayerManager* manager, |
| 83 const RequestMediaResourcesCB& request_media_resources_cb, | 85 const RequestMediaResourcesCB& request_media_resources_cb, |
| 84 const GURL& frame_url); | 86 const GURL& frame_url); |
| 85 | 87 |
| 88 // TODO(qinmin): Simplify the MediaPlayerListener class to only listen to |
| 89 // media interrupt events. And have a separate child class to listen to all |
| 90 // the events needed by MediaPlayerBridge. http://crbug.com/422597. |
| 91 // MediaPlayerListener callbacks. |
| 92 virtual void OnVideoSizeChanged(int width, int height); |
| 93 virtual void OnMediaError(int error_type); |
| 94 virtual void OnBufferingUpdate(int percent); |
| 95 virtual void OnPlaybackComplete(); |
| 96 virtual void OnMediaInterrupted(); |
| 97 virtual void OnSeekComplete(); |
| 98 virtual void OnMediaPrepared(); |
| 99 |
| 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 |
| 102 // events. Otherwise, it also listens to the events from |j_media_player|. |
| 103 void AttachListener(jobject j_media_player); |
| 104 void DetachListener(); |
| 105 |
| 86 MediaPlayerManager* manager() { return manager_; } | 106 MediaPlayerManager* manager() { return manager_; } |
| 87 | 107 |
| 88 RequestMediaResourcesCB request_media_resources_cb_; | 108 RequestMediaResourcesCB request_media_resources_cb_; |
| 89 | 109 |
| 90 private: | 110 private: |
| 111 friend class MediaPlayerListener; |
| 112 |
| 91 // Player ID assigned to this player. | 113 // Player ID assigned to this player. |
| 92 int player_id_; | 114 int player_id_; |
| 93 | 115 |
| 94 // Resource manager for all the media players. | 116 // Resource manager for all the media players. |
| 95 MediaPlayerManager* manager_; | 117 MediaPlayerManager* manager_; |
| 96 | 118 |
| 97 // Url for the frame that contains this player. | 119 // Url for the frame that contains this player. |
| 98 GURL frame_url_; | 120 GURL frame_url_; |
| 99 | 121 |
| 122 // Listener object that listens to all the media player events. |
| 123 scoped_ptr<MediaPlayerListener> listener_; |
| 124 |
| 125 // Weak pointer passed to |listener_| for callbacks. |
| 126 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 127 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; |
| 128 |
| 100 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); | 129 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); |
| 101 }; | 130 }; |
| 102 | 131 |
| 103 } // namespace media | 132 } // namespace media |
| 104 | 133 |
| 105 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ | 134 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ |
| OLD | NEW |