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