| 6 |
| 7 | namespace tgcalls { |
| 8 |
| 9 | rtc::scoped_refptr<VideoCapturerTrackSource> VideoCapturerTrackSource::Create() { |
| 10 | const size_t kWidth = 640; |
| 11 | const size_t kHeight = 480; |
| 12 | const size_t kFps = 30; |
| 13 |
| 14 | std::unique_ptr<webrtc::VideoCaptureModule::DeviceInfo> info( |
| 15 | webrtc::VideoCaptureFactory::CreateDeviceInfo()); |
| 16 | if (!info) { |
| 17 | return nullptr; |
| 18 | } |
| 19 | int num_devices = info->NumberOfDevices(); |
| 20 |
| 21 | for (int i = 0; i < num_devices; ++i) { |
| 22 | if (auto capturer = VideoCameraCapturer::Create(kWidth, kHeight, kFps, i)) { |
| 23 | return new rtc::RefCountedObject<VideoCapturerTrackSource>( |
| 24 | CreateTag{}, |
| 25 | std::move(capturer)); |
| 26 | } |
| 27 | } |
| 28 | return nullptr; |
| 29 | } |
| 30 |
| 31 | VideoCapturerTrackSource::VideoCapturerTrackSource( |
| 32 | const CreateTag &, |
| 33 | std::unique_ptr<VideoCameraCapturer> capturer) : |
| 34 | VideoTrackSource(/*remote=*/false), |
| 35 | _capturer(std::move(capturer)) { |
| 36 | } |
| 37 |
| 38 | VideoCameraCapturer *VideoCapturerTrackSource::capturer() const { |
| 39 | return _capturer.get(); |
| 40 | } |
| 41 |
| 42 | rtc::VideoSourceInterface<webrtc::VideoFrame>* VideoCapturerTrackSource::source() { |
| 43 | return _capturer.get(); |
| 44 | } |
| 45 |
| 46 | } // namespace tgcalls |
| 47 |