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 21 matching lines...) Expand all Loading... |
32 enum MediaErrorType { | 32 enum MediaErrorType { |
33 MEDIA_ERROR_FORMAT, | 33 MEDIA_ERROR_FORMAT, |
34 MEDIA_ERROR_DECODE, | 34 MEDIA_ERROR_DECODE, |
35 MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK, | 35 MEDIA_ERROR_NOT_VALID_FOR_PROGRESSIVE_PLAYBACK, |
36 MEDIA_ERROR_INVALID_CODE, | 36 MEDIA_ERROR_INVALID_CODE, |
37 }; | 37 }; |
38 | 38 |
39 // Callback when the player needs decoding resources. | 39 // Callback when the player needs decoding resources. |
40 typedef base::Callback<void(int player_id)> RequestMediaResourcesCB; | 40 typedef base::Callback<void(int player_id)> RequestMediaResourcesCB; |
41 | 41 |
| 42 // Virtual destructor. |
| 43 // For most subclasses we can delete on the caller thread. |
| 44 virtual void DeleteOnCorrectThread(); |
| 45 |
42 // Passing an external java surface object to the player. | 46 // Passing an external java surface object to the player. |
43 virtual void SetVideoSurface(gfx::ScopedJavaSurface surface) = 0; | 47 virtual void SetVideoSurface(gfx::ScopedJavaSurface surface) = 0; |
44 | 48 |
45 // Start playing the media. | 49 // Start playing the media. |
46 virtual void Start() = 0; | 50 virtual void Start() = 0; |
47 | 51 |
48 // Pause the media. | 52 // Pause the media. |
49 virtual void Pause(bool is_media_related_action) = 0; | 53 virtual void Pause(bool is_media_related_action) = 0; |
50 | 54 |
51 // Seek to a particular position, based on renderer signaling actual seek | 55 // Seek to a particular position, based on renderer signaling actual seek |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 virtual void OnPlaybackComplete(); | 99 virtual void OnPlaybackComplete(); |
96 virtual void OnMediaInterrupted(); | 100 virtual void OnMediaInterrupted(); |
97 virtual void OnSeekComplete(); | 101 virtual void OnSeekComplete(); |
98 virtual void OnMediaPrepared(); | 102 virtual void OnMediaPrepared(); |
99 | 103 |
100 // Attach/Detaches |listener_| for listening to all the media events. If | 104 // Attach/Detaches |listener_| for listening to all the media events. If |
101 // |j_media_player| is NULL, |listener_| only listens to the system media | 105 // |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|. | 106 // events. Otherwise, it also listens to the events from |j_media_player|. |
103 void AttachListener(jobject j_media_player); | 107 void AttachListener(jobject j_media_player); |
104 void DetachListener(); | 108 void DetachListener(); |
| 109 |
| 110 // When destroying a subclassed object on a non-UI thread |
| 111 // it is still required to destroy the |listener_| related stuff |
| 112 // on the UI thread. |
| 113 void DestroyListenerOnUIThread(); |
105 void SetAudible(bool is_audible); | 114 void SetAudible(bool is_audible); |
106 | 115 |
107 MediaPlayerManager* manager() { return manager_; } | 116 MediaPlayerManager* manager() { return manager_; } |
108 | 117 |
109 RequestMediaResourcesCB request_media_resources_cb_; | 118 RequestMediaResourcesCB request_media_resources_cb_; |
110 | 119 |
111 private: | 120 private: |
112 friend class MediaPlayerListener; | 121 friend class MediaPlayerListener; |
113 | 122 |
114 // Player ID assigned to this player. | 123 // Player ID assigned to this player. |
(...skipping 14 matching lines...) Expand all Loading... |
129 // Weak pointer passed to |listener_| for callbacks. | 138 // Weak pointer passed to |listener_| for callbacks. |
130 // NOTE: Weak pointers must be invalidated before all other member variables. | 139 // NOTE: Weak pointers must be invalidated before all other member variables. |
131 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; | 140 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; |
132 | 141 |
133 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); | 142 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); |
134 }; | 143 }; |
135 | 144 |
136 } // namespace media | 145 } // namespace media |
137 | 146 |
138 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ | 147 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ |
OLD | NEW |