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

Side by Side Diff: content/renderer/media/webmediaplayer_ms.h

Issue 2969093002: Make rendering of MediaStreams reflect changes to its set of tracks. (Closed)
Patch Set: rebase Created 3 years, 4 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
OLDNEW
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 <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
16 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
17 #include "content/renderer/media/media_stream.h"
17 #include "media/blink/webmediaplayer_delegate.h" 18 #include "media/blink/webmediaplayer_delegate.h"
18 #include "media/blink/webmediaplayer_util.h" 19 #include "media/blink/webmediaplayer_util.h"
19 #include "media/renderers/gpu_video_accelerator_factories.h" 20 #include "media/renderers/gpu_video_accelerator_factories.h"
20 #include "media/renderers/skcanvas_video_renderer.h" 21 #include "media/renderers/skcanvas_video_renderer.h"
21 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" 22 #include "third_party/WebKit/public/platform/WebMediaPlayer.h"
22 #include "url/origin.h" 23 #include "url/origin.h"
23 24
24 namespace blink { 25 namespace blink {
25 class WebLocalFrame; 26 class WebLocalFrame;
26 class WebMediaPlayerClient; 27 class WebMediaPlayerClient;
(...skipping 28 matching lines...) Expand all
55 // Renderer process. 56 // Renderer process.
56 // 57 //
57 // WebMediaPlayerMS works with multiple objects, the most important ones are: 58 // WebMediaPlayerMS works with multiple objects, the most important ones are:
58 // 59 //
59 // MediaStreamVideoRenderer 60 // MediaStreamVideoRenderer
60 // provides video frames for rendering. 61 // provides video frames for rendering.
61 // 62 //
62 // blink::WebMediaPlayerClient 63 // blink::WebMediaPlayerClient
63 // WebKit client of this media player object. 64 // WebKit client of this media player object.
64 class CONTENT_EXPORT WebMediaPlayerMS 65 class CONTENT_EXPORT WebMediaPlayerMS
65 : public NON_EXPORTED_BASE(blink::WebMediaPlayer), 66 : public NON_EXPORTED_BASE(MediaStreamObserver),
67 public NON_EXPORTED_BASE(blink::WebMediaPlayer),
66 public NON_EXPORTED_BASE(media::WebMediaPlayerDelegate::Observer), 68 public NON_EXPORTED_BASE(media::WebMediaPlayerDelegate::Observer),
67 public NON_EXPORTED_BASE(base::SupportsWeakPtr<WebMediaPlayerMS>) { 69 public NON_EXPORTED_BASE(base::SupportsWeakPtr<WebMediaPlayerMS>) {
68 public: 70 public:
69 // Construct a WebMediaPlayerMS with reference to the client, and 71 // Construct a WebMediaPlayerMS with reference to the client, and
70 // a MediaStreamClient which provides MediaStreamVideoRenderer. 72 // a MediaStreamClient which provides MediaStreamVideoRenderer.
71 // |delegate| must not be null. 73 // |delegate| must not be null.
72 WebMediaPlayerMS( 74 WebMediaPlayerMS(
73 blink::WebLocalFrame* frame, 75 blink::WebLocalFrame* frame,
74 blink::WebMediaPlayerClient* client, 76 blink::WebMediaPlayerClient* client,
75 media::WebMediaPlayerDelegate* delegate, 77 media::WebMediaPlayerDelegate* delegate,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 int level, 174 int level,
173 int internalformat, 175 int internalformat,
174 unsigned format, 176 unsigned format,
175 unsigned type, 177 unsigned type,
176 int xoffset, 178 int xoffset,
177 int yoffset, 179 int yoffset,
178 int zoffset, 180 int zoffset,
179 bool flip_y, 181 bool flip_y,
180 bool premultiply_alpha) override; 182 bool premultiply_alpha) override;
181 183
184 // MediaStreamObserver implementation
185 void TrackAdded(const blink::WebMediaStreamTrack& track) override;
186 void TrackRemoved(const blink::WebMediaStreamTrack& track) override;
187
182 private: 188 private:
183 friend class WebMediaPlayerMSTest; 189 friend class WebMediaPlayerMSTest;
184 190
185 void OnFirstFrameReceived(media::VideoRotation video_rotation, 191 void OnFirstFrameReceived(media::VideoRotation video_rotation,
186 bool is_opaque); 192 bool is_opaque);
187 void OnOpacityChanged(bool is_opaque); 193 void OnOpacityChanged(bool is_opaque);
188 void OnRotationChanged(media::VideoRotation video_rotation, bool is_opaque); 194 void OnRotationChanged(media::VideoRotation video_rotation, bool is_opaque);
189 195
190 // Need repaint due to state change. 196 // Need repaint due to state change.
191 void RepaintInternal(); 197 void RepaintInternal();
192 198
193 // The callback for source to report error. 199 // The callback for source to report error.
194 void OnSourceError(); 200 void OnSourceError();
195 201
196 // Helpers that set the network/ready state and notifies the client if 202 // Helpers that set the network/ready state and notifies the client if
197 // they've changed. 203 // they've changed.
198 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); 204 void SetNetworkState(blink::WebMediaPlayer::NetworkState state);
199 void SetReadyState(blink::WebMediaPlayer::ReadyState state); 205 void SetReadyState(blink::WebMediaPlayer::ReadyState state);
200 206
201 // Getter method to |client_|. 207 // Getter method to |client_|.
202 blink::WebMediaPlayerClient* get_client() { return client_; } 208 blink::WebMediaPlayerClient* get_client() { return client_; }
203 209
210 // To be run when tracks are added or removed.
211 void Reload();
212 void ReloadVideo();
213 void ReloadAudio();
214
204 blink::WebLocalFrame* const frame_; 215 blink::WebLocalFrame* const frame_;
205 216
206 blink::WebMediaPlayer::NetworkState network_state_; 217 blink::WebMediaPlayer::NetworkState network_state_;
207 blink::WebMediaPlayer::ReadyState ready_state_; 218 blink::WebMediaPlayer::ReadyState ready_state_;
208 219
209 const blink::WebTimeRanges buffered_; 220 const blink::WebTimeRanges buffered_;
210 221
211 blink::WebMediaPlayerClient* const client_; 222 blink::WebMediaPlayerClient* const client_;
212 223
213 // WebMediaPlayer notifies the |delegate_| of playback state changes using 224 // WebMediaPlayer notifies the |delegate_| of playback state changes using
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // The last volume received by setVolume() and the last volume multiplier from 270 // The last volume received by setVolume() and the last volume multiplier from
260 // OnVolumeMultiplierUpdate(). The multiplier is typical 1.0, but may be less 271 // OnVolumeMultiplierUpdate(). The multiplier is typical 1.0, but may be less
261 // if the WebMediaPlayerDelegate has requested a volume reduction (ducking) 272 // if the WebMediaPlayerDelegate has requested a volume reduction (ducking)
262 // for a transient sound. Playout volume is derived by volume * multiplier. 273 // for a transient sound. Playout volume is derived by volume * multiplier.
263 double volume_; 274 double volume_;
264 double volume_multiplier_; 275 double volume_multiplier_;
265 276
266 // True if playback should be started upon the next call to OnShown(). Only 277 // True if playback should be started upon the next call to OnShown(). Only
267 // used on Android. 278 // used on Android.
268 bool should_play_upon_shown_; 279 bool should_play_upon_shown_;
280 blink::WebMediaStream web_stream_;
281 // IDs of the tracks currently played.
282 blink::WebString current_video_track_id_;
283 blink::WebString current_audio_track_id_;
269 284
270 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS); 285 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerMS);
271 }; 286 };
272 287
273 } // namespace content 288 } // namespace content
274 289
275 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_ 290 #endif // CONTENT_RENDERER_MEDIA_WEBMEDIAPLAYER_MS_H_
OLDNEW
« no previous file with comments | « content/browser/webrtc/webrtc_getusermedia_browsertest.cc ('k') | content/renderer/media/webmediaplayer_ms.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698