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 | |
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 void DestroyListener(); | |
xhwang
2015/05/06 17:42:44
When do we need to call this?
Tima Vaisburd
2015/05/08 07:30:54
Changed the name to DestroyListenerOnUIThread and
| |
105 void SetAudible(bool is_audible); | 110 void SetAudible(bool is_audible); |
106 | 111 |
107 MediaPlayerManager* manager() { return manager_; } | 112 MediaPlayerManager* manager() { return manager_; } |
108 | 113 |
109 RequestMediaResourcesCB request_media_resources_cb_; | 114 RequestMediaResourcesCB request_media_resources_cb_; |
110 | 115 |
111 private: | 116 private: |
112 friend class MediaPlayerListener; | 117 friend class MediaPlayerListener; |
113 | 118 |
114 // Player ID assigned to this player. | 119 // Player ID assigned to this player. |
(...skipping 14 matching lines...) Expand all Loading... | |
129 // Weak pointer passed to |listener_| for callbacks. | 134 // Weak pointer passed to |listener_| for callbacks. |
130 // NOTE: Weak pointers must be invalidated before all other member variables. | 135 // NOTE: Weak pointers must be invalidated before all other member variables. |
131 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; | 136 base::WeakPtrFactory<MediaPlayerAndroid> weak_factory_; |
132 | 137 |
133 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); | 138 DISALLOW_COPY_AND_ASSIGN(MediaPlayerAndroid); |
134 }; | 139 }; |
135 | 140 |
136 } // namespace media | 141 } // namespace media |
137 | 142 |
138 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ | 143 #endif // MEDIA_BASE_ANDROID_MEDIA_PLAYER_ANDROID_H_ |
OLD | NEW |