4 * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, ByungWook Jang <bw.jang@samsung.com>,
7 * Manoj Kumar K <manojkumar.k@samsung.com>, Abhishek Bajaj <abhi.bajaj@samsung.com>, Nikhilesh Mittal <nikhilesh.m@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
30 #ifdef HAVE_SYS_TYPES_H
31 #include <sys/types.h>
34 #include <glib.h> /* for G_OS_WIN32 */
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
57 * wfdconfig_message_new:
58 * @msg: pointer to new #WFDMessage
60 * Allocate a new WFDMessage and store the result in @msg.
62 * Returns: a #WFDResult.
65 wfdconfig_message_new (WFDMessage ** msg)
69 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
71 newmsg = g_new0 (WFDMessage, 1);
75 return wfdconfig_message_init (newmsg);
79 * wfdconfig_message_init:
82 * Initialize @msg so that its contents are as if it was freshly allocated
83 * with wfdconfig_message_new(). This function is mostly used to initialize a message
84 * allocated on the stack. wfdconfig_message_uninit() undoes this operation.
86 * When this function is invoked on newly allocated data (with malloc or on the
87 * stack), its contents should be set to 0 before calling this function.
89 * Returns: a #WFDResult.
92 wfdconfig_message_init (WFDMessage * msg)
94 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
100 * wfdconfig_message_uninit:
101 * @msg: a #WFDMessage
103 * Free all resources allocated in @msg. @msg should not be used anymore after
104 * this function. This function should be used when @msg was allocated on the
105 * stack and initialized with wfdconfig_message_init().
107 * Returns: a #WFDResult.
110 wfdconfig_message_uninit (WFDMessage * msg)
112 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
114 if(msg->audio_codecs) {
116 if(msg->audio_codecs->list) {
117 for(; i<msg->audio_codecs->count; i++) {
118 FREE_STRING(msg->audio_codecs->list[i].audio_format);
119 msg->audio_codecs->list[i].modes=0;
120 msg->audio_codecs->list[i].latency=0;
122 FREE_STRING(msg->audio_codecs->list);
124 FREE_STRING(msg->audio_codecs);
127 if(msg->video_formats) {
128 FREE_STRING(msg->video_formats->list);
129 FREE_STRING(msg->video_formats);
132 if(msg->video_3d_formats) {
133 FREE_STRING(msg->video_3d_formats);
136 if(msg->content_protection) {
137 FREE_STRING(msg->content_protection);
140 if(msg->display_edid) {
141 if(msg->display_edid->edid_payload)
142 FREE_STRING(msg->display_edid->edid_payload);
143 FREE_STRING(msg->display_edid);
146 if(msg->coupled_sink) {
147 FREE_STRING(msg->coupled_sink);
150 if(msg->trigger_method) {
151 FREE_STRING(msg->trigger_method->wfd_trigger_method);
152 FREE_STRING(msg->trigger_method);
155 if(msg->presentation_url) {
156 FREE_STRING(msg->trigger_method);
159 if(msg->client_rtp_ports) {
160 FREE_STRING(msg->client_rtp_ports->profile);
161 FREE_STRING(msg->client_rtp_ports->mode);
162 FREE_STRING(msg->client_rtp_ports);
166 FREE_STRING(msg->route);
170 FREE_STRING(msg->I2C);
173 if(msg->av_format_change_timing) {
174 FREE_STRING(msg->av_format_change_timing);
177 if(msg->preferred_display_mode) {
178 FREE_STRING(msg->preferred_display_mode);
181 if(msg->uibc_capability) {
182 FREE_STRING(msg->uibc_capability);
185 if(msg->uibc_setting) {
186 FREE_STRING(msg->uibc_setting);
189 if(msg->standby_resume_capability) {
190 FREE_STRING(msg->standby_resume_capability);
194 FREE_STRING(msg->standby);
197 if(msg->connector_type) {
198 FREE_STRING(msg->connector_type);
201 if(msg->idr_request) {
202 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 g_string_append_printf (lines,":");
324 if(msg->content_protection->hdcp2_spec) {
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," %10"G_GUINT64_FORMAT, msg->av_format_change_timing->PTS);
421 g_string_append_printf (lines," %10"G_GUINT64_FORMAT, 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," %06"G_GUINT64_FORMAT, 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=%u", 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 g_string_append_printf (lines,"\r\n");
573 if(msg->idr_request) {
574 g_string_append_printf (lines,"wfd_idr_request");
575 g_string_append_printf (lines,"\r\n");
578 //g_string_append_printf (lines,"\0");
579 /*if(g_str_has_suffix (lines,"\r\n\0"))
581 guint32 length = g_strlen(lines);
582 lines[length-2] = '\0';
584 return g_string_free (lines, FALSE);
587 gchar* wfdconfig_parameter_names_as_text (const WFDMessage *msg)
589 /* change all vars so they match rfc? */
591 g_return_val_if_fail (msg != NULL, NULL);
593 lines = g_string_new ("");
595 /* list of audio codecs */
596 if(msg->audio_codecs) {
597 g_string_append_printf (lines,"wfd_audio_codecs");
598 g_string_append_printf (lines,"\r\n");
600 /* list of video codecs */
601 if(msg->video_formats) {
602 g_string_append_printf (lines,"wfd_video_formats");
603 g_string_append_printf (lines,"\r\n");
605 /* list of video 3D codecs */
606 if(msg->video_3d_formats) {
607 g_string_append_printf (lines,"wfd_3d_video_formats");
608 g_string_append_printf (lines,"\r\n");
610 if(msg->content_protection) {
611 g_string_append_printf (lines,"wfd_content_protection");
612 g_string_append_printf (lines,"\r\n");
614 if(msg->display_edid) {
615 g_string_append_printf (lines,"wfd_display_edid");
616 g_string_append_printf (lines,"\r\n");
618 if(msg->coupled_sink) {
619 g_string_append_printf (lines,"wfd_coupled_sink");
620 g_string_append_printf (lines,"\r\n");
622 if(msg->trigger_method) {
623 g_string_append_printf (lines,"wfd_trigger_method");
624 g_string_append_printf (lines,"\r\n");
626 if(msg->presentation_url) {
627 g_string_append_printf (lines,"wfd_presentation_URL");
628 g_string_append_printf (lines,"\r\n");
630 if(msg->client_rtp_ports) {
631 g_string_append_printf (lines,"wfd_client_rtp_ports");
632 g_string_append_printf (lines,"\r\n");
635 g_string_append_printf (lines,"wfd_route");
636 g_string_append_printf (lines,"\r\n");
639 g_string_append_printf (lines,"wfd_I2C");
640 g_string_append_printf (lines,"\r\n");
642 if(msg->av_format_change_timing) {
643 g_string_append_printf (lines,"wfd_av_format_change_timing");
644 g_string_append_printf (lines,"\r\n");
646 if(msg->preferred_display_mode) {
647 g_string_append_printf (lines,"wfd_preferred_display_mode");
648 g_string_append_printf (lines,"\r\n");
650 if(msg->uibc_capability) {
651 g_string_append_printf (lines,"wfd_uibc_capability");
652 g_string_append_printf (lines,"\r\n");
654 if(msg->uibc_setting) {
655 g_string_append_printf (lines,"wfd_uibc_setting");
656 g_string_append_printf (lines,"\r\n");
658 if(msg->standby_resume_capability) {
659 g_string_append_printf (lines,"wfd_standby_resume_capability");
660 g_string_append_printf (lines,"\r\n");
663 g_string_append_printf (lines,"wfd_standby");
664 g_string_append_printf (lines,"\r\n");
666 if(msg->connector_type) {
667 g_string_append_printf (lines,"wfd_connector_type");
668 g_string_append_printf (lines,"\r\n");
670 if(msg->idr_request) {
671 g_string_append_printf (lines,"wfd_idr_request");
672 g_string_append_printf (lines,"\r\n");
674 return g_string_free (lines, FALSE);
678 read_string_space_ended (gchar * dest, guint size, gchar * src)
682 while (!g_ascii_isspace (*src) && *src != '\0') {
693 read_string_char_ended (gchar * dest, guint size, gchar del, gchar * src)
697 while (*src != del && *src != '\0') {
708 read_string_type_and_value (gchar * type, gchar * value, guint tsize, guint vsize, gchar del, gchar * src)
713 while (*src != del && *src != '\0') {
724 while (*src != '\0') {
734 wfdconfig_parse_line (WFDMessage * msg, gchar * buffer)
736 gchar type[8192] = {0};
737 gchar value[8192] = {0};
738 gchar temp[8192] = {0};
741 gchar *result = NULL;
743 #define WFD_SKIP_SPACE(q) if (*q && g_ascii_isspace (*q)) q++
744 #define WFD_SKIP_EQUAL(q) if (*q && *q == '=') q++
745 #define WFD_SKIP_COMMA(q) if (*q && g_ascii_ispunct (*q)) q++
746 #define WFD_READ_STRING(field) read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); REPLACE_STRING (field, temp)
747 #define WFD_READ_CHAR_END_STRING(field, del) read_string_char_ended (temp, sizeof (temp), del, v); v+=strlen(temp); REPLACE_STRING (field, temp)
748 #define WFD_READ_UINT32(field) read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); field = strtoul (temp, NULL, 16)
749 #define WFD_READ_UINT32_DIGIT(field) read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); field = strtoul (temp, NULL, 10)
751 //g_print("wfdconfig_parse_line input: %s\n", buffer);
752 read_string_type_and_value (type, value, sizeof(type), sizeof(value), ':', p);
753 //g_print("wfdconfig_parse_line type:%s value:%s\n", type, value);
754 if(!g_strcmp0(type,"wfd_audio_codecs")) {
755 msg->audio_codecs = g_new0 (WFDAudioCodeclist, 1);
758 msg->audio_codecs->count= strlen(v)/16;
759 msg->audio_codecs->list = g_new0 (WFDAudioCodec, msg->audio_codecs->count);
760 for(;i<msg->audio_codecs->count;i++) {
762 WFD_READ_STRING(msg->audio_codecs->list[i].audio_format);
764 WFD_READ_UINT32(msg->audio_codecs->list[i].modes);
766 WFD_READ_UINT32(msg->audio_codecs->list[i].latency);
770 } else if(!g_strcmp0(type,"wfd_video_formats")) {
771 msg->video_formats = g_new0 (WFDVideoCodeclist, 1);
773 msg->video_formats->count = 1;
774 msg->video_formats->list = g_new0 (WFDVideoCodec, 1);
776 WFD_READ_UINT32(msg->video_formats->list->native);
778 WFD_READ_UINT32(msg->video_formats->list->preferred_display_mode_supported);
780 WFD_READ_UINT32(msg->video_formats->list->H264_codec.profile);
782 WFD_READ_UINT32(msg->video_formats->list->H264_codec.level);
784 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.CEA_Support);
786 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.VESA_Support);
788 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.HH_Support);
790 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.latency);
792 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.min_slice_size);
794 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.slice_enc_params);
796 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support);
798 if(msg->video_formats->list->preferred_display_mode_supported == 1) {
799 WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_hres);
801 WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_vres);
805 }else if(!g_strcmp0(type,"wfd_3d_video_formats")) {
806 msg->video_3d_formats = g_new0 (WFD3DFormats, 1);
808 msg->video_3d_formats->count = 1;
809 msg->video_3d_formats->list = g_new0 (WFD3dCapList, 1);
811 WFD_READ_UINT32(msg->video_3d_formats->list->native);
813 WFD_READ_UINT32(msg->video_3d_formats->list->preferred_display_mode_supported);
815 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.profile);
817 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.level);
819 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.video_3d_capability);
821 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.latency);
823 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.min_slice_size);
825 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.slice_enc_params);
827 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support);
829 if(msg->video_3d_formats->list->preferred_display_mode_supported == 1) {
830 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.max_hres);
832 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.max_vres);
836 } else if(!g_strcmp0(type,"wfd_content_protection")) {
837 msg->content_protection = g_new0 (WFDContentProtection, 1);
840 msg->content_protection->hdcp2_spec = g_new0 (WFDHdcp2Spec, 1);
841 if(strstr(v,"none")) {
842 msg->content_protection->hdcp2_spec->hdcpversion=g_strdup("none");
844 WFD_READ_STRING(msg->content_protection->hdcp2_spec->hdcpversion);
846 WFD_READ_STRING(msg->content_protection->hdcp2_spec->TCPPort);
849 } else if(!g_strcmp0(type,"wfd_display_edid")) {
850 msg->display_edid = g_new0 (WFDDisplayEdid, 1);
853 if(strstr(v,"none")) {
854 msg->display_edid->edid_supported = 0;
856 msg->display_edid->edid_supported = 1;
857 WFD_READ_UINT32(msg->display_edid->edid_block_count);
859 if(msg->display_edid->edid_block_count) {
860 gchar *edid_string = v;
861 int i=0, j=0, size =0;
862 guint32 payload_size = EDID_BLOCK_SIZE * msg->display_edid->edid_block_count;
863 msg->display_edid->edid_payload = g_malloc(payload_size);
864 size = EDID_BLOCK_SIZE*msg->display_edid->edid_block_count*2;
867 if(edid_string[i]>0x29 && edid_string[i]<0x40) k=edid_string[i]-48;
868 else if(edid_string[i]>0x60 && edid_string[i]<0x67) k=edid_string[i]-87;
869 else if(edid_string[i]>0x40 && edid_string[i]<0x47) k=edid_string[i]-55;
871 if(edid_string[i+1]>0x29 && edid_string[i+1]<0x40) kk=edid_string[i+1]-48;
872 else if(edid_string[i+1]>0x60 && edid_string[i+1]<0x67) kk=edid_string[i+1]-87;
873 else if(edid_string[i+1]>0x40 && edid_string[i+1]<0x47) kk=edid_string[i+1]-55;
875 msg->display_edid->edid_payload[j] = (k<<4)|kk;
878 //memcpy(msg->display_edid->edid_payload, v, payload_size);
879 v += (payload_size*2);
880 } else v += strlen(v);
883 } else if(!g_strcmp0(type,"wfd_coupled_sink")) {
884 msg->coupled_sink = g_new0 (WFDCoupledSink, 1);
886 msg->coupled_sink->coupled_sink_cap = g_new0 (WFDCoupled_sink_cap, 1);
888 WFD_READ_UINT32(msg->coupled_sink->coupled_sink_cap->status);
890 WFD_READ_STRING(msg->coupled_sink->coupled_sink_cap->sink_address);
892 } else if(!g_strcmp0(type,"wfd_trigger_method")) {
893 msg->trigger_method = g_new0 (WFDTriggerMethod, 1);
896 WFD_READ_STRING(msg->trigger_method->wfd_trigger_method);
898 } else if(!g_strcmp0(type,"wfd_presentation_URL")) {
899 msg->presentation_url = g_new0 (WFDPresentationUrl, 1);
902 WFD_READ_STRING(msg->presentation_url->wfd_url0);
904 WFD_READ_STRING(msg->presentation_url->wfd_url1);
906 } else if(!g_strcmp0(type,"wfd_client_rtp_ports")) {
907 msg->client_rtp_ports = g_new0 (WFDClientRtpPorts, 1);
910 WFD_READ_STRING(msg->client_rtp_ports->profile);
912 WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port0);
914 WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port1);
916 WFD_READ_STRING(msg->client_rtp_ports->mode);
918 } else if(!g_strcmp0(type,"wfd_route")) {
919 msg->route = g_new0 (WFDRoute, 1);
922 WFD_READ_STRING(msg->route->destination);
924 } else if(!g_strcmp0(type,"wfd_I2C")) {
925 msg->I2C = g_new0 (WFDI2C, 1);
927 msg->I2C->I2CPresent = TRUE;
929 WFD_READ_UINT32_DIGIT(msg->I2C->I2C_port);
930 if(msg->I2C->I2C_port) msg->I2C->I2CPresent = TRUE;
932 } else if(!g_strcmp0(type,"wfd_av_format_change_timing")) {
933 msg->av_format_change_timing = g_new0 (WFDAVFormatChangeTiming, 1);
936 WFD_READ_UINT32(msg->av_format_change_timing->PTS);
938 WFD_READ_UINT32(msg->av_format_change_timing->DTS);
940 } else if(!g_strcmp0(type,"wfd_preferred_display_mode")) {
941 msg->preferred_display_mode = g_new0 (WFDPreferredDisplayMode, 1);
944 if(!strstr(v,"none")) {
945 msg->preferred_display_mode->displaymodesupported = FALSE;
947 WFD_READ_UINT32(msg->preferred_display_mode->p_clock);
949 WFD_READ_UINT32(msg->preferred_display_mode->H);
951 WFD_READ_UINT32(msg->preferred_display_mode->HB);
953 WFD_READ_UINT32(msg->preferred_display_mode->HSPOL_HSOFF);
955 WFD_READ_UINT32(msg->preferred_display_mode->HSW);
957 WFD_READ_UINT32(msg->preferred_display_mode->V);
959 WFD_READ_UINT32(msg->preferred_display_mode->VB);
961 WFD_READ_UINT32(msg->preferred_display_mode->VSPOL_VSOFF);
963 WFD_READ_UINT32(msg->preferred_display_mode->VSW);
965 WFD_READ_UINT32(msg->preferred_display_mode->VBS3D);
967 WFD_READ_UINT32(msg->preferred_display_mode->V2d_s3d_modes);
969 WFD_READ_UINT32(msg->preferred_display_mode->P_depth);
971 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.profile);
973 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.level);
975 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.CEA_Support);
977 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.VESA_Support);
979 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.HH_Support);
981 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.latency);
983 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.min_slice_size);
985 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.slice_enc_params);
987 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.frame_rate_control_support);
989 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_hres);
991 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_vres);
995 } else if(!g_strcmp0(type,"wfd_uibc_capability")) {
996 msg->uibc_capability = g_new0 (WFDUibcCapability, 1);
997 if(strstr(v,"input_category_list")) {
998 gchar *tstring = NULL;
999 msg->uibc_capability->uibcsupported = TRUE;
1001 WFD_READ_CHAR_END_STRING(tstring, '=');
1002 if(!g_strcmp0(tstring,"input_category_list")) {
1003 gchar temp2[8192]={0};
1004 guint rem_len=0, read_len=0;
1005 WFD_READ_CHAR_END_STRING(tstring, ';');
1006 rem_len = strlen(tstring);
1009 read_string_char_ended (temp2, 8192, ',', tstring+read_len);
1010 read_len += (strlen(temp2)+1);
1011 if(strstr(temp2,"GENERIC")) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_GENERIC;
1012 else if(strstr(temp2,"HIDC")) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_HIDC;
1013 else msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_UNKNOWN;
1014 } while(read_len < rem_len);
1016 result = strstr(v,"generic_cap_list");
1018 memset(temp2, 0, 8192);
1022 WFD_READ_CHAR_END_STRING(tstring, '=');
1023 if(!g_strcmp0(tstring,"generic_cap_list")) {
1025 WFD_READ_CHAR_END_STRING(tstring, ';');
1026 rem_len = strlen(tstring);
1028 read_string_char_ended (temp2, 8192, ',', tstring+read_len);
1029 read_len += (strlen(temp2)+1);
1030 if(strstr(temp2,"Keyboard")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_KEYBOARD;
1031 else if(strstr(temp2,"Mouse")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MOUSE;
1032 else if(strstr(temp2,"SingleTouch")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_SINGLETOUCH;
1033 else if(strstr(temp2,"MultiTouch")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MULTITOUCH;
1034 else if(strstr(temp2,"Joystick")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_JOYSTICK;
1035 else if(strstr(temp2,"Camera")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_CAMERA;
1036 else if(strstr(temp2,"Gesture")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_GESTURE;
1037 else if(strstr(temp2,"RemoteControl")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_REMOTECONTROL;
1038 else msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_UNKNOWN;
1039 } while(read_len < rem_len);
1042 result = strstr (v, "hidc_cap_list");
1046 WFD_READ_CHAR_END_STRING(tstring, '=');
1047 if(!g_strcmp0(tstring,"hidc_cap_list")) {
1048 gchar inp_type[8192];
1049 gchar inp_path[8192];
1050 memset(temp2, 0, 8192);
1053 detailed_cap *temp_cap;
1054 WFD_READ_CHAR_END_STRING(tstring, ';');
1055 rem_len = strlen(tstring);
1056 msg->uibc_capability->hidc_cap_list.next = g_new0 (detailed_cap, 1);
1057 temp_cap = msg->uibc_capability->hidc_cap_list.next;
1059 msg->uibc_capability->hidc_cap_list.cap_count++;
1060 read_string_char_ended (temp2, 8192, ',', tstring+read_len);
1061 read_len += (strlen(temp2)+1);
1062 read_string_type_and_value (inp_type, inp_path, sizeof(inp_type), sizeof(inp_path), '/',temp2);
1063 if(strstr(inp_type,"Keyboard")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_KEYBOARD;
1064 else if(strstr(inp_type,"Mouse")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MOUSE;
1065 else if(strstr(inp_type,"SingleTouch")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_SINGLETOUCH;
1066 else if(strstr(inp_type,"MultiTouch")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MULTITOUCH;
1067 else if(strstr(inp_type,"Joystick")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_JOYSTICK;
1068 else if(strstr(inp_type,"Camera")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_CAMERA;
1069 else if(strstr(inp_type,"Gesture")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_GESTURE;
1070 else if(strstr(inp_type,"RemoteControl")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_REMOTECONTROL;
1071 else temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_UNKNOWN;
1073 if(strstr(inp_path,"Infrared")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_INFRARED;
1074 else if(strstr(inp_path,"USB")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_USB;
1075 else if(strstr(inp_path,"BT")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_BT;
1076 else if(strstr(inp_path,"Zigbee")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_ZIGBEE;
1077 else if(strstr(inp_path,"Wi-Fi")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_WIFI;
1078 else if(strstr(inp_path,"No-SP")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_NOSP;
1079 else temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_UNKNOWN;
1080 if(read_len < rem_len) {
1081 temp_cap->next = g_new0 (detailed_cap, 1);
1082 temp_cap = temp_cap->next;
1084 } while(read_len < rem_len);
1087 result = strstr(v,"port");
1088 if(result != NULL) {
1090 WFD_READ_CHAR_END_STRING(tstring, '=');
1091 if(!g_strcmp0(tstring,"port")) {
1093 WFD_READ_CHAR_END_STRING(tstring, ';');
1094 if(!strstr(tstring,"none")) {
1095 msg->uibc_capability->tcp_port = strtoul (tstring, NULL, 10);
1100 } else if (strstr(v,"none")) {
1101 msg->uibc_capability->uibcsupported = FALSE;
1103 } else if(!g_strcmp0(type,"wfd_uibc_setting")) {
1104 msg->uibc_setting = g_new0 (WFDUibcSetting, 1);
1107 if(!g_strcmp0(v, "enable"))
1108 msg->uibc_setting->uibc_setting = TRUE;
1110 msg->uibc_setting->uibc_setting = FALSE;
1112 } else if(!g_strcmp0(type,"wfd_standby_resume_capability")) {
1113 msg->standby_resume_capability = g_new0 (WFDStandbyResumeCapability, 1);
1116 if(!g_strcmp0(v, "supported"))
1117 msg->standby_resume_capability->standby_resume_cap = TRUE;
1119 msg->standby_resume_capability->standby_resume_cap = FALSE;
1121 } else if(!g_strcmp0(type,"wfd_standby")) {
1122 msg->standby = g_new0 (WFDStandby, 1);
1123 msg->standby->wfd_standby = TRUE;
1124 } else if(!g_strcmp0(type,"wfd_connector_type")) {
1125 msg->connector_type = g_new0 (WFDConnectorType, 1);
1127 msg->connector_type->supported = TRUE;
1129 WFD_READ_UINT32(msg->connector_type->connector_type);
1131 } else if(!g_strcmp0(type,"wfd_idr_request")) {
1132 msg->idr_request = g_new0 (WFDIdrRequest, 1);
1133 msg->idr_request->idr_request = TRUE;
1140 * wfdconfig_message_parse_buffer:
1141 * @data: the start of the buffer
1142 * @size: the size of the buffer
1143 * @msg: the result #WFDMessage
1145 * Parse the contents of @size bytes pointed to by @data and store the result in
1148 * Returns: #WFD_OK on success.
1151 wfdconfig_message_parse_buffer (const guint8 * data, guint size, WFDMessage * msg)
1154 gchar buffer[MAX_LINE_LEN] = {0};
1157 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1158 g_return_val_if_fail (data != NULL, WFD_EINVAL);
1159 g_return_val_if_fail (size != 0, WFD_EINVAL);
1161 p = (const gchar *) data;
1168 while (*p != '\n' && *p != '\r' && *p != '\0') {
1169 if (idx < sizeof (buffer) - 1)
1174 wfdconfig_parse_line (msg, buffer);
1185 * wfdconfig_message_dump:
1186 * @msg: a #WFDMessage
1188 * Dump the parsed contents of @msg to stdout.
1190 * Returns: a #WFDResult.
1193 wfdconfig_message_dump (const WFDMessage * msg)
1195 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1196 debug_log("===========WFD Message dump=========");
1198 if(msg->audio_codecs) {
1200 debug_log("Audio supported formats : \n");
1201 for(;i<msg->audio_codecs->count;i++) {
1202 debug_log("Codec: %s\n",msg->audio_codecs->list[i].audio_format);
1203 if(!strcmp(msg->audio_codecs->list[i].audio_format,"LPCM")) {
1204 if(msg->audio_codecs->list[i].modes & WFD_FREQ_44100)
1205 debug_log(" Freq: %d\n", 44100);
1206 if(msg->audio_codecs->list[i].modes & WFD_FREQ_48000)
1207 debug_log(" Freq: %d\n", 48000);
1208 debug_log(" Channels: %d\n", 2);
1210 if(!strcmp(msg->audio_codecs->list[i].audio_format,"AAC")) {
1211 debug_log(" Freq: %d\n", 48000);
1212 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_2)
1213 debug_log(" Channels: %d\n", 2);
1214 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_4)
1215 debug_log(" Channels: %d\n", 4);
1216 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_6)
1217 debug_log(" Channels: %d\n", 6);
1218 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_8)
1219 debug_log(" Channels: %d\n", 8);
1221 if(!strcmp(msg->audio_codecs->list[i].audio_format,"AC3")) {
1222 debug_log(" Freq: %d\n", 48000);
1223 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_2)
1224 debug_log(" Channels: %d\n", 2);
1225 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_4)
1226 debug_log(" Channels: %d\n", 4);
1227 if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_6)
1228 debug_log(" Channels: %d\n", 6);
1230 debug_log(" Bitwidth: %d\n", 16);
1231 debug_log(" Latency: %d\n", msg->audio_codecs->list[i].latency);
1236 if(msg->video_formats) {
1237 debug_log("Video supported formats : \n");
1238 if(msg->video_formats->list) {
1239 debug_log("Codec: H264\n");
1240 guint nativeindex = 0;
1241 if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_CEA_RESOLUTION) {
1242 debug_log (" Native type: CEA\n");
1243 } else if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_VESA_RESOLUTION) {
1244 debug_log (" Native type: VESA\n");
1245 } else if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_HH_RESOLUTION) {
1246 debug_log (" Native type: HH\n");
1248 nativeindex = msg->video_formats->list->native >> 3;
1249 debug_log (" Resolution: %d\n", (1 << nativeindex));
1251 if(msg->video_formats->list->H264_codec.profile & WFD_H264_BASE_PROFILE) {
1252 debug_log (" Profile: BASE\n");
1253 } else if(msg->video_formats->list->H264_codec.profile & WFD_H264_HIGH_PROFILE) {
1254 debug_log (" Profile: HIGH\n");
1255 } if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_1) {
1256 debug_log (" Level: 3.1\n");
1257 } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_2) {
1258 debug_log (" Level: 3.2\n");
1259 } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4) {
1260 debug_log (" Level: 4\n");
1261 } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_1) {
1262 debug_log (" Level: 4.1\n");
1263 } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_2) {
1264 debug_log (" Level: 4.2\n");
1266 debug_log (" Latency: %d\n", msg->video_formats->list->H264_codec.misc_params.latency);
1267 debug_log (" min_slice_size: %x\n", msg->video_formats->list->H264_codec.misc_params.min_slice_size);
1268 debug_log (" slice_enc_params: %x\n", msg->video_formats->list->H264_codec.misc_params.slice_enc_params);
1269 debug_log (" frame_rate_control_support: %x\n", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support);
1270 if(msg->video_formats->list->H264_codec.max_hres) {
1271 debug_log (" Max Height: %04d\n", msg->video_formats->list->H264_codec.max_hres);
1273 if(msg->video_formats->list->H264_codec.max_vres) {
1274 debug_log (" Max Width: %04d\n", msg->video_formats->list->H264_codec.max_vres);
1279 if(msg->video_3d_formats) {
1280 debug_log ("wfd_3d_formats");
1284 if(msg->content_protection) {
1285 debug_log ("wfd_content_protection");
1289 if(msg->display_edid) {
1290 debug_log ("wfd_display_edid");
1294 if(msg->coupled_sink) {
1295 debug_log ("wfd_coupled_sink");
1299 if(msg->trigger_method) {
1300 debug_log (" Trigger type: %s\n", msg->trigger_method->wfd_trigger_method);
1303 if(msg->presentation_url) {
1304 debug_log ("wfd_presentation_URL");
1308 if(msg->client_rtp_ports) {
1309 debug_log(" Client RTP Ports : \n");
1310 if(msg->client_rtp_ports->profile) {
1311 debug_log ("%s\n", msg->client_rtp_ports->profile);
1312 debug_log (" %d\n", msg->client_rtp_ports->rtp_port0);
1313 debug_log (" %d\n", msg->client_rtp_ports->rtp_port1);
1314 debug_log (" %s\n", msg->client_rtp_ports->mode);
1320 debug_log ("wfd_route");
1325 debug_log ("wfd_I2C");
1329 if(msg->av_format_change_timing) {
1330 debug_log ("wfd_av_format_change_timing");
1334 if(msg->preferred_display_mode) {
1335 debug_log ("wfd_preferred_display_mode");
1339 if(msg->uibc_capability) {
1340 debug_log ("wfd_uibc_capability \r\n");
1341 debug_log ("input category list:");
1342 if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC)
1343 debug_log ("GENERIC");
1344 if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC)
1346 if(!msg->uibc_capability->input_category_list.input_cat)
1348 if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) {
1349 debug_log ("generic cap list: ");
1350 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD)
1351 debug_log("keyboard ");
1352 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE)
1353 debug_log("mouse ");
1354 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH)
1355 debug_log("single-touch ");
1356 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH)
1357 debug_log("multi-touch ");
1358 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK)
1359 debug_log("joystick ");
1360 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA)
1361 debug_log("camera ");
1362 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE)
1363 debug_log("gesture ");
1364 if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL)
1365 debug_log("remote control ");
1366 if(!msg->uibc_capability->generic_cap_list.inp_type)
1369 if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) {
1370 debug_log ("hidc cap list:");
1371 if(msg->uibc_capability->hidc_cap_list.cap_count) {
1372 detailed_cap *temp_cap = msg->uibc_capability->hidc_cap_list.next;
1374 if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) {
1375 debug_log("keyboard ");
1376 } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) {
1377 debug_log("mouse ");
1378 } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) {
1379 debug_log("single-touch ");
1380 } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) {
1381 debug_log("multi-touch ");
1382 } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) {
1383 debug_log("joystick ");
1384 } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) {
1385 debug_log("camera ");
1386 } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) {
1387 debug_log("gesture ");
1388 } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) {
1389 debug_log("remote control ");
1390 } else if(!temp_cap->p.inp_type) {
1393 if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_INFRARED) {
1394 debug_log("infrared");
1395 } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_USB) {
1397 } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_BT) {
1398 debug_log("bluetooth");
1399 } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_WIFI) {
1401 } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_ZIGBEE) {
1402 debug_log("Zigbee");
1403 } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_NOSP) {
1405 } else if(!temp_cap->p.inp_path) {
1408 temp_cap = temp_cap->next;
1412 if(msg->uibc_capability->tcp_port)
1413 debug_log("tcp port:%u", msg->uibc_capability->tcp_port);
1414 if(!msg->uibc_capability->tcp_port)
1415 debug_log ("tcp port: none");
1419 if(msg->uibc_setting) {
1420 debug_log ("wfd_uibc_setting: ");
1421 if(msg->uibc_setting->uibc_setting) {
1423 } else debug_log("false");
1427 if(msg->standby_resume_capability) {
1428 debug_log ("wfd_standby_resume_capability");
1433 debug_log ("wfd_standby");
1437 if(msg->connector_type) {
1438 debug_log ("wfd_connector_type");
1442 if(msg->idr_request) {
1443 debug_log ("wfd_idr_request");
1447 debug_log("===============================================\n");
1451 WFDResult wfdconfig_set_supported_audio_format(WFDMessage *msg, WFDAudioFormats aCodec, guint aFreq, guint aChanels,
1452 guint aBitwidth, guint32 aLatency)
1454 guint temp = aCodec;
1456 guint pcm = 0, aac = 0, ac3 = 0;
1458 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1460 if(!msg->audio_codecs)
1461 msg->audio_codecs = g_new0 (WFDAudioCodeclist, 1);
1463 if(aCodec != WFD_AUDIO_UNKNOWN) {
1465 msg->audio_codecs->count++;
1468 msg->audio_codecs->list = g_new0 (WFDAudioCodec, msg->audio_codecs->count);
1469 for(; i<msg->audio_codecs->count; i++) {
1470 if((aCodec & WFD_AUDIO_LPCM) && (!pcm)) {
1471 msg->audio_codecs->list[i].audio_format = g_strdup("LPCM");
1472 msg->audio_codecs->list[i].modes = aFreq;
1473 msg->audio_codecs->list[i].latency = aLatency;
1475 } else if((aCodec & WFD_AUDIO_AAC) && (!aac)) {
1476 msg->audio_codecs->list[i].audio_format = g_strdup("AAC");
1477 msg->audio_codecs->list[i].modes = aChanels;
1478 msg->audio_codecs->list[i].latency = aLatency;
1480 } else if((aCodec & WFD_AUDIO_AC3) && (!ac3)) {
1481 msg->audio_codecs->list[i].audio_format = g_strdup("AC3");
1482 msg->audio_codecs->list[i].modes = aChanels;
1483 msg->audio_codecs->list[i].latency = aLatency;
1491 WFDResult wfdconfig_set_prefered_audio_format(WFDMessage *msg, WFDAudioFormats aCodec, WFDAudioFreq aFreq, WFDAudioChannels aChanels,
1492 guint aBitwidth, guint32 aLatency)
1495 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1497 if(!msg->audio_codecs)
1498 msg->audio_codecs = g_new0 (WFDAudioCodeclist, 1);
1500 msg->audio_codecs->list = g_new0 (WFDAudioCodec, 1);
1501 msg->audio_codecs->count = 1;
1502 if(aCodec == WFD_AUDIO_LPCM) {
1503 msg->audio_codecs->list->audio_format = g_strdup("LPCM");
1504 msg->audio_codecs->list->modes = aFreq;
1505 msg->audio_codecs->list->latency = aLatency;
1506 } else if(aCodec == WFD_AUDIO_AAC) {
1507 msg->audio_codecs->list->audio_format = g_strdup("AAC");
1508 msg->audio_codecs->list->modes = aChanels;
1509 msg->audio_codecs->list->latency = aLatency;
1510 } else if(aCodec == WFD_AUDIO_AC3) {
1511 msg->audio_codecs->list->audio_format = g_strdup("AC3");
1512 msg->audio_codecs->list->modes = aChanels;
1513 msg->audio_codecs->list->latency = aLatency;
1518 WFDResult wfdconfig_get_supported_audio_format(WFDMessage *msg, guint *aCodec, guint *aFreq, guint *aChanels,
1519 guint *aBitwidth, guint32 *aLatency)
1522 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1523 g_return_val_if_fail (msg->audio_codecs != NULL, WFD_EINVAL);
1525 for(; i<msg->audio_codecs->count; i++) {
1526 if(!g_strcmp0(msg->audio_codecs->list[i].audio_format,"LPCM")) {
1527 *aCodec |= WFD_AUDIO_LPCM;
1528 *aFreq |= msg->audio_codecs->list[i].modes;
1529 *aChanels |= WFD_CHANNEL_2;
1531 *aLatency = msg->audio_codecs->list[i].latency;
1532 } else if(!g_strcmp0(msg->audio_codecs->list[i].audio_format,"AAC")) {
1533 *aCodec |= WFD_AUDIO_AAC;
1534 *aFreq |= WFD_FREQ_48000;
1535 *aChanels |= msg->audio_codecs->list[i].modes;
1537 *aLatency = msg->audio_codecs->list[i].latency;
1538 } else if(!g_strcmp0(msg->audio_codecs->list[i].audio_format,"AC3")) {
1539 *aCodec |= WFD_AUDIO_AC3;
1540 *aFreq |= WFD_FREQ_48000;
1541 *aChanels |= msg->audio_codecs->list[i].modes;
1543 *aLatency = msg->audio_codecs->list[i].latency;
1549 WFDResult wfdconfig_get_prefered_audio_format(WFDMessage *msg, WFDAudioFormats *aCodec, WFDAudioFreq *aFreq, WFDAudioChannels *aChanels,
1550 guint *aBitwidth, guint32 *aLatency)
1552 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1554 if(!g_strcmp0(msg->audio_codecs->list->audio_format,"LPCM")) {
1555 *aCodec = WFD_AUDIO_LPCM;
1556 *aFreq = msg->audio_codecs->list->modes;
1557 *aChanels = WFD_CHANNEL_2;
1559 *aLatency = msg->audio_codecs->list->latency;
1560 } else if(!g_strcmp0(msg->audio_codecs->list->audio_format,"AAC")) {
1561 *aCodec = WFD_AUDIO_AAC;
1562 *aFreq = WFD_FREQ_48000;
1563 *aChanels = msg->audio_codecs->list->modes;
1565 *aLatency = msg->audio_codecs->list->latency;
1566 } else if(!g_strcmp0(msg->audio_codecs->list->audio_format,"AC3")) {
1567 *aCodec = WFD_AUDIO_AC3;
1568 *aFreq = WFD_FREQ_48000;
1569 *aChanels = msg->audio_codecs->list->modes;
1571 *aLatency = msg->audio_codecs->list->latency;
1576 WFDResult wfdconfig_set_supported_video_format(WFDMessage *msg, WFDVideoCodecs vCodec,
1577 WFDVideoNativeResolution vNative, guint64 vNativeResolution,
1578 guint64 vCEAResolution, guint64 vVESAResolution, guint64 vHHResolution,
1579 guint vProfile, guint vLevel, guint32 vLatency, guint32 vMaxHeight,
1580 guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control)
1582 guint nativeindex = 0;
1583 guint64 temp = vNativeResolution;
1585 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1587 if(!msg->video_formats)
1588 msg->video_formats = g_new0 (WFDVideoCodeclist, 1);
1590 if(vCodec != WFD_VIDEO_UNKNOWN) {
1591 msg->video_formats->list = g_new0 (WFDVideoCodec, 1);
1597 msg->video_formats->list->native = nativeindex-1;
1598 msg->video_formats->list->native <<= 3;
1600 if(vNative == WFD_VIDEO_VESA_RESOLUTION)
1601 msg->video_formats->list->native |= 1;
1602 else if(vNative == WFD_VIDEO_HH_RESOLUTION)
1603 msg->video_formats->list->native |= 2;
1605 msg->video_formats->list->preferred_display_mode_supported = 1;
1606 msg->video_formats->list->H264_codec.profile = vProfile;
1607 msg->video_formats->list->H264_codec.level = vLevel;
1608 msg->video_formats->list->H264_codec.max_hres = vMaxHeight;
1609 msg->video_formats->list->H264_codec.max_vres = vMaxWidth;
1610 msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution;
1611 msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution;
1612 msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution;
1613 msg->video_formats->list->H264_codec.misc_params.latency = vLatency;
1614 msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size;
1615 msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params;
1616 msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control;
1621 WFDResult wfdconfig_set_prefered_video_format(WFDMessage *msg, WFDVideoCodecs vCodec,
1622 WFDVideoNativeResolution vNative, guint64 vNativeResolution,
1623 WFDVideoCEAResolution vCEAResolution, WFDVideoVESAResolution vVESAResolution,
1624 WFDVideoHHResolution vHHResolution, WFDVideoH264Profile vProfile,
1625 WFDVideoH264Level vLevel, guint32 vLatency, guint32 vMaxHeight,
1626 guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control)
1628 guint nativeindex = 0;
1629 guint64 temp = vNativeResolution;
1631 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1633 if(!msg->video_formats)
1634 msg->video_formats = g_new0 (WFDVideoCodeclist, 1);
1635 msg->video_formats->list = g_new0 (WFDVideoCodec, 1);
1642 if(nativeindex) msg->video_formats->list->native = nativeindex-1;
1643 msg->video_formats->list->native <<= 3;
1645 if(vNative == WFD_VIDEO_VESA_RESOLUTION)
1646 msg->video_formats->list->native |= 1;
1647 else if(vNative == WFD_VIDEO_HH_RESOLUTION)
1648 msg->video_formats->list->native |= 2;
1650 msg->video_formats->list->preferred_display_mode_supported = 0;
1651 msg->video_formats->list->H264_codec.profile = vProfile;
1652 msg->video_formats->list->H264_codec.level = vLevel;
1653 msg->video_formats->list->H264_codec.max_hres = vMaxHeight;
1654 msg->video_formats->list->H264_codec.max_vres = vMaxWidth;
1655 msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution;
1656 msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution;
1657 msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution;
1658 msg->video_formats->list->H264_codec.misc_params.latency = vLatency;
1659 msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size;
1660 msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params;
1661 msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control;
1665 WFDResult wfdconfig_get_supported_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec,
1666 WFDVideoNativeResolution *vNative, guint64 *vNativeResolution,
1667 guint64 *vCEAResolution, guint64 *vVESAResolution, guint64 *vHHResolution,
1668 guint *vProfile, guint *vLevel, guint32 *vLatency, guint32 *vMaxHeight,
1669 guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control)
1671 guint nativeindex = 0;
1673 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1674 g_return_val_if_fail (msg->video_formats != NULL, WFD_EINVAL);
1675 g_return_val_if_fail (msg->video_formats->list != NULL, WFD_EINVAL);
1677 *vCodec = WFD_VIDEO_H264;
1678 *vNative = msg->video_formats->list->native & 0x7;
1679 nativeindex = msg->video_formats->list->native >> 3;
1680 *vNativeResolution = (guint64)1 << nativeindex;
1681 *vProfile = msg->video_formats->list->H264_codec.profile;
1682 *vLevel = msg->video_formats->list->H264_codec.level;
1683 *vMaxHeight = msg->video_formats->list->H264_codec.max_hres;
1684 *vMaxWidth = msg->video_formats->list->H264_codec.max_vres;
1685 *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support;
1686 *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support;
1687 *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support;
1688 *vLatency = msg->video_formats->list->H264_codec.misc_params.latency;
1689 *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size;
1690 *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params;
1691 *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support;
1695 WFDResult wfdconfig_get_prefered_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec,
1696 WFDVideoNativeResolution *vNative, guint64 *vNativeResolution,
1697 WFDVideoCEAResolution *vCEAResolution, WFDVideoVESAResolution *vVESAResolution,
1698 WFDVideoHHResolution *vHHResolution, WFDVideoH264Profile *vProfile,
1699 WFDVideoH264Level *vLevel, guint32 *vLatency, guint32 *vMaxHeight,
1700 guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control)
1702 guint nativeindex = 0;
1703 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1704 g_return_val_if_fail (msg->video_formats != NULL, WFD_EINVAL);
1705 g_return_val_if_fail (msg->video_formats->list != NULL, WFD_EINVAL);
1707 *vCodec = WFD_VIDEO_H264;
1708 *vNative = msg->video_formats->list->native & 0x7;
1709 nativeindex = msg->video_formats->list->native >> 3;
1710 *vNativeResolution = (guint64)1 << nativeindex;
1711 *vProfile = msg->video_formats->list->H264_codec.profile;
1712 *vLevel = msg->video_formats->list->H264_codec.level;
1713 *vMaxHeight = msg->video_formats->list->H264_codec.max_hres;
1714 *vMaxWidth = msg->video_formats->list->H264_codec.max_vres;
1715 *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support;
1716 *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support;
1717 *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support;
1718 *vLatency = msg->video_formats->list->H264_codec.misc_params.latency;
1719 *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size;
1720 *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params;
1721 *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support;
1725 WFDResult wfdconfig_set_contentprotection_type(WFDMessage *msg, WFDHDCPProtection hdcpversion, guint32 TCPPort)
1727 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1729 if(!msg->content_protection) msg->content_protection = g_new0 (WFDContentProtection, 1);
1730 if(hdcpversion == WFD_HDCP_NONE) return WFD_OK;
1731 msg->content_protection->hdcp2_spec = g_new0 (WFDHdcp2Spec, 1);
1732 if(hdcpversion == WFD_HDCP_2_0) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup("HDCP2.0");
1733 else if(hdcpversion == WFD_HDCP_2_1) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup("HDCP2.1");
1735 snprintf(str, 11, "port=%d", TCPPort);
1736 msg->content_protection->hdcp2_spec->TCPPort = g_strdup(str);
1740 WFDResult wfdconfig_get_contentprotection_type(WFDMessage *msg, WFDHDCPProtection *hdcpversion, guint32 *TCPPort)
1742 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1743 if(msg->content_protection && msg->content_protection->hdcp2_spec) {
1744 char *result = NULL;
1746 if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"none")) {
1747 debug_warning("HDCP none");
1748 *hdcpversion = WFD_HDCP_NONE;
1752 if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"HDCP2.0")) *hdcpversion = WFD_HDCP_2_0;
1753 else if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"HDCP2.1")) *hdcpversion = WFD_HDCP_2_1;
1755 debug_warning("Unknown protection type");
1756 *hdcpversion = WFD_HDCP_NONE;
1761 result = strtok_r(msg->content_protection->hdcp2_spec->TCPPort, "=", &ptr);
1762 while (result !=NULL) {
1763 result = strtok_r(NULL, "=", &ptr);
1764 *TCPPort = atoi (result);
1767 } else *hdcpversion = WFD_HDCP_NONE;
1771 WFDResult wfdconfig_set_display_EDID(WFDMessage *msg, gboolean edid_supported, guint32 edid_blockcount, gchar *edid_playload)
1773 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1774 if(!msg->display_edid) msg->display_edid = g_new0 (WFDDisplayEdid, 1);
1775 msg->display_edid->edid_supported = edid_supported;
1776 if(!edid_supported) return WFD_OK;
1777 msg->display_edid->edid_block_count = edid_blockcount;
1778 if(edid_blockcount) {
1779 msg->display_edid->edid_payload = g_malloc(128 * edid_blockcount);
1780 if(!msg->display_edid->edid_payload)
1781 memcpy(msg->display_edid->edid_payload, edid_playload, 128 * edid_blockcount);
1782 } else msg->display_edid->edid_payload = g_strdup("none");
1786 WFDResult wfdconfig_get_display_EDID(WFDMessage *msg, gboolean *edid_supported, guint32 *edid_blockcount, gchar **edid_playload)
1788 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1789 if(msg->display_edid ) {
1790 if(msg->display_edid->edid_supported) {
1791 *edid_blockcount = msg->display_edid->edid_block_count;
1792 if(msg->display_edid->edid_block_count) {
1794 temp = g_malloc(EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
1796 memset(temp, 0, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
1797 memcpy(temp, msg->display_edid->edid_payload, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
1798 *edid_playload = temp;
1799 *edid_supported = TRUE;
1801 } else *edid_playload = g_strdup("none");
1803 } else *edid_supported = FALSE;
1807 WFDResult wfdconfig_set_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus status, gchar *sink_address)
1809 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1810 if(!msg->coupled_sink) msg->coupled_sink = g_new0 (WFDCoupledSink, 1);
1811 if(status == WFD_SINK_UNKNOWN) return WFD_OK;
1812 msg->coupled_sink->coupled_sink_cap = g_new0 (WFDCoupled_sink_cap, 1);
1813 msg->coupled_sink->coupled_sink_cap->status = status;
1814 msg->coupled_sink->coupled_sink_cap->sink_address = g_strdup(sink_address);
1818 WFDResult wfdconfig_get_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus *status, gchar **sink_address)
1820 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1821 if(msg->coupled_sink && msg->coupled_sink->coupled_sink_cap) {
1822 *status = msg->coupled_sink->coupled_sink_cap->status;
1823 *sink_address = g_strdup(msg->coupled_sink->coupled_sink_cap->sink_address);
1824 } else *status = WFD_SINK_UNKNOWN;
1828 WFDResult wfdconfig_set_trigger_type(WFDMessage *msg, WFDTrigger trigger)
1830 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1832 if(!msg->trigger_method)
1833 msg->trigger_method = g_new0 (WFDTriggerMethod, 1);
1834 if(trigger == WFD_TRIGGER_SETUP)
1835 msg->trigger_method->wfd_trigger_method = g_strdup("SETUP");
1836 else if(trigger == WFD_TRIGGER_PAUSE)
1837 msg->trigger_method->wfd_trigger_method = g_strdup("PAUSE");
1838 else if(trigger == WFD_TRIGGER_TEARDOWN)
1839 msg->trigger_method->wfd_trigger_method = g_strdup("TEARDOWN");
1840 else if(trigger == WFD_TRIGGER_PLAY)
1841 msg->trigger_method->wfd_trigger_method = g_strdup("PLAY");
1847 WFDResult wfdconfig_get_trigger_type(WFDMessage *msg, WFDTrigger *trigger)
1849 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1850 if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "SETUP"))
1851 *trigger = WFD_TRIGGER_SETUP;
1852 else if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "PAUSE"))
1853 *trigger = WFD_TRIGGER_PAUSE;
1854 else if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "TEARDOWN"))
1855 *trigger = WFD_TRIGGER_TEARDOWN;
1856 else if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "PLAY"))
1857 *trigger = WFD_TRIGGER_PLAY;
1859 *trigger = WFD_TRIGGER_UNKNOWN;
1865 WFDResult wfdconfig_set_presentation_url(WFDMessage *msg, gchar *wfd_url0, gchar *wfd_url1)
1867 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1868 if(!msg->presentation_url) msg->presentation_url = g_new0 (WFDPresentationUrl, 1);
1869 if(wfd_url0) msg->presentation_url->wfd_url0 = g_strdup(wfd_url0);
1870 if(wfd_url1) msg->presentation_url->wfd_url1 = g_strdup(wfd_url1);
1874 WFDResult wfdconfig_get_presentation_url(WFDMessage *msg, gchar **wfd_url0, gchar **wfd_url1)
1876 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1877 if(msg->presentation_url) {
1878 *wfd_url0 = g_strdup(msg->presentation_url->wfd_url0);
1879 *wfd_url1 = g_strdup(msg->presentation_url->wfd_url1);
1884 WFDResult wfdconfig_set_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode trans, WFDRTSPProfile profile,
1885 WFDRTSPLowerTrans lowertrans, guint32 rtp_port0, guint32 rtp_port1)
1888 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1890 if(!msg->client_rtp_ports)
1891 msg->client_rtp_ports = g_new0 (WFDClientRtpPorts, 1);
1893 if(trans != WFD_RTSP_TRANS_UNKNOWN) {
1894 lines = g_string_new ("");
1895 if(trans == WFD_RTSP_TRANS_RTP) g_string_append_printf (lines,"RTP");
1896 else if(trans == WFD_RTSP_TRANS_RDT) g_string_append_printf (lines,"RDT");
1898 if(profile == WFD_RTSP_PROFILE_AVP) g_string_append_printf (lines,"/AVP");
1899 else if(profile == WFD_RTSP_PROFILE_SAVP) g_string_append_printf (lines,"/SAVP");
1901 if(lowertrans == WFD_RTSP_LOWER_TRANS_UDP) g_string_append_printf (lines,"/UDP;unicast");
1902 else if(lowertrans == WFD_RTSP_LOWER_TRANS_UDP_MCAST) g_string_append_printf (lines,"/UDP;multicast");
1903 else if(lowertrans == WFD_RTSP_LOWER_TRANS_TCP) g_string_append_printf (lines,"/TCP;unicast");
1904 else if(lowertrans == WFD_RTSP_LOWER_TRANS_HTTP) g_string_append_printf (lines,"/HTTP");
1906 msg->client_rtp_ports->profile = g_string_free (lines, FALSE);
1907 msg->client_rtp_ports->rtp_port0 = rtp_port0;
1908 msg->client_rtp_ports->rtp_port1 = rtp_port1;
1909 msg->client_rtp_ports->mode = g_strdup("mode=play");
1914 WFDResult wfdconfig_get_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode *trans, WFDRTSPProfile *profile,
1915 WFDRTSPLowerTrans *lowertrans, guint32 *rtp_port0, guint32 *rtp_port1)
1917 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1918 g_return_val_if_fail (msg->client_rtp_ports != NULL, WFD_EINVAL);
1920 if(g_strrstr(msg->client_rtp_ports->profile, "RTP")) *trans = WFD_RTSP_TRANS_RTP;
1921 if(g_strrstr(msg->client_rtp_ports->profile, "RDT")) *trans = WFD_RTSP_TRANS_RDT;
1922 if(g_strrstr(msg->client_rtp_ports->profile, "AVP")) *profile = WFD_RTSP_PROFILE_AVP;
1923 if(g_strrstr(msg->client_rtp_ports->profile, "SAVP")) *profile = WFD_RTSP_PROFILE_SAVP;
1924 if(g_strrstr(msg->client_rtp_ports->profile, "UDP;unicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP;
1925 if(g_strrstr(msg->client_rtp_ports->profile, "UDP;multicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP_MCAST;
1926 if(g_strrstr(msg->client_rtp_ports->profile, "TCP;unicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_TCP;
1927 if(g_strrstr(msg->client_rtp_ports->profile, "HTTP")) *lowertrans = WFD_RTSP_LOWER_TRANS_HTTP;
1929 *rtp_port0 = msg->client_rtp_ports->rtp_port0;
1930 *rtp_port1 = msg->client_rtp_ports->rtp_port1;
1935 WFDResult wfdconfig_set_audio_sink_type(WFDMessage *msg, WFDSinkType sinktype)
1937 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1938 if(!msg->route) msg->route = g_new0 (WFDRoute, 1);
1939 if(sinktype == WFD_PRIMARY_SINK) msg->route->destination = g_strdup("primary");
1940 else if(sinktype == WFD_SECONDARY_SINK) msg->route->destination = g_strdup("secondary");
1944 WFDResult wfdconfig_get_audio_sink_type(WFDMessage *msg, WFDSinkType *sinktype)
1946 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1948 if(!g_strcmp0(msg->route->destination,"primary")) *sinktype = WFD_PRIMARY_SINK;
1949 else if(!g_strcmp0(msg->route->destination,"secondary")) *sinktype = WFD_SECONDARY_SINK;
1954 WFDResult wfdconfig_set_I2C_port(WFDMessage *msg, gboolean i2csupport, guint32 i2cport)
1956 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1957 if(!msg->I2C) msg->I2C = g_new0 (WFDI2C, 1);
1958 msg->I2C->I2CPresent = i2csupport;
1959 msg->I2C->I2C_port = i2cport;
1963 WFDResult wfdconfig_get_I2C_port(WFDMessage *msg, gboolean *i2csupport, guint32 *i2cport)
1965 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1966 if(msg->I2C && msg->I2C->I2CPresent) {
1967 *i2csupport = msg->I2C->I2CPresent;
1968 *i2cport = msg->I2C->I2C_port;
1969 } else *i2csupport = FALSE;
1973 WFDResult wfdconfig_set_av_format_change_timing(WFDMessage *msg, guint64 PTS, guint64 DTS)
1975 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1976 if(!msg->av_format_change_timing) msg->av_format_change_timing = g_new0 (WFDAVFormatChangeTiming, 1);
1977 msg->av_format_change_timing->PTS = PTS;
1978 msg->av_format_change_timing->DTS = DTS;
1982 WFDResult wfdconfig_get_av_format_change_timing(WFDMessage *msg, guint64 *PTS, guint64 *DTS)
1984 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1985 if(msg->av_format_change_timing) {
1986 *PTS = msg->av_format_change_timing->PTS;
1987 *DTS = msg->av_format_change_timing->DTS;
1992 WFDResult wfdconfig_set_uibc_capability(WFDMessage *msg, guint32 input_category, guint32 inp_type, WFDHIDCTypePathPair *inp_pair,
1993 guint32 inp_type_path_count, guint32 tcp_port)
1995 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
1996 if(!msg->uibc_capability) msg->uibc_capability = g_new0 (WFDUibcCapability, 1);
1997 msg->uibc_capability->uibcsupported = TRUE;
1998 msg->uibc_capability->input_category_list.input_cat = input_category;
1999 msg->uibc_capability->generic_cap_list.inp_type = inp_type;
2000 msg->uibc_capability->hidc_cap_list.cap_count = inp_type_path_count;
2001 if(msg->uibc_capability->hidc_cap_list.cap_count) {
2002 detailed_cap *temp_cap;
2004 msg->uibc_capability->hidc_cap_list.next = g_new0 (detailed_cap, 1);
2005 temp_cap = msg->uibc_capability->hidc_cap_list.next;
2006 for(;i<inp_type_path_count;) {
2007 temp_cap->p.inp_type = inp_pair[i].inp_type;
2008 temp_cap->p.inp_path = inp_pair[i].inp_path;
2010 if(i<inp_type_path_count) {
2011 temp_cap->next = g_new0 (detailed_cap, 1);
2012 temp_cap = temp_cap->next;
2016 msg->uibc_capability->tcp_port = tcp_port;
2020 WFDResult wfdconfig_get_uibc_capability(WFDMessage *msg, guint32 *input_category, guint32 *inp_type, WFDHIDCTypePathPair **inp_pair,
2021 guint32 *inp_type_path_count, guint32 *tcp_port)
2023 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2024 if(msg->uibc_capability && msg->uibc_capability->uibcsupported) {
2025 *input_category = msg->uibc_capability->input_category_list.input_cat;
2026 *inp_type = msg->uibc_capability->generic_cap_list.inp_type;
2027 *inp_type_path_count = msg->uibc_capability->hidc_cap_list.cap_count;
2028 if(msg->uibc_capability->hidc_cap_list.cap_count) {
2029 detailed_cap *temp_cap;
2031 *inp_pair = g_new0 (WFDHIDCTypePathPair, msg->uibc_capability->hidc_cap_list.cap_count);
2032 temp_cap = msg->uibc_capability->hidc_cap_list.next;
2034 (*(inp_pair))[i].inp_type = temp_cap->p.inp_type;
2035 (*(inp_pair))[i].inp_path = temp_cap->p.inp_path;
2036 temp_cap = temp_cap->next;
2040 *tcp_port = msg->uibc_capability->tcp_port;
2045 WFDResult wfdconfig_set_uibc_status(WFDMessage *msg, gboolean uibc_enable)
2047 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2048 if(!msg->uibc_setting) msg->uibc_setting = g_new0 (WFDUibcSetting, 1);
2049 msg->uibc_setting->uibc_setting = uibc_enable;
2053 WFDResult wfdconfig_get_uibc_status(WFDMessage *msg, gboolean *uibc_enable)
2055 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2056 if(msg->uibc_setting) *uibc_enable = msg->uibc_setting->uibc_setting;
2059 #ifdef STANDBY_RESUME_CAPABILITY
2060 WFDResult wfdconfig_set_standby_resume_capability(WFDMessage *msg, gboolean supported)
2062 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2063 if(!msg->standby_resume_capability) msg->standby_resume_capability = g_new0 (WFDStandbyResumeCapability, 1);
2064 msg->standby_resume_capability->standby_resume_cap = supported;
2068 WFDResult wfdconfig_get_standby_resume_capability(WFDMessage *msg, gboolean *supported)
2070 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2071 if(msg->standby_resume_capability) *supported = msg->standby_resume_capability->standby_resume_cap;
2075 WFDResult wfdconfig_set_standby(WFDMessage *msg, gboolean standby_enable)
2077 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2078 if(!msg->standby) msg->standby = g_new0 (WFDStandby, 1);
2079 msg->standby->wfd_standby = standby_enable;
2083 WFDResult wfdconfig_get_standby(WFDMessage *msg, gboolean *standby_enable)
2085 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2086 if(msg->standby) *standby_enable = msg->standby->wfd_standby;
2090 WFDResult wfdconfig_set_connector_type(WFDMessage *msg, WFDConnector connector)
2092 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2093 if(!msg->connector_type) msg->connector_type = g_new0 (WFDConnectorType, 1);
2094 msg->connector_type->connector_type = connector;
2098 WFDResult wfdconfig_get_connector_type(WFDMessage *msg, WFDConnector *connector)
2100 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2101 if(msg->connector_type) *connector = msg->connector_type->connector_type;
2105 WFDResult wfdconfig_set_idr_request(WFDMessage *msg)
2107 g_return_val_if_fail (msg != NULL, WFD_EINVAL);
2108 if(!msg->idr_request) msg->idr_request = g_new0 (WFDIdrRequest, 1);
2109 msg->idr_request->idr_request = TRUE;