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() { delete this; } | |
45 | |
46 // Passing an external java surface object to the player. | 42 // Passing an external java surface object to the player. |
47 virtual void SetVideoSurface(gfx::ScopedJavaSurface surface) = 0; | 43 virtual void SetVideoSurface(gfx::ScopedJavaSurface surface) = 0; |
48 | 44 |
49 // Start playing the media. | 45 // Start playing the media. |
50 virtual void Start() = 0; | 46 virtual void Start() = 0; |
51 | 47 |
52 // Pause the media. | 48 // Pause the media. |
53 virtual void Pause(bool is_media_related_action) = 0; | 49 virtual void Pause(bool is_media_related_action) = 0; |
54 | 50 |
55 // Seek to a particular position, based on renderer signaling actual seek | 51 // Seek to a particular position, based on renderer signaling actual seek |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 virtual void OnPlaybackComplete(); | 95 virtual void OnPlaybackComplete(); |
100 virtual void OnMediaInterrupted(); | 96 virtual void OnMediaInterrupted(); |
101 virtual void OnSeekComplete(); | 97 virtual void OnSeekComplete(); |
102 virtual void OnMediaPrepared(); | 98 virtual void OnMediaPrepared(); |
103 | 99 |
104 // Attach/Detaches |listener_| for listening to all the media events. If | 100 // Attach/Detaches |listener_| for listening to all the media events. If |
105 // |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 |
106 // 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|. |
107 void AttachListener(jobject j_media_player); | 103 void AttachListener(jobject j_media_player); |
108 void DetachListener(); | 104 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(); | |
114 void SetAudible(bool is_audible); | 105 void SetAudible(bool is_audible); |
115 | 106 |
116 MediaPlayerManager* manager() { return manager_; } | 107 MediaPlayerManager* manager() { return manager_; } |
117 | 108 |
118 RequestMediaResourcesCB request_media_resources_cb_; | 109 RequestMediaResourcesCB request_media_resources_cb_; |
119 | 110 |
120 private: | 111 private: |
121 friend class MediaPlayerListener; | 112 friend class MediaPlayerListener; |
122 | 113 |
123 // Player ID assigned to this player. | 114 // Player ID assigned to this player. |
(...skipping 14 matching lines...) Expand all Loading... |
138 // Weak pointer passed to |listener_| for callbacks. | 129 // Weak pointer passed to |listener_| for callbacks. |
139 // NOTE: Weak pointers must be invalidated before all other member variables. | 130 // NOTE: Weak pointers must be invalidated before all other member variables. |
140 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; | 131 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; |
141 | 132 |
142 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); | 133 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); |
143 }; | 134 }; |
144 | 135 |
145 } // namespace media | 136 } // namespace media |
146 | 137 |
147 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ | 138 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ |
OLD | NEW |