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 */
33 #include <gst/gstinfo.h> /* For GST_STR_NULL */
35 #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);
210 * wfdconfig_message_free:
211 * @msg: a #WFDMessage
213 * Free all resources allocated by @msg. @msg should not be used anymore after
214 * this function. This function should be used when @msg was dynamically
215 * allocated with wfdconfig_message_new().
217 * Returns: a #WFDResult.
220 wfdconfig_message_free (WFDMessage * msg)
222 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
224 wfdconfig_message_uninit (msg);
231 * wfdconfig_message_as_text:
232 * @msg: a #WFDMessage
234 * Convert the contents of @msg to a text string.
236 * Returns: A dynamically allocated string representing the WFD description.
239 wfdconfig_message_as_text (const WFDMessage * msg)
241 /* change all vars so they match rfc? */
243 g_return_val_if_fail (msg != NULL, NULL);
245 lines = g_string_new ("");
247 /* list of audio codecs */
248 if(msg->audio_codecs) {
250 g_string_append_printf (lines,"wfd_audio_codecs");
251 if(msg->audio_codecs->list) {
252 g_string_append_printf (lines,":");
253 for(; i<msg->audio_codecs->count; i++) {
254 g_string_append_printf (lines," %s",msg->audio_codecs->list[i].audio_format);
255 g_string_append_printf (lines," %08x",msg->audio_codecs->list[i].modes);
256 g_string_append_printf (lines," %02x",msg->audio_codecs->list[i].latency);
257 if((i+1)<msg->audio_codecs->count)
258 g_string_append_printf (lines,",");
261 g_string_append_printf (lines,"\r\n");
264 /* list of video codecs */
265 if(msg->video_formats) {
266 g_string_append_printf (lines,"wfd_video_formats");
267 if(msg->video_formats->list) {
268 g_string_append_printf (lines,":");
269 g_string_append_printf (lines," %02x", msg->video_formats->list->native);
270 g_string_append_printf (lines," %02x", msg->video_formats->list->preferred_display_mode_supported);
271 g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.profile);
272 g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.level);
273 g_string_append_printf (lines," %08x", msg->video_formats->list->H264_codec.misc_params.CEA_Support);
274 g_string_append_printf (lines," %08x", msg->video_formats->list->H264_codec.misc_params.VESA_Support);
275 g_string_append_printf (lines," %08x", msg->video_formats->list->H264_codec.misc_params.HH_Support);
276 g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.misc_params.latency);
277 g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.misc_params.min_slice_size);
278 g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.misc_params.slice_enc_params);
279 g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support);
281 if(msg->video_formats->list->H264_codec.max_hres)
282 g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_hres);
284 g_string_append_printf (lines," none");
286 if(msg->video_formats->list->H264_codec.max_vres)
287 g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_vres);
289 g_string_append_printf (lines," none");
291 g_string_append_printf (lines,"\r\n");
294 /* list of video 3D codecs */
295 if(msg->video_3d_formats) {
296 g_string_append_printf (lines,"wfd_3d_video_formats");
297 g_string_append_printf (lines,":");
298 if(msg->video_3d_formats->list) {
299 g_string_append_printf (lines," %02x", msg->video_3d_formats->list->native);
300 g_string_append_printf (lines," %02x", msg->video_3d_formats->list->preferred_display_mode_supported);
301 g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.profile);
302 g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.level);
303 g_string_append_printf (lines," %16x", msg->video_3d_formats->list->H264_codec.misc_params.video_3d_capability);
304 g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.misc_params.latency);
305 g_string_append_printf (lines," %04x", msg->video_3d_formats->list->H264_codec.misc_params.min_slice_size);
306 g_string_append_printf (lines," %04x", msg->video_3d_formats->list->H264_codec.misc_params.slice_enc_params);
307 g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support);
308 if(msg->video_3d_formats->list->H264_codec.max_hres)
309 g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_hres);
311 g_string_append_printf (lines," none");
312 if(msg->video_3d_formats->list->H264_codec.max_vres)
313 g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_vres);
315 g_string_append_printf (lines," none");
317 g_string_append_printf (lines," none");
319 g_string_append_printf (lines,"\r\n");
322 if(msg->content_protection) {
323 g_string_append_printf (lines,"wfd_content_protection");
324 if(msg->content_protection->hdcp2_spec) {
325 g_string_append_printf (lines,":");
326 if( msg->content_protection->hdcp2_spec->hdcpversion) {
327 g_string_append_printf (lines," %s", msg->content_protection->hdcp2_spec->hdcpversion);
328 g_string_append_printf (lines," %s", msg->content_protection->hdcp2_spec->TCPPort);
330 g_string_append_printf (lines," none");
333 g_string_append_printf (lines,"\r\n");
336 if(msg->display_edid) {
337 g_string_append_printf (lines,"wfd_display_edid");
338 g_string_append_printf (lines,":");
339 if(msg->display_edid->edid_supported) {
340 g_string_append_printf (lines," %d", msg->display_edid->edid_supported);
341 if(msg->display_edid->edid_block_count)
342 g_string_append_printf (lines," %d", msg->display_edid->edid_block_count);
344 g_string_append_printf (lines," none");
346 g_string_append_printf (lines," none");
348 g_string_append_printf (lines,"\r\n");
351 if(msg->coupled_sink) {
352 g_string_append_printf (lines,"wfd_coupled_sink");
353 g_string_append_printf (lines,":");
354 if(msg->coupled_sink->coupled_sink_cap) {
355 g_string_append_printf (lines," %02x", msg->coupled_sink->coupled_sink_cap->status);
356 if(msg->coupled_sink->coupled_sink_cap->sink_address)
357 g_string_append_printf (lines," %s", msg->coupled_sink->coupled_sink_cap->sink_address);
359 g_string_append_printf (lines," none");
361 g_string_append_printf (lines," none");
363 g_string_append_printf (lines,"\r\n");
366 if(msg->trigger_method) {
367 g_string_append_printf (lines,"wfd_trigger_method");
368 g_string_append_printf (lines,":");
369 g_string_append_printf (lines," %s", msg->trigger_method->wfd_trigger_method);
370 g_string_append_printf (lines,"\r\n");
373 if(msg->presentation_url) {
374 g_string_append_printf (lines,"wfd_presentation_URL");
375 g_string_append_printf (lines,":");
376 if(msg->presentation_url->wfd_url0)
377 g_string_append_printf (lines," %s", msg->presentation_url->wfd_url0);
379 g_string_append_printf (lines," none");
380 if(msg->presentation_url->wfd_url1)
381 g_string_append_printf (lines," %s", msg->presentation_url->wfd_url1);
383 g_string_append_printf (lines," none");
384 g_string_append_printf (lines,"\r\n");
386 if(msg->client_rtp_ports) {
387 g_string_append_printf (lines,"wfd_client_rtp_ports");
388 if(msg->client_rtp_ports->profile) {
389 g_string_append_printf (lines,":");
390 g_string_append_printf (lines," %s", msg->client_rtp_ports->profile);
391 g_string_append_printf (lines," %d", msg->client_rtp_ports->rtp_port0);
392 g_string_append_printf (lines," %d", msg->client_rtp_ports->rtp_port1);
393 g_string_append_printf (lines," %s", msg->client_rtp_ports->mode);
395 g_string_append_printf (lines,"\r\n");
399 g_string_append_printf (lines,"wfd_route");
400 g_string_append_printf (lines,":");
401 g_string_append_printf (lines," %s", msg->route->destination);
402 g_string_append_printf (lines,"\r\n");
406 g_string_append_printf (lines,"wfd_I2C");
407 g_string_append_printf (lines,":");
408 if(msg->I2C->I2CPresent)
409 g_string_append_printf (lines," %x", msg->I2C->I2C_port);
411 g_string_append_printf (lines," none");
412 g_string_append_printf (lines,"\r\n");
415 if(msg->av_format_change_timing) {
416 g_string_append_printf (lines,"wfd_av_format_change_timing");
417 g_string_append_printf (lines,":");
418 g_string_append_printf (lines," %10llu", msg->av_format_change_timing->PTS);
419 g_string_append_printf (lines," %10llu", msg->av_format_change_timing->DTS);
420 g_string_append_printf (lines,"\r\n");
423 if(msg->preferred_display_mode) {
424 g_string_append_printf (lines,"wfd_preferred_display_mode");
425 g_string_append_printf (lines,":");
426 if(msg->preferred_display_mode->displaymodesupported) {
427 g_string_append_printf (lines," %06llu", msg->preferred_display_mode->p_clock);
428 g_string_append_printf (lines," %04x", msg->preferred_display_mode->H);
429 g_string_append_printf (lines," %04x", msg->preferred_display_mode->HB);
430 g_string_append_printf (lines," %04x", msg->preferred_display_mode->HSPOL_HSOFF);
431 g_string_append_printf (lines," %04x", msg->preferred_display_mode->HSW);
432 g_string_append_printf (lines," %04x", msg->preferred_display_mode->V);
433 g_string_append_printf (lines," %04x", msg->preferred_display_mode->VB);
434 g_string_append_printf (lines," %04x", msg->preferred_display_mode->VSPOL_VSOFF);
435 g_string_append_printf (lines," %04x", msg->preferred_display_mode->VSW);
436 g_string_append_printf (lines," %02x", msg->preferred_display_mode->VBS3D);
437 g_string_append_printf (lines," %02x", msg->preferred_display_mode->V2d_s3d_modes);
438 g_string_append_printf (lines," %02x", msg->preferred_display_mode->P_depth);
439 } else g_string_append_printf (lines," none");
440 g_string_append_printf (lines,"\r\n");
443 if(msg->uibc_capability) {
444 g_string_append_printf (lines,"wfd_uibc_capability");
445 g_string_append_printf (lines,":");
446 if(msg->uibc_capability->uibcsupported) {
447 g_string_append_printf (lines," input_category_list=");
448 if(msg->uibc_capability->input_category_list.input_cat) {
450 if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) {
451 tempcap |= WFD_UIBC_INPUT_CAT_GENERIC;
452 g_string_append_printf (lines,"GENERIC");
453 if(msg->uibc_capability->input_category_list.input_cat != tempcap) g_string_append_printf (lines,", ");
455 if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) {
456 tempcap |= WFD_UIBC_INPUT_CAT_HIDC;
457 g_string_append_printf (lines,"HIDC");
458 if(msg->uibc_capability->input_category_list.input_cat != tempcap) g_string_append_printf (lines,", ");
461 else g_string_append_printf (lines,"none");
462 g_string_append_printf (lines,";");
463 g_string_append_printf (lines," generic_cap_list=");
464 if(msg->uibc_capability->generic_cap_list.inp_type) {
466 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) {
467 tempcap |= WFD_UIBC_INPUT_TYPE_KEYBOARD;
468 g_string_append_printf (lines,"Keyboard");
469 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
471 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) {
472 tempcap |= WFD_UIBC_INPUT_TYPE_MOUSE;
473 g_string_append_printf (lines,"Mouse");
474 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
476 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) {
477 tempcap |= WFD_UIBC_INPUT_TYPE_SINGLETOUCH;
478 g_string_append_printf (lines,"SingleTouch");
479 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
481 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) {
482 tempcap |= WFD_UIBC_INPUT_TYPE_MULTITOUCH;
483 g_string_append_printf (lines,"MultiTouch");
484 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
486 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) {
487 tempcap |= WFD_UIBC_INPUT_TYPE_JOYSTICK;
488 g_string_append_printf (lines,"Joystick");
489 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
491 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) {
492 tempcap |= WFD_UIBC_INPUT_TYPE_CAMERA;
493 g_string_append_printf (lines,"Camera");
494 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
496 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) {
497 tempcap |= WFD_UIBC_INPUT_TYPE_GESTURE;
498 g_string_append_printf (lines,"Gesture");
499 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
501 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) {
502 tempcap |= WFD_UIBC_INPUT_TYPE_REMOTECONTROL;
503 g_string_append_printf (lines,"RemoteControl");
504 if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", ");
507 else g_string_append_printf (lines,"none");
508 g_string_append_printf (lines,";");
509 g_string_append_printf (lines," hidc_cap_list=");
510 if(msg->uibc_capability->hidc_cap_list.cap_count) {
511 detailed_cap *temp_cap = msg->uibc_capability->hidc_cap_list.next;
514 if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_KEYBOARD) g_string_append_printf (lines,"Keyboard");
515 else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_MOUSE) g_string_append_printf (lines,"Mouse");
516 else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_SINGLETOUCH) g_string_append_printf (lines,"SingleTouch");
517 else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_MULTITOUCH) g_string_append_printf (lines,"MultiTouch");
518 else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_JOYSTICK) g_string_append_printf (lines,"Joystick");
519 else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_CAMERA) g_string_append_printf (lines,"Camera");
520 else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_GESTURE) g_string_append_printf (lines,"Gesture");
521 else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_REMOTECONTROL) g_string_append_printf (lines,"RemoteControl");
522 g_string_append_printf (lines,"/");
523 if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_INFRARED) g_string_append_printf (lines,"Infrared");
524 else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_USB) g_string_append_printf (lines,"USB");
525 else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_BT) g_string_append_printf (lines,"BT");
526 else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_ZIGBEE) g_string_append_printf (lines,"Zigbee");
527 else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_WIFI) g_string_append_printf (lines,"Wi-Fi");
528 else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_NOSP) g_string_append_printf (lines,"No-SP");
529 temp_cap = temp_cap->next;
530 if(temp_cap) g_string_append_printf (lines,", ");
532 } else g_string_append_printf (lines,"none");
533 g_string_append_printf (lines,";");
534 if(msg->uibc_capability->tcp_port) g_string_append_printf (lines," port=%x", msg->uibc_capability->tcp_port);
535 else g_string_append_printf (lines,"port=none");
536 } else g_string_append_printf (lines," none");
537 g_string_append_printf (lines,"\r\n");
540 if(msg->uibc_setting) {
541 g_string_append_printf (lines,"wfd_uibc_setting");
542 g_string_append_printf (lines,":");
543 if(msg->uibc_setting->uibc_setting)
544 g_string_append_printf (lines," enable");
546 g_string_append_printf (lines," disable");
547 g_string_append_printf (lines,"\r\n");
550 if(msg->standby_resume_capability) {
551 g_string_append_printf (lines,"wfd_standby_resume_capability");
552 g_string_append_printf (lines,":");
553 if(msg->standby_resume_capability->standby_resume_cap)
554 g_string_append_printf (lines," supported");
556 g_string_append_printf (lines," none");
557 g_string_append_printf (lines,"\r\n");
561 g_string_append_printf (lines,"wfd_standby");
562 g_string_append_printf (lines,"\r\n");
565 if(msg->connector_type) {
566 g_string_append_printf (lines,"wfd_connector_type");
567 g_string_append_printf (lines,":");
568 if(msg->connector_type->connector_type)
569 g_string_append_printf (lines," %02x", msg->connector_type->connector_type);
571 g_string_append_printf (lines," none");
572 g_string_append_printf (lines,"\r\n");
575 if(msg->idr_request) {
576 g_string_append_printf (lines,"wfd_idr_request");
577 g_string_append_printf (lines,"\r\n");
580 //g_string_append_printf (lines,"\0");
581 /*if(g_str_has_suffix (lines,"\r\n\0"))
583 guint32 length = g_strlen(lines);
584 lines[length-2] = '\0';
586 return g_string_free (lines, FALSE);
589 gchar* wfdconfig_parameter_names_as_text (const WFDMessage *msg)
591 /* change all vars so they match rfc? */
593 g_return_val_if_fail (msg != NULL, NULL);
595 lines = g_string_new ("");
597 /* list of audio codecs */
598 if(msg->audio_codecs) {
599 g_string_append_printf (lines,"wfd_audio_codecs");
600 g_string_append_printf (lines,"\r\n");
602 /* list of video codecs */
603 if(msg->video_formats) {
604 g_string_append_printf (lines,"wfd_video_formats");
605 g_string_append_printf (lines,"\r\n");
607 /* list of video 3D codecs */
608 if(msg->video_3d_formats) {
609 g_string_append_printf (lines,"wfd_3d_video_formats");
610 g_string_append_printf (lines,"\r\n");
612 if(msg->content_protection) {
613 g_string_append_printf (lines,"wfd_content_protection");
614 g_string_append_printf (lines,"\r\n");
616 if(msg->display_edid) {
617 g_string_append_printf (lines,"wfd_display_edid");
618 g_string_append_printf (lines,"\r\n");
620 if(msg->coupled_sink) {
621 g_string_append_printf (lines,"wfd_coupled_sink");
622 g_string_append_printf (lines,"\r\n");
624 if(msg->trigger_method) {
625 g_string_append_printf (lines,"wfd_trigger_method");
626 g_string_append_printf (lines,"\r\n");
628 if(msg->presentation_url) {
629 g_string_append_printf (lines,"wfd_presentation_URL");
630 g_string_append_printf (lines,"\r\n");
632 if(msg->client_rtp_ports) {
633 g_string_append_printf (lines,"wfd_client_rtp_ports");
634 g_string_append_printf (lines,"\r\n");
637 g_string_append_printf (lines,"wfd_route");
638 g_string_append_printf (lines,"\r\n");
641 g_string_append_printf (lines,"wfd_I2C");
642 g_string_append_printf (lines,"\r\n");
644 if(msg->av_format_change_timing) {
645 g_string_append_printf (lines,"wfd_av_format_change_timing");
646 g_string_append_printf (lines,"\r\n");
648 if(msg->preferred_display_mode) {
649 g_string_append_printf (lines,"wfd_preferred_display_mode");
650 g_string_append_printf (lines,"\r\n");
652 if(msg->uibc_capability) {
653 g_string_append_printf (lines,"wfd_uibc_capability");
654 g_string_append_printf (lines,"\r\n");
656 if(msg->uibc_setting) {
657 g_string_append_printf (lines,"wfd_uibc_setting");
658 g_string_append_printf (lines,"\r\n");
660 if(msg->standby_resume_capability) {
661 g_string_append_printf (lines,"wfd_standby_resume_capability");
662 g_string_append_printf (lines,"\r\n");
665 g_string_append_printf (lines,"wfd_standby");
666 g_string_append_printf (lines,"\r\n");
668 if(msg->connector_type) {
669 g_string_append_printf (lines,"wfd_connector_type");
670 g_string_append_printf (lines,"\r\n");
672 if(msg->idr_request) {
673 g_string_append_printf (lines,"wfd_idr_request");
674 g_string_append_printf (lines,"\r\n");
676 return g_string_free (lines, FALSE);
682 return c >= '0' && c <= '9' ? c - '0'
683 : c >= 'A' && c <= 'F' ? c - 'A' + 10
684 : c >= 'a' && c <= 'f' ? c - 'a' + 10 : 0;
688 read_string (gchar * dest, guint size, gchar ** src)
694 while (g_ascii_isspace (**src))
697 while (!g_ascii_isspace (**src) && **src != '\0') {
708 read_string_del (gchar * dest, guint size, gchar del, gchar ** src)
714 while (g_ascii_isspace (**src))
717 while (**src != del && **src != '\0') {
727 read_string_space_ended (gchar * dest, guint size, gchar * src)
731 while (!g_ascii_isspace (*src) && *src != '\0') {
742 read_string_char_ended (gchar * dest, guint size, gchar del, gchar * src)
746 while (*src != del && *src != '\0') {
757 read_string_type_and_value (gchar * type, gchar * value, guint tsize, guint vsize, gchar del, gchar * src)
762 while (*src != del && *src != '\0') {
773 while (*src != '\0') {
783 wfdconfig_parse_line (WFDMessage * msg, gchar * buffer)
791 #define WFD_SKIP_SPACE(q) if (*q && g_ascii_isspace (*q)) q++
792 #define WFD_SKIP_COMMA(q) if (*q && g_ascii_ispunct (*q)) q++
793 #define WFD_READ_STRING(field) read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); REPLACE_STRING (field, temp)
794 #define WFD_READ_CHAR_END_STRING(field, del) read_string_char_ended (temp, sizeof (temp), del, v); v+=strlen(temp); REPLACE_STRING (field, temp)
795 #define WFD_READ_UINT32(field) read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); field = strtoul (temp, NULL, 16)
796 #define WFD_READ_UINT32_DIGIT(field) read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); field = strtoul (temp, NULL, 10)
798 //g_print("wfdconfig_parse_line input: %s\n", buffer);
799 read_string_type_and_value (type, value, sizeof(type), sizeof(value), ':', p);
800 //g_print("wfdconfig_parse_line type:%s value:%s\n", type, value);
801 if(!g_strcmp0(type,"wfd_audio_codecs")) {
802 msg->audio_codecs = g_new0 (WFDAudioCodeclist, 1);
805 msg->audio_codecs->count= strlen(v)/16;
806 msg->audio_codecs->list = g_new0 (WFDAudioCodec, msg->audio_codecs->count);
807 for(;i<msg->audio_codecs->count;i++) {
809 WFD_READ_STRING(msg->audio_codecs->list[i].audio_format);
811 WFD_READ_UINT32(msg->audio_codecs->list[i].modes);
813 WFD_READ_UINT32(msg->audio_codecs->list[i].latency);
817 } else if(!g_strcmp0(type,"wfd_video_formats")) {
818 msg->video_formats = g_new0 (WFDVideoCodeclist, 1);
820 msg->video_formats->count = 1;
821 msg->video_formats->list = g_new0 (WFDVideoCodec, 1);
823 WFD_READ_UINT32(msg->video_formats->list->native);
825 WFD_READ_UINT32(msg->video_formats->list->preferred_display_mode_supported);
827 WFD_READ_UINT32(msg->video_formats->list->H264_codec.profile);
829 WFD_READ_UINT32(msg->video_formats->list->H264_codec.level);
831 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.CEA_Support);
833 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.VESA_Support);
835 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.HH_Support);
837 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.latency);
839 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.min_slice_size);
841 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.slice_enc_params);
843 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support);
845 if(msg->video_formats->list->preferred_display_mode_supported == 1) {
846 WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_hres);
848 WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_vres);
852 }else if(!g_strcmp0(type,"wfd_3d_formats")) {
853 msg->video_3d_formats = g_new0 (WFD3DFormats, 1);
855 msg->video_3d_formats->count = 1;
856 msg->video_3d_formats->list = g_new0 (WFD3dCapList, 1);
858 WFD_READ_UINT32(msg->video_3d_formats->list->native);
860 WFD_READ_UINT32(msg->video_3d_formats->list->preferred_display_mode_supported);
862 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.profile);
864 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.level);
866 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.video_3d_capability);
868 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.latency);
870 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.min_slice_size);
872 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.slice_enc_params);
874 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support);
876 if(msg->video_formats->list->preferred_display_mode_supported == 1) {
877 WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_hres);
879 WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_vres);
883 } else if(!g_strcmp0(type,"wfd_content_protection")) {
884 msg->content_protection = g_new0 (WFDContentProtection, 1);
887 msg->content_protection->hdcp2_spec = g_new0 (WFDHdcp2Spec, 1);
888 if(strstr(v,"none")) {
889 msg->content_protection->hdcp2_spec->hdcpversion=g_strdup("none");
891 WFD_READ_STRING(msg->content_protection->hdcp2_spec->hdcpversion);
893 WFD_READ_STRING(msg->content_protection->hdcp2_spec->TCPPort);
896 } else if(!g_strcmp0(type,"wfd_display_edid")) {
897 msg->display_edid = g_new0 (WFDDisplayEdid, 1);
900 if(strstr(v,"none")) {
901 msg->display_edid->edid_supported = 0;
903 msg->display_edid->edid_supported = 1;
904 WFD_READ_UINT32(msg->display_edid->edid_block_count);
906 if(msg->display_edid->edid_block_count) {
907 guint32 payload_size = EDID_BLOCK_SIZE * msg->display_edid->edid_block_count;
908 msg->display_edid->edid_payload = g_malloc(payload_size);
909 memcpy(msg->display_edid->edid_payload, v, payload_size);
911 } else v += strlen(v);
914 } else if(!g_strcmp0(type,"wfd_coupled_sink")) {
915 msg->coupled_sink = g_new0 (WFDCoupledSink, 1);
917 msg->coupled_sink->coupled_sink_cap = g_new0 (WFDCoupled_sink_cap, 1);
919 WFD_READ_UINT32(msg->coupled_sink->coupled_sink_cap->status);
921 WFD_READ_STRING(msg->coupled_sink->coupled_sink_cap->sink_address);
923 } else if(!g_strcmp0(type,"wfd_trigger_method")) {
924 msg->trigger_method = g_new0 (WFDTriggerMethod, 1);
927 WFD_READ_STRING(msg->trigger_method->wfd_trigger_method);
929 } else if(!g_strcmp0(type,"wfd_presentation_URL")) {
930 msg->presentation_url = g_new0 (WFDPresentationUrl, 1);
933 WFD_READ_STRING(msg->presentation_url->wfd_url0);
935 WFD_READ_STRING(msg->presentation_url->wfd_url1);
937 } else if(!g_strcmp0(type,"wfd_client_rtp_ports")) {
938 msg->client_rtp_ports = g_new0 (WFDClientRtpPorts, 1);
941 WFD_READ_STRING(msg->client_rtp_ports->profile);
943 WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port0);
945 WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port1);
947 WFD_READ_STRING(msg->client_rtp_ports->mode);
949 } else if(!g_strcmp0(type,"wfd_route")) {
950 msg->route = g_new0 (WFDRoute, 1);
953 WFD_READ_STRING(msg->route->destination);
955 } else if(!g_strcmp0(type,"wfd_I2C")) {
956 msg->I2C = g_new0 (WFDI2C, 1);
958 msg->I2C->I2CPresent = TRUE;
960 WFD_READ_UINT32_DIGIT(msg->I2C->I2C_port);
961 if(msg->I2C->I2C_port) msg->I2C->I2CPresent = TRUE;
963 } else if(!g_strcmp0(type,"wfd_av_format_change_timing")) {
964 msg->av_format_change_timing = g_new0 (WFDAVFormatChangeTiming, 1);
967 WFD_READ_UINT32(msg->av_format_change_timing->PTS);
969 WFD_READ_UINT32(msg->av_format_change_timing->DTS);
971 } else if(!g_strcmp0(type,"wfd_preferred_display_mode")) {
972 msg->preferred_display_mode = g_new0 (WFDPreferredDisplayMode, 1);
975 if(!strstr(v,"none")) {
976 msg->preferred_display_mode->displaymodesupported = FALSE;
978 WFD_READ_UINT32(msg->preferred_display_mode->p_clock);
980 WFD_READ_UINT32(msg->preferred_display_mode->H);
982 WFD_READ_UINT32(msg->preferred_display_mode->HB);
984 WFD_READ_UINT32(msg->preferred_display_mode->HSPOL_HSOFF);
986 WFD_READ_UINT32(msg->preferred_display_mode->HSW);
988 WFD_READ_UINT32(msg->preferred_display_mode->V);
990 WFD_READ_UINT32(msg->preferred_display_mode->VB);
992 WFD_READ_UINT32(msg->preferred_display_mode->VSPOL_VSOFF);
994 WFD_READ_UINT32(msg->preferred_display_mode->VSW);
996 WFD_READ_UINT32(msg->preferred_display_mode->VBS3D);
998 WFD_READ_UINT32(msg->preferred_display_mode->V2d_s3d_modes);
1000 WFD_READ_UINT32(msg->preferred_display_mode->P_depth);
1002 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.profile);
1004 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.level);
1006 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.CEA_Support);
1008 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.VESA_Support);
1010 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.HH_Support);
1012 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.latency);
1014 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.min_slice_size);
1016 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.slice_enc_params);
1018 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.frame_rate_control_support);
1020 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_hres);
1022 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_vres);
1026 } else if(!g_strcmp0(type,"wfd_uibc_capability")) {
1027 msg->uibc_capability = g_new0 (WFDUibcCapability, 1);
1028 if(!strstr(v,"none")) {
1029 msg->uibc_capability->uibcsupported = FALSE;
1031 gchar *tstring = NULL;
1032 msg->uibc_capability->uibcsupported = TRUE;
1033 WFD_READ_CHAR_END_STRING(tstring, '=');
1034 if(!g_strcmp0(tstring,"input_category_list")) {
1035 if(!strstr(v,"none")) {
1039 guint rem_len, read_len=0;
1040 WFD_READ_CHAR_END_STRING(tstring, ';');
1041 rem_len = strlen(tstring);
1043 read_string_char_ended (temp, 8192, ',', tstring+read_len);
1044 read_len += (strlen(temp)+1);
1045 if(!g_strcmp0(temp,"GENERIC")) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_GENERIC;
1046 else if(!g_strcmp0(temp,"HIDC")) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_HIDC;
1047 else msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_UNKNOWN;
1048 } while(read_len < rem_len);
1051 WFD_READ_CHAR_END_STRING(tstring, '=');
1052 if(!g_strcmp0(tstring,"generic_cap_list=")) {
1053 if(!strstr(v,"none")) {
1056 guint rem_len, read_len=0;
1057 WFD_READ_CHAR_END_STRING(tstring, ';');
1058 rem_len = strlen(tstring);
1060 read_string_char_ended (temp, 8192, ',', tstring+read_len);
1061 read_len += (strlen(temp)+1);
1062 if(!g_strcmp0(temp,"Keyboard")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_KEYBOARD;
1063 else if(!g_strcmp0(temp,"Mouse")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MOUSE;
1064 else if(!g_strcmp0(temp,"SingleTouch")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_SINGLETOUCH;
1065 else if(!g_strcmp0(temp,"MultiTouch")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MULTITOUCH;
1066 else if(!g_strcmp0(temp,"Joystick")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_JOYSTICK;
1067 else if(!g_strcmp0(temp,"Camera")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_CAMERA;
1068 else if(!g_strcmp0(temp,"Gesture")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_GESTURE;
1069 else if(!g_strcmp0(temp,"RemoteControl")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_REMOTECONTROL;
1070 else msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_UNKNOWN;
1071 } while(read_len < rem_len);
1074 WFD_READ_CHAR_END_STRING(tstring, '=');
1075 if(!g_strcmp0(tstring,"hidc_cap_list=")) {
1076 if(!strstr(v,"none")) {
1079 gchar inp_type[8192];
1080 gchar inp_path[8192];
1081 guint rem_len, read_len=0;
1082 detailed_cap *temp_cap;
1083 WFD_READ_CHAR_END_STRING(tstring, ';');
1084 rem_len = strlen(tstring);
1085 msg->uibc_capability->hidc_cap_list.next = g_new0 (detailed_cap, 1);
1086 temp_cap = msg->uibc_capability->hidc_cap_list.next;
1088 msg->uibc_capability->hidc_cap_list.cap_count++;
1089 read_string_char_ended (temp, 8192, ',', tstring+read_len);
1090 read_len += (strlen(temp)+1);
1091 read_string_type_and_value (inp_type, inp_path, sizeof(inp_type), sizeof(inp_path), '/', temp);
1092 if(!strstr(inp_type,"Keyboard")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_KEYBOARD;
1093 else if(!strstr(inp_type,"Mouse")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MOUSE;
1094 else if(!strstr(inp_type,"SingleTouch")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_SINGLETOUCH;
1095 else if(!strstr(inp_type,"MultiTouch")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MULTITOUCH;
1096 else if(!strstr(inp_type,"Joystick")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_JOYSTICK;
1097 else if(!strstr(inp_type,"Camera")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_CAMERA;
1098 else if(!strstr(inp_type,"Gesture")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_GESTURE;
1099 else if(!strstr(inp_type,"RemoteControl")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_REMOTECONTROL;
1100 else temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_UNKNOWN;
1102 if(!strstr(inp_path,"Infrared")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_INFRARED;
1103 else if(!strstr(inp_path,"USB")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_USB;
1104 else if(!strstr(inp_path,"BT")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_BT;
1105 else if(!strstr(inp_path,"Zigbee")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_ZIGBEE;
1106 else if(!strstr(inp_path,"Wi-Fi")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_WIFI;
1107 else if(!strstr(inp_path,"No-SP")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_NOSP;
1108 else temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_UNKNOWN;
1109 if(read_len < rem_len) {
1110 temp_cap->next = g_new0 (detailed_cap, 1);
1111 temp_cap = temp_cap->next;
1113 } while(read_len < rem_len);
1116 WFD_READ_CHAR_END_STRING(tstring, '=');
1117 if(!g_strcmp0(tstring,"hidc_cap_list=")) {
1118 if(!strstr(v,"none")) {
1120 WFD_READ_UINT32(msg->uibc_capability->tcp_port);
1124 } else if(!g_strcmp0(type,"wfd_uibc_setting")) {
1125 msg->uibc_setting = g_new0 (WFDUibcSetting, 1);
1128 if(!g_strcmp0(v, "enable"))
1129 msg->uibc_setting->uibc_setting = TRUE;
1131 msg->uibc_setting->uibc_setting = FALSE;
1133 } else if(!g_strcmp0(type,"wfd_standby_resume_capability")) {
1134 msg->standby_resume_capability = g_new0 (WFDStandbyResumeCapability, 1);
1137 if(!g_strcmp0(v, "supported"))
1138 msg->standby_resume_capability->standby_resume_cap = TRUE;
1140 msg->standby_resume_capability->standby_resume_cap = FALSE;
1142 } else if(!g_strcmp0(type,"wfd_standby")) {
1143 msg->standby = g_new0 (WFDStandby, 1);
1144 msg->standby->wfd_standby = TRUE;
1145 } else if(!g_strcmp0(type,"wfd_connector_type")) {
1146 msg->connector_type = g_new0 (WFDConnectorType, 1);
1148 msg->connector_type->supported = TRUE;
1150 WFD_READ_UINT32(msg->connector_type->connector_type);
1152 } else if(!g_strcmp0(type,"wfd_idr_request")) {
1153 msg->idr_request = g_new0 (WFDIdrRequest, 1);
1154 msg->idr_request->idr_request = TRUE;
1161 * wfdconfig_message_parse_buffer:
1162 * @data: the start of the buffer
1163 * @size: the size of the buffer
1164 * @msg: the result #WFDMessage
1166 * Parse the contents of @size bytes pointed to by @data and store the result in
1169 * Returns: #WFD_OK on success.
1172 wfdconfig_message_parse_buffer (const guint8 * data, guint size, WFDMessage * msg)
1175 gchar buffer[MAX_LINE_LEN];
1178 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1179 g_return_val_if_fail (data != NULL, WFD_EINVAL);
1180 g_return_val_if_fail (size != 0, WFD_EINVAL);
1182 GST_LOG("wfdconfig_message_parse_buffer input: %s\n", data);
1191 while (*p != '\n' && *p != '\r' && *p != '\0') {
1192 if (idx < sizeof (buffer) - 1)
1197 wfdconfig_parse_line (msg, buffer);
1208 * wfdconfig_message_dump:
1209 * @msg: a #WFDMessage
1211 * Dump the parsed contents of @msg to stdout.
1213 * Returns: a #WFDResult.
1216 wfdconfig_message_dump (const WFDMessage * msg)
1218 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1219 debug_log("===========WFD Message dump=========");
1221 if(msg->audio_codecs) {
1223 debug_log("Audio supported formats : \n");
1224 for(;i<msg->audio_codecs->count;i++) {
1225 debug_log("Codec: %s\n",msg->audio_codecs->list[i].audio_format);
1226 if(!strcmp(msg->audio_codecs->list[i].audio_format,"LPCM")) {
1227 if(msg->audio_codecs->list[i].modes & WFD_FREQ_44100)
1228 debug_log(" Freq: %d\n", 44100);
1229 if(msg->audio_codecs->list[i].modes & WFD_FREQ_48000)
1230 debug_log(" Freq: %d\n", 48000);
1231 debug_log(" Channels: %d\n", 2);
1233 if(!strcmp(msg->audio_codecs->list[i].audio_format,"AAC")) {
1234 debug_log(" Freq: %d\n", 48000);
1235 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_2)
1236 debug_log(" Channels: %d\n", 2);
1237 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_4)
1238 debug_log(" Channels: %d\n", 4);
1239 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_6)
1240 debug_log(" Channels: %d\n", 6);
1241 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_8)
1242 debug_log(" Channels: %d\n", 8);
1244 if(!strcmp(msg->audio_codecs->list[i].audio_format,"AC3")) {
1245 debug_log(" Freq: %d\n", 48000);
1246 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_2)
1247 debug_log(" Channels: %d\n", 2);
1248 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_4)
1249 debug_log(" Channels: %d\n", 4);
1250 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_6)
1251 debug_log(" Channels: %d\n", 6);
1253 debug_log(" Bitwidth: %d\n", 16);
1254 debug_log(" Latency: %d\n", msg->audio_codecs->list[i].latency);
1259 if(msg->video_formats) {
1260 debug_log("Video supported formats : \n");
1261 if(msg->video_formats->list) {
1262 debug_log("Codec: H264\n");
1263 guint nativeindex = 0;
1264 if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_CEA_RESOLUTION) {
1265 debug_log (" Native type: CEA\n");
1266 } else if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_VESA_RESOLUTION) {
1267 debug_log (" Native type: VESA\n");
1268 } else if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_HH_RESOLUTION) {
1269 debug_log (" Native type: HH\n");
1271 nativeindex = msg->video_formats->list->native >> 3;
1272 debug_log (" Resolution: %d\n", (1 << nativeindex));
1274 if(msg->video_formats->list->H264_codec.profile & WFD_H264_BASE_PROFILE) {
1275 debug_log (" Profile: BASE\n");
1276 } else if(msg->video_formats->list->H264_codec.profile & WFD_H264_HIGH_PROFILE) {
1277 debug_log (" Profile: HIGH\n");
1278 } if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_1) {
1279 debug_log (" Level: 3.1\n");
1280 } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_2) {
1281 debug_log (" Level: 3.2\n");
1282 } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4) {
1283 debug_log (" Level: 4\n");
1284 } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_1) {
1285 debug_log (" Level: 4.1\n");
1286 } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_2) {
1287 debug_log (" Level: 4.2\n");
1289 debug_log (" Latency: %d\n", msg->video_formats->list->H264_codec.misc_params.latency);
1290 debug_log (" min_slice_size: %x\n", msg->video_formats->list->H264_codec.misc_params.min_slice_size);
1291 debug_log (" slice_enc_params: %x\n", msg->video_formats->list->H264_codec.misc_params.slice_enc_params);
1292 debug_log (" frame_rate_control_support: %x\n", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support);
1293 if(msg->video_formats->list->H264_codec.max_hres) {
1294 debug_log (" Max Height: %04d\n", msg->video_formats->list->H264_codec.max_hres);
1296 if(msg->video_formats->list->H264_codec.max_vres) {
1297 debug_log (" Max Width: %04d\n", msg->video_formats->list->H264_codec.max_vres);
1302 if(msg->video_3d_formats) {
1303 debug_log ("wfd_3d_formats");
1307 if(msg->content_protection) {
1308 debug_log ("wfd_content_protection");
1312 if(msg->display_edid) {
1313 debug_log ("wfd_display_edid");
1317 if(msg->coupled_sink) {
1318 debug_log ("wfd_coupled_sink");
1322 if(msg->trigger_method) {
1323 debug_log (" Trigger type: %s\n", msg->trigger_method->wfd_trigger_method);
1326 if(msg->presentation_url) {
1327 debug_log ("wfd_presentation_URL");
1331 if(msg->client_rtp_ports) {
1332 debug_log(" Client RTP Ports : \n");
1333 if(msg->client_rtp_ports->profile) {
1334 debug_log ("%s\n", msg->client_rtp_ports->profile);
1335 debug_log (" %d\n", msg->client_rtp_ports->rtp_port0);
1336 debug_log (" %d\n", msg->client_rtp_ports->rtp_port1);
1337 debug_log (" %s\n", msg->client_rtp_ports->mode);
1342 debug_log ("wfd_route");
1347 debug_log ("wfd_I2C");
1351 if(msg->av_format_change_timing) {
1352 debug_log ("wfd_av_format_change_timing");
1356 if(msg->preferred_display_mode) {
1357 debug_log ("wfd_preferred_display_mode");
1361 if(msg->uibc_capability) {
1362 debug_log ("wfd_uibc_capability");
1366 if(msg->uibc_setting) {
1367 debug_log ("wfd_uibc_setting");
1371 if(msg->standby_resume_capability) {
1372 debug_log ("wfd_standby_resume_capability");
1377 debug_log ("wfd_standby");
1381 if(msg->connector_type) {
1382 debug_log ("wfd_connector_type");
1386 if(msg->idr_request) {
1387 debug_log ("wfd_idr_request");
1390 debug_log("===============================================\n");
1394 WFDResult wfdconfig_set_supported_audio_format(WFDMessage *msg, WFDAudioFormats aCodec, guint aFreq, guint aChanels,
1395 guint aBitwidth, guint32 aLatency)
1397 guint temp = aCodec;
1399 guint pcm = 0, aac = 0, ac3 = 0;
1401 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1403 if(!msg->audio_codecs)
1404 msg->audio_codecs = g_new0 (WFDAudioCodeclist, 1);
1406 if(aCodec != WFD_AUDIO_UNKNOWN) {
1408 msg->audio_codecs->count++;
1411 msg->audio_codecs->list = g_new0 (WFDAudioCodec, msg->audio_codecs->count);
1412 for(; i<msg->audio_codecs->count; i++) {
1413 if((aCodec & WFD_AUDIO_LPCM) && (!pcm)) {
1414 msg->audio_codecs->list[i].audio_format = g_strdup("LPCM");
1415 msg->audio_codecs->list[i].modes = aFreq;
1416 msg->audio_codecs->list[i].latency = aLatency;
1418 } else if((aCodec & WFD_AUDIO_AAC) && (!aac)) {
1419 msg->audio_codecs->list[i].audio_format = g_strdup("AAC");
1420 msg->audio_codecs->list[i].modes = aChanels;
1421 msg->audio_codecs->list[i].latency = aLatency;
1423 } else if((aCodec & WFD_AUDIO_AC3) && (!ac3)) {
1424 msg->audio_codecs->list[i].audio_format = g_strdup("AC3");
1425 msg->audio_codecs->list[i].modes = aChanels;
1426 msg->audio_codecs->list[i].latency = aLatency;
1434 WFDResult wfdconfig_set_prefered_audio_format(WFDMessage *msg, WFDAudioFormats aCodec, WFDAudioFreq aFreq, WFDAudioChannels aChanels,
1435 guint aBitwidth, guint32 aLatency)
1438 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1440 if(!msg->audio_codecs)
1441 msg->audio_codecs = g_new0 (WFDAudioCodeclist, 1);
1443 msg->audio_codecs->list = g_new0 (WFDAudioCodec, 1);
1444 msg->audio_codecs->count = 1;
1445 if(aCodec == WFD_AUDIO_LPCM) {
1446 msg->audio_codecs->list->audio_format = g_strdup("LPCM");
1447 msg->audio_codecs->list->modes = aFreq;
1448 msg->audio_codecs->list->latency = aLatency;
1449 } else if(aCodec == WFD_AUDIO_AAC) {
1450 msg->audio_codecs->list->audio_format = g_strdup("AAC");
1451 msg->audio_codecs->list->modes = aChanels;
1452 msg->audio_codecs->list->latency = aLatency;
1453 } else if(aCodec == WFD_AUDIO_AC3) {
1454 msg->audio_codecs->list->audio_format = g_strdup("AC3");
1455 msg->audio_codecs->list->modes = aChanels;
1456 msg->audio_codecs->list->latency = aLatency;
1461 WFDResult wfdconfig_get_supported_audio_format(WFDMessage *msg, guint *aCodec, guint *aFreq, guint *aChanels,
1462 guint *aBitwidth, guint32 *aLatency)
1465 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1466 g_return_val_if_fail (msg->audio_codecs != NULL, WFD_EINVAL);
1468 for(; i<msg->audio_codecs->count; i++) {
1469 if(!g_strcmp0(msg->audio_codecs->list[i].audio_format,"LPCM")) {
1470 *aCodec |= WFD_AUDIO_LPCM;
1471 *aFreq |= msg->audio_codecs->list[i].modes;
1472 *aChanels |= WFD_CHANNEL_2;
1474 *aLatency = msg->audio_codecs->list[i].latency;
1475 } else if(!g_strcmp0(msg->audio_codecs->list[i].audio_format,"AAC")) {
1476 *aCodec |= WFD_AUDIO_AAC;
1477 *aFreq |= WFD_FREQ_48000;
1478 *aChanels |= msg->audio_codecs->list[i].modes;
1480 *aLatency = msg->audio_codecs->list[i].latency;
1481 } else if(!g_strcmp0(msg->audio_codecs->list[i].audio_format,"AC3")) {
1482 *aCodec |= WFD_AUDIO_AC3;
1483 *aFreq |= WFD_FREQ_48000;
1484 *aChanels |= msg->audio_codecs->list[i].modes;
1486 *aLatency = msg->audio_codecs->list[i].latency;
1492 WFDResult wfdconfig_get_prefered_audio_format(WFDMessage *msg, WFDAudioFormats *aCodec, WFDAudioFreq *aFreq, WFDAudioChannels *aChanels,
1493 guint *aBitwidth, guint32 *aLatency)
1495 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1497 if(!g_strcmp0(msg->audio_codecs->list->audio_format,"LPCM")) {
1498 *aCodec = WFD_AUDIO_LPCM;
1499 *aFreq = msg->audio_codecs->list->modes;
1500 *aChanels = WFD_CHANNEL_2;
1502 *aLatency = msg->audio_codecs->list->latency;
1503 } else if(!g_strcmp0(msg->audio_codecs->list->audio_format,"AAC")) {
1504 *aCodec = WFD_AUDIO_AAC;
1505 *aFreq = WFD_FREQ_48000;
1506 *aChanels = msg->audio_codecs->list->modes;
1508 *aLatency = msg->audio_codecs->list->latency;
1509 } else if(!g_strcmp0(msg->audio_codecs->list->audio_format,"AC3")) {
1510 *aCodec = WFD_AUDIO_AC3;
1511 *aFreq = WFD_FREQ_48000;
1512 *aChanels = msg->audio_codecs->list->modes;
1514 *aLatency = msg->audio_codecs->list->latency;
1519 WFDResult wfdconfig_set_supported_video_format(WFDMessage *msg, WFDVideoCodecs vCodec,
1520 WFDVideoNativeResolution vNative, guint64 vNativeResolution,
1521 guint64 vCEAResolution, guint64 vVESAResolution, guint64 vHHResolution,
1522 guint vProfile, guint vLevel, guint32 vLatency, guint32 vMaxHeight,
1523 guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control)
1525 guint nativeindex = 0;
1526 guint64 temp = vNativeResolution;
1528 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1530 if(!msg->video_formats)
1531 msg->video_formats = g_new0 (WFDVideoCodeclist, 1);
1533 if(vCodec != WFD_VIDEO_UNKNOWN) {
1534 msg->video_formats->list = g_new0 (WFDVideoCodec, 1);
1540 msg->video_formats->list->native = nativeindex-1;
1541 msg->video_formats->list->native <<= 3;
1543 if(vNative == WFD_VIDEO_VESA_RESOLUTION)
1544 msg->video_formats->list->native |= 1;
1545 else if(vNative == WFD_VIDEO_HH_RESOLUTION)
1546 msg->video_formats->list->native |= 2;
1548 msg->video_formats->list->preferred_display_mode_supported = 1;
1549 msg->video_formats->list->H264_codec.profile = vProfile;
1550 msg->video_formats->list->H264_codec.level = vLevel;
1551 msg->video_formats->list->H264_codec.max_hres = vMaxHeight;
1552 msg->video_formats->list->H264_codec.max_vres = vMaxWidth;
1553 msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution;
1554 msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution;
1555 msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution;
1556 msg->video_formats->list->H264_codec.misc_params.latency = vLatency;
1557 msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size;
1558 msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params;
1559 msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control;
1564 WFDResult wfdconfig_set_prefered_video_format(WFDMessage *msg, WFDVideoCodecs vCodec,
1565 WFDVideoNativeResolution vNative, guint64 vNativeResolution,
1566 WFDVideoCEAResolution vCEAResolution, WFDVideoVESAResolution vVESAResolution,
1567 WFDVideoHHResolution vHHResolution, WFDVideoH264Profile vProfile,
1568 WFDVideoH264Level vLevel, guint32 vLatency, guint32 vMaxHeight,
1569 guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control)
1571 guint nativeindex = 0;
1572 guint64 temp = vNativeResolution;
1574 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1576 if(!msg->video_formats)
1577 msg->video_formats = g_new0 (WFDVideoCodeclist, 1);
1578 msg->video_formats->list = g_new0 (WFDVideoCodec, 1);
1585 if(nativeindex) msg->video_formats->list->native = nativeindex-1;
1586 msg->video_formats->list->native <<= 3;
1588 if(vNative == WFD_VIDEO_VESA_RESOLUTION)
1589 msg->video_formats->list->native |= 1;
1590 else if(vNative == WFD_VIDEO_HH_RESOLUTION)
1591 msg->video_formats->list->native |= 2;
1593 msg->video_formats->list->preferred_display_mode_supported = 0;
1594 msg->video_formats->list->H264_codec.profile = vProfile;
1595 msg->video_formats->list->H264_codec.level = vLevel;
1596 msg->video_formats->list->H264_codec.max_hres = vMaxHeight;
1597 msg->video_formats->list->H264_codec.max_vres = vMaxWidth;
1598 msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution;
1599 msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution;
1600 msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution;
1601 msg->video_formats->list->H264_codec.misc_params.latency = vLatency;
1602 msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size;
1603 msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params;
1604 msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control;
1608 WFDResult wfdconfig_get_supported_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec,
1609 WFDVideoNativeResolution *vNative, guint64 *vNativeResolution,
1610 guint64 *vCEAResolution, guint64 *vVESAResolution, guint64 *vHHResolution,
1611 guint *vProfile, guint *vLevel, guint32 *vLatency, guint32 *vMaxHeight,
1612 guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control)
1614 guint nativeindex = 0;
1616 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1617 *vCodec = WFD_VIDEO_H264;
1618 *vNative = msg->video_formats->list->native & 0x7;
1619 nativeindex = msg->video_formats->list->native >> 3;
1620 *vNativeResolution = 1 << nativeindex;
1621 *vProfile = msg->video_formats->list->H264_codec.profile;
1622 *vLevel = msg->video_formats->list->H264_codec.level;
1623 *vMaxHeight = msg->video_formats->list->H264_codec.max_hres;
1624 *vMaxWidth = msg->video_formats->list->H264_codec.max_vres;
1625 *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support;
1626 *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support;
1627 *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support;
1628 *vLatency = msg->video_formats->list->H264_codec.misc_params.latency;
1629 *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size;
1630 *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params;
1631 *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support;
1635 WFDResult wfdconfig_get_prefered_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec,
1636 WFDVideoNativeResolution *vNative, guint64 *vNativeResolution,
1637 WFDVideoCEAResolution *vCEAResolution, WFDVideoVESAResolution *vVESAResolution,
1638 WFDVideoHHResolution *vHHResolution, WFDVideoH264Profile *vProfile,
1639 WFDVideoH264Level *vLevel, guint32 *vLatency, guint32 *vMaxHeight,
1640 guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control)
1642 guint nativeindex = 0;
1643 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1645 *vCodec = WFD_VIDEO_H264;
1646 *vNative = msg->video_formats->list->native & 0x7;
1647 nativeindex = msg->video_formats->list->native >> 3;
1648 *vNativeResolution = 1 << nativeindex;
1649 *vProfile = msg->video_formats->list->H264_codec.profile;
1650 *vLevel = msg->video_formats->list->H264_codec.level;
1651 *vMaxHeight = msg->video_formats->list->H264_codec.max_hres;
1652 *vMaxWidth = msg->video_formats->list->H264_codec.max_vres;
1653 *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support;
1654 *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support;
1655 *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support;
1656 *vLatency = msg->video_formats->list->H264_codec.misc_params.latency;
1657 *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size;
1658 *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params;
1659 *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support;
1663 WFDResult wfdconfig_set_contentprotection_type(WFDMessage *msg, WFDHDCPProtection hdcpversion, guint32 TCPPort)
1665 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1669 fp = fopen(LIBHDCP, "r");
1675 if(!msg->content_protection) msg->content_protection = g_new0 (WFDContentProtection, 1);
1676 if(hdcpversion == WFD_HDCP_NONE) return WFD_OK;
1677 msg->content_protection->hdcp2_spec = g_new0 (WFDHdcp2Spec, 1);
1678 if(hdcpversion == WFD_HDCP_2_0) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup("HDCP2.0");
1679 else if(hdcpversion == WFD_HDCP_2_1) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup("HDCP2.1");
1681 sprintf(str, "port=%d", TCPPort);
1682 msg->content_protection->hdcp2_spec->TCPPort = g_strdup(str);
1686 WFDResult wfdconfig_get_contentprotection_type(WFDMessage *msg, WFDHDCPProtection *hdcpversion, guint32 *TCPPort)
1688 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1689 if(msg->content_protection && msg->content_protection->hdcp2_spec) {
1690 char *result = NULL;
1692 if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"none")) {
1693 *hdcpversion = WFD_HDCP_NONE;
1697 if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"HDCP2.0")) *hdcpversion = WFD_HDCP_2_0;
1698 else if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"HDCP2.1")) *hdcpversion = WFD_HDCP_2_1;
1699 result = strtok(msg->content_protection->hdcp2_spec->TCPPort, "=");
1700 while (result !=NULL) {
1701 result = strtok(NULL, "=");
1702 *TCPPort = atoi (result);
1705 } else *hdcpversion = WFD_HDCP_NONE;
1709 WFDResult wfdconfig_set_display_EDID(WFDMessage *msg, gboolean edid_supported, guint32 edid_blockcount, gchar *edid_playload)
1711 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1712 if(!msg->display_edid) msg->display_edid = g_new0 (WFDDisplayEdid, 1);
1713 msg->display_edid->edid_supported = edid_supported;
1714 if(!edid_supported) return WFD_OK;
1715 msg->display_edid->edid_block_count = edid_blockcount;
1716 if(edid_blockcount) {
1717 msg->display_edid->edid_payload = g_malloc(128 * edid_blockcount);
1718 if(!msg->display_edid->edid_payload)
1719 memcpy(msg->display_edid->edid_payload, edid_playload, 128 * edid_blockcount);
1720 } else msg->display_edid->edid_payload = g_strdup("none");
1724 WFDResult wfdconfig_get_display_EDID(WFDMessage *msg, gboolean *edid_supported, guint32 *edid_blockcount, gchar **edid_playload)
1726 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1727 if(msg->display_edid ) {
1728 if(msg->display_edid->edid_supported) {
1729 *edid_blockcount = msg->display_edid->edid_block_count;
1730 if(msg->display_edid->edid_block_count) {
1732 temp = g_malloc(EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
1734 memset(temp, 0, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
1735 memcpy(temp, msg->display_edid->edid_payload, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
1736 *edid_playload = temp;
1737 *edid_supported = TRUE;
1739 } else *edid_playload = g_strdup("none");
1741 } else *edid_supported = FALSE;
1745 WFDResult wfdconfig_set_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus status, gchar *sink_address)
1747 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1748 if(!msg->coupled_sink) msg->coupled_sink = g_new0 (WFDCoupledSink, 1);
1749 if(status == WFD_SINK_UNKNOWN) return WFD_OK;
1750 msg->coupled_sink->coupled_sink_cap = g_new0 (WFDCoupled_sink_cap, 1);
1751 msg->coupled_sink->coupled_sink_cap->status = status;
1752 msg->coupled_sink->coupled_sink_cap->sink_address = g_strdup(sink_address);
1756 WFDResult wfdconfig_get_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus *status, gchar **sink_address)
1758 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1759 if(msg->coupled_sink && msg->coupled_sink->coupled_sink_cap) {
1760 *status = msg->coupled_sink->coupled_sink_cap->status;
1761 *sink_address = g_strdup(msg->coupled_sink->coupled_sink_cap->sink_address);
1762 } else *status = WFD_SINK_UNKNOWN;
1766 WFDResult wfdconfig_set_trigger_type(WFDMessage *msg, WFDTrigger trigger)
1768 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1770 if(!msg->trigger_method)
1771 msg->trigger_method = g_new0 (WFDTriggerMethod, 1);
1772 if(trigger == WFD_TRIGGER_SETUP)
1773 msg->trigger_method->wfd_trigger_method = g_strdup("SETUP");
1774 else if(trigger == WFD_TRIGGER_PAUSE)
1775 msg->trigger_method->wfd_trigger_method = g_strdup("PAUSE");
1776 else if(trigger == WFD_TRIGGER_TEARDOWN)
1777 msg->trigger_method->wfd_trigger_method = g_strdup("TEARDOWN");
1778 else if(trigger == WFD_TRIGGER_PLAY)
1779 msg->trigger_method->wfd_trigger_method = g_strdup("PLAY");
1785 WFDResult wfdconfig_get_trigger_type(WFDMessage *msg, WFDTrigger *trigger)
1787 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1788 if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "SETUP"))
1789 *trigger = WFD_TRIGGER_SETUP;
1790 else if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "PAUSE"))
1791 *trigger = WFD_TRIGGER_PAUSE;
1792 else if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "TEARDOWN"))
1793 *trigger = WFD_TRIGGER_TEARDOWN;
1794 else if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "PLAY"))
1795 *trigger = WFD_TRIGGER_PLAY;
1797 *trigger = WFD_TRIGGER_UNKNOWN;
1803 WFDResult wfdconfig_set_presentation_url(WFDMessage *msg, gchar *wfd_url0, gchar *wfd_url1)
1805 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1806 if(!msg->presentation_url) msg->presentation_url = g_new0 (WFDPresentationUrl, 1);
1807 if(wfd_url0) msg->presentation_url->wfd_url0 = g_strdup(wfd_url0);
1808 if(wfd_url1) msg->presentation_url->wfd_url1 = g_strdup(wfd_url1);
1812 WFDResult wfdconfig_get_presentation_url(WFDMessage *msg, gchar **wfd_url0, gchar **wfd_url1)
1814 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1815 if(msg->presentation_url) {
1816 *wfd_url0 = g_strdup(msg->presentation_url->wfd_url0);
1817 *wfd_url1 = g_strdup(msg->presentation_url->wfd_url1);
1822 WFDResult wfdconfig_set_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode trans, WFDRTSPProfile profile,
1823 WFDRTSPLowerTrans lowertrans, guint32 rtp_port0, guint32 rtp_port1)
1826 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1828 if(!msg->client_rtp_ports)
1829 msg->client_rtp_ports = g_new0 (WFDClientRtpPorts, 1);
1831 if(trans != WFD_RTSP_TRANS_UNKNOWN) {
1832 lines = g_string_new ("");
1833 if(trans == WFD_RTSP_TRANS_RTP) g_string_append_printf (lines,"RTP");
1834 else if(trans == WFD_RTSP_TRANS_RDT) g_string_append_printf (lines,"RDT");
1836 if(profile == WFD_RTSP_PROFILE_AVP) g_string_append_printf (lines,"/AVP");
1837 else if(profile == WFD_RTSP_PROFILE_SAVP) g_string_append_printf (lines,"/SAVP");
1839 if(lowertrans == WFD_RTSP_LOWER_TRANS_UDP) g_string_append_printf (lines,"/UDP;unicast");
1840 else if(lowertrans == WFD_RTSP_LOWER_TRANS_UDP_MCAST) g_string_append_printf (lines,"/UDP;multicast");
1841 else if(lowertrans == WFD_RTSP_LOWER_TRANS_TCP) g_string_append_printf (lines,"/TCP;unicast");
1842 else if(lowertrans == WFD_RTSP_LOWER_TRANS_HTTP) g_string_append_printf (lines,"/HTTP");
1844 msg->client_rtp_ports->profile = g_string_free (lines, FALSE);
1845 msg->client_rtp_ports->rtp_port0 = rtp_port0;
1846 msg->client_rtp_ports->rtp_port1 = rtp_port1;
1847 msg->client_rtp_ports->mode = g_strdup("mode=play");
1852 WFDResult wfdconfig_get_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode *trans, WFDRTSPProfile *profile,
1853 WFDRTSPLowerTrans *lowertrans, guint32 *rtp_port0, guint32 *rtp_port1)
1855 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1856 g_return_val_if_fail (msg->client_rtp_ports != NULL, WFD_EINVAL);
1858 if(g_strrstr(msg->client_rtp_ports->profile, "RTP")) *trans = WFD_RTSP_TRANS_RTP;
1859 if(g_strrstr(msg->client_rtp_ports->profile, "RDT")) *trans = WFD_RTSP_TRANS_RDT;
1860 if(g_strrstr(msg->client_rtp_ports->profile, "AVP")) *profile = WFD_RTSP_PROFILE_AVP;
1861 if(g_strrstr(msg->client_rtp_ports->profile, "SAVP")) *profile = WFD_RTSP_PROFILE_SAVP;
1862 if(g_strrstr(msg->client_rtp_ports->profile, "UDP;unicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP;
1863 if(g_strrstr(msg->client_rtp_ports->profile, "UDP;multicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP_MCAST;
1864 if(g_strrstr(msg->client_rtp_ports->profile, "TCP;unicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_TCP;
1865 if(g_strrstr(msg->client_rtp_ports->profile, "HTTP")) *lowertrans = WFD_RTSP_LOWER_TRANS_HTTP;
1867 *rtp_port0 = msg->client_rtp_ports->rtp_port0;
1868 *rtp_port1 = msg->client_rtp_ports->rtp_port1;
1873 WFDResult wfdconfig_set_audio_sink_type(WFDMessage *msg, WFDSinkType sinktype)
1875 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1876 if(!msg->route) msg->route = g_new0 (WFDRoute, 1);
1877 if(sinktype == WFD_PRIMARY_SINK) msg->route->destination = g_strdup("primary");
1878 else if(sinktype == WFD_SECONDARY_SINK) msg->route->destination = g_strdup("secondary");
1882 WFDResult wfdconfig_get_audio_sink_type(WFDMessage *msg, WFDSinkType *sinktype)
1884 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1886 if(!g_strcmp0(msg->route->destination,"primary")) *sinktype = WFD_PRIMARY_SINK;
1887 else if(!g_strcmp0(msg->route->destination,"secondary")) *sinktype = WFD_SECONDARY_SINK;
1892 WFDResult wfdconfig_set_I2C_port(WFDMessage *msg, gboolean i2csupport, guint32 i2cport)
1894 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1895 if(!msg->I2C) msg->I2C = g_new0 (WFDI2C, 1);
1896 msg->I2C->I2CPresent = i2csupport;
1897 msg->I2C->I2C_port = i2cport;
1901 WFDResult wfdconfig_get_I2C_port(WFDMessage *msg, gboolean *i2csupport, guint32 *i2cport)
1903 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1904 if(msg->I2C && msg->I2C->I2CPresent) {
1905 *i2csupport = msg->I2C->I2CPresent;
1906 *i2cport = msg->I2C->I2C_port;
1907 } else *i2csupport = FALSE;
1911 WFDResult wfdconfig_set_av_format_change_timing(WFDMessage *msg, guint64 PTS, guint64 DTS)
1913 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1914 if(!msg->av_format_change_timing) msg->av_format_change_timing = g_new0 (WFDAVFormatChangeTiming, 1);
1915 msg->av_format_change_timing->PTS = PTS;
1916 msg->av_format_change_timing->DTS = DTS;
1920 WFDResult wfdconfig_get_av_format_change_timing(WFDMessage *msg, guint64 *PTS, guint64 *DTS)
1922 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1923 if(msg->av_format_change_timing) {
1924 *PTS = msg->av_format_change_timing->PTS;
1925 *DTS = msg->av_format_change_timing->DTS;
1930 WFDResult wfdconfig_set_uibc_capability(WFDMessage *msg, guint32 input_category, guint32 inp_type, WFDHIDCTypePathPair *inp_pair,
1931 guint32 inp_type_path_count, guint32 tcp_port)
1933 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1934 if(!msg->uibc_capability) msg->uibc_capability = g_new0 (WFDUibcCapability, 1);
1935 msg->uibc_capability->uibcsupported = TRUE;
1936 msg->uibc_capability->input_category_list.input_cat = input_category;
1937 msg->uibc_capability->generic_cap_list.inp_type = inp_type;
1938 msg->uibc_capability->hidc_cap_list.cap_count = inp_type_path_count;
1939 if(msg->uibc_capability->hidc_cap_list.cap_count) {
1940 detailed_cap *temp_cap;
1942 msg->uibc_capability->hidc_cap_list.next = g_new0 (detailed_cap, 1);
1943 temp_cap = msg->uibc_capability->hidc_cap_list.next;
1944 for(;i<inp_type_path_count;) {
1945 temp_cap->p.inp_type = inp_pair[i].inp_type;
1946 temp_cap->p.inp_path = inp_pair[i].inp_path;
1948 if(i<inp_type_path_count) {
1949 temp_cap->next = g_new0 (detailed_cap, 1);
1950 temp_cap = temp_cap->next;
1954 msg->uibc_capability->tcp_port = tcp_port;
1958 WFDResult wfdconfig_get_uibc_capability(WFDMessage *msg, guint32 *input_category, guint32 *inp_type, WFDHIDCTypePathPair *inp_pair,
1959 guint32 *inp_type_path_count, guint32 *tcp_port)
1961 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1962 if(msg->uibc_capability && msg->uibc_capability->uibcsupported) {
1963 *input_category = msg->uibc_capability->input_category_list.input_cat;
1964 *inp_type = msg->uibc_capability->generic_cap_list.inp_type;
1965 if(msg->uibc_capability->hidc_cap_list.cap_count) {
1966 detailed_cap *temp_cap;
1968 inp_pair = g_new0 (WFDHIDCTypePathPair, msg->uibc_capability->hidc_cap_list.cap_count);
1969 temp_cap = msg->uibc_capability->hidc_cap_list.next;
1971 inp_pair[i].inp_type = temp_cap->p.inp_type;
1972 inp_pair[i].inp_path = temp_cap->p.inp_path;
1973 temp_cap = temp_cap->next;
1977 *tcp_port = msg->uibc_capability->tcp_port;
1982 WFDResult wfdconfig_set_uibc_status(WFDMessage *msg, gboolean uibc_enable)
1984 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1985 if(!msg->uibc_setting) msg->uibc_setting = g_new0 (WFDUibcSetting, 1);
1986 msg->uibc_setting->uibc_setting = uibc_enable;
1990 WFDResult wfdconfig_get_uibc_status(WFDMessage *msg, gboolean *uibc_enable)
1992 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1993 if(msg->uibc_setting) *uibc_enable = msg->uibc_setting->uibc_setting;
1996 #ifdef STANDBY_RESUME_CAPABILITY
1997 WFDResult wfdconfig_set_standby_resume_capability(WFDMessage *msg, gboolean supported)
1999 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2000 if(!msg->standby_resume_capability) msg->standby_resume_capability = g_new0 (WFDStandbyResumeCapability, 1);
2001 msg->standby_resume_capability->standby_resume_cap = supported;
2005 WFDResult wfdconfig_get_standby_resume_capability(WFDMessage *msg, gboolean *supported)
2007 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2008 if(msg->standby_resume_capability) *supported = msg->standby_resume_capability->standby_resume_cap;
2012 WFDResult wfdconfig_set_standby(WFDMessage *msg, gboolean standby_enable)
2014 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2015 if(!msg->standby) msg->standby = g_new0 (WFDStandby, 1);
2016 msg->standby->wfd_standby = standby_enable;
2020 WFDResult wfdconfig_get_standby(WFDMessage *msg, gboolean *standby_enable)
2022 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2023 if(msg->standby) *standby_enable = msg->standby->wfd_standby;
2027 WFDResult wfdconfig_set_connector_type(WFDMessage *msg, WFDConnector connector)
2029 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2030 if(!msg->connector_type) msg->connector_type = g_new0 (WFDConnectorType, 1);
2031 msg->connector_type->connector_type = connector;
2035 WFDResult wfdconfig_get_connector_type(WFDMessage *msg, WFDConnector *connector)
2037 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2038 if(msg->connector_type) *connector = msg->connector_type->connector_type;
2042 WFDResult wfdconfig_set_idr_request(WFDMessage *msg)
2044 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2045 if(!msg->idr_request) msg->idr_request = g_new0 (WFDIdrRequest, 1);
2046 msg->idr_request->idr_request = TRUE;