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/callback.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/time/time.h" |
11 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
12 #include "content/public/renderer/media_stream_sink.h" | 13 #include "content/public/renderer/media_stream_sink.h" |
13 | 14 |
14 namespace media { | 15 namespace media { |
15 class VideoCaptureFormat; | 16 class VideoCaptureFormat; |
16 class VideoFrame; | 17 class VideoFrame; |
17 } | 18 } |
18 | 19 |
19 namespace blink { | 20 namespace blink { |
20 class WebMediaStreamTrack; | 21 class WebMediaStreamTrack; |
21 } | 22 } |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 | 25 |
| 26 // This callback is used to deliver video frames. |
| 27 // |estimated_capture_time| - An optional field to provide the capture time of |
| 28 // the delivered video frame. This field usually means the local time when the |
| 29 // video frame was generated. It is possible for this value to be null if this |
| 30 // timing information cannot be determined. There is no gurantee that this |
| 31 // value is accurate. For example video frames from a remote source can only |
| 32 // provide this timing information as an estimate. |
| 33 // |video_frame->timestamp()| gives the presentation timestamp of the video |
| 34 // frame relative to the first frame generated by the corresponding source. |
| 35 // Because a source can start generating frames before a subscriber is added, |
| 36 // the first video frame delivered may not have timestamp equal to 0. |
25 typedef base::Callback< | 37 typedef base::Callback< |
26 void(const scoped_refptr<media::VideoFrame>&, | 38 void(const scoped_refptr<media::VideoFrame>& video_frame, |
27 const media::VideoCaptureFormat&)> | 39 const media::VideoCaptureFormat& format, |
28 VideoSinkDeliverFrameCB; | 40 const base::TimeTicks& estimated_capture_time)> |
| 41 VideoCaptureDeliverFrameCB; |
29 | 42 |
30 // MediaStreamVideoSink is an interface used for receiving video frames from a | 43 // MediaStreamVideoSink is an interface used for receiving video frames from a |
31 // Video Stream Track or a Video Source. | 44 // Video Stream Track or a Video Source. |
32 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html | 45 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html |
33 // All methods calls will be done from the main render thread. | 46 // All methods calls will be done from the main render thread. |
34 class CONTENT_EXPORT MediaStreamVideoSink : public MediaStreamSink { | 47 class CONTENT_EXPORT MediaStreamVideoSink : public MediaStreamSink { |
35 public: | 48 public: |
36 // An implementation of MediaStreamVideoSink should call AddToVideoTrack when | 49 // An implementation of MediaStreamVideoSink should call AddToVideoTrack when |
37 // it is ready to receive data from a video track. Before the implementation | 50 // it is ready to receive data from a video track. Before the implementation |
38 // is destroyed, RemoveFromVideoTrack must be called. | 51 // is destroyed, RemoveFromVideoTrack must be called. |
39 // | 52 // |
40 // Calls to these methods must be done on the main render thread. | 53 // Calls to these methods must be done on the main render thread. |
41 // Note that |callback| for frame delivery happens on the IO thread. | 54 // Note that |callback| for frame delivery happens on the IO thread. |
42 // | 55 // |
43 // Calling RemoveFromVideoTrack also not stop frame delivery through the | 56 // Calling RemoveFromVideoTrack also not stop frame delivery through the |
44 // callback immediately because it may happen on another thread. | 57 // callback immediately because it may happen on another thread. |
45 // The added callback will be reset on the render thread. | 58 // The added callback will be reset on the render thread. |
46 static void AddToVideoTrack(MediaStreamVideoSink* sink, | 59 static void AddToVideoTrack(MediaStreamVideoSink* sink, |
47 const VideoSinkDeliverFrameCB& callback, | 60 const VideoCaptureDeliverFrameCB& callback, |
48 const blink::WebMediaStreamTrack& track); | 61 const blink::WebMediaStreamTrack& track); |
49 static void RemoveFromVideoTrack(MediaStreamVideoSink* sink, | 62 static void RemoveFromVideoTrack(MediaStreamVideoSink* sink, |
50 const blink::WebMediaStreamTrack& track); | 63 const blink::WebMediaStreamTrack& track); |
51 | 64 |
52 protected: | 65 protected: |
53 virtual ~MediaStreamVideoSink() {} | 66 virtual ~MediaStreamVideoSink() {} |
54 }; | 67 }; |
55 | 68 |
56 | 69 |
57 } // namespace content | 70 } // namespace content |
58 | 71 |
59 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_ | 72 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_VIDEO_SINK_H_ |
OLD | NEW |