OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 161 } |
162 | 162 |
163 // Stop the video capturer. | 163 // Stop the video capturer. |
164 virtual void Stop() = 0; | 164 virtual void Stop() = 0; |
165 // Check if the video capturer is running. | 165 // Check if the video capturer is running. |
166 virtual bool IsRunning() = 0; | 166 virtual bool IsRunning() = 0; |
167 CaptureState capture_state() const { | 167 CaptureState capture_state() const { |
168 return capture_state_; | 168 return capture_state_; |
169 } | 169 } |
170 | 170 |
171 virtual bool GetApplyRotation() { return apply_rotation_; } | 171 virtual bool apply_rotation() { return apply_rotation_; } |
172 | 172 |
173 // Returns true if the capturer is screencasting. This can be used to | 173 // Returns true if the capturer is screencasting. This can be used to |
174 // implement screencast specific behavior. | 174 // implement screencast specific behavior. |
175 virtual bool IsScreencast() const = 0; | 175 virtual bool IsScreencast() const = 0; |
176 | 176 |
177 // Caps the VideoCapturer's format according to max_format. It can e.g. be | 177 // Caps the VideoCapturer's format according to max_format. It can e.g. be |
178 // used to prevent cameras from capturing at a resolution or framerate that | 178 // used to prevent cameras from capturing at a resolution or framerate that |
179 // the capturer is capable of but not performing satisfactorily at. | 179 // the capturer is capable of but not performing satisfactorily at. |
180 // The capping is an upper bound for each component of the capturing format. | 180 // The capping is an upper bound for each component of the capturing format. |
181 // The fourcc component is ignored. | 181 // The fourcc component is ignored. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // Implements VideoSourceInterface | 215 // Implements VideoSourceInterface |
216 void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink, | 216 void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink, |
217 const rtc::VideoSinkWants& wants) override; | 217 const rtc::VideoSinkWants& wants) override; |
218 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override; | 218 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override; |
219 | 219 |
220 protected: | 220 protected: |
221 // OnSinkWantsChanged can be overridden to change the default behavior | 221 // OnSinkWantsChanged can be overridden to change the default behavior |
222 // when a sink changes its VideoSinkWants by calling AddOrUpdateSink. | 222 // when a sink changes its VideoSinkWants by calling AddOrUpdateSink. |
223 virtual void OnSinkWantsChanged(const rtc::VideoSinkWants& wants); | 223 virtual void OnSinkWantsChanged(const rtc::VideoSinkWants& wants); |
224 | 224 |
| 225 // Reports the appropriate frame size after adaptation. Returns true |
| 226 // if a frame is wanted. Returns false if there are no interested |
| 227 // sinks, or if the VideoAdapter decides to drop the frame. |
| 228 bool AdaptFrame(int width, int height, int* out_width, int* out_height, |
| 229 int* crop_width, int* crop_height, int* crop_x, int* crop_y); |
| 230 |
225 // Callback attached to SignalFrameCaptured where SignalVideoFrames is called. | 231 // Callback attached to SignalFrameCaptured where SignalVideoFrames is called. |
226 void OnFrameCaptured(VideoCapturer* video_capturer, | 232 void OnFrameCaptured(VideoCapturer* video_capturer, |
227 const CapturedFrame* captured_frame); | 233 const CapturedFrame* captured_frame); |
228 | 234 |
229 // Called when a frame has been captured and converted to a VideoFrame. | 235 // Called when a frame has been captured and converted to a |
230 // OnFrame can be called directly by an implementation that does not use | 236 // VideoFrame. OnFrame can be called directly by an implementation |
231 // SignalFrameCaptured or OnFrameCaptured. | 237 // that does not use SignalFrameCaptured or OnFrameCaptured. The |
232 void OnFrame(VideoCapturer* capturer, const VideoFrame* frame); | 238 // orig_width and orig_height are used only to produce stats. |
| 239 void OnFrame(const VideoFrame& frame, int orig_width, int orig_height); |
233 | 240 |
234 VideoAdapter* video_adapter() { return &video_adapter_; } | 241 VideoAdapter* video_adapter() { return &video_adapter_; } |
235 | 242 |
236 void SetCaptureState(CaptureState state); | 243 void SetCaptureState(CaptureState state); |
237 | 244 |
238 // subclasses override this virtual method to provide a vector of fourccs, in | 245 // subclasses override this virtual method to provide a vector of fourccs, in |
239 // order of preference, that are expected by the media engine. | 246 // order of preference, that are expected by the media engine. |
240 virtual bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) = 0; | 247 virtual bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) = 0; |
241 | 248 |
242 // mutators to set private attributes | 249 // mutators to set private attributes |
(...skipping 23 matching lines...) Expand all Loading... |
266 | 273 |
267 // Convert captured frame to readable string for LOG messages. | 274 // Convert captured frame to readable string for LOG messages. |
268 std::string ToString(const CapturedFrame* frame) const; | 275 std::string ToString(const CapturedFrame* frame) const; |
269 | 276 |
270 // Updates filtered_supported_formats_ so that it contains the formats in | 277 // Updates filtered_supported_formats_ so that it contains the formats in |
271 // supported_formats_ that fulfill all applied restrictions. | 278 // supported_formats_ that fulfill all applied restrictions. |
272 void UpdateFilteredSupportedFormats(); | 279 void UpdateFilteredSupportedFormats(); |
273 // Returns true if format doesn't fulfill all applied restrictions. | 280 // Returns true if format doesn't fulfill all applied restrictions. |
274 bool ShouldFilterFormat(const VideoFormat& format) const; | 281 bool ShouldFilterFormat(const VideoFormat& format) const; |
275 | 282 |
276 void UpdateInputSize(const CapturedFrame* captured_frame); | 283 void UpdateInputSize(int width, int height); |
277 | 284 |
278 rtc::ThreadChecker thread_checker_; | 285 rtc::ThreadChecker thread_checker_; |
279 std::string id_; | 286 std::string id_; |
280 CaptureState capture_state_; | 287 CaptureState capture_state_; |
281 std::unique_ptr<VideoFrameFactory> frame_factory_; | 288 std::unique_ptr<VideoFrameFactory> frame_factory_; |
282 std::unique_ptr<VideoFormat> capture_format_; | 289 std::unique_ptr<VideoFormat> capture_format_; |
283 std::vector<VideoFormat> supported_formats_; | 290 std::vector<VideoFormat> supported_formats_; |
284 std::unique_ptr<VideoFormat> max_format_; | 291 std::unique_ptr<VideoFormat> max_format_; |
285 std::vector<VideoFormat> filtered_supported_formats_; | 292 std::vector<VideoFormat> filtered_supported_formats_; |
286 | 293 |
(...skipping 13 matching lines...) Expand all Loading... |
300 | 307 |
301 // Whether capturer should apply rotation to the frame before signaling it. | 308 // Whether capturer should apply rotation to the frame before signaling it. |
302 bool apply_rotation_; | 309 bool apply_rotation_; |
303 | 310 |
304 RTC_DISALLOW_COPY_AND_ASSIGN(VideoCapturer); | 311 RTC_DISALLOW_COPY_AND_ASSIGN(VideoCapturer); |
305 }; | 312 }; |
306 | 313 |
307 } // namespace cricket | 314 } // namespace cricket |
308 | 315 |
309 #endif // WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ | 316 #endif // WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ |
OLD | NEW |