OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_MEDIA_STREAM_VIDEO_SOURCE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ |
6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "content/common/content_export.h" | 11 #include "content/common/content_export.h" |
12 #include "content/renderer/media/media_stream_dependency_factory.h" | 12 #include "content/renderer/media/media_stream_dependency_factory.h" |
13 #include "content/renderer/media/media_stream_source.h" | 13 #include "content/renderer/media/media_stream_source.h" |
14 #include "media/base/video_frame.h" | 14 #include "media/base/video_frame.h" |
15 #include "media/base/video_frame_pool.h" | 15 #include "media/base/video_frame_pool.h" |
16 #include "media/video/capture/video_capture_types.h" | 16 #include "media/video/capture/video_capture_types.h" |
17 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 17 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
18 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 18 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
19 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 19 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
20 | 20 |
21 namespace media { | 21 namespace media { |
22 class VideoFrame; | 22 class VideoFrame; |
23 } | 23 } |
24 | 24 |
25 namespace content { | 25 namespace content { |
26 | 26 |
27 class MediaStreamDependencyFactory; | 27 class MediaStreamDependencyFactory; |
| 28 class MediaStreamVideoTrack; |
28 class WebRtcVideoCapturerAdapter; | 29 class WebRtcVideoCapturerAdapter; |
29 | 30 |
30 // MediaStreamVideoSource is an interface used for sending video frames to a | 31 // MediaStreamVideoSource is an interface used for sending video frames to a |
31 // MediaStreamVideoTrack. | 32 // MediaStreamVideoTrack. |
32 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html | 33 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html |
33 // The purpose of this base class is to be able to implement different | 34 // The purpose of this base class is to be able to implement different |
34 // MediaStreaVideoSources such as local video capture, video sources received | 35 // MediaStreaVideoSources such as local video capture, video sources received |
35 // on a PeerConnection or a source created in NaCl. | 36 // on a PeerConnection or a source created in NaCl. |
36 // All methods calls will be done from the main render thread. | 37 // All methods calls will be done from the main render thread. |
37 // | 38 // |
38 // When the first track is added to the source by calling AddTrack | 39 // When the first track is added to the source by calling AddTrack |
39 // the MediaStreamVideoSource implementation calls GetCurrentSupportedFormats. | 40 // the MediaStreamVideoSource implementation calls GetCurrentSupportedFormats. |
40 // the source implementation must call OnSupportedFormats. | 41 // the source implementation must call OnSupportedFormats. |
41 // MediaStreamVideoSource then match the constraints provided in AddTrack with | 42 // MediaStreamVideoSource then match the constraints provided in AddTrack with |
42 // the formats and call StartSourceImpl. The source implementation must call | 43 // the formats and call StartSourceImpl. The source implementation must call |
43 // OnStartDone when the underlying source has been started or failed to | 44 // OnStartDone when the underlying source has been started or failed to |
44 // start. | 45 // start. |
45 class CONTENT_EXPORT MediaStreamVideoSource | 46 class CONTENT_EXPORT MediaStreamVideoSource |
46 : public MediaStreamSource, | 47 : public MediaStreamSource, |
47 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 48 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
48 public: | 49 public: |
49 explicit MediaStreamVideoSource(MediaStreamDependencyFactory* factory); | 50 explicit MediaStreamVideoSource(MediaStreamDependencyFactory* factory); |
50 virtual ~MediaStreamVideoSource(); | 51 virtual ~MediaStreamVideoSource(); |
51 | 52 |
| 53 // Returns the MediaStreamVideoSource object owned by |source|. |
| 54 static MediaStreamVideoSource* GetVideoSource( |
| 55 const blink::WebMediaStreamSource& source); |
| 56 |
52 // Puts |track| in the registered tracks list. | 57 // Puts |track| in the registered tracks list. |
53 virtual void AddTrack(const blink::WebMediaStreamTrack& track, | 58 void AddTrack(MediaStreamVideoTrack* track, |
54 const blink::WebMediaConstraints& constraints, | 59 const blink::WebMediaConstraints& constraints, |
55 const ConstraintsCallback& callback) OVERRIDE; | 60 const ConstraintsCallback& callback); |
56 virtual void RemoveTrack(const blink::WebMediaStreamTrack& track) OVERRIDE; | 61 void RemoveTrack(MediaStreamVideoTrack* track); |
57 | 62 |
58 // TODO(ronghuawu): Remove webrtc::VideoSourceInterface from the public | 63 // TODO(ronghuawu): Remove webrtc::VideoSourceInterface from the public |
59 // interface of this class. | 64 // interface of this class. |
60 // This creates a VideoSourceInterface implementation if it does not already | 65 // This creates a VideoSourceInterface implementation if it does not already |
61 // exist. | 66 // exist. |
62 webrtc::VideoSourceInterface* GetAdapter(); | 67 webrtc::VideoSourceInterface* GetAdapter(); |
63 | 68 |
64 // Constraint keys used by a video source. | 69 // Constraint keys used by a video source. |
65 // Specified by draft-alvestrand-constraints-resolution-00b | 70 // Specified by draft-alvestrand-constraints-resolution-00b |
66 static const char kMinAspectRatio[]; // minAspectRatio | 71 static const char kMinAspectRatio[]; // minAspectRatio |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 const ConstraintsCallback& callback); | 156 const ConstraintsCallback& callback); |
152 ~RequestedConstraints(); | 157 ~RequestedConstraints(); |
153 | 158 |
154 blink::WebMediaConstraints constraints; | 159 blink::WebMediaConstraints constraints; |
155 ConstraintsCallback callback; | 160 ConstraintsCallback callback; |
156 }; | 161 }; |
157 std::vector<RequestedConstraints> requested_constraints_; | 162 std::vector<RequestedConstraints> requested_constraints_; |
158 | 163 |
159 media::VideoCaptureFormats supported_formats_; | 164 media::VideoCaptureFormats supported_formats_; |
160 | 165 |
| 166 // Tracks that currently are receiving video frames. |
| 167 std::vector<MediaStreamVideoTrack*> tracks_; |
| 168 |
161 // TODO(perkj): The below classes use webrtc/libjingle types. The goal is to | 169 // TODO(perkj): The below classes use webrtc/libjingle types. The goal is to |
162 // get rid of them as far as possible. | 170 // get rid of them as far as possible. |
163 MediaStreamDependencyFactory* factory_; | 171 MediaStreamDependencyFactory* factory_; |
164 scoped_refptr<webrtc::VideoSourceInterface> adapter_; | 172 scoped_refptr<webrtc::VideoSourceInterface> adapter_; |
165 WebRtcVideoCapturerAdapter* capture_adapter_; | 173 WebRtcVideoCapturerAdapter* capture_adapter_; |
166 | 174 |
167 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); | 175 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); |
168 }; | 176 }; |
169 | 177 |
170 } // namespace content | 178 } // namespace content |
171 | 179 |
172 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ | 180 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ |
OLD | NEW |