OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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 CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_PROXY_ANDROID_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_PROXY_ANDROID_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/time.h" |
| 11 #include "content/public/renderer/render_view_observer.h" |
| 12 #include "googleurl/src/gurl.h" |
| 13 #include "media/base/android/demuxer_stream_player_params.h" |
| 14 #include "media/base/android/media_player_android.h" |
| 15 #include "media/base/media_keys.h" |
| 16 |
| 17 namespace content { |
| 18 class WebMediaPlayerAndroid; |
| 19 class WebMediaPlayerManagerAndroid; |
| 20 |
| 21 // This class manages IPC communication between WebMediaPlayerAndroid and the |
| 22 // MediaPlayerManagerAndroid in the browser process. |
| 23 class WebMediaPlayerProxyAndroid : public RenderViewObserver { |
| 24 public: |
| 25 // Construct a WebMediaPlayerProxyAndroid object for the |render_view|. |
| 26 // |manager| is passed to this class so that it can find the right |
| 27 // WebMediaPlayerAndroid using player IDs. |
| 28 WebMediaPlayerProxyAndroid( |
| 29 RenderView* render_view, |
| 30 WebMediaPlayerManagerAndroid* manager); |
| 31 virtual ~WebMediaPlayerProxyAndroid(); |
| 32 |
| 33 // RenderViewObserver overrides. |
| 34 virtual bool OnMessageReceived(const IPC::Message& msg) OVERRIDE; |
| 35 |
| 36 // Initializes a MediaPlayerAndroid object in browser process. |
| 37 void Initialize(int player_id, |
| 38 const GURL& url, |
| 39 media::MediaPlayerAndroid::SourceType source_type, |
| 40 const GURL& first_party_for_cookies); |
| 41 |
| 42 // Starts the player. |
| 43 void Start(int player_id); |
| 44 |
| 45 // Pausees the player. |
| 46 void Pause(int player_id); |
| 47 |
| 48 // Performs seek on the player. |
| 49 void Seek(int player_id, base::TimeDelta time); |
| 50 |
| 51 // Release resources for the player. |
| 52 void ReleaseResources(int player_id); |
| 53 |
| 54 // Destroy the player in the browser process |
| 55 void DestroyPlayer(int player_id); |
| 56 |
| 57 // Request the player to enter fullscreen. |
| 58 void EnterFullscreen(int player_id); |
| 59 |
| 60 // Request the player to exit fullscreen. |
| 61 void ExitFullscreen(int player_id); |
| 62 |
| 63 #if defined(GOOGLE_TV) |
| 64 // Request an external surface for out-of-band compositing. |
| 65 void RequestExternalSurface(int player_id, const gfx::RectF& geometry); |
| 66 |
| 67 // RenderViewObserver overrides. |
| 68 virtual void DidCommitCompositorFrame() OVERRIDE; |
| 69 #endif |
| 70 |
| 71 // Media source related methods. |
| 72 void DemuxerReady(int player_id, |
| 73 const media::MediaPlayerHostMsg_DemuxerReady_Params&); |
| 74 void ReadFromDemuxerAck( |
| 75 int player_id, |
| 76 const media::MediaPlayerHostMsg_ReadFromDemuxerAck_Params& params); |
| 77 void DurationChanged(int player_id, const base::TimeDelta& duration); |
| 78 |
| 79 // Encrypted media related methods. |
| 80 void InitializeCDM(int media_keys_id, const std::vector<uint8>& uuid); |
| 81 void GenerateKeyRequest(int media_keys_id, |
| 82 const std::string& type, |
| 83 const std::vector<uint8>& init_data); |
| 84 void AddKey(int media_keys_id, |
| 85 const std::vector<uint8>& key, |
| 86 const std::vector<uint8>& init_data, |
| 87 const std::string& session_id); |
| 88 void CancelKeyRequest(int media_keys_id, const std::string& session_id); |
| 89 |
| 90 private: |
| 91 WebMediaPlayerAndroid* GetWebMediaPlayer(int player_id); |
| 92 |
| 93 // Message handlers. |
| 94 void OnMediaMetadataChanged(int player_id, |
| 95 base::TimeDelta duration, |
| 96 int width, |
| 97 int height, |
| 98 bool success); |
| 99 void OnMediaPlaybackCompleted(int player_id); |
| 100 void OnMediaBufferingUpdate(int player_id, int percent); |
| 101 void OnMediaSeekCompleted(int player_id, base::TimeDelta current_time); |
| 102 void OnMediaError(int player_id, int error); |
| 103 void OnVideoSizeChanged(int player_id, int width, int height); |
| 104 void OnTimeUpdate(int player_id, base::TimeDelta current_time); |
| 105 void OnMediaPlayerReleased(int player_id); |
| 106 void OnDidExitFullscreen(int player_id); |
| 107 void OnDidEnterFullscreen(int player_id); |
| 108 void OnPlayerPlay(int player_id); |
| 109 void OnPlayerPause(int player_id); |
| 110 void OnReadFromDemuxer(int player_id, |
| 111 media::DemuxerStream::Type type, |
| 112 bool seek_done); |
| 113 void OnMediaSeekRequest(int player_id, |
| 114 base::TimeDelta time_to_seek, |
| 115 unsigned seek_request_id); |
| 116 void OnMediaConfigRequest(int player_id); |
| 117 void OnKeyAdded(int media_keys_id, const std::string& session_id); |
| 118 void OnKeyError(int media_keys_id, |
| 119 const std::string& session_id, |
| 120 media::MediaKeys::KeyError error_code, |
| 121 int system_code); |
| 122 void OnKeyMessage(int media_keys_id, |
| 123 const std::string& session_id, |
| 124 const std::string& message, |
| 125 const std::string& destination_url); |
| 126 |
| 127 WebMediaPlayerManagerAndroid* manager_; |
| 128 |
| 129 DISALLOW_IMPLICIT_CONSTRUCTORS(WebMediaPlayerProxyAndroid); |
| 130 }; |
| 131 |
| 132 } // namespace content |
| 133 |
| 134 #endif // CONTENT_RENDERER_MEDIA_ANDROID_WEBMEDIAPLAYER_PROXY_ANDROID_H_ |
OLD | NEW |