Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: webkit/media/webmediaplayer_ms.h

Issue 10918052: create a separate WebMediaPlayer for URL derived from media stream (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: code review Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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_WEBMEDIAPLAYER_MS_H_
6 #define WEBKIT_MEDIA_WEBMEDIAPLAYER_MS_H_
7
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "googleurl/src/gurl.h"
12 #include "skia/ext/platform_canvas.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayer.h"
14 #include "webkit/media/skcanvas_video_renderer.h"
15
16 namespace WebKit {
17 class WebFrame;
18 class WebMediaPlayerClient;
19 }
20
21 namespace media {
22 class MediaLog;
23 }
24
25 namespace webkit_media {
26
27 class MediaStreamClient;
28 class VideoFrameProvider;
29 class WebMediaPlayerDelegate;
30
31 // WebMediaPlayerMS delegates calls from WebCore::MediaPlayerPrivate to
32 // Chrome's media player when "src" is from media stream.
33 //
34 // WebMediaPlayerMS works with multiple objects, the most important ones are:
35 //
36 // VideoFrameProvider
37 // provides video frames for rendering.
38 //
39 // TODO(wjia): add AudioPlayer.
40 // AudioPlayer
41 // plays audio streams.
42 //
43 // WebKit::WebMediaPlayerClient
44 // WebKit client of this media player object.
45 //
scherkus (not reviewing) 2012/09/20 19:27:00 nit: remove extra // line
wjia(left Chromium) 2012/09/21 19:47:27 Done.
46
scherkus (not reviewing) 2012/09/20 19:27:00 nit: remove extra blank line
wjia(left Chromium) 2012/09/21 19:47:27 Done.
47 class WebMediaPlayerMS
48 : public WebKit::WebMediaPlayer,
49 public base::SupportsWeakPtr<WebMediaPlayerMS> {
50 public:
51 // Construct a WebMediaPlayerMS with reference to the client, and
52 // a MediaStreamClient which provides VideoFrameProvider.
53 WebMediaPlayerMS(WebKit::WebFrame* frame,
54 WebKit::WebMediaPlayerClient* client,
55 base::WeakPtr<WebMediaPlayerDelegate> delegate,
56 MediaStreamClient* media_stream_client,
57 media::MediaLog* media_log);
58 virtual ~WebMediaPlayerMS();
59
60 virtual void load(const WebKit::WebURL& url, CORSMode cors_mode) OVERRIDE;
61 virtual void cancelLoad() OVERRIDE;
62
63 // Playback controls.
64 virtual void play() OVERRIDE;
65 virtual void pause() OVERRIDE;
66 virtual bool supportsFullscreen() const OVERRIDE;
67 virtual bool supportsSave() const OVERRIDE;
68 virtual void seek(float seconds) OVERRIDE;
69 virtual void setEndTime(float seconds) OVERRIDE;
70 virtual void setRate(float rate) OVERRIDE;
71 virtual void setVolume(float volume) OVERRIDE;
72 virtual void setVisible(bool visible) OVERRIDE;
73 virtual void setPreload(WebKit::WebMediaPlayer::Preload preload) OVERRIDE;
74 virtual bool totalBytesKnown() OVERRIDE;
75 virtual const WebKit::WebTimeRanges& buffered() OVERRIDE;
76 virtual float maxTimeSeekable() const OVERRIDE;
77
78 // Methods for painting.
79 virtual void setSize(const WebKit::WebSize& size) OVERRIDE;
80
81 virtual void paint(WebKit::WebCanvas* canvas,
82 const WebKit::WebRect& rect,
83 uint8_t alpha) OVERRIDE;
84
85 // True if the loaded media has a playable video/audio track.
86 virtual bool hasVideo() const OVERRIDE;
87 virtual bool hasAudio() const OVERRIDE;
88
89 // Dimensions of the video.
90 virtual WebKit::WebSize naturalSize() const OVERRIDE;
91
92 // Getters of playback state.
93 virtual bool paused() const OVERRIDE;
94 virtual bool seeking() const OVERRIDE;
95 virtual float duration() const OVERRIDE;
96 virtual float currentTime() const OVERRIDE;
97
98 // Get rate of loading the resource.
99 virtual int32 dataRate() const OVERRIDE;
100
101 // Internal states of loading and network.
102 virtual WebKit::WebMediaPlayer::NetworkState networkState() const OVERRIDE;
103 virtual WebKit::WebMediaPlayer::ReadyState readyState() const OVERRIDE;
104
105 virtual bool didLoadingProgress() const OVERRIDE;
106 virtual unsigned long long totalBytes() const OVERRIDE;
107
108 virtual bool hasSingleSecurityOrigin() const OVERRIDE;
109 virtual bool didPassCORSAccessCheck() const OVERRIDE;
110 virtual WebKit::WebMediaPlayer::MovieLoadType movieLoadType() const OVERRIDE;
111
112 virtual float mediaTimeForTimeValue(float timeValue) const OVERRIDE;
113
114 virtual unsigned decodedFrameCount() const OVERRIDE;
115 virtual unsigned droppedFrameCount() const OVERRIDE;
116 virtual unsigned audioDecodedByteCount() const OVERRIDE;
117 virtual unsigned videoDecodedByteCount() const OVERRIDE;
118
119 virtual WebKit::WebVideoFrame* getCurrentFrame() OVERRIDE;
120 virtual void putCurrentFrame(WebKit::WebVideoFrame* web_video_frame) OVERRIDE;
121
122 private:
123 // The callback for VideoFrameProvider to signal a new frame is available.
124 void OnFrameAvailable(const scoped_refptr<media::VideoFrame>& frame);
125 // Need repaint due to state change.
126 void RepaintInternal();
127
128 // The callback for source to report error.
129 void OnSourceError();
130
131 // Helpers that set the network/ready state and notifies the client if
132 // they've changed.
133 void SetNetworkState(WebKit::WebMediaPlayer::NetworkState state);
134 void SetReadyState(WebKit::WebMediaPlayer::ReadyState state);
135
136 // Getter method to |client_|.
137 WebKit::WebMediaPlayerClient* GetClient();
138
139 WebKit::WebFrame* frame_;
140
141 WebKit::WebMediaPlayer::NetworkState network_state_;
142 WebKit::WebMediaPlayer::ReadyState ready_state_;
143
144 WebKit::WebTimeRanges buffered_;
145
146 // Used for DCHECKs to ensure methods calls executed in the correct thread.
147 base::ThreadChecker thread_checker_;
148
149 WebKit::WebMediaPlayerClient* client_;
150
151 base::WeakPtr<WebMediaPlayerDelegate> delegate_;
152
153 MediaStreamClient* media_stream_client_;
154 scoped_refptr<VideoFrameProvider> video_frame_provider_;
155 bool video_frame_provider_started_;
156 bool paused_;
157 scoped_refptr<media::VideoFrame> current_frame_;
158 bool pending_repaint_;
159 bool got_first_frame_;
160 base::TimeDelta start_time_;
161 unsigned total_frame_count_;
162 unsigned dropped_frame_count_;
163 SkCanvasVideoRenderer video_renderer_;
164
165 scoped_refptr<media::MediaLog> media_log_;
166
167 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS);
168 };
169
170 } // namespace webkit_media
171
172 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_MS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698