#define FREE_STRING(field) if (field != NULL) g_free(field); (field) = NULL;
#define REPLACE_STRING(field, val) FREE_STRING(field); (field) = g_strdup(val);
#define EDID_BLOCK_SIZE 128
+#define EDID_BLOCK_COUNT_MAX_SIZE 256
+
enum {
WFD_SESSION,
WFD_MEDIA,
g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.misc_params.slice_enc_params);
g_string_append_printf(lines, " %02x", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support);
- if (msg->video_formats->list->H264_codec.max_hres) {
+ if (msg->video_formats->list->preferred_display_mode_supported == WFD_PREFERRED_DISPLAY_MODE_SUPPORTED
+ && msg->video_formats->list->H264_codec.max_hres) {
g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.max_hres);
} else {
g_string_append_printf(lines, STRING_WFD_SPACE);
g_string_append_printf(lines, STRING_WFD_NONE);
}
- if (msg->video_formats->list->H264_codec.max_vres) {
+ if (msg->video_formats->list->preferred_display_mode_supported == WFD_PREFERRED_DISPLAY_MODE_SUPPORTED
+ && msg->video_formats->list->H264_codec.max_vres) {
g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.max_vres);
} else {
g_string_append_printf(lines, STRING_WFD_SPACE);
g_string_append_printf(lines, " %04x", msg->video_3d_formats->list->H264_codec.misc_params.min_slice_size);
g_string_append_printf(lines, " %04x", msg->video_3d_formats->list->H264_codec.misc_params.slice_enc_params);
g_string_append_printf(lines, " %02x", msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support);
- if (msg->video_3d_formats->list->H264_codec.max_hres) {
+ if (msg->video_3d_formats->list->preferred_display_mode_supported == WFD_PREFERRED_DISPLAY_MODE_SUPPORTED
+ && msg->video_3d_formats->list->H264_codec.max_hres) {
g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.max_hres);
} else {
g_string_append_printf(lines, STRING_WFD_SPACE);
g_string_append_printf(lines, STRING_WFD_NONE);
}
- if (msg->video_3d_formats->list->H264_codec.max_vres) {
+ if (msg->video_3d_formats->list->preferred_display_mode_supported == WFD_PREFERRED_DISPLAY_MODE_SUPPORTED
+ && msg->video_3d_formats->list->H264_codec.max_vres) {
g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.max_vres);
} else {
g_string_append_printf(lines, STRING_WFD_SPACE);
g_string_append_printf(lines, STRING_WFD_DISPLAY_EDID);
g_string_append_printf(lines, STRING_WFD_COLON);
if (msg->display_edid->edid_supported) {
- g_string_append_printf(lines, " %d", msg->display_edid->edid_supported);
- if (msg->display_edid->edid_block_count) {
- g_string_append_printf(lines, " %d", msg->display_edid->edid_block_count);
+ if (msg->display_edid->edid_block_count > 0 &&
+ msg->display_edid->edid_block_count <= EDID_BLOCK_COUNT_MAX_SIZE) {
+ g_string_append_printf(lines, STRING_WFD_SPACE "%04x", msg->display_edid->edid_block_count);
+ g_string_append_printf(lines, STRING_WFD_SPACE "%s", msg->display_edid->edid_payload);
+
} else {
g_string_append_printf(lines, STRING_WFD_SPACE);
g_string_append_printf(lines, STRING_WFD_NONE);
WFD_SKIP_SPACE(v);
WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support);
WFD_SKIP_SPACE(v);
- if (msg->video_formats->list->preferred_display_mode_supported == 1) {
+ if (msg->video_formats->list->preferred_display_mode_supported == WFD_PREFERRED_DISPLAY_MODE_SUPPORTED) {
WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_hres);
WFD_SKIP_SPACE(v);
WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_vres);
WFD_SKIP_SPACE(v);
WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support);
WFD_SKIP_SPACE(v);
- if (msg->video_3d_formats->list->preferred_display_mode_supported == 1) {
+ if (msg->video_3d_formats->list->preferred_display_mode_supported == WFD_PREFERRED_DISPLAY_MODE_SUPPORTED) {
WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.max_hres);
WFD_SKIP_SPACE(v);
WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.max_vres);
WFDVideoNativeResolution vNative, guint64 vNativeResolution,
guint64 vCEAResolution, guint64 vVESAResolution, guint64 vHHResolution,
guint vProfile, guint vLevel, guint32 vLatency, guint32 vMaxHeight,
- guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control)
+ guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control,
+ guint preferred_display_mode)
{
guint nativeindex = 0;
guint64 temp = vNativeResolution;
else if (vNative == WFD_VIDEO_HH_RESOLUTION)
msg->video_formats->list->native |= 2;
- msg->video_formats->list->preferred_display_mode_supported = 1;
+ msg->video_formats->list->preferred_display_mode_supported = preferred_display_mode;
msg->video_formats->list->H264_codec.profile = vProfile;
msg->video_formats->list->H264_codec.level = vLevel;
msg->video_formats->list->H264_codec.max_hres = vMaxWidth;
else if (vNative == WFD_VIDEO_HH_RESOLUTION)
msg->video_formats->list->native |= 2;
- msg->video_formats->list->preferred_display_mode_supported = 0;
+ msg->video_formats->list->preferred_display_mode_supported = WFD_PREFERRED_DISPLAY_MODE_NOT_SUPPORTED;
msg->video_formats->list->H264_codec.profile = vProfile;
msg->video_formats->list->H264_codec.level = vLevel;
msg->video_formats->list->H264_codec.max_hres = vMaxWidth;
if (!msg->display_edid) msg->display_edid = g_new0(WFDDisplayEdid, 1);
msg->display_edid->edid_supported = edid_supported;
if (!edid_supported) return WFD_OK;
- msg->display_edid->edid_block_count = edid_blockcount;
- if (edid_blockcount) {
- msg->display_edid->edid_payload = g_malloc(128 * edid_blockcount);
+ if (edid_blockcount > 0 && edid_blockcount <= EDID_BLOCK_COUNT_MAX_SIZE) {
+ msg->display_edid->edid_block_count = edid_blockcount;
+ msg->display_edid->edid_payload = g_malloc(EDID_BLOCK_SIZE * edid_blockcount);
if (!msg->display_edid->edid_payload)
- memcpy(msg->display_edid->edid_payload, edid_playload, 128 * edid_blockcount);
- } else msg->display_edid->edid_payload = g_strdup(STRING_WFD_NONE);
+ memcpy(msg->display_edid->edid_payload, edid_playload, EDID_BLOCK_SIZE * edid_blockcount);
+ else
+ msg->display_edid->edid_supported = FALSE;
+ } else
+ msg->display_edid->edid_supported = FALSE;
+
return WFD_OK;
}
WFDResult wfdconfig_get_display_EDID(WFDMessage *msg, gboolean *edid_supported, guint32 *edid_blockcount, gchar **edid_playload)
{
g_return_val_if_fail(msg != NULL, WFD_EINVAL);
+ g_return_val_if_fail(edid_supported != NULL, WFD_EINVAL);
+ g_return_val_if_fail(edid_blockcount != NULL, WFD_EINVAL);
+ g_return_val_if_fail(edid_playload != NULL, WFD_EINVAL);
+
if (msg->display_edid) {
if (msg->display_edid->edid_supported) {
*edid_blockcount = msg->display_edid->edid_block_count;
- if (msg->display_edid->edid_block_count) {
+ if (msg->display_edid->edid_block_count > 0) {
char *temp;
- temp = g_malloc(EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
+ temp = g_malloc0(EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
if (temp) {
- memset(temp, 0, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
memcpy(temp, msg->display_edid->edid_payload, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
*edid_playload = temp;
*edid_supported = TRUE;
+ } else {
+ *edid_supported = FALSE;
}
- } else *edid_playload = g_strdup(STRING_WFD_NONE);
+ } else *edid_supported = FALSE;
}
} else *edid_supported = FALSE;
return WFD_OK;