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