OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_PROXY_ANDROID_H_ |
| 6 #define WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_PROXY_ANDROID_H_ |
| 7 |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 |
| 11 namespace base { |
| 12 class MessageLoopProxy; |
| 13 } |
| 14 |
| 15 namespace webkit_media { |
| 16 |
| 17 class WebMediaPlayerAndroid; |
| 18 |
| 19 // Acts as a thread proxy between media::MediaPlayerBridge and |
| 20 // WebMediaPlayerAndroid so that callbacks are posted onto the render thread. |
| 21 class WebMediaPlayerProxyAndroid |
| 22 : public base::RefCountedThreadSafe<WebMediaPlayerProxyAndroid> { |
| 23 public: |
| 24 WebMediaPlayerProxyAndroid( |
| 25 const scoped_refptr<base::MessageLoopProxy>& render_loop, |
| 26 base::WeakPtr<WebMediaPlayerAndroid> webmediaplayer); |
| 27 |
| 28 // Callbacks from media::MediaPlayerBridge to WebMediaPlayerAndroid. |
| 29 void MediaErrorCallback(int error_type); |
| 30 void MediaInfoCallback(int info_type); |
| 31 void VideoSizeChangedCallback(int width, int height); |
| 32 void BufferingUpdateCallback(int percent); |
| 33 void PlaybackCompleteCallback(); |
| 34 void SeekCompleteCallback(); |
| 35 void MediaPreparedCallback(); |
| 36 |
| 37 private: |
| 38 friend class base::RefCountedThreadSafe<WebMediaPlayerProxyAndroid>; |
| 39 virtual ~WebMediaPlayerProxyAndroid(); |
| 40 |
| 41 // Notify |webmediaplayer_| that an error has occured. |
| 42 void MediaErrorTask(int error_type); |
| 43 |
| 44 // Notify |webmediaplayer_| that some info has been received from |
| 45 // media::MediaPlayerBridge. |
| 46 void MediaInfoTask(int info_type); |
| 47 |
| 48 // Notify |webmediaplayer_| that the video size has changed. |
| 49 void VideoSizeChangedTask(int width, int height); |
| 50 |
| 51 // Notify |webmediaplayer_| that an update in buffering has occured. |
| 52 void BufferingUpdateTask(int percent); |
| 53 |
| 54 // Notify |webmediaplayer_| that playback has completed. |
| 55 void PlaybackCompleteTask(); |
| 56 |
| 57 // Notify |webmediaplayer_| that seek has completed. |
| 58 void SeekCompleteTask(); |
| 59 |
| 60 // Notify |webmediaplayer_| that media has been prepared successfully. |
| 61 void MediaPreparedTask(); |
| 62 |
| 63 // The render message loop where WebKit lives. |
| 64 scoped_refptr<base::MessageLoopProxy> render_loop_; |
| 65 |
| 66 // The WebMediaPlayerAndroid object all the callbacks should be send to. |
| 67 base::WeakPtr<WebMediaPlayerAndroid> webmediaplayer_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerProxyAndroid); |
| 70 }; |
| 71 |
| 72 } // namespace webkit_media |
| 73 |
| 74 #endif // WEBKIT_MEDIA_ANDROID_WEBMEDIAPLAYER_PROXY_ANDROID_H_ |
OLD | NEW |