23#include <freerdp/config.h>
25#if defined(CHANNEL_RDPECAM)
27#include <winpr/wtypes.h>
28#include <freerdp/channels/rdpecam.h>
30WINPR_ATTR_FORMAT_ARG(5, 6)
31static inline
void rdpecam_PrintWarning(wLog* log, const
char* file, const
char* fkt,
size_t line,
32 WINPR_FORMAT_ARG const
char* fmt, ...)
34 const DWORD level = WLOG_WARN;
35 va_list ap = WINPR_C_ARRAY_INIT;
38 if (WLog_IsLevelActive(log, level))
39 WLog_PrintTextMessageVA(log, level, line, file, fkt, fmt, ap);
54#define rdpecam_valid_messageId(id) \
55 rdpecam_valid_messageId_((id), WLog_Get(TAG), __FILE__, __func__, __LINE__)
57static inline bool rdpecam_valid_messageId_(UINT8
id, wLog* log,
const char* file,
const char* fkt,
62 case CAM_MSG_ID_SuccessResponse:
63 case CAM_MSG_ID_ErrorResponse:
64 case CAM_MSG_ID_SelectVersionRequest:
65 case CAM_MSG_ID_SelectVersionResponse:
66 case CAM_MSG_ID_DeviceAddedNotification:
67 case CAM_MSG_ID_DeviceRemovedNotification:
68 case CAM_MSG_ID_ActivateDeviceRequest:
69 case CAM_MSG_ID_DeactivateDeviceRequest:
70 case CAM_MSG_ID_StreamListRequest:
71 case CAM_MSG_ID_StreamListResponse:
72 case CAM_MSG_ID_MediaTypeListRequest:
73 case CAM_MSG_ID_MediaTypeListResponse:
74 case CAM_MSG_ID_CurrentMediaTypeRequest:
75 case CAM_MSG_ID_CurrentMediaTypeResponse:
76 case CAM_MSG_ID_StartStreamsRequest:
77 case CAM_MSG_ID_StopStreamsRequest:
78 case CAM_MSG_ID_SampleRequest:
79 case CAM_MSG_ID_SampleResponse:
80 case CAM_MSG_ID_SampleErrorResponse:
81 case CAM_MSG_ID_PropertyListRequest:
82 case CAM_MSG_ID_PropertyListResponse:
83 case CAM_MSG_ID_PropertyValueRequest:
84 case CAM_MSG_ID_PropertyValueResponse:
85 case CAM_MSG_ID_SetPropertyValueRequest:
88 rdpecam_PrintWarning(log, file, fkt, line,
"Invalid CAM_MSG_ID %" PRIu8,
id);
104#define rdpecam_valid_CamErrorCode(code) \
105 rdpecam_valid_CamErrorCode_((code), WLog_Get(TAG), __FILE__, __func__, __LINE__)
107static inline bool rdpecam_valid_CamErrorCode_(UINT32 code, wLog* log,
const char* file,
108 const char* fkt,
size_t line)
112 case CAM_ERROR_CODE_UnexpectedError:
113 case CAM_ERROR_CODE_InvalidMessage:
114 case CAM_ERROR_CODE_NotInitialized:
115 case CAM_ERROR_CODE_InvalidRequest:
116 case CAM_ERROR_CODE_InvalidStreamNumber:
117 case CAM_ERROR_CODE_InvalidMediaType:
118 case CAM_ERROR_CODE_OutOfMemory:
119 case CAM_ERROR_CODE_ItemNotFound:
120 case CAM_ERROR_CODE_SetNotFound:
121 case CAM_ERROR_CODE_OperationNotSupported:
124 rdpecam_PrintWarning(log, file, fkt, line,
"Invalid CAM_ERROR_CODE %" PRIu32, code);
140#define rdpecam_valid_CamStreamFrameSourceType(val) \
141 rdpecam_valid_CamStreamFrameSourceType_((val), WLog_Get(TAG), __FILE__, __func__, __LINE__)
143static inline bool rdpecam_valid_CamStreamFrameSourceType_(UINT16 val, wLog* log,
const char* file,
144 const char* fkt,
size_t line)
148 case CAM_STREAM_FRAME_SOURCE_TYPE_Color:
149 case CAM_STREAM_FRAME_SOURCE_TYPE_Infrared:
150 case CAM_STREAM_FRAME_SOURCE_TYPE_Custom:
153 rdpecam_PrintWarning(log, file, fkt, line,
154 "Invalid CAM_STREAM_FRAME_SOURCE_TYPES %" PRIu16, val);
170#define rdpecam_valid_CamStreamCategory(val) \
171 rdpecam_valid_CamStreamCategory_((val), WLog_Get(TAG), __FILE__, __func__, __LINE__)
173static inline bool rdpecam_valid_CamStreamCategory_(UINT8 val, wLog* log,
const char* file,
174 const char* fkt,
size_t line)
178 case CAM_STREAM_CATEGORY_Capture:
181 rdpecam_PrintWarning(log, file, fkt, line,
"Invalid CAM_STREAM_CATEGORY %" PRIu8, val);
197#define rdpecam_valid_CamMediaFormat(val) \
198 rdpecam_valid_CamMediaFormat_((val), WLog_Get(TAG), __FILE__, __func__, __LINE__)
200static inline bool rdpecam_valid_CamMediaFormat_(UINT8 val, wLog* log,
const char* file,
201 const char* fkt,
size_t line)
205 case CAM_MEDIA_FORMAT_INVALID:
206 case CAM_MEDIA_FORMAT_H264:
207 case CAM_MEDIA_FORMAT_MJPG:
208 case CAM_MEDIA_FORMAT_YUY2:
209 case CAM_MEDIA_FORMAT_NV12:
210 case CAM_MEDIA_FORMAT_I420:
211 case CAM_MEDIA_FORMAT_RGB24:
212 case CAM_MEDIA_FORMAT_RGB32:
215 rdpecam_PrintWarning(log, file, fkt, line,
"Invalid CAM_MEDIA_FORMAT %" PRIu8, val);
231#define rdpecam_valid_MediaTypeDescriptionFlags(val) \
232 rdpecam_valid_MediaTypeDescriptionFlags_((val), WLog_Get(TAG), __FILE__, __func__, __LINE__)
234static inline bool rdpecam_valid_MediaTypeDescriptionFlags_(UINT8 val, wLog* log,
const char* file,
235 const char* fkt,
size_t line)
239 case CAM_MEDIA_TYPE_DESCRIPTION_FLAG_DecodingRequired:
240 case CAM_MEDIA_TYPE_DESCRIPTION_FLAG_BottomUpImage:
243 rdpecam_PrintWarning(log, file, fkt, line,
244 "Invalid CAM_MEDIA_TYPE_DESCRIPTION_FLAGS %" PRIu8, val);
260#define rdpecam_valid_CamPropertyMode(val) \
261 rdpecam_valid_CamPropertyMode_((val), WLog_Get(TAG), __FILE__, __func__, __LINE__)
262static inline bool rdpecam_valid_CamPropertyMode_(UINT8 val, wLog* log,
const char* file,
263 const char* fkt,
size_t line)
267 case CAM_PROPERTY_MODE_Manual:
268 case CAM_PROPERTY_MODE_Auto:
271 rdpecam_PrintWarning(log, file, fkt, line,
"Invalid CAM_PROPERTY_MODE %" PRIu8, val);
287#define rdpecam_valid_CamPropertySet(val) \
288 rdpecam_valid_CamPropertySet_((val), WLog_Get(TAG), __FILE__, __func__, __LINE__)
290static inline bool rdpecam_valid_CamPropertySet_(UINT8 val, wLog* log,
const char* file,
291 const char* fkt,
size_t line)
295 case CAM_PROPERTY_SET_CameraControl:
296 case CAM_PROPERTY_SET_VideoProcAmp:
299 rdpecam_PrintWarning(log, file, fkt, line,
"Invalid CAM_PROPERTY_SET %" PRIu8, val);
315#define rdpecam_valid_CamPropertyCapabilities(val) \
316 rdpecam_valid_CamPropertyCapabilities_((val), WLog_Get(TAG), __FILE__, __func__, __LINE__)
318static inline bool rdpecam_valid_CamPropertyCapabilities_(UINT32 val, wLog* log,
const char* file,
319 const char* fkt,
size_t line)
321 if ((val & ~((UINT32)CAM_PROPERTY_CAPABILITY_Manual | CAM_PROPERTY_CAPABILITY_Auto)) != 0)
323 rdpecam_PrintWarning(log, file, fkt, line,
"Invalid CAM_PROPERTY_CAPABILITIES %" PRIu8,