2011-07-07 08:21:25 +00:00
|
|
|
/*
|
2012-02-16 18:18:21 +00:00
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
2011-07-07 08:21:25 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-07-12 10:03:52 +00:00
|
|
|
#include <errno.h>
|
2011-07-07 08:21:25 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <linux/videodev2.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
2013-07-12 10:03:52 +00:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
#include <sys/mman.h>
|
2018-11-28 16:47:49 +01:00
|
|
|
#include <sys/select.h>
|
|
|
|
|
#include <time.h>
|
2013-07-12 10:03:52 +00:00
|
|
|
#include <unistd.h>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2011-07-07 08:21:25 +00:00
|
|
|
#include <new>
|
2018-11-28 16:47:49 +01:00
|
|
|
#include <string>
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2019-01-25 20:26:48 +01:00
|
|
|
#include "api/scoped_refptr.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "media/base/video_common.h"
|
2023-01-30 14:10:49 +01:00
|
|
|
#if defined(WEBRTC_USE_PIPEWIRE)
|
|
|
|
|
#include "modules/video_capture/linux/video_capture_pipewire.h"
|
|
|
|
|
#endif
|
2022-05-10 15:01:32 +02:00
|
|
|
#include "modules/video_capture/linux/video_capture_v4l2.h"
|
2018-11-28 16:47:49 +01:00
|
|
|
#include "modules/video_capture/video_capture.h"
|
2023-01-30 14:10:49 +01:00
|
|
|
#include "modules/video_capture/video_capture_options.h"
|
2017-11-09 09:33:23 +01:00
|
|
|
#include "rtc_base/logging.h"
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2016-03-21 16:44:31 +01:00
|
|
|
namespace webrtc {
|
|
|
|
|
namespace videocapturemodule {
|
|
|
|
|
rtc::scoped_refptr<VideoCaptureModule> VideoCaptureImpl::Create(
|
|
|
|
|
const char* deviceUniqueId) {
|
2021-04-27 14:43:08 +02:00
|
|
|
auto implementation = rtc::make_ref_counted<VideoCaptureModuleV4L2>();
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2017-11-09 09:33:23 +01:00
|
|
|
if (implementation->Init(deviceUniqueId) != 0)
|
|
|
|
|
return nullptr;
|
2011-07-07 08:21:25 +00:00
|
|
|
|
2017-11-09 09:33:23 +01:00
|
|
|
return implementation;
|
2011-07-07 08:21:25 +00:00
|
|
|
}
|
2023-01-30 14:10:49 +01:00
|
|
|
|
|
|
|
|
rtc::scoped_refptr<VideoCaptureModule> VideoCaptureImpl::Create(
|
|
|
|
|
VideoCaptureOptions* options,
|
|
|
|
|
const char* deviceUniqueId) {
|
|
|
|
|
#if defined(WEBRTC_USE_PIPEWIRE)
|
|
|
|
|
if (options->allow_pipewire()) {
|
|
|
|
|
auto implementation =
|
|
|
|
|
rtc::make_ref_counted<VideoCaptureModulePipeWire>(options);
|
|
|
|
|
|
|
|
|
|
if (implementation->Init(deviceUniqueId) == 0)
|
|
|
|
|
return implementation;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
if (options->allow_v4l2()) {
|
|
|
|
|
auto implementation = rtc::make_ref_counted<VideoCaptureModuleV4L2>();
|
|
|
|
|
|
|
|
|
|
if (implementation->Init(deviceUniqueId) == 0)
|
|
|
|
|
return implementation;
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
2013-07-03 15:12:26 +00:00
|
|
|
} // namespace videocapturemodule
|
|
|
|
|
} // namespace webrtc
|