Make USB permissions work in the new permission message system
[chromium-blink-merge.git] / content / renderer / media / rtc_video_renderer.h
blob67a62af89692a273be979ad9169fa835628c6c19
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.
5 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_RENDERER_H_
6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_RENDERER_H_
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "content/common/content_export.h"
11 #include "content/common/media/video_capture.h"
12 #include "content/public/renderer/media_stream_video_sink.h"
13 #include "content/public/renderer/video_frame_provider.h"
14 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
15 #include "ui/gfx/geometry/size.h"
17 namespace base {
18 class SingleThreadTaskRunner;
21 namespace content {
23 // RTCVideoRenderer is a VideoFrameProvider designed for rendering Video
24 // MediaStreamTracks [1], RTCVideoRenderer implements MediaStreamVideoSink in
25 // order to render video frames provided from a MediaStreamVideoTrack, to which
26 // it AddToVideoTrack()s itself when the VideoFrameProvider is Start()ed
27 // and RemoveFromVideoTrack()s itself when the latter is Stop()ed.
29 // [1] http://dev.w3.org/2011/webrtc/editor/getusermedia.html#mediastreamtrack
31 // TODO(wuchengli): Add unit test. See the link below for reference.
32 // http://src.chromium.org/viewvc/chrome/trunk/src/content/renderer/media/rtc_vi
33 // deo_decoder_unittest.cc?revision=180591&view=markup
34 class CONTENT_EXPORT RTCVideoRenderer
35 : NON_EXPORTED_BASE(public VideoFrameProvider),
36 NON_EXPORTED_BASE(public MediaStreamVideoSink) {
37 public:
38 RTCVideoRenderer(const blink::WebMediaStreamTrack& video_track,
39 const base::Closure& error_cb,
40 const RepaintCB& repaint_cb);
42 // VideoFrameProvider implementation. Called on the main thread.
43 void Start() override;
44 void Stop() override;
45 void Play() override;
46 void Pause() override;
48 protected:
49 ~RTCVideoRenderer() override;
51 private:
52 enum State {
53 STARTED,
54 PAUSED,
55 STOPPED,
58 void OnVideoFrame(const scoped_refptr<media::VideoFrame>& frame,
59 const base::TimeTicks& estimated_capture_time);
61 // MediaStreamVideoSink implementation. Called on the main thread.
62 void OnReadyStateChanged(
63 blink::WebMediaStreamSource::ReadyState state) override;
65 void RenderSignalingFrame();
67 const base::Closure error_cb_;
68 const RepaintCB repaint_cb_;
69 const scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
70 State state_;
71 gfx::Size frame_size_;
72 const blink::WebMediaStreamTrack video_track_;
73 base::WeakPtrFactory<RTCVideoRenderer> weak_factory_;
75 DISALLOW_COPY_AND_ASSIGN(RTCVideoRenderer);
78 } // namespace content
80 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_RENDERER_H_