OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ |
6 #define CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
12 #include "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
13 #include "cc/layers/video_frame_provider.h" | 13 #include "cc/layers/video_frame_provider.h" |
14 #include "media/filters/skcanvas_video_renderer.h" | 14 #include "media/filters/skcanvas_video_renderer.h" |
15 #include "skia/ext/platform_canvas.h" | 15 #include "skia/ext/platform_canvas.h" |
16 #include "third_party/WebKit/public/web/WebMediaPlayer.h" | 16 #include "third_party/WebKit/public/web/WebMediaPlayer.h" |
17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
18 | 18 |
19 namespace WebKit { | 19 namespace blink { |
20 class WebFrame; | 20 class WebFrame; |
21 class WebMediaPlayerClient; | 21 class WebMediaPlayerClient; |
22 } | 22 } |
23 | 23 |
24 namespace media { | 24 namespace media { |
25 class MediaLog; | 25 class MediaLog; |
26 } | 26 } |
27 | 27 |
28 namespace webkit { | 28 namespace webkit { |
29 class WebLayerImpl; | 29 class WebLayerImpl; |
(...skipping 10 matching lines...) Expand all Loading... |
40 // | 40 // |
41 // WebMediaPlayerMS works with multiple objects, the most important ones are: | 41 // WebMediaPlayerMS works with multiple objects, the most important ones are: |
42 // | 42 // |
43 // VideoFrameProvider | 43 // VideoFrameProvider |
44 // provides video frames for rendering. | 44 // provides video frames for rendering. |
45 // | 45 // |
46 // TODO(wjia): add AudioPlayer. | 46 // TODO(wjia): add AudioPlayer. |
47 // AudioPlayer | 47 // AudioPlayer |
48 // plays audio streams. | 48 // plays audio streams. |
49 // | 49 // |
50 // WebKit::WebMediaPlayerClient | 50 // blink::WebMediaPlayerClient |
51 // WebKit client of this media player object. | 51 // WebKit client of this media player object. |
52 class WebMediaPlayerMS | 52 class WebMediaPlayerMS |
53 : public WebKit::WebMediaPlayer, | 53 : public blink::WebMediaPlayer, |
54 public cc::VideoFrameProvider, | 54 public cc::VideoFrameProvider, |
55 public base::SupportsWeakPtr<WebMediaPlayerMS> { | 55 public base::SupportsWeakPtr<WebMediaPlayerMS> { |
56 public: | 56 public: |
57 // Construct a WebMediaPlayerMS with reference to the client, and | 57 // Construct a WebMediaPlayerMS with reference to the client, and |
58 // a MediaStreamClient which provides VideoFrameProvider. | 58 // a MediaStreamClient which provides VideoFrameProvider. |
59 WebMediaPlayerMS(WebKit::WebFrame* frame, | 59 WebMediaPlayerMS(blink::WebFrame* frame, |
60 WebKit::WebMediaPlayerClient* client, | 60 blink::WebMediaPlayerClient* client, |
61 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 61 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
62 MediaStreamClient* media_stream_client, | 62 MediaStreamClient* media_stream_client, |
63 media::MediaLog* media_log); | 63 media::MediaLog* media_log); |
64 virtual ~WebMediaPlayerMS(); | 64 virtual ~WebMediaPlayerMS(); |
65 | 65 |
66 virtual void load(LoadType load_type, | 66 virtual void load(LoadType load_type, |
67 const WebKit::WebURL& url, | 67 const blink::WebURL& url, |
68 CORSMode cors_mode) OVERRIDE; | 68 CORSMode cors_mode) OVERRIDE; |
69 | 69 |
70 // Playback controls. | 70 // Playback controls. |
71 virtual void play() OVERRIDE; | 71 virtual void play() OVERRIDE; |
72 virtual void pause() OVERRIDE; | 72 virtual void pause() OVERRIDE; |
73 virtual bool supportsFullscreen() const OVERRIDE; | 73 virtual bool supportsFullscreen() const OVERRIDE; |
74 virtual bool supportsSave() const OVERRIDE; | 74 virtual bool supportsSave() const OVERRIDE; |
75 virtual void seek(double seconds); | 75 virtual void seek(double seconds); |
76 virtual void setRate(double rate); | 76 virtual void setRate(double rate); |
77 virtual void setVolume(double volume); | 77 virtual void setVolume(double volume); |
78 virtual void setPreload(WebKit::WebMediaPlayer::Preload preload) OVERRIDE; | 78 virtual void setPreload(blink::WebMediaPlayer::Preload preload) OVERRIDE; |
79 virtual const WebKit::WebTimeRanges& buffered() OVERRIDE; | 79 virtual const blink::WebTimeRanges& buffered() OVERRIDE; |
80 virtual double maxTimeSeekable() const; | 80 virtual double maxTimeSeekable() const; |
81 | 81 |
82 // Methods for painting. | 82 // Methods for painting. |
83 virtual void paint(WebKit::WebCanvas* canvas, | 83 virtual void paint(blink::WebCanvas* canvas, |
84 const WebKit::WebRect& rect, | 84 const blink::WebRect& rect, |
85 unsigned char alpha) OVERRIDE; | 85 unsigned char alpha) OVERRIDE; |
86 | 86 |
87 // True if the loaded media has a playable video/audio track. | 87 // True if the loaded media has a playable video/audio track. |
88 virtual bool hasVideo() const OVERRIDE; | 88 virtual bool hasVideo() const OVERRIDE; |
89 virtual bool hasAudio() const OVERRIDE; | 89 virtual bool hasAudio() const OVERRIDE; |
90 | 90 |
91 // Dimensions of the video. | 91 // Dimensions of the video. |
92 virtual WebKit::WebSize naturalSize() const OVERRIDE; | 92 virtual blink::WebSize naturalSize() const OVERRIDE; |
93 | 93 |
94 // Getters of playback state. | 94 // Getters of playback state. |
95 virtual bool paused() const OVERRIDE; | 95 virtual bool paused() const OVERRIDE; |
96 virtual bool seeking() const OVERRIDE; | 96 virtual bool seeking() const OVERRIDE; |
97 virtual double duration() const; | 97 virtual double duration() const; |
98 virtual double currentTime() const; | 98 virtual double currentTime() const; |
99 | 99 |
100 // Internal states of loading and network. | 100 // Internal states of loading and network. |
101 virtual WebKit::WebMediaPlayer::NetworkState networkState() const OVERRIDE; | 101 virtual blink::WebMediaPlayer::NetworkState networkState() const OVERRIDE; |
102 virtual WebKit::WebMediaPlayer::ReadyState readyState() const OVERRIDE; | 102 virtual blink::WebMediaPlayer::ReadyState readyState() const OVERRIDE; |
103 | 103 |
104 virtual bool didLoadingProgress() const OVERRIDE; | 104 virtual bool didLoadingProgress() const OVERRIDE; |
105 | 105 |
106 virtual bool hasSingleSecurityOrigin() const OVERRIDE; | 106 virtual bool hasSingleSecurityOrigin() const OVERRIDE; |
107 virtual bool didPassCORSAccessCheck() const OVERRIDE; | 107 virtual bool didPassCORSAccessCheck() const OVERRIDE; |
108 | 108 |
109 virtual double mediaTimeForTimeValue(double timeValue) const; | 109 virtual double mediaTimeForTimeValue(double timeValue) const; |
110 | 110 |
111 virtual unsigned decodedFrameCount() const OVERRIDE; | 111 virtual unsigned decodedFrameCount() const OVERRIDE; |
112 virtual unsigned droppedFrameCount() const OVERRIDE; | 112 virtual unsigned droppedFrameCount() const OVERRIDE; |
(...skipping 11 matching lines...) Expand all Loading... |
124 // The callback for VideoFrameProvider to signal a new frame is available. | 124 // The callback for VideoFrameProvider to signal a new frame is available. |
125 void OnFrameAvailable(const scoped_refptr<media::VideoFrame>& frame); | 125 void OnFrameAvailable(const scoped_refptr<media::VideoFrame>& frame); |
126 // Need repaint due to state change. | 126 // Need repaint due to state change. |
127 void RepaintInternal(); | 127 void RepaintInternal(); |
128 | 128 |
129 // The callback for source to report error. | 129 // The callback for source to report error. |
130 void OnSourceError(); | 130 void OnSourceError(); |
131 | 131 |
132 // Helpers that set the network/ready state and notifies the client if | 132 // Helpers that set the network/ready state and notifies the client if |
133 // they've changed. | 133 // they've changed. |
134 void SetNetworkState(WebKit::WebMediaPlayer::NetworkState state); | 134 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); |
135 void SetReadyState(WebKit::WebMediaPlayer::ReadyState state); | 135 void SetReadyState(blink::WebMediaPlayer::ReadyState state); |
136 | 136 |
137 // Getter method to |client_|. | 137 // Getter method to |client_|. |
138 WebKit::WebMediaPlayerClient* GetClient(); | 138 blink::WebMediaPlayerClient* GetClient(); |
139 | 139 |
140 WebKit::WebFrame* frame_; | 140 blink::WebFrame* frame_; |
141 | 141 |
142 WebKit::WebMediaPlayer::NetworkState network_state_; | 142 blink::WebMediaPlayer::NetworkState network_state_; |
143 WebKit::WebMediaPlayer::ReadyState ready_state_; | 143 blink::WebMediaPlayer::ReadyState ready_state_; |
144 | 144 |
145 WebKit::WebTimeRanges buffered_; | 145 blink::WebTimeRanges buffered_; |
146 | 146 |
147 // Used for DCHECKs to ensure methods calls executed in the correct thread. | 147 // Used for DCHECKs to ensure methods calls executed in the correct thread. |
148 base::ThreadChecker thread_checker_; | 148 base::ThreadChecker thread_checker_; |
149 | 149 |
150 WebKit::WebMediaPlayerClient* client_; | 150 blink::WebMediaPlayerClient* client_; |
151 | 151 |
152 base::WeakPtr<WebMediaPlayerDelegate> delegate_; | 152 base::WeakPtr<WebMediaPlayerDelegate> delegate_; |
153 | 153 |
154 MediaStreamClient* media_stream_client_; | 154 MediaStreamClient* media_stream_client_; |
155 | 155 |
156 // Specify content:: to disambiguate from cc::. | 156 // Specify content:: to disambiguate from cc::. |
157 scoped_refptr<content::VideoFrameProvider> video_frame_provider_; | 157 scoped_refptr<content::VideoFrameProvider> video_frame_provider_; |
158 bool paused_; | 158 bool paused_; |
159 | 159 |
160 // |current_frame_| is updated only on main thread. The object it holds | 160 // |current_frame_| is updated only on main thread. The object it holds |
(...skipping 23 matching lines...) Expand all Loading... |
184 scoped_refptr<MediaStreamAudioRenderer> audio_renderer_; | 184 scoped_refptr<MediaStreamAudioRenderer> audio_renderer_; |
185 | 185 |
186 scoped_refptr<media::MediaLog> media_log_; | 186 scoped_refptr<media::MediaLog> media_log_; |
187 | 187 |
188 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS); | 188 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS); |
189 }; | 189 }; |
190 | 190 |
191 } // namespace content | 191 } // namespace content |
192 | 192 |
193 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ | 193 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ |
OLD | NEW |