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/video/capture/video_capture_types.h" | 16 #include "media/video/capture/video_capture_types.h" |
16 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" | 17 #include "third_party/WebKit/public/platform/WebMediaConstraints.h" |
17 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 18 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
18 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" | 19 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h" |
19 | 20 |
20 namespace media { | 21 namespace media { |
21 class VideoFrame; | 22 class VideoFrame; |
22 } | 23 } |
23 | 24 |
24 namespace content { | 25 namespace content { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // call OnSupportedFormats after this method has been called. After this | 112 // call OnSupportedFormats after this method has been called. After this |
112 // method has been called, MediaStreamVideoSource may be deleted. | 113 // method has been called, MediaStreamVideoSource may be deleted. |
113 virtual void StopSourceImpl() = 0; | 114 virtual void StopSourceImpl() = 0; |
114 | 115 |
115 private: | 116 private: |
116 // Creates a webrtc::VideoSourceInterface used by libjingle. | 117 // Creates a webrtc::VideoSourceInterface used by libjingle. |
117 void InitAdapter(); | 118 void InitAdapter(); |
118 | 119 |
119 // Finds the first constraints in |requested_constraints_| that can be | 120 // Finds the first constraints in |requested_constraints_| that can be |
120 // fulfilled. |best_format| is set to the video resolution that can be | 121 // fulfilled. |best_format| is set to the video resolution that can be |
121 // fulfilled. |resulting_constraints| is set to the found constraints in | 122 // fulfilled. |frame_output_size| is the requested frame size after cropping. |
| 123 // |resulting_constraints| is set to the found constraints in |
122 // |requested_constraints_|. | 124 // |requested_constraints_|. |
123 bool FindBestFormatWithConstraints( | 125 bool FindBestFormatWithConstraints( |
124 const media::VideoCaptureFormats& formats, | 126 const media::VideoCaptureFormats& formats, |
125 media::VideoCaptureFormat* best_format, | 127 media::VideoCaptureFormat* best_format, |
| 128 gfx::Size* frame_output_size, |
126 blink::WebMediaConstraints* resulting_constraints); | 129 blink::WebMediaConstraints* resulting_constraints); |
127 | 130 |
128 // Trigger all cached callbacks from AddTrack. AddTrack is successful | 131 // Trigger all cached callbacks from AddTrack. AddTrack is successful |
129 // if the capture delegate has started and the constraints provided in | 132 // if the capture delegate has started and the constraints provided in |
130 // AddTrack match the format that was used to start the device. | 133 // AddTrack match the format that was used to start the device. |
131 void FinalizeAddTrack(); | 134 void FinalizeAddTrack(); |
132 | 135 |
133 enum State { | 136 enum State { |
134 NEW, | 137 NEW, |
135 RETRIEVING_CAPABILITIES, | 138 RETRIEVING_CAPABILITIES, |
136 STARTING, | 139 STARTING, |
137 STARTED, | 140 STARTED, |
138 ENDED | 141 ENDED |
139 }; | 142 }; |
140 State state_; | 143 State state_; |
141 | 144 |
142 media::VideoCaptureFormat current_format_; | 145 media::VideoCaptureFormat current_format_; |
143 blink::WebMediaConstraints current_constraints_; | 146 blink::WebMediaConstraints current_constraints_; |
| 147 gfx::Size frame_output_size_; |
144 | 148 |
145 struct RequestedConstraints { | 149 struct RequestedConstraints { |
146 RequestedConstraints(const blink::WebMediaConstraints& constraints, | 150 RequestedConstraints(const blink::WebMediaConstraints& constraints, |
147 const ConstraintsCallback& callback); | 151 const ConstraintsCallback& callback); |
148 ~RequestedConstraints(); | 152 ~RequestedConstraints(); |
149 | 153 |
150 blink::WebMediaConstraints constraints; | 154 blink::WebMediaConstraints constraints; |
151 ConstraintsCallback callback; | 155 ConstraintsCallback callback; |
152 }; | 156 }; |
153 std::vector<RequestedConstraints> requested_constraints_; | 157 std::vector<RequestedConstraints> requested_constraints_; |
154 | 158 |
155 media::VideoCaptureFormats supported_formats_; | 159 media::VideoCaptureFormats supported_formats_; |
156 | 160 |
157 // TODO(perkj): The below classes use webrtc/libjingle types. The goal is to | 161 // TODO(perkj): The below classes use webrtc/libjingle types. The goal is to |
158 // get rid of them as far as possible. | 162 // get rid of them as far as possible. |
159 MediaStreamDependencyFactory* factory_; | 163 MediaStreamDependencyFactory* factory_; |
160 scoped_refptr<webrtc::VideoSourceInterface> adapter_; | 164 scoped_refptr<webrtc::VideoSourceInterface> adapter_; |
161 WebRtcVideoCapturerAdapter* capture_adapter_; | 165 WebRtcVideoCapturerAdapter* capture_adapter_; |
162 | 166 |
163 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); | 167 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoSource); |
164 }; | 168 }; |
165 | 169 |
166 } // namespace content | 170 } // namespace content |
167 | 171 |
168 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ | 172 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_SOURCE_H_ |
OLD | NEW |