| 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 11 matching lines...) Expand all Loading... |
| 22 #include "webrtc/base/constructormagic.h" | 22 #include "webrtc/base/constructormagic.h" |
| 23 #include "webrtc/base/criticalsection.h" | 23 #include "webrtc/base/criticalsection.h" |
| 24 #include "webrtc/media/base/videosourceinterface.h" | 24 #include "webrtc/media/base/videosourceinterface.h" |
| 25 #include "webrtc/base/sigslot.h" | 25 #include "webrtc/base/sigslot.h" |
| 26 #include "webrtc/base/thread_checker.h" | 26 #include "webrtc/base/thread_checker.h" |
| 27 #include "webrtc/base/timestampaligner.h" | 27 #include "webrtc/base/timestampaligner.h" |
| 28 #include "webrtc/media/base/videoadapter.h" | 28 #include "webrtc/media/base/videoadapter.h" |
| 29 #include "webrtc/media/base/videobroadcaster.h" | 29 #include "webrtc/media/base/videobroadcaster.h" |
| 30 #include "webrtc/media/base/videocommon.h" | 30 #include "webrtc/media/base/videocommon.h" |
| 31 | 31 |
| 32 namespace webrtc { |
| 33 class VideoFrame; |
| 34 } |
| 32 | 35 |
| 33 namespace cricket { | 36 namespace cricket { |
| 34 | 37 |
| 35 // Current state of the capturer. | 38 // Current state of the capturer. |
| 36 enum CaptureState { | 39 enum CaptureState { |
| 37 CS_STOPPED, // The capturer has been stopped or hasn't started yet. | 40 CS_STOPPED, // The capturer has been stopped or hasn't started yet. |
| 38 CS_STARTING, // The capturer is in the process of starting. Note, it may | 41 CS_STARTING, // The capturer is in the process of starting. Note, it may |
| 39 // still fail to start. | 42 // still fail to start. |
| 40 CS_RUNNING, // The capturer has been started successfully and is now | 43 CS_RUNNING, // The capturer has been started successfully and is now |
| 41 // capturing. | 44 // capturing. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 62 // Start() | 65 // Start() |
| 63 // GetCaptureFormat() optionally | 66 // GetCaptureFormat() optionally |
| 64 // Stop() | 67 // Stop() |
| 65 // | 68 // |
| 66 // Assumption: | 69 // Assumption: |
| 67 // The Start() and Stop() methods are called by a single thread (E.g., the | 70 // The Start() and Stop() methods are called by a single thread (E.g., the |
| 68 // media engine thread). Hence, the VideoCapture subclasses dont need to be | 71 // media engine thread). Hence, the VideoCapture subclasses dont need to be |
| 69 // thread safe. | 72 // thread safe. |
| 70 // | 73 // |
| 71 class VideoCapturer : public sigslot::has_slots<>, | 74 class VideoCapturer : public sigslot::has_slots<>, |
| 72 public rtc::VideoSourceInterface<cricket::VideoFrame> { | 75 public rtc::VideoSourceInterface<webrtc::VideoFrame> { |
| 73 public: | 76 public: |
| 74 VideoCapturer(); | 77 VideoCapturer(); |
| 75 | 78 |
| 76 virtual ~VideoCapturer() {} | 79 virtual ~VideoCapturer() {} |
| 77 | 80 |
| 78 // Gets the id of the underlying device, which is available after the capturer | 81 // Gets the id of the underlying device, which is available after the capturer |
| 79 // is initialized. Can be used to determine if two capturers reference the | 82 // is initialized. Can be used to determine if two capturers reference the |
| 80 // same device. | 83 // same device. |
| 81 const std::string& GetId() const { return id_; } | 84 const std::string& GetId() const { return id_; } |
| 82 | 85 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // and users must call video_adapter()->OnOutputFormatRequest() | 165 // and users must call video_adapter()->OnOutputFormatRequest() |
| 163 // to receive frames. | 166 // to receive frames. |
| 164 bool enable_video_adapter() const { return enable_video_adapter_; } | 167 bool enable_video_adapter() const { return enable_video_adapter_; } |
| 165 void set_enable_video_adapter(bool enable_video_adapter) { | 168 void set_enable_video_adapter(bool enable_video_adapter) { |
| 166 enable_video_adapter_ = enable_video_adapter; | 169 enable_video_adapter_ = enable_video_adapter; |
| 167 } | 170 } |
| 168 | 171 |
| 169 bool GetInputSize(int* width, int* height); | 172 bool GetInputSize(int* width, int* height); |
| 170 | 173 |
| 171 // Implements VideoSourceInterface | 174 // Implements VideoSourceInterface |
| 172 void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink, | 175 void AddOrUpdateSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink, |
| 173 const rtc::VideoSinkWants& wants) override; | 176 const rtc::VideoSinkWants& wants) override; |
| 174 void RemoveSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override; | 177 void RemoveSink(rtc::VideoSinkInterface<webrtc::VideoFrame>* sink) override; |
| 175 | 178 |
| 176 protected: | 179 protected: |
| 177 // OnSinkWantsChanged can be overridden to change the default behavior | 180 // OnSinkWantsChanged can be overridden to change the default behavior |
| 178 // when a sink changes its VideoSinkWants by calling AddOrUpdateSink. | 181 // when a sink changes its VideoSinkWants by calling AddOrUpdateSink. |
| 179 virtual void OnSinkWantsChanged(const rtc::VideoSinkWants& wants); | 182 virtual void OnSinkWantsChanged(const rtc::VideoSinkWants& wants); |
| 180 | 183 |
| 181 // Reports the appropriate frame size after adaptation. Returns true | 184 // Reports the appropriate frame size after adaptation. Returns true |
| 182 // if a frame is wanted. Returns false if there are no interested | 185 // if a frame is wanted. Returns false if there are no interested |
| 183 // sinks, or if the VideoAdapter decides to drop the frame. | 186 // sinks, or if the VideoAdapter decides to drop the frame. |
| 184 | 187 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 203 int* crop_width, | 206 int* crop_width, |
| 204 int* crop_height, | 207 int* crop_height, |
| 205 int* crop_x, | 208 int* crop_x, |
| 206 int* crop_y, | 209 int* crop_y, |
| 207 int64_t* translated_camera_time_us); | 210 int64_t* translated_camera_time_us); |
| 208 | 211 |
| 209 // Called when a frame has been captured and converted to a | 212 // Called when a frame has been captured and converted to a |
| 210 // VideoFrame. OnFrame can be called directly by an implementation | 213 // VideoFrame. OnFrame can be called directly by an implementation |
| 211 // that does not use SignalFrameCaptured or OnFrameCaptured. The | 214 // that does not use SignalFrameCaptured or OnFrameCaptured. The |
| 212 // orig_width and orig_height are used only to produce stats. | 215 // orig_width and orig_height are used only to produce stats. |
| 213 void OnFrame(const VideoFrame& frame, int orig_width, int orig_height); | 216 void OnFrame(const webrtc::VideoFrame& frame, |
| 217 int orig_width, |
| 218 int orig_height); |
| 214 | 219 |
| 215 VideoAdapter* video_adapter() { return &video_adapter_; } | 220 VideoAdapter* video_adapter() { return &video_adapter_; } |
| 216 | 221 |
| 217 void SetCaptureState(CaptureState state); | 222 void SetCaptureState(CaptureState state); |
| 218 | 223 |
| 219 // subclasses override this virtual method to provide a vector of fourccs, in | 224 // subclasses override this virtual method to provide a vector of fourccs, in |
| 220 // order of preference, that are expected by the media engine. | 225 // order of preference, that are expected by the media engine. |
| 221 virtual bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) = 0; | 226 virtual bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) = 0; |
| 222 | 227 |
| 223 // mutators to set private attributes | 228 // mutators to set private attributes |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 bool apply_rotation_; | 279 bool apply_rotation_; |
| 275 | 280 |
| 276 // State for the timestamp translation. | 281 // State for the timestamp translation. |
| 277 rtc::TimestampAligner timestamp_aligner_; | 282 rtc::TimestampAligner timestamp_aligner_; |
| 278 RTC_DISALLOW_COPY_AND_ASSIGN(VideoCapturer); | 283 RTC_DISALLOW_COPY_AND_ASSIGN(VideoCapturer); |
| 279 }; | 284 }; |
| 280 | 285 |
| 281 } // namespace cricket | 286 } // namespace cricket |
| 282 | 287 |
| 283 #endif // WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ | 288 #endif // WEBRTC_MEDIA_BASE_VIDEOCAPTURER_H_ |
| OLD | NEW |