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
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_
6 #define CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_
8 #include "base/callback.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/ref_counted.h"
11 #include "base/time/time.h"
12 #include "content/common/content_export.h"
13 #include "content/common/media/video_capture.h"
14 #include "content/public/renderer/media_stream_sink.h"
15 #include "media/base/video_capturer_source.h"
18 class WebMediaStreamTrack
;
23 // MediaStreamVideoSink is an interface used for receiving video frames from a
24 // Video Stream Track or a Video Source.
25 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html
26 // All methods calls will be done from the main render thread.
27 class CONTENT_EXPORT MediaStreamVideoSink
: public MediaStreamSink
{
29 // An implementation of MediaStreamVideoSink should call AddToVideoTrack when
30 // it is ready to receive data from a video track. Before the implementation
31 // is destroyed, RemoveFromVideoTrack must be called.
33 // Calls to these methods must be done on the main render thread.
34 // Note that |callback| for frame delivery happens on the IO thread.
36 // Calling RemoveFromVideoTrack also not stop frame delivery through the
37 // callback immediately because it may happen on another thread.
38 // The added callback will be reset on the render thread.
39 static void AddToVideoTrack(MediaStreamVideoSink
* sink
,
40 const VideoCaptureDeliverFrameCB
& callback
,
41 const blink::WebMediaStreamTrack
& track
);
42 static void RemoveFromVideoTrack(MediaStreamVideoSink
* sink
,
43 const blink::WebMediaStreamTrack
& track
);
46 ~MediaStreamVideoSink() override
{}
50 } // namespace content
52 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_