From 7e7a65becd0eed6b42ce3bb6335afebb308cee5c Mon Sep 17 00:00:00 2001 From: oleg0421 Date: Mon, 17 Feb 2025 17:45:39 -0800 Subject: [PATCH] [channel,rdpecam] uvc_h264 fix for C922 camera --- channels/rdpecam/client/v4l/camera_v4l.c | 38 ++++++++++++------------ channels/rdpecam/client/v4l/uvc_h264.c | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/channels/rdpecam/client/v4l/camera_v4l.c b/channels/rdpecam/client/v4l/camera_v4l.c index 7f95bbb9b..0f2d1afbb 100644 --- a/channels/rdpecam/client/v4l/camera_v4l.c +++ b/channels/rdpecam/client/v4l/camera_v4l.c @@ -600,16 +600,27 @@ static UINT cam_v4l_stream_start(ICamHal* ihal, CameraDevice* dev, int streamInd struct v4l2_format video_fmt = { 0 }; video_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; - video_fmt.fmt.pix.sizeimage = 0; UINT32 pixelFormat = 0; if (mediaType->Format == CAM_MEDIA_FORMAT_MJPG_H264) { + if (!set_h264_muxed_format(stream, mediaType)) + { + WLog_ERR(TAG, "Failure to set H264 muxed format"); + cam_v4l_stream_close_device(stream); + return CAM_ERROR_CODE_UnexpectedError; + } + /* setup container stream format */ pixelFormat = V4L2_PIX_FMT_MJPEG; + /* limit container stream resolution to save USB bandwidth - required */ + video_fmt.fmt.pix.width = 640; + video_fmt.fmt.pix.height = 480; } else { pixelFormat = ecamToV4L2PixFormat(mediaType->Format); + video_fmt.fmt.pix.width = mediaType->Width; + video_fmt.fmt.pix.height = mediaType->Height; } if (pixelFormat == 0) @@ -619,8 +630,6 @@ static UINT cam_v4l_stream_start(ICamHal* ihal, CameraDevice* dev, int streamInd } video_fmt.fmt.pix.pixelformat = pixelFormat; - video_fmt.fmt.pix.width = mediaType->Width; - video_fmt.fmt.pix.height = mediaType->Height; /* set format and frame size */ if (ioctl(stream->fd, VIDIOC_S_FMT, &video_fmt) < 0) @@ -657,19 +666,6 @@ static UINT cam_v4l_stream_start(ICamHal* ihal, CameraDevice* dev, int streamInd } } - if (mediaType->Format == CAM_MEDIA_FORMAT_MJPG_H264) - { - if (!set_h264_muxed_format(stream, mediaType)) - { - WLog_ERR(TAG, "Failure to set H264 muxed format"); - cam_v4l_stream_close_device(stream); - return CAM_ERROR_CODE_UnexpectedError; - } - - /* set pixelFormat for following WLog_INFO */ - pixelFormat = V4L2_PIX_FMT_H264; - } - size_t maxSample = cam_v4l_stream_alloc_buffers(stream); if (maxSample == 0) { @@ -699,9 +695,13 @@ static UINT cam_v4l_stream_start(ICamHal* ihal, CameraDevice* dev, int streamInd return CAM_ERROR_CODE_OutOfMemory; } - char fourccstr[5] = { 0 }; - WLog_INFO(TAG, "Camera format: %s, width: %u, height: %u, fps: %u/%u", - cam_v4l_get_fourcc_str(pixelFormat, fourccstr, ARRAYSIZE(fourccstr)), + char fourccstr[16] = { 0 }; + if (mediaType->Format == CAM_MEDIA_FORMAT_MJPG_H264) + strncpy(fourccstr, "H264 muxed", ARRAYSIZE(fourccstr) - 1); + else + cam_v4l_get_fourcc_str(pixelFormat, fourccstr, ARRAYSIZE(fourccstr)); + + WLog_INFO(TAG, "Camera format: %s, width: %u, height: %u, fps: %u/%u", fourccstr, mediaType->Width, mediaType->Height, mediaType->FrameRateNumerator, mediaType->FrameRateDenominator); diff --git a/channels/rdpecam/client/v4l/uvc_h264.c b/channels/rdpecam/client/v4l/uvc_h264.c index 26d9423cd..866e98884 100644 --- a/channels/rdpecam/client/v4l/uvc_h264.c +++ b/channels/rdpecam/client/v4l/uvc_h264.c @@ -35,7 +35,7 @@ static uint8_t GUID_UVCX_H264_XU[16] = { 0x41, 0x76, 0x9E, 0xA2, 0x04, 0xDE, 0xE3, 0x47, 0x8B, 0x2B, 0xF4, 0x34, 0x1A, 0xFF, 0x00, 0x3B }; -#define TAG CHANNELS_TAG("uvc_h264.client") +#define TAG CHANNELS_TAG("rdpecam-uvch264.client") /* * get length of xu control defined by unit id and selector