xref: /aosp_15_r20/external/webrtc/modules/video_capture/linux/video_capture_linux.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include <errno.h>
12 #include <fcntl.h>
13 #include <linux/videodev2.h>
14 #include <stdio.h>
15 #include <string.h>
16 #include <sys/ioctl.h>
17 #include <sys/mman.h>
18 #include <sys/select.h>
19 #include <time.h>
20 #include <unistd.h>
21 
22 #include <new>
23 #include <string>
24 
25 #include "api/scoped_refptr.h"
26 #include "media/base/video_common.h"
27 #include "modules/video_capture/linux/video_capture_v4l2.h"
28 #include "modules/video_capture/video_capture.h"
29 #include "rtc_base/logging.h"
30 
31 namespace webrtc {
32 namespace videocapturemodule {
Create(const char * deviceUniqueId)33 rtc::scoped_refptr<VideoCaptureModule> VideoCaptureImpl::Create(
34     const char* deviceUniqueId) {
35   auto implementation = rtc::make_ref_counted<VideoCaptureModuleV4L2>();
36 
37   if (implementation->Init(deviceUniqueId) != 0)
38     return nullptr;
39 
40   return implementation;
41 }
42 }  // namespace videocapturemodule
43 }  // namespace webrtc
44