| 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 |
| 11 // Declaration of abstract class VideoCapturer | 11 // Declaration of abstract class VideoCapturer |
| 12 | 12 |
| 13 #ifndef WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ | 13 #ifndef WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ |
| 14 #define WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ | 14 #define WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ |
| 15 | 15 |
| 16 #include <algorithm> | 16 #include <algorithm> |
| 17 #include <memory> | 17 #include <memory> |
| 18 #include <string> | 18 #include <string> |
| 19 #include <vector> | 19 #include <vector> |
| 20 | 20 |
| 21 #include "webrtc/base/basictypes.h" | 21 #include "webrtc/base/basictypes.h" |
| 22 #include "webrtc/base/criticalsection.h" | 22 #include "webrtc/base/criticalsection.h" |
| 23 #include "webrtc/media/base/videosourceinterface.h" | 23 #include "webrtc/media/base/videosourceinterface.h" |
| 24 #include "webrtc/base/rollingaccumulator.h" | |
| 25 #include "webrtc/base/sigslot.h" | 24 #include "webrtc/base/sigslot.h" |
| 26 #include "webrtc/base/timing.h" | |
| 27 #include "webrtc/base/thread_checker.h" | 25 #include "webrtc/base/thread_checker.h" |
| 28 #include "webrtc/media/base/mediachannel.h" | |
| 29 #include "webrtc/media/base/videoadapter.h" | 26 #include "webrtc/media/base/videoadapter.h" |
| 30 #include "webrtc/media/base/videobroadcaster.h" | 27 #include "webrtc/media/base/videobroadcaster.h" |
| 31 #include "webrtc/media/base/videocommon.h" | 28 #include "webrtc/media/base/videocommon.h" |
| 32 #include "webrtc/media/base/videoframefactory.h" | 29 #include "webrtc/media/base/videoframefactory.h" |
| 33 #include "webrtc/media/devices/devicemanager.h" | 30 #include "webrtc/media/devices/devicemanager.h" |
| 34 | 31 |
| 35 | 32 |
| 36 namespace cricket { | 33 namespace cricket { |
| 37 | 34 |
| 38 // Current state of the capturer. | 35 // Current state of the capturer. |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 // and users must call video_adapter()->OnOutputFormatRequest() | 212 // and users must call video_adapter()->OnOutputFormatRequest() |
| 216 // to receive frames. | 213 // to receive frames. |
| 217 bool enable_video_adapter() const { return enable_video_adapter_; } | 214 bool enable_video_adapter() const { return enable_video_adapter_; } |
| 218 void set_enable_video_adapter(bool enable_video_adapter) { | 215 void set_enable_video_adapter(bool enable_video_adapter) { |
| 219 enable_video_adapter_ = enable_video_adapter; | 216 enable_video_adapter_ = enable_video_adapter; |
| 220 } | 217 } |
| 221 | 218 |
| 222 // Takes ownership. | 219 // Takes ownership. |
| 223 void set_frame_factory(VideoFrameFactory* frame_factory); | 220 void set_frame_factory(VideoFrameFactory* frame_factory); |
| 224 | 221 |
| 225 // Gets statistics for tracked variables recorded since the last call to | 222 // TODO(nisse): Rename function? Or pass the frame format before |
| 226 // GetStats. Note that calling GetStats resets any gathered data so it | 223 // adaptation in some other way. |
| 227 // should be called only periodically to log statistics. | 224 void GetStats(VideoFormat* last_captured_frame_format); |
| 228 void GetStats(VariableInfo<int>* adapt_drop_stats, | |
| 229 VariableInfo<int>* effect_drop_stats, | |
| 230 VariableInfo<double>* frame_time_stats, | |
| 231 VideoFormat* last_captured_frame_format); | |
| 232 | 225 |
| 233 // Implements VideoSourceInterface | 226 // Implements VideoSourceInterface |
| 234 void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink, | 227 void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink, |
| 235 const rtc::VideoSinkWants& wants) override; | 228 const rtc::VideoSinkWants& wants) override; |
| 236 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override; | 229 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override; |
| 237 | 230 |
| 238 protected: | 231 protected: |
| 239 // Signal the captured and possibly adapted frame to downstream consumers | 232 // Signal the captured and possibly adapted frame to downstream consumers |
| 240 // such as the encoder. | 233 // such as the encoder. |
| 241 // TODO(perkj): Remove once it is not used by remoting in Chrome. | 234 // TODO(perkj): Remove once it is not used by remoting in Chrome. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 std::string ToString(const CapturedFrame* frame) const; | 285 std::string ToString(const CapturedFrame* frame) const; |
| 293 | 286 |
| 294 // Updates filtered_supported_formats_ so that it contains the formats in | 287 // Updates filtered_supported_formats_ so that it contains the formats in |
| 295 // supported_formats_ that fulfill all applied restrictions. | 288 // supported_formats_ that fulfill all applied restrictions. |
| 296 void UpdateFilteredSupportedFormats(); | 289 void UpdateFilteredSupportedFormats(); |
| 297 // Returns true if format doesn't fulfill all applied restrictions. | 290 // Returns true if format doesn't fulfill all applied restrictions. |
| 298 bool ShouldFilterFormat(const VideoFormat& format) const; | 291 bool ShouldFilterFormat(const VideoFormat& format) const; |
| 299 | 292 |
| 300 void UpdateStats(const CapturedFrame* captured_frame); | 293 void UpdateStats(const CapturedFrame* captured_frame); |
| 301 | 294 |
| 302 // Helper function to save statistics on the current data from a | |
| 303 // RollingAccumulator into stats. | |
| 304 template<class T> | |
| 305 static void GetVariableSnapshot( | |
| 306 const rtc::RollingAccumulator<T>& data, | |
| 307 VariableInfo<T>* stats); | |
| 308 | |
| 309 rtc::ThreadChecker thread_checker_; | 295 rtc::ThreadChecker thread_checker_; |
| 310 std::string id_; | 296 std::string id_; |
| 311 CaptureState capture_state_; | 297 CaptureState capture_state_; |
| 312 std::unique_ptr<VideoFrameFactory> frame_factory_; | 298 std::unique_ptr<VideoFrameFactory> frame_factory_; |
| 313 std::unique_ptr<VideoFormat> capture_format_; | 299 std::unique_ptr<VideoFormat> capture_format_; |
| 314 std::vector<VideoFormat> supported_formats_; | 300 std::vector<VideoFormat> supported_formats_; |
| 315 std::unique_ptr<VideoFormat> max_format_; | 301 std::unique_ptr<VideoFormat> max_format_; |
| 316 std::vector<VideoFormat> filtered_supported_formats_; | 302 std::vector<VideoFormat> filtered_supported_formats_; |
| 317 | 303 |
| 318 int ratio_w_; // View resolution. e.g. 1280 x 720. | 304 int ratio_w_; // View resolution. e.g. 1280 x 720. |
| 319 int ratio_h_; | 305 int ratio_h_; |
| 320 bool enable_camera_list_; | 306 bool enable_camera_list_; |
| 321 bool square_pixel_aspect_ratio_; // Enable scaling to square pixels. | 307 bool square_pixel_aspect_ratio_; // Enable scaling to square pixels. |
| 322 int scaled_width_; // Current output size from ComputeScale. | 308 int scaled_width_; // Current output size from ComputeScale. |
| 323 int scaled_height_; | 309 int scaled_height_; |
| 324 | 310 |
| 325 rtc::VideoBroadcaster broadcaster_; | 311 rtc::VideoBroadcaster broadcaster_; |
| 326 bool enable_video_adapter_; | 312 bool enable_video_adapter_; |
| 327 CoordinatedVideoAdapter video_adapter_; | 313 CoordinatedVideoAdapter video_adapter_; |
| 328 | 314 |
| 329 rtc::Timing frame_length_time_reporter_; | |
| 330 rtc::CriticalSection frame_stats_crit_; | 315 rtc::CriticalSection frame_stats_crit_; |
| 331 | 316 |
| 332 int adapt_frame_drops_; | |
| 333 rtc::RollingAccumulator<int> adapt_frame_drops_data_; | |
| 334 double previous_frame_time_; | |
| 335 rtc::RollingAccumulator<double> frame_time_data_; | |
| 336 // The captured frame format before potential adapation. | 317 // The captured frame format before potential adapation. |
| 337 VideoFormat last_captured_frame_format_; | 318 VideoFormat last_captured_frame_format_; |
| 338 | 319 |
| 339 // Whether capturer should apply rotation to the frame before signaling it. | 320 // Whether capturer should apply rotation to the frame before signaling it. |
| 340 bool apply_rotation_; | 321 bool apply_rotation_; |
| 341 | 322 |
| 342 RTC_DISALLOW_COPY_AND_ASSIGN(VideoCapturer); | 323 RTC_DISALLOW_COPY_AND_ASSIGN(VideoCapturer); |
| 343 }; | 324 }; |
| 344 | 325 |
| 345 } // namespace cricket | 326 } // namespace cricket |
| 346 | 327 |
| 347 #endif // WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ | 328 #endif // WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ |
| OLD | NEW |