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

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, 2 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
« no previous file with comments | « webkit/media/webkit_media.gypi ('k') | webkit/media/webmediaplayer_ms.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class WebMediaPlayerMS
46 : public WebKit::WebMediaPlayer,
47 public base::SupportsWeakPtr<WebMediaPlayerMS> {
48 public:
49 // Construct a WebMediaPlayerMS with reference to the client, and
50 // a MediaStreamClient which provides VideoFrameProvider.
51 WebMediaPlayerMS(WebKit::WebFrame* frame,
52 WebKit::WebMediaPlayerClient* client,
53 base::WeakPtr<WebMediaPlayerDelegate> delegate,
54 MediaStreamClient* media_stream_client,
55 media::MediaLog* media_log);
56 virtual ~WebMediaPlayerMS();
57
58 virtual void load(const WebKit::WebURL& url, CORSMode cors_mode) OVERRIDE;
59 virtual void cancelLoad() OVERRIDE;
60
61 // Playback controls.
62 virtual void play() OVERRIDE;
63 virtual void pause() OVERRIDE;
64 virtual bool supportsFullscreen() const OVERRIDE;
65 virtual bool supportsSave() const OVERRIDE;
66 virtual void seek(float seconds) OVERRIDE;
67 virtual void setEndTime(float seconds) OVERRIDE;
68 virtual void setRate(float rate) OVERRIDE;
69 virtual void setVolume(float volume) OVERRIDE;
70 virtual void setVisible(bool visible) OVERRIDE;
71 virtual void setPreload(WebKit::WebMediaPlayer::Preload preload) OVERRIDE;
72 virtual bool totalBytesKnown() OVERRIDE;
73 virtual const WebKit::WebTimeRanges& buffered() OVERRIDE;
74 virtual float maxTimeSeekable() const OVERRIDE;
75
76 // Methods for painting.
77 virtual void setSize(const WebKit::WebSize& size) OVERRIDE;
78
79 virtual void paint(WebKit::WebCanvas* canvas,
80 const WebKit::WebRect& rect,
81 uint8_t alpha) OVERRIDE;
82
83 // True if the loaded media has a playable video/audio track.
84 virtual bool hasVideo() const OVERRIDE;
85 virtual bool hasAudio() const OVERRIDE;
86
87 // Dimensions of the video.
88 virtual WebKit::WebSize naturalSize() const OVERRIDE;
89
90 // Getters of playback state.
91 virtual bool paused() const OVERRIDE;
92 virtual bool seeking() const OVERRIDE;
93 virtual float duration() const OVERRIDE;
94 virtual float currentTime() const OVERRIDE;
95
96 // Get rate of loading the resource.
97 virtual int32 dataRate() const OVERRIDE;
98
99 // Internal states of loading and network.
100 virtual WebKit::WebMediaPlayer::NetworkState networkState() const OVERRIDE;
101 virtual WebKit::WebMediaPlayer::ReadyState readyState() const OVERRIDE;
102
103 virtual bool didLoadingProgress() const OVERRIDE;
104 virtual unsigned long long totalBytes() const OVERRIDE;
105
106 virtual bool hasSingleSecurityOrigin() const OVERRIDE;
107 virtual bool didPassCORSAccessCheck() const OVERRIDE;
108 virtual WebKit::WebMediaPlayer::MovieLoadType movieLoadType() const OVERRIDE;
109
110 virtual float mediaTimeForTimeValue(float timeValue) const OVERRIDE;
111
112 virtual unsigned decodedFrameCount() const OVERRIDE;
113 virtual unsigned droppedFrameCount() const OVERRIDE;
114 virtual unsigned audioDecodedByteCount() const OVERRIDE;
115 virtual unsigned videoDecodedByteCount() const OVERRIDE;
116
117 virtual WebKit::WebVideoFrame* getCurrentFrame() OVERRIDE;
118 virtual void putCurrentFrame(WebKit::WebVideoFrame* web_video_frame) OVERRIDE;
119
120 private:
121 // The callback for VideoFrameProvider to signal a new frame is available.
122 void OnFrameAvailable(const scoped_refptr<media::VideoFrame>& frame);
123 // Need repaint due to state change.
124 void RepaintInternal();
125
126 // The callback for source to report error.
127 void OnSourceError();
128
129 // Helpers that set the network/ready state and notifies the client if
130 // they've changed.
131 void SetNetworkState(WebKit::WebMediaPlayer::NetworkState state);
132 void SetReadyState(WebKit::WebMediaPlayer::ReadyState state);
133
134 // Getter method to |client_|.
135 WebKit::WebMediaPlayerClient* GetClient();
136
137 WebKit::WebFrame* frame_;
138
139 WebKit::WebMediaPlayer::NetworkState network_state_;
140 WebKit::WebMediaPlayer::ReadyState ready_state_;
141
142 WebKit::WebTimeRanges buffered_;
143
144 // Used for DCHECKs to ensure methods calls executed in the correct thread.
145 base::ThreadChecker thread_checker_;
146
147 WebKit::WebMediaPlayerClient* client_;
148
149 base::WeakPtr<WebMediaPlayerDelegate> delegate_;
150
151 MediaStreamClient* media_stream_client_;
152 scoped_refptr<VideoFrameProvider> video_frame_provider_;
153 bool video_frame_provider_started_;
154 bool paused_;
155 scoped_refptr<media::VideoFrame> current_frame_;
156 bool pending_repaint_;
157 bool got_first_frame_;
158 base::TimeDelta start_time_;
159 unsigned total_frame_count_;
160 unsigned dropped_frame_count_;
161 SkCanvasVideoRenderer video_renderer_;
162
163 scoped_refptr<media::MediaLog> media_log_;
164
165 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS);
166 };
167
168 } // namespace webkit_media
169
170 #endif // WEBKIT_MEDIA_WEBMEDIAPLAYER_MS_H_
OLDNEW
« no previous file with comments | « webkit/media/webkit_media.gypi ('k') | webkit/media/webmediaplayer_ms.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698