2 * Copyright (c) 2012, 2013 Samsung Electronics Co., Ltd.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
28 #ifdef HAVE_SYS_TYPES_H
29 #include <sys/types.h>
32 #include <glib.h> /* for G_OS_WIN32 */
34 #include "wfdconfigmessage.h"
38 /* FIXME, is currently allocated on the stack */
39 #define MAX_LINE_LEN 1024 * 16
41 #define FREE_STRING(field) if(field != NULL) g_free (field); (field) = NULL
42 #define REPLACE_STRING(field, val) FREE_STRING(field); (field) = g_strdup (val)
43 #define EDID_BLOCK_SIZE 128
44 #define LIBHDCP "/usr/lib/libhdcp library"
58 * wfdconfig_message_new:
59 * @msg: pointer to new #WFDMessage
61 * Allocate a new WFDMessage and store the result in @msg.
63 * Returns: a #WFDResult.
66 wfdconfig_message_new (WFDMessage ** msg)
70 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
72 newmsg = g_new0 (WFDMessage, 1);
76 return wfdconfig_message_init (newmsg);
80 * wfdconfig_message_init:
83 * Initialize @msg so that its contents are as if it was freshly allocated
84 * with wfdconfig_message_new(). This function is mostly used to initialize a message
85 * allocated on the stack. wfdconfig_message_uninit() undoes this operation.
87 * When this function is invoked on newly allocated data (with malloc or on the
88 * stack), its contents should be set to 0 before calling this function.
90 * Returns: a #WFDResult.
93 wfdconfig_message_init (WFDMessage * msg)
95 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
101 * wfdconfig_message_uninit:
102 * @msg: a #WFDMessage
104 * Free all resources allocated in @msg. @msg should not be used anymore after
105 * this function. This function should be used when @msg was allocated on the
106 * stack and initialized with wfdconfig_message_init().
108 * Returns: a #WFDResult.
111 wfdconfig_message_uninit (WFDMessage * msg)
113 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
115 if(msg->audio_codecs) {
117 if(msg->audio_codecs->list) {
118 for(; i<msg->audio_codecs->count; i++) {
119 FREE_STRING(msg->audio_codecs->list[i].audio_format);
120 msg->audio_codecs->list[i].modes=0;
121 msg->audio_codecs->list[i].latency=0;
123 FREE_STRING(msg->audio_codecs->list);
125 FREE_STRING(msg->audio_codecs);
128 if(msg->video_formats) {
129 FREE_STRING(msg->video_formats->list);
130 FREE_STRING(msg->video_formats);
133 if(msg->video_3d_formats) {
134 FREE_STRING(msg->video_3d_formats);
137 if(msg->content_protection) {
138 FREE_STRING(msg->content_protection);
141 if(msg->display_edid) {
142 if(msg->display_edid->edid_payload)
143 FREE_STRING(msg->display_edid->edid_payload);
144 FREE_STRING(msg->display_edid);
147 if(msg->coupled_sink) {
148 FREE_STRING(msg->coupled_sink);
151 if(msg->trigger_method) {
152 FREE_STRING(msg->trigger_method->wfd_trigger_method);
153 FREE_STRING(msg->trigger_method);
156 if(msg->presentation_url) {
157 FREE_STRING(msg->trigger_method);
160 if(msg->client_rtp_ports) {
161 FREE_STRING(msg->client_rtp_ports->profile);
162 FREE_STRING(msg->client_rtp_ports->mode);
163 FREE_STRING(msg->client_rtp_ports);
167 FREE_STRING(msg->route);
171 FREE_STRING(msg->I2C);
174 if(msg->av_format_change_timing) {
175 FREE_STRING(msg->av_format_change_timing);
178 if(msg->preferred_display_mode) {
179 FREE_STRING(msg->preferred_display_mode);
182 if(msg->uibc_capability) {
183 FREE_STRING(msg->uibc_capability);
186 if(msg->uibc_setting) {
187 FREE_STRING(msg->uibc_setting);
190 if(msg->standby_resume_capability) {
191 FREE_STRING(msg->standby_resume_capability);
195 FREE_STRING(msg->standby);
198 if(msg->connector_type) {
199 FREE_STRING(msg->connector_type);
202 if(msg->idr_request) {
203 FREE_STRING(msg->idr_request);
209 * wfdconfig_message_free:
210 * @msg: a #WFDMessage
212 * Free all resources allocated by @msg. @msg should not be used anymore after
213 * this function. This function should be used when @msg was dynamically
214 * allocated with wfdconfig_message_new().
216 * Returns: a #WFDResult.
219 wfdconfig_message_free (WFDMessage * msg)
221 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
223 wfdconfig_message_uninit (msg);
230 * wfdconfig_message_as_text:
231 * @msg: a #WFDMessage
233 * Convert the contents of @msg to a text string.
235 * Returns: A dynamically allocated string representing the WFD description.
238 wfdconfig_message_as_text (const WFDMessage * msg)
240 /* change all vars so they match rfc? */
242 g_return_val_if_fail (msg != NULL, NULL);
244 lines = g_string_new ("");
246 /* list of audio codecs */
247 if(msg->audio_codecs) {
249 g_string_append_printf (lines,"wfd_audio_codecs");
250 if(msg->audio_codecs->list) {
251 g_string_append_printf (lines,":");
252 for(; i<msg->audio_codecs->count; i++) {
253 g_string_append_printf (lines," %s",msg->audio_codecs->list[i].audio_format);
254 g_string_append_printf (lines," %08x",msg->audio_codecs->list[i].modes);
255 g_string_append_printf (lines," %02x",msg->audio_codecs->list[i].latency);
256 if((i+1)<msg->audio_codecs->count)
257 g_string_append_printf (lines,",");
260 g_string_append_printf (lines,"\r\n");
263 /* list of video codecs */
264 if(msg->video_formats) {
265 g_string_append_printf (lines,"wfd_video_formats");
266 if(msg->video_formats->list) {
267 g_string_append_printf (lines,":");
268 g_string_append_printf (lines," %02x", msg->video_formats->list->native);
269 g_string_append_printf (lines," %02x", msg->video_formats->list->preferred_display_mode_supported);
270 g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.profile);
271 g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.level);
272 g_string_append_printf (lines," %08x", msg->video_formats->list->H264_codec.misc_params.CEA_Support);
273 g_string_append_printf (lines," %08x", msg->video_formats->list->H264_codec.misc_params.VESA_Support);
274 g_string_append_printf (lines," %08x", msg->video_formats->list->H264_codec.misc_params.HH_Support);
275 g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.misc_params.latency);
276 g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.misc_params.min_slice_size);
277 g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.misc_params.slice_enc_params);
278 g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support);
280 if(msg->video_formats->list->H264_codec.max_hres)
281 g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_hres);
283 g_string_append_printf (lines," none");
285 if(msg->video_formats->list->H264_codec.max_vres)
286 g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_vres);
288 g_string_append_printf (lines," none");
290 g_string_append_printf (lines,"\r\n");
293 /* list of video 3D codecs */
294 if(msg->video_3d_formats) {
295 g_string_append_printf (lines,"wfd_3d_video_formats");
296 g_string_append_printf (lines,":");
297 if(msg->video_3d_formats->list) {
298 g_string_append_printf (lines," %02x", msg->video_3d_formats->list->native);
299 g_string_append_printf (lines," %02x", msg->video_3d_formats->list->preferred_display_mode_supported);
300 g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.profile);
301 g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.level);
302 g_string_append_printf (lines," %16x", msg->video_3d_formats->list->H264_codec.misc_params.video_3d_capability);
303 g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.misc_params.latency);
304 g_string_append_printf (lines," %04x", msg->video_3d_formats->list->H264_codec.misc_params.min_slice_size);
305 g_string_append_printf (lines," %04x", msg->video_3d_formats->list->H264_codec.misc_params.slice_enc_params);
306 g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support);
307 if(msg->video_3d_formats->list->H264_codec.max_hres)
308 g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_hres);
310 g_string_append_printf (lines," none");
311 if(msg->video_3d_formats->list->H264_codec.max_vres)
312 g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_vres);
314 g_string_append_printf (lines," none");
316 g_string_append_printf (lines," none");
318 g_string_append_printf (lines,"\r\n");
321 if(msg->content_protection) {
322 g_string_append_printf (lines,"wfd_content_protection");
323 if(msg->content_protection->hdcp2_spec) {
324 g_string_append_printf (lines,":");
325 if( msg->content_protection->hdcp2_spec->hdcpversion) {
326 g_string_append_printf (lines," %s", msg->content_protection->hdcp2_spec->hdcpversion);
327 g_string_append_printf (lines," %s", msg->content_protection->hdcp2_spec->TCPPort);
329 g_string_append_printf (lines," none");
332 g_string_append_printf (lines," none");
334 g_string_append_printf (lines,"\r\n");
337 if(msg->display_edid) {
338 g_string_append_printf (lines,"wfd_display_edid");
339 g_string_append_printf (lines,":");
340 if(msg->display_edid->edid_supported) {
341 g_string_append_printf (lines," %d", msg->display_edid->edid_supported);
342 if(msg->display_edid->edid_block_count)
343 g_string_append_printf (lines," %d", msg->display_edid->edid_block_count);
345 g_string_append_printf (lines," none");
347 g_string_append_printf (lines," none");
349 g_string_append_printf (lines,"\r\n");
352 if(msg->coupled_sink) {
353 g_string_append_printf (lines,"wfd_coupled_sink");
354 g_string_append_printf (lines,":");
355 if(msg->coupled_sink->coupled_sink_cap) {
356 g_string_append_printf (lines," %02x", msg->coupled_sink->coupled_sink_cap->status);
357 if(msg->coupled_sink->coupled_sink_cap->sink_address)
358 g_string_append_printf (lines," %s", msg->coupled_sink->coupled_sink_cap->sink_address);
360 g_string_append_printf (lines," none");
362 g_string_append_printf (lines," none");
364 g_string_append_printf (lines,"\r\n");
367 if(msg->trigger_method) {
368 g_string_append_printf (lines,"wfd_trigger_method");
369 g_string_append_printf (lines,":");
370 g_string_append_printf (lines," %s", msg->trigger_method->wfd_trigger_method);
371 g_string_append_printf (lines,"\r\n");
374 if(msg->presentation_url) {
375 g_string_append_printf (lines,"wfd_presentation_URL");
376 g_string_append_printf (lines,":");
377 if(msg->presentation_url->wfd_url0)
378 g_string_append_printf (lines," %s", msg->presentation_url->wfd_url0);
380 g_string_append_printf (lines," none");
381 if(msg->presentation_url->wfd_url1)
382 g_string_append_printf (lines," %s", msg->presentation_url->wfd_url1);
384 g_string_append_printf (lines," none");
385 g_string_append_printf (lines,"\r\n");
388 if(msg->client_rtp_ports) {
389 g_string_append_printf (lines,"wfd_client_rtp_ports");
390 if(msg->client_rtp_ports->profile) {
391 g_string_append_printf (lines,":");
392 g_string_append_printf (lines," %s", msg->client_rtp_ports->profile);
393 g_string_append_printf (lines," %d", msg->client_rtp_ports->rtp_port0);
394 g_string_append_printf (lines," %d", msg->client_rtp_ports->rtp_port1);
395 g_string_append_printf (lines," %s", msg->client_rtp_ports->mode);
397 g_string_append_printf (lines,"\r\n");
401 g_string_append_printf (lines,"wfd_route");
402 g_string_append_printf (lines,":");
403 g_string_append_printf (lines," %s", msg->route->destination);
404 g_string_append_printf (lines,"\r\n");
408 g_string_append_printf (lines,"wfd_I2C");
409 g_string_append_printf (lines,":");
410 if(msg->I2C->I2CPresent)
411 g_string_append_printf (lines," %x", msg->I2C->I2C_port);
413 g_string_append_printf (lines," none");
414 g_string_append_printf (lines,"\r\n");
417 if(msg->av_format_change_timing) {
418 g_string_append_printf (lines,"wfd_av_format_change_timing");
419 g_string_append_printf (lines,":");
420 g_string_append_printf (lines," %10llu", msg->av_format_change_timing->PTS);
421 g_string_append_printf (lines," %10llu", msg->av_format_change_timing->DTS);
422 g_string_append_printf (lines,"\r\n");
425 if(msg->preferred_display_mode) {
426 g_string_append_printf (lines,"wfd_preferred_display_mode");
427 g_string_append_printf (lines,":");
428 if(msg->preferred_display_mode->displaymodesupported) {
429 g_string_append_printf (lines," %06llu", msg->preferred_display_mode->p_clock);
430 g_string_append_printf (lines," %04x", msg->preferred_display_mode->H);
431 g_string_append_printf (lines," %04x", msg->preferred_display_mode->HB);
432 g_string_append_printf (lines," %04x", msg->preferred_display_mode->HSPOL_HSOFF);
433 g_string_append_printf (lines," %04x", msg->preferred_display_mode->HSW);
434 g_string_append_printf (lines," %04x", msg->preferred_display_mode->V);
435 g_string_append_printf (lines," %04x", msg->preferred_display_mode->VB);
436 g_string_append_printf (lines," %04x", msg->preferred_display_mode->VSPOL_VSOFF);
437 g_string_append_printf (lines," %04x", msg->preferred_display_mode->VSW);
438 g_string_append_printf (lines," %02x", msg->preferred_display_mode->VBS3D);
439 g_string_append_printf (lines," %02x", msg->preferred_display_mode->V2d_s3d_modes);
440 g_string_append_printf (lines," %02x", msg->preferred_display_mode->P_depth);
441 } else g_string_append_printf (lines," none");
442 g_string_append_printf (lines,"\r\n");
445 if(msg->uibc_capability) {
446 g_string_append_printf (lines,"wfd_uibc_capability");
447 g_string_append_printf (lines,":");
448 if(msg->uibc_capability->uibcsupported) {
449 g_string_append_printf (lines," input_category_list=");
450 if(msg->uibc_capability->input_category_list.input_cat) {
452 if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) {
453 tempcap |= WFD_UIBC_INPUT_CAT_GENERIC;
454 g_string_append_printf (lines,"GENERIC");
455 if(msg->uibc_capability->input_category_list.input_cat != tempcap) g_string_append_printf (lines,", ");
457 if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) {
458 tempcap |= WFD_UIBC_INPUT_CAT_HIDC;
459 g_string_append_printf (lines,"HIDC");
460 if(msg->uibc_capability->input_category_list.input_cat != tempcap) g_string_append_printf (lines,", ");
463 else g_string_append_printf (lines,"none");
464 g_string_append_printf (lines,";");
465 g_string_append_printf (lines," generic_cap_list=");
466 if(msg->uibc_capability->generic_cap_list.inp_type) {
468 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) {
469 tempcap |= WFD_UIBC_INPUT_TYPE_KEYBOARD;
470 g_string_append_printf (lines,"Keyboard");
471 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
473 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) {
474 tempcap |= WFD_UIBC_INPUT_TYPE_MOUSE;
475 g_string_append_printf (lines,"Mouse");
476 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
478 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) {
479 tempcap |= WFD_UIBC_INPUT_TYPE_SINGLETOUCH;
480 g_string_append_printf (lines,"SingleTouch");
481 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
483 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) {
484 tempcap |= WFD_UIBC_INPUT_TYPE_MULTITOUCH;
485 g_string_append_printf (lines,"MultiTouch");
486 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
488 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) {
489 tempcap |= WFD_UIBC_INPUT_TYPE_JOYSTICK;
490 g_string_append_printf (lines,"Joystick");
491 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
493 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) {
494 tempcap |= WFD_UIBC_INPUT_TYPE_CAMERA;
495 g_string_append_printf (lines,"Camera");
496 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
498 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) {
499 tempcap |= WFD_UIBC_INPUT_TYPE_GESTURE;
500 g_string_append_printf (lines,"Gesture");
501 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
503 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) {
504 tempcap |= WFD_UIBC_INPUT_TYPE_REMOTECONTROL;
505 g_string_append_printf (lines,"RemoteControl");
506 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
509 else g_string_append_printf (lines,"none");
510 g_string_append_printf (lines,";");
511 g_string_append_printf (lines," hidc_cap_list=");
512 if(msg->uibc_capability->hidc_cap_list.cap_count) {
513 detailed_cap *temp_cap = msg->uibc_capability->hidc_cap_list.next;
516 if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_KEYBOARD) g_string_append_printf (lines,"Keyboard");
517 else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_MOUSE) g_string_append_printf (lines,"Mouse");
518 else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_SINGLETOUCH) g_string_append_printf (lines,"SingleTouch");
519 else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_MULTITOUCH) g_string_append_printf (lines,"MultiTouch");
520 else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_JOYSTICK) g_string_append_printf (lines,"Joystick");
521 else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_CAMERA) g_string_append_printf (lines,"Camera");
522 else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_GESTURE) g_string_append_printf (lines,"Gesture");
523 else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_REMOTECONTROL) g_string_append_printf (lines,"RemoteControl");
524 g_string_append_printf (lines,"/");
525 if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_INFRARED) g_string_append_printf (lines,"Infrared");
526 else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_USB) g_string_append_printf (lines,"USB");
527 else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_BT) g_string_append_printf (lines,"BT");
528 else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_ZIGBEE) g_string_append_printf (lines,"Zigbee");
529 else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_WIFI) g_string_append_printf (lines,"Wi-Fi");
530 else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_NOSP) g_string_append_printf (lines,"No-SP");
531 temp_cap = temp_cap->next;
532 if(temp_cap) g_string_append_printf (lines,", ");
534 } else g_string_append_printf (lines,"none");
535 g_string_append_printf (lines,";");
536 if(msg->uibc_capability->tcp_port) g_string_append_printf (lines," port=%x", msg->uibc_capability->tcp_port);
537 else g_string_append_printf (lines,"port=none");
538 } else g_string_append_printf (lines," none");
539 g_string_append_printf (lines,"\r\n");
542 if(msg->uibc_setting) {
543 g_string_append_printf (lines,"wfd_uibc_setting");
544 g_string_append_printf (lines,":");
545 if(msg->uibc_setting->uibc_setting)
546 g_string_append_printf (lines," enable");
548 g_string_append_printf (lines," disable");
549 g_string_append_printf (lines,"\r\n");
552 if(msg->standby_resume_capability) {
553 g_string_append_printf (lines,"wfd_standby_resume_capability");
554 g_string_append_printf (lines,":");
555 if(msg->standby_resume_capability->standby_resume_cap)
556 g_string_append_printf (lines," supported");
558 g_string_append_printf (lines," none");
559 g_string_append_printf (lines,"\r\n");
563 g_string_append_printf (lines,"wfd_standby");
564 g_string_append_printf (lines,"\r\n");
567 if(msg->connector_type) {
568 g_string_append_printf (lines,"wfd_connector_type");
569 g_string_append_printf (lines,":");
570 if(msg->connector_type->connector_type)
571 g_string_append_printf (lines," %02x", msg->connector_type->connector_type);
573 g_string_append_printf (lines," none");
574 g_string_append_printf (lines,"\r\n");
577 if(msg->idr_request) {
578 g_string_append_printf (lines,"wfd_idr_request");
579 g_string_append_printf (lines,"\r\n");
582 //g_string_append_printf (lines,"\0");
583 /*if(g_str_has_suffix (lines,"\r\n\0"))
585 guint32 length = g_strlen(lines);
586 lines[length-2] = '\0';
588 return g_string_free (lines, FALSE);
591 gchar* wfdconfig_parameter_names_as_text (const WFDMessage *msg)
593 /* change all vars so they match rfc? */
595 g_return_val_if_fail (msg != NULL, NULL);
597 lines = g_string_new ("");
599 /* list of audio codecs */
600 if(msg->audio_codecs) {
601 g_string_append_printf (lines,"wfd_audio_codecs");
602 g_string_append_printf (lines,"\r\n");
604 /* list of video codecs */
605 if(msg->video_formats) {
606 g_string_append_printf (lines,"wfd_video_formats");
607 g_string_append_printf (lines,"\r\n");
609 /* list of video 3D codecs */
610 if(msg->video_3d_formats) {
611 g_string_append_printf (lines,"wfd_3d_video_formats");
612 g_string_append_printf (lines,"\r\n");
614 if(msg->content_protection) {
615 g_string_append_printf (lines,"wfd_content_protection");
616 g_string_append_printf (lines,"\r\n");
618 if(msg->display_edid) {
619 g_string_append_printf (lines,"wfd_display_edid");
620 g_string_append_printf (lines,"\r\n");
622 if(msg->coupled_sink) {
623 g_string_append_printf (lines,"wfd_coupled_sink");
624 g_string_append_printf (lines,"\r\n");
626 if(msg->trigger_method) {
627 g_string_append_printf (lines,"wfd_trigger_method");
628 g_string_append_printf (lines,"\r\n");
630 if(msg->presentation_url) {
631 g_string_append_printf (lines,"wfd_presentation_URL");
632 g_string_append_printf (lines,"\r\n");
634 if(msg->client_rtp_ports) {
635 g_string_append_printf (lines,"wfd_client_rtp_ports");
636 g_string_append_printf (lines,"\r\n");
639 g_string_append_printf (lines,"wfd_route");
640 g_string_append_printf (lines,"\r\n");
643 g_string_append_printf (lines,"wfd_I2C");
644 g_string_append_printf (lines,"\r\n");
646 if(msg->av_format_change_timing) {
647 g_string_append_printf (lines,"wfd_av_format_change_timing");
648 g_string_append_printf (lines,"\r\n");
650 if(msg->preferred_display_mode) {
651 g_string_append_printf (lines,"wfd_preferred_display_mode");
652 g_string_append_printf (lines,"\r\n");
654 if(msg->uibc_capability) {
655 g_string_append_printf (lines,"wfd_uibc_capability");
656 g_string_append_printf (lines,"\r\n");
658 if(msg->uibc_setting) {
659 g_string_append_printf (lines,"wfd_uibc_setting");
660 g_string_append_printf (lines,"\r\n");
662 if(msg->standby_resume_capability) {
663 g_string_append_printf (lines,"wfd_standby_resume_capability");
664 g_string_append_printf (lines,"\r\n");
667 g_string_append_printf (lines,"wfd_standby");
668 g_string_append_printf (lines,"\r\n");
670 if(msg->connector_type) {
671 g_string_append_printf (lines,"wfd_connector_type");
672 g_string_append_printf (lines,"\r\n");
674 if(msg->idr_request) {
675 g_string_append_printf (lines,"wfd_idr_request");
676 g_string_append_printf (lines,"\r\n");
678 return g_string_free (lines, FALSE);
684 return c >= '0' && c <= '9' ? c - '0'
685 : c >= 'A' && c <= 'F' ? c - 'A' + 10
686 : c >= 'a' && c <= 'f' ? c - 'a' + 10 : 0;
690 read_string (gchar * dest, guint size, gchar ** src)
696 while (g_ascii_isspace (**src))
699 while (!g_ascii_isspace (**src) && **src != '\0') {
710 read_string_del (gchar * dest, guint size, gchar del, gchar ** src)
716 while (g_ascii_isspace (**src))
719 while (**src != del && **src != '\0') {
729 read_string_space_ended (gchar * dest, guint size, gchar * src)
733 while (!g_ascii_isspace (*src) && *src != '\0') {
744 read_string_char_ended (gchar * dest, guint size, gchar del, gchar * src)
748 while (*src != del && *src != '\0') {
759 read_string_type_and_value (gchar * type, gchar * value, guint tsize, guint vsize, gchar del, gchar * src)
764 while (*src != del && *src != '\0') {
775 while (*src != '\0') {
785 wfdconfig_parse_line (WFDMessage * msg, gchar * buffer)
787 gchar type[8192] = {0};
788 gchar value[8192] = {0};
789 gchar temp[8192] = {0};
793 #define WFD_SKIP_SPACE(q) if (*q && g_ascii_isspace (*q)) q++
794 #define WFD_SKIP_EQUAL(q) if (*q && *q == '=') q++
795 #define WFD_SKIP_COMMA(q) if (*q && g_ascii_ispunct (*q)) q++
796 #define WFD_READ_STRING(field) read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); REPLACE_STRING (field, temp)
797 #define WFD_READ_CHAR_END_STRING(field, del) read_string_char_ended (temp, sizeof (temp), del, v); v+=strlen(temp); REPLACE_STRING (field, temp)
798 #define WFD_READ_UINT32(field) read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); field = strtoul (temp, NULL, 16)
799 #define WFD_READ_UINT32_DIGIT(field) read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); field = strtoul (temp, NULL, 10)
801 //g_print("wfdconfig_parse_line input: %s\n", buffer);
802 read_string_type_and_value (type, value, sizeof(type), sizeof(value), ':', p);
803 //g_print("wfdconfig_parse_line type:%s value:%s\n", type, value);
804 if(!g_strcmp0(type,"wfd_audio_codecs")) {
805 msg->audio_codecs = g_new0 (WFDAudioCodeclist, 1);
808 msg->audio_codecs->count= strlen(v)/16;
809 msg->audio_codecs->list = g_new0 (WFDAudioCodec, msg->audio_codecs->count);
810 for(;i<msg->audio_codecs->count;i++) {
812 WFD_READ_STRING(msg->audio_codecs->list[i].audio_format);
814 WFD_READ_UINT32(msg->audio_codecs->list[i].modes);
816 WFD_READ_UINT32(msg->audio_codecs->list[i].latency);
820 } else if(!g_strcmp0(type,"wfd_video_formats")) {
821 msg->video_formats = g_new0 (WFDVideoCodeclist, 1);
823 msg->video_formats->count = 1;
824 msg->video_formats->list = g_new0 (WFDVideoCodec, 1);
826 WFD_READ_UINT32(msg->video_formats->list->native);
828 WFD_READ_UINT32(msg->video_formats->list->preferred_display_mode_supported);
830 WFD_READ_UINT32(msg->video_formats->list->H264_codec.profile);
832 WFD_READ_UINT32(msg->video_formats->list->H264_codec.level);
834 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.CEA_Support);
836 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.VESA_Support);
838 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.HH_Support);
840 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.latency);
842 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.min_slice_size);
844 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.slice_enc_params);
846 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support);
848 if(msg->video_formats->list->preferred_display_mode_supported == 1) {
849 WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_hres);
851 WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_vres);
855 }else if(!g_strcmp0(type,"wfd_3d_formats")) {
856 msg->video_3d_formats = g_new0 (WFD3DFormats, 1);
858 msg->video_3d_formats->count = 1;
859 msg->video_3d_formats->list = g_new0 (WFD3dCapList, 1);
861 WFD_READ_UINT32(msg->video_3d_formats->list->native);
863 WFD_READ_UINT32(msg->video_3d_formats->list->preferred_display_mode_supported);
865 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.profile);
867 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.level);
869 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.video_3d_capability);
871 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.latency);
873 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.min_slice_size);
875 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.slice_enc_params);
877 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support);
879 if(msg->video_formats->list->preferred_display_mode_supported == 1) {
880 WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_hres);
882 WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_vres);
886 } else if(!g_strcmp0(type,"wfd_content_protection")) {
887 msg->content_protection = g_new0 (WFDContentProtection, 1);
890 msg->content_protection->hdcp2_spec = g_new0 (WFDHdcp2Spec, 1);
891 if(strstr(v,"none")) {
892 msg->content_protection->hdcp2_spec->hdcpversion=g_strdup("none");
894 WFD_READ_STRING(msg->content_protection->hdcp2_spec->hdcpversion);
896 WFD_READ_STRING(msg->content_protection->hdcp2_spec->TCPPort);
899 } else if(!g_strcmp0(type,"wfd_display_edid")) {
900 msg->display_edid = g_new0 (WFDDisplayEdid, 1);
903 if(strstr(v,"none")) {
904 msg->display_edid->edid_supported = 0;
906 msg->display_edid->edid_supported = 1;
907 WFD_READ_UINT32(msg->display_edid->edid_block_count);
909 if(msg->display_edid->edid_block_count) {
910 gchar *edid_string = v;
912 guint32 payload_size = EDID_BLOCK_SIZE * msg->display_edid->edid_block_count;
913 msg->display_edid->edid_payload = g_malloc(payload_size);
914 for (;i<(EDID_BLOCK_SIZE*msg->display_edid->edid_block_count*2); j++) {
916 if(edid_string[i]>0x29 && edid_string[i]<0x40) k=edid_string[i]-48;
917 else if(edid_string[i]>0x60 && edid_string[i]<0x67) k=edid_string[i]-87;
918 else if(edid_string[i]>0x40 && edid_string[i]<0x47) k=edid_string[i]-55;
920 if(edid_string[i+1]>0x29 && edid_string[i+1]<0x40) kk=edid_string[i+1]-48;
921 else if(edid_string[i+1]>0x60 && edid_string[i+1]<0x67) kk=edid_string[i+1]-87;
922 else if(edid_string[i+1]>0x40 && edid_string[i+1]<0x47) kk=edid_string[i+1]-55;
924 msg->display_edid->edid_payload[j] = (k<<4)|kk;
927 //memcpy(msg->display_edid->edid_payload, v, payload_size);
928 v += (payload_size*2);
929 } else v += strlen(v);
932 } else if(!g_strcmp0(type,"wfd_coupled_sink")) {
933 msg->coupled_sink = g_new0 (WFDCoupledSink, 1);
935 msg->coupled_sink->coupled_sink_cap = g_new0 (WFDCoupled_sink_cap, 1);
937 WFD_READ_UINT32(msg->coupled_sink->coupled_sink_cap->status);
939 WFD_READ_STRING(msg->coupled_sink->coupled_sink_cap->sink_address);
941 } else if(!g_strcmp0(type,"wfd_trigger_method")) {
942 msg->trigger_method = g_new0 (WFDTriggerMethod, 1);
945 WFD_READ_STRING(msg->trigger_method->wfd_trigger_method);
947 } else if(!g_strcmp0(type,"wfd_presentation_URL")) {
948 msg->presentation_url = g_new0 (WFDPresentationUrl, 1);
951 WFD_READ_STRING(msg->presentation_url->wfd_url0);
953 WFD_READ_STRING(msg->presentation_url->wfd_url1);
955 } else if(!g_strcmp0(type,"wfd_client_rtp_ports")) {
956 msg->client_rtp_ports = g_new0 (WFDClientRtpPorts, 1);
959 WFD_READ_STRING(msg->client_rtp_ports->profile);
961 WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port0);
963 WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port1);
965 WFD_READ_STRING(msg->client_rtp_ports->mode);
967 } else if(!g_strcmp0(type,"wfd_route")) {
968 msg->route = g_new0 (WFDRoute, 1);
971 WFD_READ_STRING(msg->route->destination);
973 } else if(!g_strcmp0(type,"wfd_I2C")) {
974 msg->I2C = g_new0 (WFDI2C, 1);
976 msg->I2C->I2CPresent = TRUE;
978 WFD_READ_UINT32_DIGIT(msg->I2C->I2C_port);
979 if(msg->I2C->I2C_port) msg->I2C->I2CPresent = TRUE;
981 } else if(!g_strcmp0(type,"wfd_av_format_change_timing")) {
982 msg->av_format_change_timing = g_new0 (WFDAVFormatChangeTiming, 1);
985 WFD_READ_UINT32(msg->av_format_change_timing->PTS);
987 WFD_READ_UINT32(msg->av_format_change_timing->DTS);
989 } else if(!g_strcmp0(type,"wfd_preferred_display_mode")) {
990 msg->preferred_display_mode = g_new0 (WFDPreferredDisplayMode, 1);
993 if(!strstr(v,"none")) {
994 msg->preferred_display_mode->displaymodesupported = FALSE;
996 WFD_READ_UINT32(msg->preferred_display_mode->p_clock);
998 WFD_READ_UINT32(msg->preferred_display_mode->H);
1000 WFD_READ_UINT32(msg->preferred_display_mode->HB);
1002 WFD_READ_UINT32(msg->preferred_display_mode->HSPOL_HSOFF);
1004 WFD_READ_UINT32(msg->preferred_display_mode->HSW);
1006 WFD_READ_UINT32(msg->preferred_display_mode->V);
1008 WFD_READ_UINT32(msg->preferred_display_mode->VB);
1010 WFD_READ_UINT32(msg->preferred_display_mode->VSPOL_VSOFF);
1012 WFD_READ_UINT32(msg->preferred_display_mode->VSW);
1014 WFD_READ_UINT32(msg->preferred_display_mode->VBS3D);
1016 WFD_READ_UINT32(msg->preferred_display_mode->V2d_s3d_modes);
1018 WFD_READ_UINT32(msg->preferred_display_mode->P_depth);
1020 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.profile);
1022 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.level);
1024 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.CEA_Support);
1026 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.VESA_Support);
1028 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.HH_Support);
1030 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.latency);
1032 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.min_slice_size);
1034 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.slice_enc_params);
1036 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.frame_rate_control_support);
1038 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_hres);
1040 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_vres);
1044 } else if(!g_strcmp0(type,"wfd_uibc_capability")) {
1045 msg->uibc_capability = g_new0 (WFDUibcCapability, 1);
1046 if(!strstr(v,"none")) {
1047 msg->uibc_capability->uibcsupported = FALSE;
1049 gchar *tstring = NULL;
1050 msg->uibc_capability->uibcsupported = TRUE;
1051 WFD_READ_CHAR_END_STRING(tstring, '=');
1052 if(!g_strcmp0(tstring,"input_category_list")) {
1053 if(!strstr(v,"none")) {
1057 guint rem_len, read_len=0;
1058 WFD_READ_CHAR_END_STRING(tstring, ';');
1059 rem_len = strlen(tstring);
1061 read_string_char_ended (temp, 8192, ',', tstring+read_len);
1062 read_len += (strlen(temp)+1);
1063 if(!g_strcmp0(temp,"GENERIC")) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_GENERIC;
1064 else if(!g_strcmp0(temp,"HIDC")) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_HIDC;
1065 else msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_UNKNOWN;
1066 } while(read_len < rem_len);
1069 WFD_READ_CHAR_END_STRING(tstring, '=');
1070 if(!g_strcmp0(tstring,"generic_cap_list=")) {
1071 if(!strstr(v,"none")) {
1074 guint rem_len, read_len=0;
1075 WFD_READ_CHAR_END_STRING(tstring, ';');
1076 rem_len = strlen(tstring);
1078 read_string_char_ended (temp, 8192, ',', tstring+read_len);
1079 read_len += (strlen(temp)+1);
1080 if(!g_strcmp0(temp,"Keyboard")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_KEYBOARD;
1081 else if(!g_strcmp0(temp,"Mouse")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MOUSE;
1082 else if(!g_strcmp0(temp,"SingleTouch")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_SINGLETOUCH;
1083 else if(!g_strcmp0(temp,"MultiTouch")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MULTITOUCH;
1084 else if(!g_strcmp0(temp,"Joystick")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_JOYSTICK;
1085 else if(!g_strcmp0(temp,"Camera")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_CAMERA;
1086 else if(!g_strcmp0(temp,"Gesture")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_GESTURE;
1087 else if(!g_strcmp0(temp,"RemoteControl")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_REMOTECONTROL;
1088 else msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_UNKNOWN;
1089 } while(read_len < rem_len);
1092 WFD_READ_CHAR_END_STRING(tstring, '=');
1093 if(!g_strcmp0(tstring,"hidc_cap_list=")) {
1094 if(!strstr(v,"none")) {
1097 gchar inp_type[8192];
1098 gchar inp_path[8192];
1099 guint rem_len, read_len=0;
1100 detailed_cap *temp_cap;
1101 WFD_READ_CHAR_END_STRING(tstring, ';');
1102 rem_len = strlen(tstring);
1103 msg->uibc_capability->hidc_cap_list.next = g_new0 (detailed_cap, 1);
1104 temp_cap = msg->uibc_capability->hidc_cap_list.next;
1106 msg->uibc_capability->hidc_cap_list.cap_count++;
1107 read_string_char_ended (temp, 8192, ',', tstring+read_len);
1108 read_len += (strlen(temp)+1);
1109 read_string_type_and_value (inp_type, inp_path, sizeof(inp_type), sizeof(inp_path), '/', temp);
1110 if(!strstr(inp_type,"Keyboard")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_KEYBOARD;
1111 else if(!strstr(inp_type,"Mouse")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MOUSE;
1112 else if(!strstr(inp_type,"SingleTouch")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_SINGLETOUCH;
1113 else if(!strstr(inp_type,"MultiTouch")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MULTITOUCH;
1114 else if(!strstr(inp_type,"Joystick")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_JOYSTICK;
1115 else if(!strstr(inp_type,"Camera")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_CAMERA;
1116 else if(!strstr(inp_type,"Gesture")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_GESTURE;
1117 else if(!strstr(inp_type,"RemoteControl")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_REMOTECONTROL;
1118 else temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_UNKNOWN;
1120 if(!strstr(inp_path,"Infrared")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_INFRARED;
1121 else if(!strstr(inp_path,"USB")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_USB;
1122 else if(!strstr(inp_path,"BT")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_BT;
1123 else if(!strstr(inp_path,"Zigbee")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_ZIGBEE;
1124 else if(!strstr(inp_path,"Wi-Fi")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_WIFI;
1125 else if(!strstr(inp_path,"No-SP")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_NOSP;
1126 else temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_UNKNOWN;
1127 if(read_len < rem_len) {
1128 temp_cap->next = g_new0 (detailed_cap, 1);
1129 temp_cap = temp_cap->next;
1131 } while(read_len < rem_len);
1134 WFD_READ_CHAR_END_STRING(tstring, '=');
1135 if(!g_strcmp0(tstring,"hidc_cap_list=")) {
1136 if(!strstr(v,"none")) {
1138 WFD_READ_UINT32(msg->uibc_capability->tcp_port);
1142 } else if(!g_strcmp0(type,"wfd_uibc_setting")) {
1143 msg->uibc_setting = g_new0 (WFDUibcSetting, 1);
1146 if(!g_strcmp0(v, "enable"))
1147 msg->uibc_setting->uibc_setting = TRUE;
1149 msg->uibc_setting->uibc_setting = FALSE;
1151 } else if(!g_strcmp0(type,"wfd_standby_resume_capability")) {
1152 msg->standby_resume_capability = g_new0 (WFDStandbyResumeCapability, 1);
1155 if(!g_strcmp0(v, "supported"))
1156 msg->standby_resume_capability->standby_resume_cap = TRUE;
1158 msg->standby_resume_capability->standby_resume_cap = FALSE;
1160 } else if(!g_strcmp0(type,"wfd_standby")) {
1161 msg->standby = g_new0 (WFDStandby, 1);
1162 msg->standby->wfd_standby = TRUE;
1163 } else if(!g_strcmp0(type,"wfd_connector_type")) {
1164 msg->connector_type = g_new0 (WFDConnectorType, 1);
1166 msg->connector_type->supported = TRUE;
1168 WFD_READ_UINT32(msg->connector_type->connector_type);
1170 } else if(!g_strcmp0(type,"wfd_idr_request")) {
1171 msg->idr_request = g_new0 (WFDIdrRequest, 1);
1172 msg->idr_request->idr_request = TRUE;
1179 * wfdconfig_message_parse_buffer:
1180 * @data: the start of the buffer
1181 * @size: the size of the buffer
1182 * @msg: the result #WFDMessage
1184 * Parse the contents of @size bytes pointed to by @data and store the result in
1187 * Returns: #WFD_OK on success.
1190 wfdconfig_message_parse_buffer (const guint8 * data, guint size, WFDMessage * msg)
1193 gchar buffer[MAX_LINE_LEN] = {0};
1196 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1197 g_return_val_if_fail (data != NULL, WFD_EINVAL);
1198 g_return_val_if_fail (size != 0, WFD_EINVAL);
1207 while (*p != '\n' && *p != '\r' && *p != '\0') {
1208 if (idx < sizeof (buffer) - 1)
1213 wfdconfig_parse_line (msg, buffer);
1224 * wfdconfig_message_dump:
1225 * @msg: a #WFDMessage
1227 * Dump the parsed contents of @msg to stdout.
1229 * Returns: a #WFDResult.
1232 wfdconfig_message_dump (const WFDMessage * msg)
1234 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1235 debug_log("===========WFD Message dump=========");
1237 if(msg->audio_codecs) {
1239 debug_log("Audio supported formats : \n");
1240 for(;i<msg->audio_codecs->count;i++) {
1241 debug_log("Codec: %s\n",msg->audio_codecs->list[i].audio_format);
1242 if(!strcmp(msg->audio_codecs->list[i].audio_format,"LPCM")) {
1243 if(msg->audio_codecs->list[i].modes & WFD_FREQ_44100)
1244 debug_log(" Freq: %d\n", 44100);
1245 if(msg->audio_codecs->list[i].modes & WFD_FREQ_48000)
1246 debug_log(" Freq: %d\n", 48000);
1247 debug_log(" Channels: %d\n", 2);
1249 if(!strcmp(msg->audio_codecs->list[i].audio_format,"AAC")) {
1250 debug_log(" Freq: %d\n", 48000);
1251 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_2)
1252 debug_log(" Channels: %d\n", 2);
1253 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_4)
1254 debug_log(" Channels: %d\n", 4);
1255 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_6)
1256 debug_log(" Channels: %d\n", 6);
1257 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_8)
1258 debug_log(" Channels: %d\n", 8);
1260 if(!strcmp(msg->audio_codecs->list[i].audio_format,"AC3")) {
1261 debug_log(" Freq: %d\n", 48000);
1262 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_2)
1263 debug_log(" Channels: %d\n", 2);
1264 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_4)
1265 debug_log(" Channels: %d\n", 4);
1266 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_6)
1267 debug_log(" Channels: %d\n", 6);
1269 debug_log(" Bitwidth: %d\n", 16);
1270 debug_log(" Latency: %d\n", msg->audio_codecs->list[i].latency);
1275 if(msg->video_formats) {
1276 debug_log("Video supported formats : \n");
1277 if(msg->video_formats->list) {
1278 debug_log("Codec: H264\n");
1279 guint nativeindex = 0;
1280 if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_CEA_RESOLUTION) {
1281 debug_log (" Native type: CEA\n");
1282 } else if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_VESA_RESOLUTION) {
1283 debug_log (" Native type: VESA\n");
1284 } else if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_HH_RESOLUTION) {
1285 debug_log (" Native type: HH\n");
1287 nativeindex = msg->video_formats->list->native >> 3;
1288 debug_log (" Resolution: %d\n", (1 << nativeindex));
1290 if(msg->video_formats->list->H264_codec.profile & WFD_H264_BASE_PROFILE) {
1291 debug_log (" Profile: BASE\n");
1292 } else if(msg->video_formats->list->H264_codec.profile & WFD_H264_HIGH_PROFILE) {
1293 debug_log (" Profile: HIGH\n");
1294 } if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_1) {
1295 debug_log (" Level: 3.1\n");
1296 } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_2) {
1297 debug_log (" Level: 3.2\n");
1298 } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4) {
1299 debug_log (" Level: 4\n");
1300 } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_1) {
1301 debug_log (" Level: 4.1\n");
1302 } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_2) {
1303 debug_log (" Level: 4.2\n");
1305 debug_log (" Latency: %d\n", msg->video_formats->list->H264_codec.misc_params.latency);
1306 debug_log (" min_slice_size: %x\n", msg->video_formats->list->H264_codec.misc_params.min_slice_size);
1307 debug_log (" slice_enc_params: %x\n", msg->video_formats->list->H264_codec.misc_params.slice_enc_params);
1308 debug_log (" frame_rate_control_support: %x\n", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support);
1309 if(msg->video_formats->list->H264_codec.max_hres) {
1310 debug_log (" Max Height: %04d\n", msg->video_formats->list->H264_codec.max_hres);
1312 if(msg->video_formats->list->H264_codec.max_vres) {
1313 debug_log (" Max Width: %04d\n", msg->video_formats->list->H264_codec.max_vres);
1318 if(msg->video_3d_formats) {
1319 debug_log ("wfd_3d_formats");
1323 if(msg->content_protection) {
1324 debug_log ("wfd_content_protection");
1328 if(msg->display_edid) {
1329 debug_log ("wfd_display_edid");
1333 if(msg->coupled_sink) {
1334 debug_log ("wfd_coupled_sink");
1338 if(msg->trigger_method) {
1339 debug_log (" Trigger type: %s\n", msg->trigger_method->wfd_trigger_method);
1342 if(msg->presentation_url) {
1343 debug_log ("wfd_presentation_URL");
1347 if(msg->client_rtp_ports) {
1348 debug_log(" Client RTP Ports : \n");
1349 if(msg->client_rtp_ports->profile) {
1350 debug_log ("%s\n", msg->client_rtp_ports->profile);
1351 debug_log (" %d\n", msg->client_rtp_ports->rtp_port0);
1352 debug_log (" %d\n", msg->client_rtp_ports->rtp_port1);
1353 debug_log (" %s\n", msg->client_rtp_ports->mode);
1359 debug_log ("wfd_route");
1364 debug_log ("wfd_I2C");
1368 if(msg->av_format_change_timing) {
1369 debug_log ("wfd_av_format_change_timing");
1373 if(msg->preferred_display_mode) {
1374 debug_log ("wfd_preferred_display_mode");
1378 if(msg->uibc_capability) {
1379 debug_log ("wfd_uibc_capability");
1383 if(msg->uibc_setting) {
1384 debug_log ("wfd_uibc_setting");
1388 if(msg->standby_resume_capability) {
1389 debug_log ("wfd_standby_resume_capability");
1394 debug_log ("wfd_standby");
1398 if(msg->connector_type) {
1399 debug_log ("wfd_connector_type");
1403 if(msg->idr_request) {
1404 debug_log ("wfd_idr_request");
1407 debug_log("===============================================\n");
1411 WFDResult wfdconfig_set_supported_audio_format(WFDMessage *msg, WFDAudioFormats aCodec, guint aFreq, guint aChanels,
1412 guint aBitwidth, guint32 aLatency)
1414 guint temp = aCodec;
1416 guint pcm = 0, aac = 0, ac3 = 0;
1418 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1420 if(!msg->audio_codecs)
1421 msg->audio_codecs = g_new0 (WFDAudioCodeclist, 1);
1423 if(aCodec != WFD_AUDIO_UNKNOWN) {
1425 msg->audio_codecs->count++;
1428 msg->audio_codecs->list = g_new0 (WFDAudioCodec, msg->audio_codecs->count);
1429 for(; i<msg->audio_codecs->count; i++) {
1430 if((aCodec & WFD_AUDIO_LPCM) && (!pcm)) {
1431 msg->audio_codecs->list[i].audio_format = g_strdup("LPCM");
1432 msg->audio_codecs->list[i].modes = aFreq;
1433 msg->audio_codecs->list[i].latency = aLatency;
1435 } else if((aCodec & WFD_AUDIO_AAC) && (!aac)) {
1436 msg->audio_codecs->list[i].audio_format = g_strdup("AAC");
1437 msg->audio_codecs->list[i].modes = aChanels;
1438 msg->audio_codecs->list[i].latency = aLatency;
1440 } else if((aCodec & WFD_AUDIO_AC3) && (!ac3)) {
1441 msg->audio_codecs->list[i].audio_format = g_strdup("AC3");
1442 msg->audio_codecs->list[i].modes = aChanels;
1443 msg->audio_codecs->list[i].latency = aLatency;
1451 WFDResult wfdconfig_set_prefered_audio_format(WFDMessage *msg, WFDAudioFormats aCodec, WFDAudioFreq aFreq, WFDAudioChannels aChanels,
1452 guint aBitwidth, guint32 aLatency)
1455 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1457 if(!msg->audio_codecs)
1458 msg->audio_codecs = g_new0 (WFDAudioCodeclist, 1);
1460 msg->audio_codecs->list = g_new0 (WFDAudioCodec, 1);
1461 msg->audio_codecs->count = 1;
1462 if(aCodec == WFD_AUDIO_LPCM) {
1463 msg->audio_codecs->list->audio_format = g_strdup("LPCM");
1464 msg->audio_codecs->list->modes = aFreq;
1465 msg->audio_codecs->list->latency = aLatency;
1466 } else if(aCodec == WFD_AUDIO_AAC) {
1467 msg->audio_codecs->list->audio_format = g_strdup("AAC");
1468 msg->audio_codecs->list->modes = aChanels;
1469 msg->audio_codecs->list->latency = aLatency;
1470 } else if(aCodec == WFD_AUDIO_AC3) {
1471 msg->audio_codecs->list->audio_format = g_strdup("AC3");
1472 msg->audio_codecs->list->modes = aChanels;
1473 msg->audio_codecs->list->latency = aLatency;
1478 WFDResult wfdconfig_get_supported_audio_format(WFDMessage *msg, guint *aCodec, guint *aFreq, guint *aChanels,
1479 guint *aBitwidth, guint32 *aLatency)
1482 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1483 g_return_val_if_fail (msg->audio_codecs != NULL, WFD_EINVAL);
1485 for(; i<msg->audio_codecs->count; i++) {
1486 if(!g_strcmp0(msg->audio_codecs->list[i].audio_format,"LPCM")) {
1487 *aCodec |= WFD_AUDIO_LPCM;
1488 *aFreq |= msg->audio_codecs->list[i].modes;
1489 *aChanels |= WFD_CHANNEL_2;
1491 *aLatency = msg->audio_codecs->list[i].latency;
1492 } else if(!g_strcmp0(msg->audio_codecs->list[i].audio_format,"AAC")) {
1493 *aCodec |= WFD_AUDIO_AAC;
1494 *aFreq |= WFD_FREQ_48000;
1495 *aChanels |= msg->audio_codecs->list[i].modes;
1497 *aLatency = msg->audio_codecs->list[i].latency;
1498 } else if(!g_strcmp0(msg->audio_codecs->list[i].audio_format,"AC3")) {
1499 *aCodec |= WFD_AUDIO_AC3;
1500 *aFreq |= WFD_FREQ_48000;
1501 *aChanels |= msg->audio_codecs->list[i].modes;
1503 *aLatency = msg->audio_codecs->list[i].latency;
1509 WFDResult wfdconfig_get_prefered_audio_format(WFDMessage *msg, WFDAudioFormats *aCodec, WFDAudioFreq *aFreq, WFDAudioChannels *aChanels,
1510 guint *aBitwidth, guint32 *aLatency)
1512 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1514 if(!g_strcmp0(msg->audio_codecs->list->audio_format,"LPCM")) {
1515 *aCodec = WFD_AUDIO_LPCM;
1516 *aFreq = msg->audio_codecs->list->modes;
1517 *aChanels = WFD_CHANNEL_2;
1519 *aLatency = msg->audio_codecs->list->latency;
1520 } else if(!g_strcmp0(msg->audio_codecs->list->audio_format,"AAC")) {
1521 *aCodec = WFD_AUDIO_AAC;
1522 *aFreq = WFD_FREQ_48000;
1523 *aChanels = msg->audio_codecs->list->modes;
1525 *aLatency = msg->audio_codecs->list->latency;
1526 } else if(!g_strcmp0(msg->audio_codecs->list->audio_format,"AC3")) {
1527 *aCodec = WFD_AUDIO_AC3;
1528 *aFreq = WFD_FREQ_48000;
1529 *aChanels = msg->audio_codecs->list->modes;
1531 *aLatency = msg->audio_codecs->list->latency;
1536 WFDResult wfdconfig_set_supported_video_format(WFDMessage *msg, WFDVideoCodecs vCodec,
1537 WFDVideoNativeResolution vNative, guint64 vNativeResolution,
1538 guint64 vCEAResolution, guint64 vVESAResolution, guint64 vHHResolution,
1539 guint vProfile, guint vLevel, guint32 vLatency, guint32 vMaxHeight,
1540 guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control)
1542 guint nativeindex = 0;
1543 guint64 temp = vNativeResolution;
1545 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1547 if(!msg->video_formats)
1548 msg->video_formats = g_new0 (WFDVideoCodeclist, 1);
1550 if(vCodec != WFD_VIDEO_UNKNOWN) {
1551 msg->video_formats->list = g_new0 (WFDVideoCodec, 1);
1557 msg->video_formats->list->native = nativeindex-1;
1558 msg->video_formats->list->native <<= 3;
1560 if(vNative == WFD_VIDEO_VESA_RESOLUTION)
1561 msg->video_formats->list->native |= 1;
1562 else if(vNative == WFD_VIDEO_HH_RESOLUTION)
1563 msg->video_formats->list->native |= 2;
1565 msg->video_formats->list->preferred_display_mode_supported = 1;
1566 msg->video_formats->list->H264_codec.profile = vProfile;
1567 msg->video_formats->list->H264_codec.level = vLevel;
1568 msg->video_formats->list->H264_codec.max_hres = vMaxHeight;
1569 msg->video_formats->list->H264_codec.max_vres = vMaxWidth;
1570 msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution;
1571 msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution;
1572 msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution;
1573 msg->video_formats->list->H264_codec.misc_params.latency = vLatency;
1574 msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size;
1575 msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params;
1576 msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control;
1581 WFDResult wfdconfig_set_prefered_video_format(WFDMessage *msg, WFDVideoCodecs vCodec,
1582 WFDVideoNativeResolution vNative, guint64 vNativeResolution,
1583 WFDVideoCEAResolution vCEAResolution, WFDVideoVESAResolution vVESAResolution,
1584 WFDVideoHHResolution vHHResolution, WFDVideoH264Profile vProfile,
1585 WFDVideoH264Level vLevel, guint32 vLatency, guint32 vMaxHeight,
1586 guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control)
1588 guint nativeindex = 0;
1589 guint64 temp = vNativeResolution;
1591 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1593 if(!msg->video_formats)
1594 msg->video_formats = g_new0 (WFDVideoCodeclist, 1);
1595 msg->video_formats->list = g_new0 (WFDVideoCodec, 1);
1602 if(nativeindex) msg->video_formats->list->native = nativeindex-1;
1603 msg->video_formats->list->native <<= 3;
1605 if(vNative == WFD_VIDEO_VESA_RESOLUTION)
1606 msg->video_formats->list->native |= 1;
1607 else if(vNative == WFD_VIDEO_HH_RESOLUTION)
1608 msg->video_formats->list->native |= 2;
1610 msg->video_formats->list->preferred_display_mode_supported = 0;
1611 msg->video_formats->list->H264_codec.profile = vProfile;
1612 msg->video_formats->list->H264_codec.level = vLevel;
1613 msg->video_formats->list->H264_codec.max_hres = vMaxHeight;
1614 msg->video_formats->list->H264_codec.max_vres = vMaxWidth;
1615 msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution;
1616 msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution;
1617 msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution;
1618 msg->video_formats->list->H264_codec.misc_params.latency = vLatency;
1619 msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size;
1620 msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params;
1621 msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control;
1625 WFDResult wfdconfig_get_supported_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec,
1626 WFDVideoNativeResolution *vNative, guint64 *vNativeResolution,
1627 guint64 *vCEAResolution, guint64 *vVESAResolution, guint64 *vHHResolution,
1628 guint *vProfile, guint *vLevel, guint32 *vLatency, guint32 *vMaxHeight,
1629 guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control)
1631 guint nativeindex = 0;
1633 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1634 *vCodec = WFD_VIDEO_H264;
1635 *vNative = msg->video_formats->list->native & 0x7;
1636 nativeindex = msg->video_formats->list->native >> 3;
1637 *vNativeResolution = 1 << nativeindex;
1638 *vProfile = msg->video_formats->list->H264_codec.profile;
1639 *vLevel = msg->video_formats->list->H264_codec.level;
1640 *vMaxHeight = msg->video_formats->list->H264_codec.max_hres;
1641 *vMaxWidth = msg->video_formats->list->H264_codec.max_vres;
1642 *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support;
1643 *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support;
1644 *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support;
1645 *vLatency = msg->video_formats->list->H264_codec.misc_params.latency;
1646 *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size;
1647 *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params;
1648 *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support;
1652 WFDResult wfdconfig_get_prefered_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec,
1653 WFDVideoNativeResolution *vNative, guint64 *vNativeResolution,
1654 WFDVideoCEAResolution *vCEAResolution, WFDVideoVESAResolution *vVESAResolution,
1655 WFDVideoHHResolution *vHHResolution, WFDVideoH264Profile *vProfile,
1656 WFDVideoH264Level *vLevel, guint32 *vLatency, guint32 *vMaxHeight,
1657 guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control)
1659 guint nativeindex = 0;
1660 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1662 *vCodec = WFD_VIDEO_H264;
1663 *vNative = msg->video_formats->list->native & 0x7;
1664 nativeindex = msg->video_formats->list->native >> 3;
1665 *vNativeResolution = 1 << nativeindex;
1666 *vProfile = msg->video_formats->list->H264_codec.profile;
1667 *vLevel = msg->video_formats->list->H264_codec.level;
1668 *vMaxHeight = msg->video_formats->list->H264_codec.max_hres;
1669 *vMaxWidth = msg->video_formats->list->H264_codec.max_vres;
1670 *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support;
1671 *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support;
1672 *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support;
1673 *vLatency = msg->video_formats->list->H264_codec.misc_params.latency;
1674 *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size;
1675 *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params;
1676 *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support;
1680 WFDResult wfdconfig_set_contentprotection_type(WFDMessage *msg, WFDHDCPProtection hdcpversion, guint32 TCPPort)
1682 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1686 fp = fopen(LIBHDCP, "r");
1692 if(!msg->content_protection) msg->content_protection = g_new0 (WFDContentProtection, 1);
1693 if(hdcpversion == WFD_HDCP_NONE) return WFD_OK;
1694 msg->content_protection->hdcp2_spec = g_new0 (WFDHdcp2Spec, 1);
1695 if(hdcpversion == WFD_HDCP_2_0) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup("HDCP2.0");
1696 else if(hdcpversion == WFD_HDCP_2_1) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup("HDCP2.1");
1698 sprintf(str, "port=%d", TCPPort);
1699 msg->content_protection->hdcp2_spec->TCPPort = g_strdup(str);
1703 WFDResult wfdconfig_get_contentprotection_type(WFDMessage *msg, WFDHDCPProtection *hdcpversion, guint32 *TCPPort)
1705 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1706 if(msg->content_protection && msg->content_protection->hdcp2_spec) {
1707 char *result = NULL;
1708 if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"none")) {
1709 debug_warning("HDCP none");
1710 *hdcpversion = WFD_HDCP_NONE;
1714 if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"HDCP2.0")) *hdcpversion = WFD_HDCP_2_0;
1715 else if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"HDCP2.1")) *hdcpversion = WFD_HDCP_2_1;
1717 debug_warning("Unknown protection type");
1718 *hdcpversion = WFD_HDCP_NONE;
1723 result = strtok(msg->content_protection->hdcp2_spec->TCPPort, "=");
1724 while (result !=NULL) {
1725 result = strtok(NULL, "=");
1726 *TCPPort = atoi (result);
1729 } else *hdcpversion = WFD_HDCP_NONE;
1733 WFDResult wfdconfig_set_display_EDID(WFDMessage *msg, gboolean edid_supported, guint32 edid_blockcount, gchar *edid_playload)
1735 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1736 if(!msg->display_edid) msg->display_edid = g_new0 (WFDDisplayEdid, 1);
1737 msg->display_edid->edid_supported = edid_supported;
1738 if(!edid_supported) return WFD_OK;
1739 msg->display_edid->edid_block_count = edid_blockcount;
1740 if(edid_blockcount) {
1741 msg->display_edid->edid_payload = g_malloc(128 * edid_blockcount);
1742 if(!msg->display_edid->edid_payload)
1743 memcpy(msg->display_edid->edid_payload, edid_playload, 128 * edid_blockcount);
1744 } else msg->display_edid->edid_payload = g_strdup("none");
1748 WFDResult wfdconfig_get_display_EDID(WFDMessage *msg, gboolean *edid_supported, guint32 *edid_blockcount, gchar **edid_playload)
1750 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1751 if(msg->display_edid ) {
1752 if(msg->display_edid->edid_supported) {
1753 *edid_blockcount = msg->display_edid->edid_block_count;
1754 if(msg->display_edid->edid_block_count) {
1756 temp = g_malloc(EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
1758 memset(temp, 0, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
1759 memcpy(temp, msg->display_edid->edid_payload, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
1760 *edid_playload = temp;
1761 *edid_supported = TRUE;
1763 } else *edid_playload = g_strdup("none");
1765 } else *edid_supported = FALSE;
1769 WFDResult wfdconfig_set_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus status, gchar *sink_address)
1771 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1772 if(!msg->coupled_sink) msg->coupled_sink = g_new0 (WFDCoupledSink, 1);
1773 if(status == WFD_SINK_UNKNOWN) return WFD_OK;
1774 msg->coupled_sink->coupled_sink_cap = g_new0 (WFDCoupled_sink_cap, 1);
1775 msg->coupled_sink->coupled_sink_cap->status = status;
1776 msg->coupled_sink->coupled_sink_cap->sink_address = g_strdup(sink_address);
1780 WFDResult wfdconfig_get_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus *status, gchar **sink_address)
1782 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1783 if(msg->coupled_sink && msg->coupled_sink->coupled_sink_cap) {
1784 *status = msg->coupled_sink->coupled_sink_cap->status;
1785 *sink_address = g_strdup(msg->coupled_sink->coupled_sink_cap->sink_address);
1786 } else *status = WFD_SINK_UNKNOWN;
1790 WFDResult wfdconfig_set_trigger_type(WFDMessage *msg, WFDTrigger trigger)
1792 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1794 if(!msg->trigger_method)
1795 msg->trigger_method = g_new0 (WFDTriggerMethod, 1);
1796 if(trigger == WFD_TRIGGER_SETUP)
1797 msg->trigger_method->wfd_trigger_method = g_strdup("SETUP");
1798 else if(trigger == WFD_TRIGGER_PAUSE)
1799 msg->trigger_method->wfd_trigger_method = g_strdup("PAUSE");
1800 else if(trigger == WFD_TRIGGER_TEARDOWN)
1801 msg->trigger_method->wfd_trigger_method = g_strdup("TEARDOWN");
1802 else if(trigger == WFD_TRIGGER_PLAY)
1803 msg->trigger_method->wfd_trigger_method = g_strdup("PLAY");
1809 WFDResult wfdconfig_get_trigger_type(WFDMessage *msg, WFDTrigger *trigger)
1811 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1812 if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "SETUP"))
1813 *trigger = WFD_TRIGGER_SETUP;
1814 else if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "PAUSE"))
1815 *trigger = WFD_TRIGGER_PAUSE;
1816 else if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "TEARDOWN"))
1817 *trigger = WFD_TRIGGER_TEARDOWN;
1818 else if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "PLAY"))
1819 *trigger = WFD_TRIGGER_PLAY;
1821 *trigger = WFD_TRIGGER_UNKNOWN;
1827 WFDResult wfdconfig_set_presentation_url(WFDMessage *msg, gchar *wfd_url0, gchar *wfd_url1)
1829 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1830 if(!msg->presentation_url) msg->presentation_url = g_new0 (WFDPresentationUrl, 1);
1831 if(wfd_url0) msg->presentation_url->wfd_url0 = g_strdup(wfd_url0);
1832 if(wfd_url1) msg->presentation_url->wfd_url1 = g_strdup(wfd_url1);
1836 WFDResult wfdconfig_get_presentation_url(WFDMessage *msg, gchar **wfd_url0, gchar **wfd_url1)
1838 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1839 if(msg->presentation_url) {
1840 *wfd_url0 = g_strdup(msg->presentation_url->wfd_url0);
1841 *wfd_url1 = g_strdup(msg->presentation_url->wfd_url1);
1846 WFDResult wfdconfig_set_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode trans, WFDRTSPProfile profile,
1847 WFDRTSPLowerTrans lowertrans, guint32 rtp_port0, guint32 rtp_port1)
1850 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1852 if(!msg->client_rtp_ports)
1853 msg->client_rtp_ports = g_new0 (WFDClientRtpPorts, 1);
1855 if(trans != WFD_RTSP_TRANS_UNKNOWN) {
1856 lines = g_string_new ("");
1857 if(trans == WFD_RTSP_TRANS_RTP) g_string_append_printf (lines,"RTP");
1858 else if(trans == WFD_RTSP_TRANS_RDT) g_string_append_printf (lines,"RDT");
1860 if(profile == WFD_RTSP_PROFILE_AVP) g_string_append_printf (lines,"/AVP");
1861 else if(profile == WFD_RTSP_PROFILE_SAVP) g_string_append_printf (lines,"/SAVP");
1863 if(lowertrans == WFD_RTSP_LOWER_TRANS_UDP) g_string_append_printf (lines,"/UDP;unicast");
1864 else if(lowertrans == WFD_RTSP_LOWER_TRANS_UDP_MCAST) g_string_append_printf (lines,"/UDP;multicast");
1865 else if(lowertrans == WFD_RTSP_LOWER_TRANS_TCP) g_string_append_printf (lines,"/TCP;unicast");
1866 else if(lowertrans == WFD_RTSP_LOWER_TRANS_HTTP) g_string_append_printf (lines,"/HTTP");
1868 msg->client_rtp_ports->profile = g_string_free (lines, FALSE);
1869 msg->client_rtp_ports->rtp_port0 = rtp_port0;
1870 msg->client_rtp_ports->rtp_port1 = rtp_port1;
1871 msg->client_rtp_ports->mode = g_strdup("mode=play");
1876 WFDResult wfdconfig_get_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode *trans, WFDRTSPProfile *profile,
1877 WFDRTSPLowerTrans *lowertrans, guint32 *rtp_port0, guint32 *rtp_port1)
1879 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1880 g_return_val_if_fail (msg->client_rtp_ports != NULL, WFD_EINVAL);
1882 if(g_strrstr(msg->client_rtp_ports->profile, "RTP")) *trans = WFD_RTSP_TRANS_RTP;
1883 if(g_strrstr(msg->client_rtp_ports->profile, "RDT")) *trans = WFD_RTSP_TRANS_RDT;
1884 if(g_strrstr(msg->client_rtp_ports->profile, "AVP")) *profile = WFD_RTSP_PROFILE_AVP;
1885 if(g_strrstr(msg->client_rtp_ports->profile, "SAVP")) *profile = WFD_RTSP_PROFILE_SAVP;
1886 if(g_strrstr(msg->client_rtp_ports->profile, "UDP;unicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP;
1887 if(g_strrstr(msg->client_rtp_ports->profile, "UDP;multicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP_MCAST;
1888 if(g_strrstr(msg->client_rtp_ports->profile, "TCP;unicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_TCP;
1889 if(g_strrstr(msg->client_rtp_ports->profile, "HTTP")) *lowertrans = WFD_RTSP_LOWER_TRANS_HTTP;
1891 *rtp_port0 = msg->client_rtp_ports->rtp_port0;
1892 *rtp_port1 = msg->client_rtp_ports->rtp_port1;
1897 WFDResult wfdconfig_set_audio_sink_type(WFDMessage *msg, WFDSinkType sinktype)
1899 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1900 if(!msg->route) msg->route = g_new0 (WFDRoute, 1);
1901 if(sinktype == WFD_PRIMARY_SINK) msg->route->destination = g_strdup("primary");
1902 else if(sinktype == WFD_SECONDARY_SINK) msg->route->destination = g_strdup("secondary");
1906 WFDResult wfdconfig_get_audio_sink_type(WFDMessage *msg, WFDSinkType *sinktype)
1908 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1910 if(!g_strcmp0(msg->route->destination,"primary")) *sinktype = WFD_PRIMARY_SINK;
1911 else if(!g_strcmp0(msg->route->destination,"secondary")) *sinktype = WFD_SECONDARY_SINK;
1916 WFDResult wfdconfig_set_I2C_port(WFDMessage *msg, gboolean i2csupport, guint32 i2cport)
1918 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1919 if(!msg->I2C) msg->I2C = g_new0 (WFDI2C, 1);
1920 msg->I2C->I2CPresent = i2csupport;
1921 msg->I2C->I2C_port = i2cport;
1925 WFDResult wfdconfig_get_I2C_port(WFDMessage *msg, gboolean *i2csupport, guint32 *i2cport)
1927 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1928 if(msg->I2C && msg->I2C->I2CPresent) {
1929 *i2csupport = msg->I2C->I2CPresent;
1930 *i2cport = msg->I2C->I2C_port;
1931 } else *i2csupport = FALSE;
1935 WFDResult wfdconfig_set_av_format_change_timing(WFDMessage *msg, guint64 PTS, guint64 DTS)
1937 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1938 if(!msg->av_format_change_timing) msg->av_format_change_timing = g_new0 (WFDAVFormatChangeTiming, 1);
1939 msg->av_format_change_timing->PTS = PTS;
1940 msg->av_format_change_timing->DTS = DTS;
1944 WFDResult wfdconfig_get_av_format_change_timing(WFDMessage *msg, guint64 *PTS, guint64 *DTS)
1946 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1947 if(msg->av_format_change_timing) {
1948 *PTS = msg->av_format_change_timing->PTS;
1949 *DTS = msg->av_format_change_timing->DTS;
1954 WFDResult wfdconfig_set_uibc_capability(WFDMessage *msg, guint32 input_category, guint32 inp_type, WFDHIDCTypePathPair *inp_pair,
1955 guint32 inp_type_path_count, guint32 tcp_port)
1957 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1958 if(!msg->uibc_capability) msg->uibc_capability = g_new0 (WFDUibcCapability, 1);
1959 msg->uibc_capability->uibcsupported = TRUE;
1960 msg->uibc_capability->input_category_list.input_cat = input_category;
1961 msg->uibc_capability->generic_cap_list.inp_type = inp_type;
1962 msg->uibc_capability->hidc_cap_list.cap_count = inp_type_path_count;
1963 if(msg->uibc_capability->hidc_cap_list.cap_count) {
1964 detailed_cap *temp_cap;
1966 msg->uibc_capability->hidc_cap_list.next = g_new0 (detailed_cap, 1);
1967 temp_cap = msg->uibc_capability->hidc_cap_list.next;
1968 for(;i<inp_type_path_count;) {
1969 temp_cap->p.inp_type = inp_pair[i].inp_type;
1970 temp_cap->p.inp_path = inp_pair[i].inp_path;
1972 if(i<inp_type_path_count) {
1973 temp_cap->next = g_new0 (detailed_cap, 1);
1974 temp_cap = temp_cap->next;
1978 msg->uibc_capability->tcp_port = tcp_port;
1982 WFDResult wfdconfig_get_uibc_capability(WFDMessage *msg, guint32 *input_category, guint32 *inp_type, WFDHIDCTypePathPair *inp_pair,
1983 guint32 *inp_type_path_count, guint32 *tcp_port)
1985 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1986 if(msg->uibc_capability && msg->uibc_capability->uibcsupported) {
1987 *input_category = msg->uibc_capability->input_category_list.input_cat;
1988 *inp_type = msg->uibc_capability->generic_cap_list.inp_type;
1989 if(msg->uibc_capability->hidc_cap_list.cap_count) {
1990 detailed_cap *temp_cap;
1992 inp_pair = g_new0 (WFDHIDCTypePathPair, msg->uibc_capability->hidc_cap_list.cap_count);
1993 temp_cap = msg->uibc_capability->hidc_cap_list.next;
1995 inp_pair[i].inp_type = temp_cap->p.inp_type;
1996 inp_pair[i].inp_path = temp_cap->p.inp_path;
1997 temp_cap = temp_cap->next;
2001 *tcp_port = msg->uibc_capability->tcp_port;
2006 WFDResult wfdconfig_set_uibc_status(WFDMessage *msg, gboolean uibc_enable)
2008 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2009 if(!msg->uibc_setting) msg->uibc_setting = g_new0 (WFDUibcSetting, 1);
2010 msg->uibc_setting->uibc_setting = uibc_enable;
2014 WFDResult wfdconfig_get_uibc_status(WFDMessage *msg, gboolean *uibc_enable)
2016 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2017 if(msg->uibc_setting) *uibc_enable = msg->uibc_setting->uibc_setting;
2020 #ifdef STANDBY_RESUME_CAPABILITY
2021 WFDResult wfdconfig_set_standby_resume_capability(WFDMessage *msg, gboolean supported)
2023 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2024 if(!msg->standby_resume_capability) msg->standby_resume_capability = g_new0 (WFDStandbyResumeCapability, 1);
2025 msg->standby_resume_capability->standby_resume_cap = supported;
2029 WFDResult wfdconfig_get_standby_resume_capability(WFDMessage *msg, gboolean *supported)
2031 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2032 if(msg->standby_resume_capability) *supported = msg->standby_resume_capability->standby_resume_cap;
2036 WFDResult wfdconfig_set_standby(WFDMessage *msg, gboolean standby_enable)
2038 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2039 if(!msg->standby) msg->standby = g_new0 (WFDStandby, 1);
2040 msg->standby->wfd_standby = standby_enable;
2044 WFDResult wfdconfig_get_standby(WFDMessage *msg, gboolean *standby_enable)
2046 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2047 if(msg->standby) *standby_enable = msg->standby->wfd_standby;
2051 WFDResult wfdconfig_set_connector_type(WFDMessage *msg, WFDConnector connector)
2053 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2054 if(!msg->connector_type) msg->connector_type = g_new0 (WFDConnectorType, 1);
2055 msg->connector_type->connector_type = connector;
2059 WFDResult wfdconfig_get_connector_type(WFDMessage *msg, WFDConnector *connector)
2061 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2062 if(msg->connector_type) *connector = msg->connector_type->connector_type;
2066 WFDResult wfdconfig_set_idr_request(WFDMessage *msg)
2068 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2069 if(!msg->idr_request) msg->idr_request = g_new0 (WFDIdrRequest, 1);
2070 msg->idr_request->idr_request = TRUE;