1. Fix to set video_preferred_display_mode of video format in wfd rtsp message 80/46280/1
authorSangkyu Park <sk1122.park@samsung.com>
Thu, 13 Aug 2015 08:13:56 +0000 (17:13 +0900)
committerSangkyu Park <sk1122.park@samsung.com>
Wed, 19 Aug 2015 04:45:24 +0000 (13:45 +0900)
2. Fix to handle EDID message.

Change-Id: I02970fe3327dd39ce7cb5420c55368e374198c6f
Signed-off-by: Sangkyu Park <sk1122.park@samsung.com>
packaging/libmm-scmirroring-common.spec
wfdconfig/include/wfdconfigmessage.h
wfdconfig/wfdconfigmessage.c

index ecb6d51..71b65f4 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       libmm-scmirroring-common
 Summary:    Multimedia Framework Wifi-Display Common Library
-Version:    0.0.42
+Version:    0.0.43
 Release:    0
 Group:      System/Libraries
 License:    Apache-2.0
index aea57ef..1b9bc42 100755 (executable)
@@ -324,6 +324,10 @@ typedef enum {
        WFD_CONNECTOR_PHYSICAL     = 255
 } WFDConnector;
 
+typedef enum {
+       WFD_PREFERRED_DISPLAY_MODE_NOT_SUPPORTED = 0,
+       WFD_PREFERRED_DISPLAY_MODE_SUPPORTED = 1
+} WFDPreferredDisplayModeEnum;
 
 typedef struct {
        gchar   *audio_format;
@@ -573,7 +577,8 @@ WFDResult wfdconfig_set_supported_video_format(WFDMessage *msg, WFDVideoCodecs v
                                                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);
 WFDResult wfdconfig_set_prefered_video_format(WFDMessage *msg, WFDVideoCodecs vCodec,
                                               WFDVideoNativeResolution vNative, guint64 vNativeResolution,
                                               WFDVideoCEAResolution vCEAResolution, WFDVideoVESAResolution vVESAResolution,
index 2e5744f..7016328 100755 (executable)
@@ -41,6 +41,8 @@
 #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,
@@ -297,13 +299,15 @@ wfdconfig_message_as_text(const WFDMessage *msg)
                        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);
@@ -327,14 +331,16 @@ wfdconfig_message_as_text(const WFDMessage *msg)
                        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);
@@ -369,9 +375,11 @@ wfdconfig_message_as_text(const WFDMessage *msg)
                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);
@@ -874,7 +882,7 @@ wfdconfig_parse_line(WFDMessage *msg, gchar *buffer)
                        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);
@@ -905,7 +913,7 @@ wfdconfig_parse_line(WFDMessage *msg, gchar *buffer)
                        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);
@@ -1641,7 +1649,8 @@ WFDResult wfdconfig_set_supported_video_format(WFDMessage *msg, WFDVideoCodecs v
                                                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;
@@ -1666,7 +1675,7 @@ WFDResult wfdconfig_set_supported_video_format(WFDMessage *msg, WFDVideoCodecs v
                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;
@@ -1711,7 +1720,7 @@ WFDResult wfdconfig_set_prefered_video_format(WFDMessage *msg, WFDVideoCodecs vC
        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;
@@ -1838,31 +1847,40 @@ WFDResult wfdconfig_set_display_EDID(WFDMessage *msg, gboolean edid_supported, g
        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;