OLD | NEW |
---|---|
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_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_ | 5 #ifndef CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_ |
6 #define CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_ | 6 #define CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_ |
7 | 7 |
8 #include "base/callback.h" | |
8 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
9 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
10 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
11 #include "content/public/renderer/media_stream_sink.h" | 12 #include "content/public/renderer/media_stream_sink.h" |
13 #include "media/video/capture/video_capture_types.h" | |
perkj_chrome
2014/05/08 08:15:08
Can you forward declare const media::VideoCaptureF
Alpha Left Google
2014/05/08 18:45:51
Done.
| |
12 | 14 |
13 namespace media { | 15 namespace media { |
14 class VideoFrame; | 16 class VideoFrame; |
15 } | 17 } |
16 | 18 |
17 namespace blink { | 19 namespace blink { |
18 class WebMediaStreamTrack; | 20 class WebMediaStreamTrack; |
19 } | 21 } |
20 | 22 |
21 namespace content { | 23 namespace content { |
22 | 24 |
25 typedef base::Callback< | |
26 void(const scoped_refptr<media::VideoFrame>&, | |
27 const media::VideoCaptureFormat&)> | |
28 VideoSinkDeliverFrameCB; | |
29 | |
23 // MediaStreamVideoSink is an interface used for receiving video frames from a | 30 // MediaStreamVideoSink is an interface used for receiving video frames from a |
24 // Video Stream Track or a Video Source. | 31 // Video Stream Track or a Video Source. |
25 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html | 32 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html |
26 // All methods calls will be done from the main render thread. | 33 // All methods calls will be done from the main render thread. |
27 class CONTENT_EXPORT MediaStreamVideoSink : public MediaStreamSink { | 34 class CONTENT_EXPORT MediaStreamVideoSink : public MediaStreamSink { |
28 public: | 35 public: |
29 // An implementation of MediaStreamVideoSink should call AddToVideoTrack when | 36 // An implementation of MediaStreamVideoSink should call AddToVideoTrack when |
30 // it is ready to receive data from a video track. Before the implementation | 37 // it is ready to receive data from a video track. Before the implementation |
31 // is destroyed, RemoveFromVideoTrack must be called. | 38 // is destroyed, RemoveFromVideoTrack must be called. |
32 // Calls to these methods must be done on the main render thread. | 39 // Calls to these methods must be done on the main render thread. |
40 // Note that |callback| for frame delivery can be called on an arbitrary | |
perkj_chrome
2014/05/08 08:15:08
I like not making promises, but I think Tommmi wan
Alpha Left Google
2014/05/08 18:45:51
Done.
| |
41 // thread. Calling RemoveFromVideoTrack also does not stop frame delivery | |
42 // through the callback immediately because it may happen on another thread. | |
33 static void AddToVideoTrack(MediaStreamVideoSink* sink, | 43 static void AddToVideoTrack(MediaStreamVideoSink* sink, |
44 const VideoSinkDeliverFrameCB& callback, | |
34 const blink::WebMediaStreamTrack& track); | 45 const blink::WebMediaStreamTrack& track); |
35 static void RemoveFromVideoTrack(MediaStreamVideoSink* sink, | 46 static void RemoveFromVideoTrack(MediaStreamVideoSink* sink, |
36 const blink::WebMediaStreamTrack& track); | 47 const blink::WebMediaStreamTrack& track); |
37 | 48 |
38 virtual void OnVideoFrame(const scoped_refptr<media::VideoFrame>& frame) = 0; | |
39 | |
40 protected: | 49 protected: |
41 virtual ~MediaStreamVideoSink() {} | 50 virtual ~MediaStreamVideoSink() {} |
42 }; | 51 }; |
43 | 52 |
44 | 53 |
45 } // namespace content | 54 } // namespace content |
46 | 55 |
47 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_ | 56 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_ |
OLD | NEW |