Debian Codegraph @

channels/rdpecam/client/v4l/uvc_h264.h

raw symbols SCIP
1 /**
2 * FreeRDP: A Remote Desktop Protocol Implementation
3 * MS-RDPECAM Implementation, UVC H264 support
4 *
5 * See USB_Video_Payload_H 264_1 0.pdf for more details
6 *
7 * Credits:
8 * guvcview http://guvcview.sourceforge.net
9 * Paulo Assis <[email protected]>
10 *
11 * Copyright 2025 Oleg Turovski <[email protected]>
12 *
13 * Licensed under the Apache License, Version 2.0 (the "License");
14 * you may not use this file except in compliance with the License.
15 * You may obtain a copy of the License at
16 *
17 * http://www.apache.org/licenses/LICENSE-2.0
18 *
19 * Unless required by applicable law or agreed to in writing, software
20 * distributed under the License is distributed on an "AS IS" BASIS,
21 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 * See the License for the specific language governing permissions and
23 * limitations under the License.
24 */
25
26 #ifndef UVC_H264_H
27 #define UVC_H264_H
28
29 #include <winpr/wtypes.h>
30
31 #include "../camera.h"
32 #include "camera_v4l.h"
33
34 /* UVC H.264 control selectors */
35 #define UVCX_VIDEO_CONFIG_PROBE 0x01
36 #define UVCX_VIDEO_CONFIG_COMMIT 0x02
37 #define UVCX_RATE_CONTROL_MODE 0x03
38 #define UVCX_TEMPORAL_SCALE_MODE 0x04
39 #define UVCX_SPATIAL_SCALE_MODE 0x05
40 #define UVCX_SNR_SCALE_MODE 0x06
41 #define UVCX_LTR_BUFFER_SIZE_CONTROL 0x07
42 #define UVCX_LTR_PICTURE_CONTROL 0x08
43 #define UVCX_PICTURE_TYPE_CONTROL 0x09
44 #define UVCX_VERSION 0x0A
45 #define UVCX_ENCODER_RESET 0x0B
46 #define UVCX_FRAMERATE_CONFIG 0x0C
47 #define UVCX_VIDEO_ADVANCE_CONFIG 0x0D
48 #define UVCX_BITRATE_LAYERS 0x0E
49 #define UVCX_QP_STEPS_LAYERS 0x0F
50
51 /* Video Class-Specific Request Codes */
52 #define UVC_RC_UNDEFINED 0x00
53 #define UVC_SET_CUR 0x01
54 #define UVC_GET_CUR 0x81
55 #define UVC_GET_MIN 0x82
56 #define UVC_GET_MAX 0x83
57 #define UVC_GET_RES 0x84
58 #define UVC_GET_LEN 0x85
59 #define UVC_GET_INFO 0x86
60 #define UVC_GET_DEF 0x87
61
62 /* bStreamMuxOption defines */
63 #define STREAMMUX_H264 (1 << 0) | (1 << 1)
64
65 /* wProfile defines */
66 #define PROFILE_BASELINE 0x4200
67 #define PROFILE_MAIN 0x4D00
68 #define PROFILE_HIGH 0x6400
69
70 /* bUsageType defines */
71 #define USAGETYPE_REALTIME 0x01
72
73 /* bRateControlMode defines */
74 #define RATECONTROL_CBR 0x01
75 #define RATECONTROL_VBR 0x02
76 #define RATECONTROL_CONST_QP 0x03
77
78 /* bEntropyCABAC defines */
79 #define ENTROPY_CABAC 0x01
80
81 /* bmHints defines */
82 #define BMHINTS_RESOLUTION 0x0001
83 #define BMHINTS_PROFILE 0x0002
84 #define BMHINTS_RATECONTROL 0x0004
85 #define BMHINTS_USAGE 0x0008
86 #define BMHINTS_SLICEMODE 0x0010
87 #define BMHINTS_SLICEUNITS 0x0020
88 #define BMHINTS_MVCVIEW 0x0040
89 #define BMHINTS_TEMPORAL 0x0080
90 #define BMHINTS_SNR 0x0100
91 #define BMHINTS_SPATIAL 0x0200
92 #define BMHINTS_SPATIAL_RATIO 0x0400
93 #define BMHINTS_FRAME_INTERVAL 0x0800
94 #define BMHINTS_LEAKY_BKT_SIZE 0x1000
95 #define BMHINTS_BITRATE 0x2000
96 #define BMHINTS_ENTROPY 0x4000
97 #define BMHINTS_IFRAMEPERIOD 0x8000
98
99 /* USB related defines */
100 #define USB_VIDEO_CONTROL 0x01
101 #define USB_VIDEO_CONTROL_INTERFACE 0x24
102 #define USB_VIDEO_CONTROL_XU_TYPE 0x06
103
104 #define MAX_DEVPATH_DEPTH 8
105 #define MAX_DEVPATH_STR_SIZE 32
106
107 #define WINPR_PACK_PUSH
108 #include <winpr/pack.h>
109
110 /* h264 probe commit struct (uvc 1.1) - packed */
111 typedef struct
112 {
113 uint32_t dwFrameInterval;
114 uint32_t dwBitRate;
115 uint16_t bmHints;
116 uint16_t wConfigurationIndex;
117 uint16_t wWidth;
118 uint16_t wHeight;
119 uint16_t wSliceUnits;
120 uint16_t wSliceMode;
121 uint16_t wProfile;
122 uint16_t wIFramePeriod;
123 uint16_t wEstimatedVideoDelay;
124 uint16_t wEstimatedMaxConfigDelay;
125 uint8_t bUsageType;
126 uint8_t bRateControlMode;
127 uint8_t bTemporalScaleMode;
128 uint8_t bSpatialScaleMode;
129 uint8_t bSNRScaleMode;
130 uint8_t bStreamMuxOption;
131 uint8_t bStreamFormat;
132 uint8_t bEntropyCABAC;
133 uint8_t bTimestamp;
134 uint8_t bNumOfReorderFrames;
135 uint8_t bPreviewFlipped;
136 uint8_t bView;
137 uint8_t bReserved1;
138 uint8_t bReserved2;
139 uint8_t bStreamID;
140 uint8_t bSpatialLayerRatio;
141 uint16_t wLeakyBucketSize;
142
143 } uvcx_video_config_probe_commit_t;
144
145 /* encoder reset struct - packed */
146 typedef struct
147 {
148 uint16_t wLayerID;
149
150 } uvcx_encoder_reset;
151
152 /* xu_descriptor struct - packed */
153 typedef struct
154 {
155 int8_t bLength;
156 int8_t bDescriptorType;
157 int8_t bDescriptorSubType;
158 int8_t bUnitID;
159 uint8_t guidExtensionCode[16];
160
161 } xu_descriptor;
162
163 #define WINPR_PACK_POP
164 #include <winpr/pack.h>
165
166 WINPR_ATTR_NODISCARD
167 FREERDP_LOCAL uint8_t get_uvc_h624_unit_id(const char* deviceId);
168
169 WINPR_ATTR_NODISCARD
170 FREERDP_LOCAL BOOL set_h264_muxed_format(CamV4lStream* stream,
171 const CAM_MEDIA_TYPE_DESCRIPTION* mediaType);
172
173 #endif /* UVC_H264_H */