FreeRDP
camera_v4l.c File Reference
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <linux/videodev2.h>
#include "camera.h"

Macros

#define TAG   CHANNELS_TAG("rdpecam-v4l.client")
 
#define CAM_V4L2_BUFFERS_COUNT   4
 
#define CAM_V4L2_CAPTURE_THREAD_SLEEP_MS   1000
 
#define CAM_V4L2_FRAMERATE_NUMERATOR_DEFAULT   30
 
#define CAM_V4L2_FRAMERATE_DENOMINATOR_DEFAULT   1
 

Functions

static void cam_v4l_stream_free (void *obj)
 
static void cam_v4l_stream_close_device (CamV4lStream *stream)
 
static UINT cam_v4l_stream_stop (CamV4lStream *stream)
 
static const char * cam_v4l_get_fourcc_str (unsigned int fourcc)
 
static UINT32 ecamToV4L2PixFormat (CAM_MEDIA_FORMAT ecamFormat)
 
static BOOL cam_v4l_format_supported (int fd, UINT32 format)
 
static int cam_v4l_open_device (const char *deviceId, int flags)
 
static INT16 cam_v4l_get_media_type_descriptions (ICamHal *hal, const char *deviceId, int streamIndex, const CAM_MEDIA_FORMAT_INFO *supportedFormats, size_t nSupportedFormats, CAM_MEDIA_TYPE_DESCRIPTION *mediaTypes, size_t *nMediaTypes)
 
static UINT cam_v4l_enumerate (ICamHal *ihal, ICamHalEnumCallback callback, CameraPlugin *ecam, GENERIC_CHANNEL_CALLBACK *hchannel)
 
static void cam_v4l_stream_free_buffers (CamV4lStream *stream)
 
static size_t cam_v4l_stream_alloc_buffers (CamV4lStream *stream)
 
static UINT cam_v4l_stream_capture_thread (void *param)
 
static CamV4lStream * cam_v4l_stream_create (CameraDevice *dev, int streamIndex, ICamHalSampleCapturedCallback callback)
 
static UINT cam_v4l_stream_start (ICamHal *ihal, CameraDevice *dev, int streamIndex, const CAM_MEDIA_TYPE_DESCRIPTION *mediaType, ICamHalSampleCapturedCallback callback)
 
static UINT cam_v4l_stream_stop_by_device_id (ICamHal *ihal, const char *deviceId, int streamIndex)
 
static UINT cam_v4l_free (ICamHal *ihal)
 
 FREERDP_ENTRY_POINT (UINT VCAPITYPE v4l_freerdp_rdpecam_client_subsystem_entry(PFREERDP_CAMERA_HAL_ENTRY_POINTS pEntryPoints))
 

Macro Definition Documentation

◆ CAM_V4L2_BUFFERS_COUNT

#define CAM_V4L2_BUFFERS_COUNT   4

◆ CAM_V4L2_CAPTURE_THREAD_SLEEP_MS

#define CAM_V4L2_CAPTURE_THREAD_SLEEP_MS   1000

◆ CAM_V4L2_FRAMERATE_DENOMINATOR_DEFAULT

#define CAM_V4L2_FRAMERATE_DENOMINATOR_DEFAULT   1

◆ CAM_V4L2_FRAMERATE_NUMERATOR_DEFAULT

#define CAM_V4L2_FRAMERATE_NUMERATOR_DEFAULT   30

◆ TAG

#define TAG   CHANNELS_TAG("rdpecam-v4l.client")

FreeRDP: A Remote Desktop Protocol Implementation MS-RDPECAM Implementation, V4L Interface

Copyright 2024 Oleg Turovski oleg2.nosp@m.104@.nosp@m.hotma.nosp@m.il.c.nosp@m.om

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ cam_v4l_enumerate()

static UINT cam_v4l_enumerate ( ICamHal *  ihal,
ICamHalEnumCallback  callback,
CameraPlugin ecam,
GENERIC_CHANNEL_CALLBACK hchannel 
)
static

Function description

Returns
number of video capture devices
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cam_v4l_format_supported()

static BOOL cam_v4l_format_supported ( int  fd,
UINT32  format 
)
static

Function description

Returns
TRUE or FALSE
Here is the caller graph for this function:

◆ cam_v4l_free()

static UINT cam_v4l_free ( ICamHal *  ihal)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cam_v4l_get_fourcc_str()

static const char* cam_v4l_get_fourcc_str ( unsigned int  fourcc)
static

Function description

Returns
NULL-terminated fourcc string
Here is the caller graph for this function:

◆ cam_v4l_get_media_type_descriptions()

static INT16 cam_v4l_get_media_type_descriptions ( ICamHal *  hal,
const char *  deviceId,
int  streamIndex,
const CAM_MEDIA_FORMAT_INFO supportedFormats,
size_t  nSupportedFormats,
CAM_MEDIA_TYPE_DESCRIPTION mediaTypes,
size_t *  nMediaTypes 
)
static

Function description

Returns
-1 if error, otherwise index of supportedFormats array and mediaTypes/nMediaTypes filled in
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cam_v4l_open_device()

static int cam_v4l_open_device ( const char *  deviceId,
int  flags 
)
static

Function description

Returns
file descriptor
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cam_v4l_stream_alloc_buffers()

static size_t cam_v4l_stream_alloc_buffers ( CamV4lStream *  stream)
static

Function description

Returns
0 on failure, otherwise allocated buffer size
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cam_v4l_stream_capture_thread()

static UINT cam_v4l_stream_capture_thread ( void *  param)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cam_v4l_stream_close_device()

void cam_v4l_stream_close_device ( CamV4lStream *  stream)
static

Function description

Returns
void
Here is the caller graph for this function:

◆ cam_v4l_stream_create()

static CamV4lStream* cam_v4l_stream_create ( CameraDevice dev,
int  streamIndex,
ICamHalSampleCapturedCallback  callback 
)
static

Function description

Returns
Null on failure, otherwise pointer to new CamV4lStream
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cam_v4l_stream_free()

void cam_v4l_stream_free ( void *  obj)
static

Function description

OBJECT_FREE_FN for streams hash table value

Returns
void
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cam_v4l_stream_free_buffers()

static void cam_v4l_stream_free_buffers ( CamV4lStream *  stream)
static

Function description

Returns
void
Here is the caller graph for this function:

◆ cam_v4l_stream_start()

static UINT cam_v4l_stream_start ( ICamHal *  ihal,
CameraDevice dev,
int  streamIndex,
const CAM_MEDIA_TYPE_DESCRIPTION mediaType,
ICamHalSampleCapturedCallback  callback 
)
static

Function description

Returns
0 on success, otherwise CAM_ERROR_CODE
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cam_v4l_stream_stop()

UINT cam_v4l_stream_stop ( CamV4lStream *  stream)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cam_v4l_stream_stop_by_device_id()

static UINT cam_v4l_stream_stop_by_device_id ( ICamHal *  ihal,
const char *  deviceId,
int  streamIndex 
)
static

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecamToV4L2PixFormat()

static UINT32 ecamToV4L2PixFormat ( CAM_MEDIA_FORMAT  ecamFormat)
static

Function description

Returns
one of V4L2_PIX_FMT
Here is the caller graph for this function:

◆ FREERDP_ENTRY_POINT()

FREERDP_ENTRY_POINT ( UINT VCAPITYPE   v4l_freerdp_rdpecam_client_subsystem_entry PFREERDP_CAMERA_HAL_ENTRY_POINTS pEntryPoints)

Function description

Returns
0 on success, otherwise a Win32 error code
Here is the call graph for this function: