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"
36 #include "mm_wfd_common_private.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
55 * wfdconfig_message_new:
56 * @msg: pointer to new #WFDMessage
58 * Allocate a new WFDMessage and store the result in @msg.
60 * Returns: a #WFDResult.
63 wfdconfig_message_new(WFDMessage **msg)
67 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
69 newmsg = g_new0(WFDMessage, 1);
73 return wfdconfig_message_init(newmsg);
77 * wfdconfig_message_init:
80 * Initialize @msg so that its contents are as if it was freshly allocated
81 * with wfdconfig_message_new(). This function is mostly used to initialize a message
82 * allocated on the stack. wfdconfig_message_uninit() undoes this operation.
84 * When this function is invoked on newly allocated data(with malloc or on the
85 * stack), its contents should be set to 0 before calling this function.
87 * Returns: a #WFDResult.
90 wfdconfig_message_init(WFDMessage *msg)
92 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
98 * wfdconfig_message_uninit:
101 * Free all resources allocated in @msg. @msg should not be used anymore after
102 * this function. This function should be used when @msg was allocated on the
103 * stack and initialized with wfdconfig_message_init().
105 * Returns: a #WFDResult.
108 wfdconfig_message_uninit(WFDMessage *msg)
110 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
112 if (msg->audio_codecs) {
114 if (msg->audio_codecs->list) {
115 for (; i < msg->audio_codecs->count; i++) {
116 FREE_STRING(msg->audio_codecs->list[i].audio_format);
117 msg->audio_codecs->list[i].modes = 0;
118 msg->audio_codecs->list[i].latency = 0;
120 FREE_STRING(msg->audio_codecs->list);
122 FREE_STRING(msg->audio_codecs);
125 if (msg->video_formats) {
126 FREE_STRING(msg->video_formats->list);
127 FREE_STRING(msg->video_formats);
130 if (msg->video_3d_formats) {
131 FREE_STRING(msg->video_3d_formats->list);
132 FREE_STRING(msg->video_3d_formats);
135 if (msg->content_protection) {
136 if (msg->content_protection->hdcp2_spec) {
137 FREE_STRING(msg->content_protection->hdcp2_spec->hdcpversion);
138 FREE_STRING(msg->content_protection->hdcp2_spec->TCPPort);
139 FREE_STRING(msg->content_protection->hdcp2_spec);
141 FREE_STRING(msg->content_protection);
144 if (msg->display_edid) {
145 if (msg->display_edid->edid_payload)
146 FREE_STRING(msg->display_edid->edid_payload);
147 FREE_STRING(msg->display_edid);
150 if (msg->coupled_sink) {
151 if (msg->coupled_sink->coupled_sink_cap) {
152 FREE_STRING(msg->coupled_sink->coupled_sink_cap->sink_address);
153 FREE_STRING(msg->coupled_sink->coupled_sink_cap);
155 FREE_STRING(msg->coupled_sink);
158 if (msg->trigger_method) {
159 FREE_STRING(msg->trigger_method->wfd_trigger_method);
160 FREE_STRING(msg->trigger_method);
163 if (msg->presentation_url) {
164 FREE_STRING(msg->presentation_url->wfd_url0);
165 FREE_STRING(msg->presentation_url->wfd_url1);
166 FREE_STRING(msg->presentation_url);
169 if (msg->client_rtp_ports) {
170 FREE_STRING(msg->client_rtp_ports->profile);
171 FREE_STRING(msg->client_rtp_ports->mode);
172 FREE_STRING(msg->client_rtp_ports);
176 FREE_STRING(msg->route->destination);
177 FREE_STRING(msg->route);
181 FREE_STRING(msg->I2C);
184 if (msg->av_format_change_timing) {
185 FREE_STRING(msg->av_format_change_timing);
188 if (msg->preferred_display_mode) {
189 FREE_STRING(msg->preferred_display_mode);
192 if (msg->uibc_capability) {
193 if (msg->uibc_capability->hidc_cap_list.next) {
194 detailed_cap *list = msg->uibc_capability->hidc_cap_list.next;
195 detailed_cap *temp = NULL;
202 FREE_STRING(msg->uibc_capability);
205 if (msg->uibc_setting) {
206 FREE_STRING(msg->uibc_setting);
209 if (msg->standby_resume_capability) {
210 FREE_STRING(msg->standby_resume_capability);
214 FREE_STRING(msg->standby);
217 if (msg->connector_type) {
218 FREE_STRING(msg->connector_type);
221 if (msg->idr_request) {
222 FREE_STRING(msg->idr_request);
229 * wfdconfig_message_free:
230 * @msg: a #WFDMessage
232 * Free all resources allocated by @msg. @msg should not be used anymore after
233 * this function. This function should be used when @msg was dynamically
234 * allocated with wfdconfig_message_new().
236 * Returns: a #WFDResult.
239 wfdconfig_message_free(WFDMessage *msg)
241 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
243 wfdconfig_message_uninit(msg);
250 * wfdconfig_message_as_text:
251 * @msg: a #WFDMessage
253 * Convert the contents of @msg to a text string.
255 * Returns: A dynamically allocated string representing the WFD description.
258 wfdconfig_message_as_text(const WFDMessage *msg)
260 /* change all vars so they match rfc? */
262 g_return_val_if_fail(msg != NULL, NULL);
264 lines = g_string_new("");
266 /* list of audio codecs */
267 if (msg->audio_codecs) {
269 g_string_append_printf(lines, STRING_WFD_AUDIO_CODECS);
270 if (msg->audio_codecs->list) {
271 g_string_append_printf(lines, ":");
272 for (; i < msg->audio_codecs->count; i++) {
273 g_string_append_printf(lines, " %s", msg->audio_codecs->list[i].audio_format);
274 g_string_append_printf(lines, " %08x", msg->audio_codecs->list[i].modes);
275 g_string_append_printf(lines, " %02x", msg->audio_codecs->list[i].latency);
276 if ((i + 1) < msg->audio_codecs->count)
277 g_string_append_printf(lines, ",");
280 g_string_append_printf(lines, STRING_WFD_CRLF);
283 /* list of video codecs */
284 if (msg->video_formats) {
285 g_string_append_printf(lines, STRING_WFD_VIDEO_FORMATS);
286 if (msg->video_formats->list) {
287 g_string_append_printf(lines, ":");
288 g_string_append_printf(lines, " %02x", msg->video_formats->list->native);
289 g_string_append_printf(lines, " %02x", msg->video_formats->list->preferred_display_mode_supported);
290 g_string_append_printf(lines, " %02x", msg->video_formats->list->H264_codec.profile);
291 g_string_append_printf(lines, " %02x", msg->video_formats->list->H264_codec.level);
292 g_string_append_printf(lines, " %08x", msg->video_formats->list->H264_codec.misc_params.CEA_Support);
293 g_string_append_printf(lines, " %08x", msg->video_formats->list->H264_codec.misc_params.VESA_Support);
294 g_string_append_printf(lines, " %08x", msg->video_formats->list->H264_codec.misc_params.HH_Support);
295 g_string_append_printf(lines, " %02x", msg->video_formats->list->H264_codec.misc_params.latency);
296 g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.misc_params.min_slice_size);
297 g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.misc_params.slice_enc_params);
298 g_string_append_printf(lines, " %02x", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support);
300 if (msg->video_formats->list->H264_codec.max_hres) {
301 g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.max_hres);
303 g_string_append_printf(lines, STRING_WFD_SPACE);
304 g_string_append_printf(lines, STRING_WFD_NONE);
306 if (msg->video_formats->list->H264_codec.max_vres) {
307 g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.max_vres);
309 g_string_append_printf(lines, STRING_WFD_SPACE);
310 g_string_append_printf(lines, STRING_WFD_NONE);
313 g_string_append_printf(lines, STRING_WFD_CRLF);
316 /* list of video 3D codecs */
317 if (msg->video_3d_formats) {
318 g_string_append_printf(lines, STRING_WFD_3D_VIDEO_FORMATS);
319 g_string_append_printf(lines, ":");
320 if (msg->video_3d_formats->list) {
321 g_string_append_printf(lines, " %02x", msg->video_3d_formats->list->native);
322 g_string_append_printf(lines, " %02x", msg->video_3d_formats->list->preferred_display_mode_supported);
323 g_string_append_printf(lines, " %02x", msg->video_3d_formats->list->H264_codec.profile);
324 g_string_append_printf(lines, " %02x", msg->video_3d_formats->list->H264_codec.level);
325 g_string_append_printf(lines, " %016llx", msg->video_3d_formats->list->H264_codec.misc_params.video_3d_capability);
326 g_string_append_printf(lines, " %02x", msg->video_3d_formats->list->H264_codec.misc_params.latency);
327 g_string_append_printf(lines, " %04x", msg->video_3d_formats->list->H264_codec.misc_params.min_slice_size);
328 g_string_append_printf(lines, " %04x", msg->video_3d_formats->list->H264_codec.misc_params.slice_enc_params);
329 g_string_append_printf(lines, " %02x", msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support);
330 if (msg->video_3d_formats->list->H264_codec.max_hres) {
331 g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.max_hres);
333 g_string_append_printf(lines, STRING_WFD_SPACE);
334 g_string_append_printf(lines, STRING_WFD_NONE);
337 if (msg->video_3d_formats->list->H264_codec.max_vres) {
338 g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.max_vres);
340 g_string_append_printf(lines, STRING_WFD_SPACE);
341 g_string_append_printf(lines, STRING_WFD_NONE);
344 g_string_append_printf(lines, STRING_WFD_SPACE);
345 g_string_append_printf(lines, STRING_WFD_NONE);
347 g_string_append_printf(lines, STRING_WFD_CRLF);
350 if (msg->content_protection) {
351 g_string_append_printf(lines, STRING_WFD_CONTENT_PROTECTION);
352 g_string_append_printf(lines, ":");
353 if (msg->content_protection->hdcp2_spec) {
354 if (msg->content_protection->hdcp2_spec->hdcpversion) {
355 g_string_append_printf(lines, " %s", msg->content_protection->hdcp2_spec->hdcpversion);
356 g_string_append_printf(lines, " %s", msg->content_protection->hdcp2_spec->TCPPort);
358 g_string_append_printf(lines, STRING_WFD_SPACE);
359 g_string_append_printf(lines, STRING_WFD_NONE);
362 g_string_append_printf(lines, STRING_WFD_SPACE);
363 g_string_append_printf(lines, STRING_WFD_NONE);
365 g_string_append_printf(lines, STRING_WFD_CRLF);
368 if (msg->display_edid) {
369 g_string_append_printf(lines, STRING_WFD_DISPLAY_EDID);
370 g_string_append_printf(lines, ":");
371 if (msg->display_edid->edid_supported) {
372 g_string_append_printf(lines, " %d", msg->display_edid->edid_supported);
373 if (msg->display_edid->edid_block_count) {
374 g_string_append_printf(lines, " %d", msg->display_edid->edid_block_count);
376 g_string_append_printf(lines, STRING_WFD_SPACE);
377 g_string_append_printf(lines, STRING_WFD_NONE);
380 g_string_append_printf(lines, STRING_WFD_SPACE);
381 g_string_append_printf(lines, STRING_WFD_NONE);
383 g_string_append_printf(lines, STRING_WFD_CRLF);
386 if (msg->coupled_sink) {
387 g_string_append_printf(lines, STRING_WFD_COUPLED_SINK);
388 g_string_append_printf(lines, ":");
389 if (msg->coupled_sink->coupled_sink_cap) {
390 g_string_append_printf(lines, " %02x", msg->coupled_sink->coupled_sink_cap->status);
391 if (msg->coupled_sink->coupled_sink_cap->sink_address) {
392 g_string_append_printf(lines, " %s", msg->coupled_sink->coupled_sink_cap->sink_address);
394 g_string_append_printf(lines, STRING_WFD_SPACE);
395 g_string_append_printf(lines, STRING_WFD_NONE);
398 g_string_append_printf(lines, STRING_WFD_SPACE);
399 g_string_append_printf(lines, STRING_WFD_NONE);
401 g_string_append_printf(lines, STRING_WFD_CRLF);
404 if (msg->trigger_method) {
405 g_string_append_printf(lines, STRING_WFD_TRIGGER_METHOD);
406 g_string_append_printf(lines, ":");
407 g_string_append_printf(lines, " %s", msg->trigger_method->wfd_trigger_method);
408 g_string_append_printf(lines, STRING_WFD_CRLF);
411 if (msg->presentation_url) {
412 g_string_append_printf(lines, STRING_WFD_PRESENTATION_URL);
413 g_string_append_printf(lines, ":");
414 if (msg->presentation_url->wfd_url0) {
415 g_string_append_printf(lines, " %s", msg->presentation_url->wfd_url0);
417 g_string_append_printf(lines, STRING_WFD_SPACE);
418 g_string_append_printf(lines, STRING_WFD_NONE);
420 if (msg->presentation_url->wfd_url1) {
421 g_string_append_printf(lines, " %s", msg->presentation_url->wfd_url1);
423 g_string_append_printf(lines, STRING_WFD_SPACE);
424 g_string_append_printf(lines, STRING_WFD_NONE);
426 g_string_append_printf(lines, STRING_WFD_CRLF);
429 if (msg->client_rtp_ports) {
430 g_string_append_printf(lines, STRING_WFD_CLIENT_RTP_PORTS);
431 if (msg->client_rtp_ports->profile) {
432 g_string_append_printf(lines, ":");
433 g_string_append_printf(lines, " %s", msg->client_rtp_ports->profile);
434 g_string_append_printf(lines, " %d", msg->client_rtp_ports->rtp_port0);
435 g_string_append_printf(lines, " %d", msg->client_rtp_ports->rtp_port1);
436 g_string_append_printf(lines, " %s", msg->client_rtp_ports->mode);
438 g_string_append_printf(lines, STRING_WFD_CRLF);
442 g_string_append_printf(lines, STRING_WFD_ROUTE);
443 g_string_append_printf(lines, ":");
444 g_string_append_printf(lines, " %s", msg->route->destination);
445 g_string_append_printf(lines, STRING_WFD_CRLF);
449 g_string_append_printf(lines, STRING_WFD_I2C);
450 g_string_append_printf(lines, ":");
451 g_string_append_printf(lines, STRING_WFD_SPACE);
452 if (msg->I2C->I2CPresent) {
453 g_string_append_printf(lines, "%x", msg->I2C->I2C_port);
455 g_string_append_printf(lines, STRING_WFD_NONE);
457 g_string_append_printf(lines, STRING_WFD_CRLF);
460 if (msg->av_format_change_timing) {
461 g_string_append_printf(lines, STRING_WFD_AV_FORMAT_CHANGE_TIMING);
462 g_string_append_printf(lines, ":");
463 g_string_append_printf(lines, " %010llx", msg->av_format_change_timing->PTS);
464 g_string_append_printf(lines, " %010llx", msg->av_format_change_timing->DTS);
465 g_string_append_printf(lines, STRING_WFD_CRLF);
468 if (msg->preferred_display_mode) {
469 g_string_append_printf(lines, STRING_WFD_PREFERRED_DISPLAY_MODE);
470 g_string_append_printf(lines, ":");
471 if (msg->preferred_display_mode->displaymodesupported) {
472 g_string_append_printf(lines, " %06llx", msg->preferred_display_mode->p_clock);
473 g_string_append_printf(lines, " %04x", msg->preferred_display_mode->H);
474 g_string_append_printf(lines, " %04x", msg->preferred_display_mode->HB);
475 g_string_append_printf(lines, " %04x", msg->preferred_display_mode->HSPOL_HSOFF);
476 g_string_append_printf(lines, " %04x", msg->preferred_display_mode->HSW);
477 g_string_append_printf(lines, " %04x", msg->preferred_display_mode->V);
478 g_string_append_printf(lines, " %04x", msg->preferred_display_mode->VB);
479 g_string_append_printf(lines, " %04x", msg->preferred_display_mode->VSPOL_VSOFF);
480 g_string_append_printf(lines, " %04x", msg->preferred_display_mode->VSW);
481 g_string_append_printf(lines, " %02x", msg->preferred_display_mode->VBS3D);
482 g_string_append_printf(lines, " %02x", msg->preferred_display_mode->V2d_s3d_modes);
483 g_string_append_printf(lines, " %02x", msg->preferred_display_mode->P_depth);
485 g_string_append_printf(lines, STRING_WFD_SPACE);
486 g_string_append_printf(lines, STRING_WFD_NONE);
488 g_string_append_printf(lines, STRING_WFD_CRLF);
491 if (msg->uibc_capability) {
492 g_string_append_printf(lines, STRING_WFD_UIBC_CAPABILITY);
493 g_string_append_printf(lines, ":");
494 if (msg->uibc_capability->uibcsupported) {
495 g_string_append_printf(lines, STRING_WFD_SPACE);
496 g_string_append_printf(lines, STRING_WFD_INPUT_CATEGORY_LIST);
497 g_string_append_printf(lines, "=");
498 if (msg->uibc_capability->input_category_list.input_cat) {
500 if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) {
501 tempcap |= WFD_UIBC_INPUT_CAT_GENERIC;
502 g_string_append_printf(lines, STRING_WFD_GENERIC);
503 if (msg->uibc_capability->input_category_list.input_cat != tempcap) {
504 g_string_append_printf(lines, ", ");
507 if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) {
508 tempcap |= WFD_UIBC_INPUT_CAT_HIDC;
509 g_string_append_printf(lines, STRING_WFD_HIDC);
510 if (msg->uibc_capability->input_category_list.input_cat != tempcap) {
511 g_string_append_printf(lines, ", ");
515 g_string_append_printf(lines, STRING_WFD_NONE);
517 g_string_append_printf(lines, ";");
518 g_string_append_printf(lines, STRING_WFD_SPACE);
519 g_string_append_printf(lines, STRING_WFD_GENERIC_CAP_LIST);
520 g_string_append_printf(lines, "=");
521 if (msg->uibc_capability->generic_cap_list.inp_type) {
523 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) {
524 tempcap |= WFD_UIBC_INPUT_TYPE_KEYBOARD;
525 g_string_append_printf(lines, STRING_WFD_KEYBOARD);
526 if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", ");
528 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) {
529 tempcap |= WFD_UIBC_INPUT_TYPE_MOUSE;
530 g_string_append_printf(lines, STRING_WFD_MOUSE);
531 if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", ");
533 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) {
534 tempcap |= WFD_UIBC_INPUT_TYPE_SINGLETOUCH;
535 g_string_append_printf(lines, STRING_WFD_SINGLE_TOUCH);
536 if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", ");
538 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) {
539 tempcap |= WFD_UIBC_INPUT_TYPE_MULTITOUCH;
540 g_string_append_printf(lines, STRING_WFD_MULTI_TOUCH);
541 if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", ");
543 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) {
544 tempcap |= WFD_UIBC_INPUT_TYPE_JOYSTICK;
545 g_string_append_printf(lines, STRING_WFD_JOYSTICK);
546 if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", ");
548 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) {
549 tempcap |= WFD_UIBC_INPUT_TYPE_CAMERA;
550 g_string_append_printf(lines, STRING_WFD_CAMERA);
551 if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", ");
553 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) {
554 tempcap |= WFD_UIBC_INPUT_TYPE_GESTURE;
555 g_string_append_printf(lines, STRING_WFD_GESTURE);
556 if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", ");
558 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) {
559 tempcap |= WFD_UIBC_INPUT_TYPE_REMOTECONTROL;
560 g_string_append_printf(lines, STRING_WFD_REMOTE_CONTROL);
561 if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", ");
564 g_string_append_printf(lines, STRING_WFD_NONE);
566 g_string_append_printf(lines, ";");
567 g_string_append_printf(lines, STRING_WFD_SPACE);
568 g_string_append_printf(lines, STRING_WFD_HIDC_CAP_LIST);
569 g_string_append_printf(lines, "=");
570 if (msg->uibc_capability->hidc_cap_list.cap_count) {
571 detailed_cap *temp_cap = msg->uibc_capability->hidc_cap_list.next;
573 if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_KEYBOARD) g_string_append_printf(lines, STRING_WFD_KEYBOARD);
574 else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_MOUSE) g_string_append_printf(lines, STRING_WFD_MOUSE);
575 else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_SINGLETOUCH) g_string_append_printf(lines, STRING_WFD_SINGLE_TOUCH);
576 else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_MULTITOUCH) g_string_append_printf(lines, STRING_WFD_MULTI_TOUCH);
577 else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_JOYSTICK) g_string_append_printf(lines, STRING_WFD_JOYSTICK);
578 else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_CAMERA) g_string_append_printf(lines, STRING_WFD_CAMERA);
579 else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_GESTURE) g_string_append_printf(lines, STRING_WFD_GESTURE);
580 else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_REMOTECONTROL) g_string_append_printf(lines, STRING_WFD_REMOTE_CONTROL);
581 g_string_append_printf(lines, "/");
582 if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_INFRARED) g_string_append_printf(lines, STRING_WFD_INFRARED);
583 else if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_USB) g_string_append_printf(lines, STRING_WFD_USB);
584 else if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_BT) g_string_append_printf(lines, STRING_WFD_BT);
585 else if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_ZIGBEE) g_string_append_printf(lines, STRING_WFD_ZIGBEE);
586 else if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_WIFI) g_string_append_printf(lines, STRING_WFD_WIFI);
587 else if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_NOSP) g_string_append_printf(lines, STRING_WFD_NO_SP);
588 temp_cap = temp_cap->next;
589 if (temp_cap) g_string_append_printf(lines, ", ");
592 g_string_append_printf(lines, STRING_WFD_NONE);
594 g_string_append_printf(lines, ";");
595 if (msg->uibc_capability->tcp_port) {
596 g_string_append_printf(lines, STRING_WFD_PORT);
597 g_string_append_printf(lines, "=%u", msg->uibc_capability->tcp_port);
599 g_string_append_printf(lines, STRING_WFD_PORT);
600 g_string_append_printf(lines, "=");
601 g_string_append_printf(lines, STRING_WFD_NONE);
604 g_string_append_printf(lines, STRING_WFD_SPACE);
605 g_string_append_printf(lines, STRING_WFD_NONE);
607 g_string_append_printf(lines, STRING_WFD_CRLF);
610 if (msg->uibc_setting) {
611 g_string_append_printf(lines, STRING_WFD_UIBC_SETTING);
612 g_string_append_printf(lines, ":");
613 g_string_append_printf(lines, STRING_WFD_SPACE);
614 if (msg->uibc_setting->uibc_setting)
615 g_string_append_printf(lines, STRING_WFD_ENABLE);
617 g_string_append_printf(lines, STRING_WFD_DISABLE);
618 g_string_append_printf(lines, STRING_WFD_CRLF);
621 if (msg->standby_resume_capability) {
622 g_string_append_printf(lines, STRING_WFD_STANDBY_RESUME_CAPABILITY);
623 g_string_append_printf(lines, ":");
624 g_string_append_printf(lines, STRING_WFD_SPACE);
625 if (msg->standby_resume_capability->standby_resume_cap)
626 g_string_append_printf(lines, STRING_WFD_SUPPORTED);
628 g_string_append_printf(lines, STRING_WFD_NONE);
629 g_string_append_printf(lines, STRING_WFD_CRLF);
633 g_string_append_printf(lines, STRING_WFD_STANDBY);
634 g_string_append_printf(lines, STRING_WFD_CRLF);
637 if (msg->connector_type) {
638 g_string_append_printf(lines, STRING_WFD_CONNECTOR_TYPE);
639 g_string_append_printf(lines, ":");
640 g_string_append_printf(lines, STRING_WFD_CRLF);
643 if (msg->idr_request) {
644 g_string_append_printf(lines, STRING_WFD_IDR_REQUEST);
645 g_string_append_printf(lines, STRING_WFD_CRLF);
648 /*g_string_append_printf (lines, "\0"); */
649 /*if(g_str_has_suffix (lines, "\r\n\0"))
651 guint32 length = g_strlen(lines);
652 lines[length-2] = '\0';
654 return g_string_free(lines, FALSE);
657 gchar *wfdconfig_parameter_names_as_text(const WFDMessage *msg)
659 /* change all vars so they match rfc? */
661 g_return_val_if_fail(msg != NULL, NULL);
663 lines = g_string_new("");
665 /* list of audio codecs */
666 if (msg->audio_codecs) {
667 g_string_append_printf(lines, STRING_WFD_AUDIO_CODECS);
668 g_string_append_printf(lines, STRING_WFD_CRLF);
670 /* list of video codecs */
671 if (msg->video_formats) {
672 g_string_append_printf(lines, STRING_WFD_VIDEO_FORMATS);
673 g_string_append_printf(lines, STRING_WFD_CRLF);
675 /* list of video 3D codecs */
676 if (msg->video_3d_formats) {
677 g_string_append_printf(lines, STRING_WFD_3D_VIDEO_FORMATS);
678 g_string_append_printf(lines, STRING_WFD_CRLF);
680 if (msg->content_protection) {
681 g_string_append_printf(lines, STRING_WFD_CONTENT_PROTECTION);
682 g_string_append_printf(lines, STRING_WFD_CRLF);
684 if (msg->display_edid) {
685 g_string_append_printf(lines, STRING_WFD_DISPLAY_EDID);
686 g_string_append_printf(lines, STRING_WFD_CRLF);
688 if (msg->coupled_sink) {
689 g_string_append_printf(lines, STRING_WFD_COUPLED_SINK);
690 g_string_append_printf(lines, STRING_WFD_CRLF);
692 if (msg->trigger_method) {
693 g_string_append_printf(lines, STRING_WFD_TRIGGER_METHOD);
694 g_string_append_printf(lines, STRING_WFD_CRLF);
696 if (msg->presentation_url) {
697 g_string_append_printf(lines, STRING_WFD_PRESENTATION_URL);
698 g_string_append_printf(lines, STRING_WFD_CRLF);
700 if (msg->client_rtp_ports) {
701 g_string_append_printf(lines, STRING_WFD_CLIENT_RTP_PORTS);
702 g_string_append_printf(lines, STRING_WFD_CRLF);
705 g_string_append_printf(lines, STRING_WFD_ROUTE);
706 g_string_append_printf(lines, STRING_WFD_CRLF);
709 g_string_append_printf(lines, STRING_WFD_I2C);
710 g_string_append_printf(lines, STRING_WFD_CRLF);
712 if (msg->av_format_change_timing) {
713 g_string_append_printf(lines, STRING_WFD_AV_FORMAT_CHANGE_TIMING);
714 g_string_append_printf(lines, STRING_WFD_CRLF);
716 if (msg->preferred_display_mode) {
717 g_string_append_printf(lines, STRING_WFD_PREFERRED_DISPLAY_MODE);
718 g_string_append_printf(lines, STRING_WFD_CRLF);
720 if (msg->uibc_capability) {
721 g_string_append_printf(lines, STRING_WFD_UIBC_CAPABILITY);
722 g_string_append_printf(lines, STRING_WFD_CRLF);
724 if (msg->uibc_setting) {
725 g_string_append_printf(lines, STRING_WFD_UIBC_SETTING);
726 g_string_append_printf(lines, STRING_WFD_CRLF);
728 if (msg->standby_resume_capability) {
729 g_string_append_printf(lines, STRING_WFD_STANDBY_RESUME_CAPABILITY);
730 g_string_append_printf(lines, STRING_WFD_CRLF);
733 g_string_append_printf(lines, STRING_WFD_STANDBY);
734 g_string_append_printf(lines, STRING_WFD_CRLF);
736 if (msg->connector_type) {
737 g_string_append_printf(lines, STRING_WFD_CONNECTOR_TYPE);
738 g_string_append_printf(lines, STRING_WFD_CRLF);
740 if (msg->idr_request) {
741 g_string_append_printf(lines, STRING_WFD_IDR_REQUEST);
742 g_string_append_printf(lines, STRING_WFD_CRLF);
744 return g_string_free(lines, FALSE);
748 read_string_space_ended(gchar *dest, guint size, gchar *src)
752 while (!g_ascii_isspace(*src) && *src != '\0') {
763 read_string_char_ended(gchar *dest, guint size, gchar del, gchar *src)
767 while (*src != del && *src != '\0') {
778 read_string_type_and_value(gchar *type, gchar *value, guint tsize, guint vsize, gchar del, gchar *src)
783 while (*src != del && *src != '\0') {
794 while (*src != '\0') {
804 wfdconfig_parse_line(WFDMessage *msg, gchar *buffer)
806 gchar type[8192] = {0};
807 gchar value[8192] = {0};
808 gchar temp[8192] = {0};
811 gchar *result = NULL;
813 #define WFD_SKIP_SPACE(q) if (*q && g_ascii_isspace(*q)) q++;
814 #define WFD_SKIP_EQUAL(q) if (*q && *q == '=') q++;
815 #define WFD_SKIP_COMMA(q) if (*q && g_ascii_ispunct(*q)) q++;
816 #define WFD_READ_STRING(field) read_string_space_ended(temp, sizeof(temp), v); v += strlen(temp); REPLACE_STRING(field, temp);
817 #define WFD_READ_CHAR_END_STRING(field, del) read_string_char_ended(temp, sizeof(temp), del, v); v += strlen(temp); REPLACE_STRING(field, temp);
818 #define WFD_READ_UINT32(field) read_string_space_ended(temp, sizeof(temp), v); v += strlen(temp); field = strtoul(temp, NULL, 16);
819 #define WFD_READ_UINT32_DIGIT(field) read_string_space_ended(temp, sizeof(temp), v); v += strlen(temp); field = strtoul(temp, NULL, 10);
821 /*g_print("wfdconfig_parse_line input: %s\n", buffer); */
822 read_string_type_and_value(type, value, sizeof(type), sizeof(value), ':', p);
823 /*g_print("wfdconfig_parse_line type:%s value:%s\n", type, value); */
824 if (!g_strcmp0(type, STRING_WFD_AUDIO_CODECS)) {
825 msg->audio_codecs = g_new0(WFDAudioCodeclist, 1);
828 msg->audio_codecs->count = strlen(v) / 16;
829 msg->audio_codecs->list = g_new0(WFDAudioCodec, msg->audio_codecs->count);
830 for (; i < msg->audio_codecs->count; i++) {
832 WFD_READ_STRING(msg->audio_codecs->list[i].audio_format);
834 WFD_READ_UINT32(msg->audio_codecs->list[i].modes);
836 WFD_READ_UINT32(msg->audio_codecs->list[i].latency);
840 } else if (!g_strcmp0(type, STRING_WFD_VIDEO_FORMATS)) {
841 msg->video_formats = g_new0(WFDVideoCodeclist, 1);
843 msg->video_formats->count = 1;
844 msg->video_formats->list = g_new0(WFDVideoCodec, 1);
846 WFD_READ_UINT32(msg->video_formats->list->native);
848 WFD_READ_UINT32(msg->video_formats->list->preferred_display_mode_supported);
850 WFD_READ_UINT32(msg->video_formats->list->H264_codec.profile);
852 WFD_READ_UINT32(msg->video_formats->list->H264_codec.level);
854 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.CEA_Support);
856 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.VESA_Support);
858 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.HH_Support);
860 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.latency);
862 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.min_slice_size);
864 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.slice_enc_params);
866 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support);
868 if (msg->video_formats->list->preferred_display_mode_supported == 1) {
869 WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_hres);
871 WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_vres);
875 } else if (!g_strcmp0(type, STRING_WFD_3D_VIDEO_FORMATS)) {
876 msg->video_3d_formats = g_new0(WFD3DFormats, 1);
878 msg->video_3d_formats->count = 1;
879 msg->video_3d_formats->list = g_new0(WFD3dCapList, 1);
881 WFD_READ_UINT32(msg->video_3d_formats->list->native);
883 WFD_READ_UINT32(msg->video_3d_formats->list->preferred_display_mode_supported);
885 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.profile);
887 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.level);
889 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.video_3d_capability);
891 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.latency);
893 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.min_slice_size);
895 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.slice_enc_params);
897 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support);
899 if (msg->video_3d_formats->list->preferred_display_mode_supported == 1) {
900 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.max_hres);
902 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.max_vres);
906 } else if (!g_strcmp0(type, STRING_WFD_CONTENT_PROTECTION)) {
907 msg->content_protection = g_new0(WFDContentProtection, 1);
910 msg->content_protection->hdcp2_spec = g_new0(WFDHdcp2Spec, 1);
911 if (strstr(v, STRING_WFD_NONE)) {
912 msg->content_protection->hdcp2_spec->hdcpversion = g_strdup(STRING_WFD_NONE);
914 WFD_READ_STRING(msg->content_protection->hdcp2_spec->hdcpversion);
916 WFD_READ_STRING(msg->content_protection->hdcp2_spec->TCPPort);
919 } else if (!g_strcmp0(type, STRING_WFD_DISPLAY_EDID)) {
920 msg->display_edid = g_new0(WFDDisplayEdid, 1);
923 if (strstr(v, STRING_WFD_NONE)) {
924 msg->display_edid->edid_supported = 0;
926 msg->display_edid->edid_supported = 1;
927 WFD_READ_UINT32(msg->display_edid->edid_block_count);
929 if (msg->display_edid->edid_block_count) {
930 gchar *edid_string = v;
931 int i = 0, j = 0, size = 0;
932 guint32 payload_size = EDID_BLOCK_SIZE * msg->display_edid->edid_block_count;
933 msg->display_edid->edid_payload = g_malloc(payload_size);
934 size = EDID_BLOCK_SIZE * msg->display_edid->edid_block_count * 2;
935 for (; i < size; j++) {
937 if (edid_string[i] > 0x29 && edid_string[i] < 0x40) k = edid_string[i] - 48;
938 else if (edid_string[i] > 0x60 && edid_string[i] < 0x67) k = edid_string[i] - 87;
939 else if (edid_string[i] > 0x40 && edid_string[i] < 0x47) k = edid_string[i] - 55;
941 if (edid_string[i + 1] > 0x29 && edid_string[i + 1] < 0x40) kk = edid_string[i + 1] - 48;
942 else if (edid_string[i + 1] > 0x60 && edid_string[i + 1] < 0x67) kk = edid_string[i + 1] - 87;
943 else if (edid_string[i + 1] > 0x40 && edid_string[i + 1] < 0x47) kk = edid_string[i + 1] - 55;
945 msg->display_edid->edid_payload[j] = (k << 4) | kk;
948 /*memcpy(msg->display_edid->edid_payload, v, payload_size); */
949 v += (payload_size * 2);
950 } else v += strlen(v);
953 } else if (!g_strcmp0(type, STRING_WFD_COUPLED_SINK)) {
954 msg->coupled_sink = g_new0(WFDCoupledSink, 1);
956 msg->coupled_sink->coupled_sink_cap = g_new0(WFDCoupled_sink_cap, 1);
958 WFD_READ_UINT32(msg->coupled_sink->coupled_sink_cap->status);
960 WFD_READ_STRING(msg->coupled_sink->coupled_sink_cap->sink_address);
962 } else if (!g_strcmp0(type, STRING_WFD_TRIGGER_METHOD)) {
963 msg->trigger_method = g_new0(WFDTriggerMethod, 1);
966 WFD_READ_STRING(msg->trigger_method->wfd_trigger_method);
968 } else if (!g_strcmp0(type, STRING_WFD_PRESENTATION_URL)) {
969 msg->presentation_url = g_new0(WFDPresentationUrl, 1);
972 WFD_READ_STRING(msg->presentation_url->wfd_url0);
974 WFD_READ_STRING(msg->presentation_url->wfd_url1);
976 } else if (!g_strcmp0(type, STRING_WFD_CLIENT_RTP_PORTS)) {
977 msg->client_rtp_ports = g_new0(WFDClientRtpPorts, 1);
980 WFD_READ_STRING(msg->client_rtp_ports->profile);
982 WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port0);
984 WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port1);
986 WFD_READ_STRING(msg->client_rtp_ports->mode);
988 } else if (!g_strcmp0(type, STRING_WFD_ROUTE)) {
989 msg->route = g_new0(WFDRoute, 1);
992 WFD_READ_STRING(msg->route->destination);
994 } else if (!g_strcmp0(type, STRING_WFD_I2C)) {
995 msg->I2C = g_new0(WFDI2C, 1);
997 msg->I2C->I2CPresent = TRUE;
999 WFD_READ_UINT32_DIGIT(msg->I2C->I2C_port);
1000 if (msg->I2C->I2C_port) msg->I2C->I2CPresent = TRUE;
1002 } else if (!g_strcmp0(type, STRING_WFD_AV_FORMAT_CHANGE_TIMING)) {
1003 msg->av_format_change_timing = g_new0(WFDAVFormatChangeTiming, 1);
1006 WFD_READ_UINT32(msg->av_format_change_timing->PTS);
1008 WFD_READ_UINT32(msg->av_format_change_timing->DTS);
1010 } else if (!g_strcmp0(type, STRING_WFD_PREFERRED_DISPLAY_MODE)) {
1011 msg->preferred_display_mode = g_new0(WFDPreferredDisplayMode, 1);
1014 if (!strstr(v, STRING_WFD_NONE)) {
1015 msg->preferred_display_mode->displaymodesupported = FALSE;
1017 WFD_READ_UINT32(msg->preferred_display_mode->p_clock);
1019 WFD_READ_UINT32(msg->preferred_display_mode->H);
1021 WFD_READ_UINT32(msg->preferred_display_mode->HB);
1023 WFD_READ_UINT32(msg->preferred_display_mode->HSPOL_HSOFF);
1025 WFD_READ_UINT32(msg->preferred_display_mode->HSW);
1027 WFD_READ_UINT32(msg->preferred_display_mode->V);
1029 WFD_READ_UINT32(msg->preferred_display_mode->VB);
1031 WFD_READ_UINT32(msg->preferred_display_mode->VSPOL_VSOFF);
1033 WFD_READ_UINT32(msg->preferred_display_mode->VSW);
1035 WFD_READ_UINT32(msg->preferred_display_mode->VBS3D);
1037 WFD_READ_UINT32(msg->preferred_display_mode->V2d_s3d_modes);
1039 WFD_READ_UINT32(msg->preferred_display_mode->P_depth);
1041 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.profile);
1043 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.level);
1045 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.CEA_Support);
1047 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.VESA_Support);
1049 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.HH_Support);
1051 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.latency);
1053 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.min_slice_size);
1055 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.slice_enc_params);
1057 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.frame_rate_control_support);
1059 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_hres);
1061 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_vres);
1065 } else if (!g_strcmp0(type, STRING_WFD_UIBC_CAPABILITY)) {
1066 msg->uibc_capability = g_new0(WFDUibcCapability, 1);
1067 if (strstr(v, STRING_WFD_INPUT_CATEGORY_LIST)) {
1068 gchar *tstring = NULL;
1069 msg->uibc_capability->uibcsupported = TRUE;
1071 WFD_READ_CHAR_END_STRING(tstring, '=');
1072 if (!g_strcmp0(tstring, STRING_WFD_INPUT_CATEGORY_LIST)) {
1073 gchar temp2[8192] = {0};
1074 guint rem_len = 0, read_len = 0;
1075 WFD_READ_CHAR_END_STRING(tstring, ';');
1076 rem_len = strlen(tstring);
1079 read_string_char_ended(temp2, 8192, ',', tstring + read_len);
1080 read_len += (strlen(temp2) + 1);
1081 if (strstr(temp2, STRING_WFD_GENERIC)) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_GENERIC;
1082 else if (strstr(temp2, STRING_WFD_HIDC)) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_HIDC;
1083 else msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_UNKNOWN;
1084 } while (read_len < rem_len);
1086 result = strstr(v, STRING_WFD_GENERIC_CAP_LIST);
1087 if (result != NULL) {
1088 memset(temp2, 0, 8192);
1092 WFD_READ_CHAR_END_STRING(tstring, '=');
1093 if (!g_strcmp0(tstring, STRING_WFD_GENERIC_CAP_LIST)) {
1095 WFD_READ_CHAR_END_STRING(tstring, ';');
1096 rem_len = strlen(tstring);
1098 read_string_char_ended(temp2, 8192, ',', tstring + read_len);
1099 read_len += (strlen(temp2) + 1);
1100 if (strstr(temp2, STRING_WFD_KEYBOARD)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_KEYBOARD;
1101 else if (strstr(temp2, STRING_WFD_MOUSE)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MOUSE;
1102 else if (strstr(temp2, STRING_WFD_SINGLE_TOUCH)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_SINGLETOUCH;
1103 else if (strstr(temp2, STRING_WFD_MULTI_TOUCH)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MULTITOUCH;
1104 else if (strstr(temp2, STRING_WFD_JOYSTICK)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_JOYSTICK;
1105 else if (strstr(temp2, STRING_WFD_CAMERA)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_CAMERA;
1106 else if (strstr(temp2, STRING_WFD_GESTURE)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_GESTURE;
1107 else if (strstr(temp2, STRING_WFD_REMOTE_CONTROL)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_REMOTECONTROL;
1108 else msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_UNKNOWN;
1109 } while (read_len < rem_len);
1112 result = strstr(v, STRING_WFD_HIDC_CAP_LIST);
1113 if (result != NULL) {
1116 WFD_READ_CHAR_END_STRING(tstring, '=');
1117 if (!g_strcmp0(tstring, STRING_WFD_HIDC_CAP_LIST)) {
1118 gchar inp_type[8192];
1119 gchar inp_path[8192];
1120 memset(temp2, 0, 8192);
1123 detailed_cap *temp_cap;
1124 WFD_READ_CHAR_END_STRING(tstring, ';');
1125 rem_len = strlen(tstring);
1126 msg->uibc_capability->hidc_cap_list.next = g_new0(detailed_cap, 1);
1127 temp_cap = msg->uibc_capability->hidc_cap_list.next;
1129 msg->uibc_capability->hidc_cap_list.cap_count++;
1130 read_string_char_ended(temp2, 8192, ',', tstring + read_len);
1131 read_len += (strlen(temp2) + 1);
1132 read_string_type_and_value(inp_type, inp_path, sizeof(inp_type), sizeof(inp_path), '/', temp2);
1133 if (strstr(inp_type, STRING_WFD_KEYBOARD)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_KEYBOARD;
1134 else if (strstr(inp_type, STRING_WFD_MOUSE)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MOUSE;
1135 else if (strstr(inp_type, STRING_WFD_SINGLE_TOUCH)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_SINGLETOUCH;
1136 else if (strstr(inp_type, STRING_WFD_MULTI_TOUCH)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MULTITOUCH;
1137 else if (strstr(inp_type, STRING_WFD_JOYSTICK)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_JOYSTICK;
1138 else if (strstr(inp_type, STRING_WFD_CAMERA)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_CAMERA;
1139 else if (strstr(inp_type, STRING_WFD_GESTURE)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_GESTURE;
1140 else if (strstr(inp_type, STRING_WFD_REMOTE_CONTROL)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_REMOTECONTROL;
1141 else temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_UNKNOWN;
1143 if (strstr(inp_path, STRING_WFD_INFRARED)) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_INFRARED;
1144 else if (strstr(inp_path, STRING_WFD_USB)) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_USB;
1145 else if (strstr(inp_path, STRING_WFD_BT)) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_BT;
1146 else if (strstr(inp_path, STRING_WFD_ZIGBEE)) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_ZIGBEE;
1147 else if (strstr(inp_path, STRING_WFD_WIFI)) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_WIFI;
1148 else if (strstr(inp_path, STRING_WFD_NO_SP)) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_NOSP;
1149 else temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_UNKNOWN;
1150 if (read_len < rem_len) {
1151 temp_cap->next = g_new0(detailed_cap, 1);
1152 temp_cap = temp_cap->next;
1154 } while (read_len < rem_len);
1157 result = strstr(v, STRING_WFD_PORT);
1158 if (result != NULL) {
1160 WFD_READ_CHAR_END_STRING(tstring, '=');
1161 if (!g_strcmp0(tstring, STRING_WFD_PORT)) {
1163 WFD_READ_CHAR_END_STRING(tstring, ';');
1164 if (!strstr(tstring, STRING_WFD_NONE)) {
1165 msg->uibc_capability->tcp_port = strtoul(tstring, NULL, 10);
1170 } else if (strstr(v, STRING_WFD_NONE)) {
1171 msg->uibc_capability->uibcsupported = FALSE;
1173 } else if (!g_strcmp0(type, STRING_WFD_UIBC_SETTING)) {
1174 msg->uibc_setting = g_new0(WFDUibcSetting, 1);
1177 if (!g_strcmp0(v, STRING_WFD_ENABLE))
1178 msg->uibc_setting->uibc_setting = TRUE;
1180 msg->uibc_setting->uibc_setting = FALSE;
1182 } else if (!g_strcmp0(type, STRING_WFD_STANDBY_RESUME_CAPABILITY)) {
1183 msg->standby_resume_capability = g_new0(WFDStandbyResumeCapability, 1);
1186 if (!g_strcmp0(v, STRING_WFD_SUPPORTED))
1187 msg->standby_resume_capability->standby_resume_cap = TRUE;
1189 msg->standby_resume_capability->standby_resume_cap = FALSE;
1191 } else if (!g_strcmp0(type, STRING_WFD_STANDBY)) {
1192 msg->standby = g_new0(WFDStandby, 1);
1193 msg->standby->wfd_standby = TRUE;
1194 } else if (!g_strcmp0(type, STRING_WFD_CONNECTOR_TYPE)) {
1195 msg->connector_type = g_new0(WFDConnectorType, 1);
1197 msg->connector_type->supported = TRUE;
1199 WFD_READ_UINT32(msg->connector_type->connector_type);
1201 } else if (!g_strcmp0(type, STRING_WFD_IDR_REQUEST)) {
1202 msg->idr_request = g_new0(WFDIdrRequest, 1);
1203 msg->idr_request->idr_request = TRUE;
1210 * wfdconfig_message_parse_buffer:
1211 * @data: the start of the buffer
1212 * @size: the size of the buffer
1213 * @msg: the result #WFDMessage
1215 * Parse the contents of @size bytes pointed to by @data and store the result in
1218 * Returns: #WFD_OK on success.
1221 wfdconfig_message_parse_buffer(const guint8 *data, guint size, WFDMessage *msg)
1224 gchar buffer[MAX_LINE_LEN] = {0};
1227 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1228 g_return_val_if_fail(data != NULL, WFD_EINVAL);
1229 g_return_val_if_fail(size != 0, WFD_EINVAL);
1231 p = (const gchar *) data;
1238 while (*p != '\n' && *p != '\r' && *p != '\0') {
1239 if (idx < sizeof(buffer) - 1)
1244 wfdconfig_parse_line(msg, buffer);
1255 * wfdconfig_message_dump:
1256 * @msg: a #WFDMessage
1258 * Dump the parsed contents of @msg to stdout.
1260 * Returns: a #WFDResult.
1263 wfdconfig_message_dump(const WFDMessage *msg)
1265 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1266 wfd_debug("===========WFD Message dump=========");
1268 if (msg->audio_codecs) {
1270 wfd_debug("Audio supported formats : ");
1271 for (; i < msg->audio_codecs->count; i++) {
1272 wfd_debug("Codec: %s", msg->audio_codecs->list[i].audio_format);
1273 if (!strcmp(msg->audio_codecs->list[i].audio_format, STRING_WFD_LPCM)) {
1274 if (msg->audio_codecs->list[i].modes & WFD_FREQ_44100)
1275 wfd_debug(" Freq: %d", 44100);
1276 if (msg->audio_codecs->list[i].modes & WFD_FREQ_48000)
1277 wfd_debug(" Freq: %d", 48000);
1278 wfd_debug(" Channels: %d", 2);
1280 if (!strcmp(msg->audio_codecs->list[i].audio_format, STRING_WFD_AAC)) {
1281 wfd_debug(" Freq: %d", 48000);
1282 if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_2)
1283 wfd_debug(" Channels: %d", 2);
1284 if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_4)
1285 wfd_debug(" Channels: %d", 4);
1286 if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_6)
1287 wfd_debug(" Channels: %d", 6);
1288 if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_8)
1289 wfd_debug(" Channels: %d", 8);
1291 if (!strcmp(msg->audio_codecs->list[i].audio_format, STRING_WFD_AC3)) {
1292 wfd_debug(" Freq: %d", 48000);
1293 if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_2)
1294 wfd_debug(" Channels: %d", 2);
1295 if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_4)
1296 wfd_debug(" Channels: %d", 4);
1297 if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_6)
1298 wfd_debug(" Channels: %d", 6);
1300 wfd_debug(" Bitwidth: %d", 16);
1301 wfd_debug(" Latency: %d", msg->audio_codecs->list[i].latency);
1306 if (msg->video_formats) {
1307 wfd_debug("Video supported formats : ");
1308 if (msg->video_formats->list) {
1309 wfd_debug("Codec: H264");
1310 guint nativeindex = 0;
1311 if ((msg->video_formats->list->native & 0x7) == WFD_VIDEO_CEA_RESOLUTION) {
1312 wfd_debug(" Native type: CEA");
1313 } else if ((msg->video_formats->list->native & 0x7) == WFD_VIDEO_VESA_RESOLUTION) {
1314 wfd_debug(" Native type: VESA");
1315 } else if ((msg->video_formats->list->native & 0x7) == WFD_VIDEO_HH_RESOLUTION) {
1316 wfd_debug(" Native type: HH");
1318 nativeindex = msg->video_formats->list->native >> 3;
1319 wfd_debug(" Resolution: %d", (1 << nativeindex));
1321 if (msg->video_formats->list->H264_codec.profile & WFD_H264_BASE_PROFILE) {
1322 wfd_debug(" Profile: BASE");
1323 } else if (msg->video_formats->list->H264_codec.profile & WFD_H264_HIGH_PROFILE) {
1324 wfd_debug(" Profile: HIGH");
1326 if (msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_1) {
1327 wfd_debug(" Level: 3.1");
1328 } else if (msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_2) {
1329 wfd_debug(" Level: 3.2");
1330 } else if (msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4) {
1331 wfd_debug(" Level: 4");
1332 } else if (msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_1) {
1333 wfd_debug(" Level: 4.1");
1334 } else if (msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_2) {
1335 wfd_debug(" Level: 4.2");
1337 wfd_debug(" Latency: %d", msg->video_formats->list->H264_codec.misc_params.latency);
1338 wfd_debug(" min_slice_size: %x", msg->video_formats->list->H264_codec.misc_params.min_slice_size);
1339 wfd_debug(" slice_enc_params: %x", msg->video_formats->list->H264_codec.misc_params.slice_enc_params);
1340 wfd_debug(" frame_rate_control_support: %x", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support);
1341 if (msg->video_formats->list->H264_codec.max_hres) {
1342 wfd_debug(" Max Width: %04d", msg->video_formats->list->H264_codec.max_hres);
1344 if (msg->video_formats->list->H264_codec.max_vres) {
1345 wfd_debug(" Max Height: %04d", msg->video_formats->list->H264_codec.max_vres);
1350 if (msg->video_3d_formats) {
1351 wfd_debug("wfd_3d_formats");
1354 if (msg->content_protection) {
1355 wfd_debug(STRING_WFD_CONTENT_PROTECTION);
1358 if (msg->display_edid) {
1359 wfd_debug(STRING_WFD_DISPLAY_EDID);
1362 if (msg->coupled_sink) {
1363 wfd_debug(STRING_WFD_COUPLED_SINK);
1366 if (msg->trigger_method) {
1367 wfd_debug(" Trigger type: %s", msg->trigger_method->wfd_trigger_method);
1370 if (msg->presentation_url) {
1371 wfd_debug(STRING_WFD_PRESENTATION_URL);
1374 if (msg->client_rtp_ports) {
1375 wfd_debug(" Client RTP Ports : ");
1376 if (msg->client_rtp_ports->profile) {
1377 wfd_debug("%s", msg->client_rtp_ports->profile);
1378 wfd_debug(" %d", msg->client_rtp_ports->rtp_port0);
1379 wfd_debug(" %d", msg->client_rtp_ports->rtp_port1);
1380 wfd_debug(" %s", msg->client_rtp_ports->mode);
1385 wfd_debug(STRING_WFD_ROUTE);
1389 wfd_debug(STRING_WFD_I2C);
1392 if (msg->av_format_change_timing) {
1393 wfd_debug(STRING_WFD_AV_FORMAT_CHANGE_TIMING);
1396 if (msg->preferred_display_mode) {
1397 wfd_debug(STRING_WFD_PREFERRED_DISPLAY_MODE);
1400 if (msg->uibc_capability) {
1401 wfd_debug("wfd_uibc_capability \r");
1402 wfd_debug("input category list:");
1403 if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC)
1404 wfd_debug(STRING_WFD_GENERIC);
1405 if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC)
1406 wfd_debug(STRING_WFD_HIDC);
1407 if (!msg->uibc_capability->input_category_list.input_cat)
1408 wfd_debug(STRING_WFD_NONE);
1409 if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) {
1410 wfd_debug("generic cap list: ");
1411 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD)
1412 wfd_debug("keyboard ");
1413 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE)
1414 wfd_debug("mouse ");
1415 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH)
1416 wfd_debug("single-touch ");
1417 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH)
1418 wfd_debug("multi-touch ");
1419 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK)
1420 wfd_debug("joystick ");
1421 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA)
1422 wfd_debug("camera ");
1423 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE)
1424 wfd_debug("gesture ");
1425 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL)
1426 wfd_debug("remote control ");
1427 if (!msg->uibc_capability->generic_cap_list.inp_type)
1430 if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) {
1431 wfd_debug("hidc cap list:");
1432 if (msg->uibc_capability->hidc_cap_list.cap_count) {
1433 detailed_cap *temp_cap = msg->uibc_capability->hidc_cap_list.next;
1435 if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) {
1436 wfd_debug("keyboard ");
1437 } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) {
1438 wfd_debug("mouse ");
1439 } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) {
1440 wfd_debug("single-touch ");
1441 } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) {
1442 wfd_debug("multi-touch ");
1443 } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) {
1444 wfd_debug("joystick ");
1445 } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) {
1446 wfd_debug("camera ");
1447 } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) {
1448 wfd_debug("gesture ");
1449 } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) {
1450 wfd_debug("remote control ");
1451 } else if (!temp_cap->p.inp_type) {
1454 if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_INFRARED) {
1455 wfd_debug(STRING_WFD_INFRARED);
1456 } else if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_USB) {
1457 wfd_debug(STRING_WFD_USB);
1458 } else if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_BT) {
1459 wfd_debug(STRING_WFD_BT);
1460 } else if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_WIFI) {
1461 wfd_debug(STRING_WFD_WIFI);
1462 } else if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_ZIGBEE) {
1463 wfd_debug(STRING_WFD_ZIGBEE);
1464 } else if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_NOSP) {
1465 wfd_debug(STRING_WFD_NO_SP);
1466 } else if (!temp_cap->p.inp_path) {
1467 wfd_debug(STRING_WFD_NONE);
1469 temp_cap = temp_cap->next;
1473 if (msg->uibc_capability->tcp_port)
1474 wfd_debug("tcp port:%u", msg->uibc_capability->tcp_port);
1475 if (!msg->uibc_capability->tcp_port)
1476 wfd_debug("tcp port: none");
1479 if (msg->uibc_setting) {
1480 wfd_debug("wfd_uibc_setting: ");
1481 if (msg->uibc_setting->uibc_setting) {
1483 } else wfd_debug("false");
1486 if (msg->standby_resume_capability) {
1487 wfd_debug(STRING_WFD_STANDBY_RESUME_CAPABILITY);
1491 wfd_debug(STRING_WFD_STANDBY);
1494 if (msg->connector_type) {
1495 wfd_debug(STRING_WFD_CONNECTOR_TYPE);
1498 if (msg->idr_request) {
1499 wfd_debug(STRING_WFD_IDR_REQUEST);
1502 wfd_debug("===============================================");
1506 WFDResult wfdconfig_set_supported_audio_format(WFDMessage *msg, WFDAudioFormats aCodec, guint aFreq, guint aChanels,
1507 guint aBitwidth, guint32 aLatency)
1509 guint temp = aCodec;
1511 guint pcm = 0, aac = 0, ac3 = 0;
1513 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1515 if (!msg->audio_codecs)
1516 msg->audio_codecs = g_new0(WFDAudioCodeclist, 1);
1518 if (aCodec != WFD_AUDIO_UNKNOWN) {
1520 msg->audio_codecs->count++;
1523 msg->audio_codecs->list = g_new0(WFDAudioCodec, msg->audio_codecs->count);
1524 for (; i < msg->audio_codecs->count; i++) {
1525 if ((aCodec & WFD_AUDIO_LPCM) && (!pcm)) {
1526 msg->audio_codecs->list[i].audio_format = g_strdup(STRING_WFD_LPCM);
1527 msg->audio_codecs->list[i].modes = aFreq;
1528 msg->audio_codecs->list[i].latency = aLatency;
1530 } else if ((aCodec & WFD_AUDIO_AAC) && (!aac)) {
1531 msg->audio_codecs->list[i].audio_format = g_strdup(STRING_WFD_AAC);
1532 msg->audio_codecs->list[i].modes = aChanels;
1533 msg->audio_codecs->list[i].latency = aLatency;
1535 } else if ((aCodec & WFD_AUDIO_AC3) && (!ac3)) {
1536 msg->audio_codecs->list[i].audio_format = g_strdup(STRING_WFD_AC3);
1537 msg->audio_codecs->list[i].modes = aChanels;
1538 msg->audio_codecs->list[i].latency = aLatency;
1546 WFDResult wfdconfig_set_prefered_audio_format(WFDMessage *msg, WFDAudioFormats aCodec, WFDAudioFreq aFreq, WFDAudioChannels aChanels,
1547 guint aBitwidth, guint32 aLatency)
1550 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1552 if (!msg->audio_codecs)
1553 msg->audio_codecs = g_new0(WFDAudioCodeclist, 1);
1555 msg->audio_codecs->list = g_new0(WFDAudioCodec, 1);
1556 msg->audio_codecs->count = 1;
1557 if (aCodec == WFD_AUDIO_LPCM) {
1558 msg->audio_codecs->list->audio_format = g_strdup(STRING_WFD_LPCM);
1559 msg->audio_codecs->list->modes = aFreq;
1560 msg->audio_codecs->list->latency = aLatency;
1561 } else if (aCodec == WFD_AUDIO_AAC) {
1562 msg->audio_codecs->list->audio_format = g_strdup(STRING_WFD_AAC);
1563 msg->audio_codecs->list->modes = aChanels;
1564 msg->audio_codecs->list->latency = aLatency;
1565 } else if (aCodec == WFD_AUDIO_AC3) {
1566 msg->audio_codecs->list->audio_format = g_strdup(STRING_WFD_AC3);
1567 msg->audio_codecs->list->modes = aChanels;
1568 msg->audio_codecs->list->latency = aLatency;
1573 WFDResult wfdconfig_get_supported_audio_format(WFDMessage *msg, guint *aCodec, guint *aFreq, guint *aChanels,
1574 guint *aBitwidth, guint32 *aLatency)
1577 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1578 g_return_val_if_fail(msg->audio_codecs != NULL, WFD_EINVAL);
1580 for (; i < msg->audio_codecs->count; i++) {
1581 if (!g_strcmp0(msg->audio_codecs->list[i].audio_format, STRING_WFD_LPCM)) {
1582 *aCodec |= WFD_AUDIO_LPCM;
1583 *aFreq |= msg->audio_codecs->list[i].modes;
1584 *aChanels |= WFD_CHANNEL_2;
1586 *aLatency = msg->audio_codecs->list[i].latency;
1587 } else if (!g_strcmp0(msg->audio_codecs->list[i].audio_format, STRING_WFD_AAC)) {
1588 *aCodec |= WFD_AUDIO_AAC;
1589 *aFreq |= WFD_FREQ_48000;
1590 *aChanels |= msg->audio_codecs->list[i].modes;
1592 *aLatency = msg->audio_codecs->list[i].latency;
1593 } else if (!g_strcmp0(msg->audio_codecs->list[i].audio_format, STRING_WFD_AC3)) {
1594 *aCodec |= WFD_AUDIO_AC3;
1595 *aFreq |= WFD_FREQ_48000;
1596 *aChanels |= msg->audio_codecs->list[i].modes;
1598 *aLatency = msg->audio_codecs->list[i].latency;
1604 WFDResult wfdconfig_get_prefered_audio_format(WFDMessage *msg, WFDAudioFormats *aCodec, WFDAudioFreq *aFreq, WFDAudioChannels *aChanels,
1605 guint *aBitwidth, guint32 *aLatency)
1607 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1609 if (!g_strcmp0(msg->audio_codecs->list->audio_format, STRING_WFD_LPCM)) {
1610 *aCodec = WFD_AUDIO_LPCM;
1611 *aFreq = msg->audio_codecs->list->modes;
1612 *aChanels = WFD_CHANNEL_2;
1614 *aLatency = msg->audio_codecs->list->latency;
1615 } else if (!g_strcmp0(msg->audio_codecs->list->audio_format, STRING_WFD_AAC)) {
1616 *aCodec = WFD_AUDIO_AAC;
1617 *aFreq = WFD_FREQ_48000;
1618 *aChanels = msg->audio_codecs->list->modes;
1620 *aLatency = msg->audio_codecs->list->latency;
1621 } else if (!g_strcmp0(msg->audio_codecs->list->audio_format, STRING_WFD_AC3)) {
1622 *aCodec = WFD_AUDIO_AC3;
1623 *aFreq = WFD_FREQ_48000;
1624 *aChanels = msg->audio_codecs->list->modes;
1626 *aLatency = msg->audio_codecs->list->latency;
1631 WFDResult wfdconfig_set_supported_video_format(WFDMessage *msg, WFDVideoCodecs vCodec,
1632 WFDVideoNativeResolution vNative, guint64 vNativeResolution,
1633 guint64 vCEAResolution, guint64 vVESAResolution, guint64 vHHResolution,
1634 guint vProfile, guint vLevel, guint32 vLatency, guint32 vMaxHeight,
1635 guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control)
1637 guint nativeindex = 0;
1638 guint64 temp = vNativeResolution;
1640 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1642 if (!msg->video_formats)
1643 msg->video_formats = g_new0(WFDVideoCodeclist, 1);
1645 if (vCodec != WFD_VIDEO_UNKNOWN) {
1646 msg->video_formats->list = g_new0(WFDVideoCodec, 1);
1652 msg->video_formats->list->native = nativeindex - 1;
1653 msg->video_formats->list->native <<= 3;
1655 if (vNative == WFD_VIDEO_VESA_RESOLUTION)
1656 msg->video_formats->list->native |= 1;
1657 else if (vNative == WFD_VIDEO_HH_RESOLUTION)
1658 msg->video_formats->list->native |= 2;
1660 msg->video_formats->list->preferred_display_mode_supported = 1;
1661 msg->video_formats->list->H264_codec.profile = vProfile;
1662 msg->video_formats->list->H264_codec.level = vLevel;
1663 msg->video_formats->list->H264_codec.max_hres = vMaxWidth;
1664 msg->video_formats->list->H264_codec.max_vres = vMaxHeight;
1665 msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution;
1666 msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution;
1667 msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution;
1668 msg->video_formats->list->H264_codec.misc_params.latency = vLatency;
1669 msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size;
1670 msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params;
1671 msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control;
1676 WFDResult wfdconfig_set_prefered_video_format(WFDMessage *msg, WFDVideoCodecs vCodec,
1677 WFDVideoNativeResolution vNative, guint64 vNativeResolution,
1678 WFDVideoCEAResolution vCEAResolution, WFDVideoVESAResolution vVESAResolution,
1679 WFDVideoHHResolution vHHResolution, WFDVideoH264Profile vProfile,
1680 WFDVideoH264Level vLevel, guint32 vLatency, guint32 vMaxHeight,
1681 guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control)
1683 guint nativeindex = 0;
1684 guint64 temp = vNativeResolution;
1686 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1688 if (!msg->video_formats)
1689 msg->video_formats = g_new0(WFDVideoCodeclist, 1);
1690 msg->video_formats->list = g_new0(WFDVideoCodec, 1);
1697 if (nativeindex) msg->video_formats->list->native = nativeindex - 1;
1698 msg->video_formats->list->native <<= 3;
1700 if (vNative == WFD_VIDEO_VESA_RESOLUTION)
1701 msg->video_formats->list->native |= 1;
1702 else if (vNative == WFD_VIDEO_HH_RESOLUTION)
1703 msg->video_formats->list->native |= 2;
1705 msg->video_formats->list->preferred_display_mode_supported = 0;
1706 msg->video_formats->list->H264_codec.profile = vProfile;
1707 msg->video_formats->list->H264_codec.level = vLevel;
1708 msg->video_formats->list->H264_codec.max_hres = vMaxWidth;
1709 msg->video_formats->list->H264_codec.max_vres = vMaxHeight;
1710 msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution;
1711 msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution;
1712 msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution;
1713 msg->video_formats->list->H264_codec.misc_params.latency = vLatency;
1714 msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size;
1715 msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params;
1716 msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control;
1720 WFDResult wfdconfig_get_supported_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec,
1721 WFDVideoNativeResolution *vNative, guint64 *vNativeResolution,
1722 guint64 *vCEAResolution, guint64 *vVESAResolution, guint64 *vHHResolution,
1723 guint *vProfile, guint *vLevel, guint32 *vLatency, guint32 *vMaxHeight,
1724 guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control)
1726 guint nativeindex = 0;
1728 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1729 g_return_val_if_fail(msg->video_formats != NULL, WFD_EINVAL);
1730 g_return_val_if_fail(msg->video_formats->list != NULL, WFD_EINVAL);
1732 *vCodec = WFD_VIDEO_H264;
1733 *vNative = msg->video_formats->list->native & 0x7;
1734 nativeindex = msg->video_formats->list->native >> 3;
1735 *vNativeResolution = (guint64)1 << nativeindex;
1736 *vProfile = msg->video_formats->list->H264_codec.profile;
1737 *vLevel = msg->video_formats->list->H264_codec.level;
1738 *vMaxWidth = msg->video_formats->list->H264_codec.max_hres;
1739 *vMaxHeight = msg->video_formats->list->H264_codec.max_vres;
1740 *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support;
1741 *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support;
1742 *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support;
1743 *vLatency = msg->video_formats->list->H264_codec.misc_params.latency;
1744 *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size;
1745 *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params;
1746 *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support;
1750 WFDResult wfdconfig_get_prefered_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec,
1751 WFDVideoNativeResolution *vNative, guint64 *vNativeResolution,
1752 WFDVideoCEAResolution *vCEAResolution, WFDVideoVESAResolution *vVESAResolution,
1753 WFDVideoHHResolution *vHHResolution, WFDVideoH264Profile *vProfile,
1754 WFDVideoH264Level *vLevel, guint32 *vLatency, guint32 *vMaxHeight,
1755 guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control)
1757 guint nativeindex = 0;
1758 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1759 g_return_val_if_fail(msg->video_formats != NULL, WFD_EINVAL);
1760 g_return_val_if_fail(msg->video_formats->list != NULL, WFD_EINVAL);
1762 *vCodec = WFD_VIDEO_H264;
1763 *vNative = msg->video_formats->list->native & 0x7;
1764 nativeindex = msg->video_formats->list->native >> 3;
1765 *vNativeResolution = (guint64)1 << nativeindex;
1766 *vProfile = msg->video_formats->list->H264_codec.profile;
1767 *vLevel = msg->video_formats->list->H264_codec.level;
1768 *vMaxWidth = msg->video_formats->list->H264_codec.max_hres;
1769 *vMaxHeight = msg->video_formats->list->H264_codec.max_vres;
1770 *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support;
1771 *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support;
1772 *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support;
1773 *vLatency = msg->video_formats->list->H264_codec.misc_params.latency;
1774 *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size;
1775 *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params;
1776 *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support;
1780 WFDResult wfdconfig_set_contentprotection_type(WFDMessage *msg, WFDHDCPProtection hdcpversion, guint32 TCPPort)
1782 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1784 if (!msg->content_protection) msg->content_protection = g_new0(WFDContentProtection, 1);
1785 if (hdcpversion == WFD_HDCP_NONE) return WFD_OK;
1786 msg->content_protection->hdcp2_spec = g_new0(WFDHdcp2Spec, 1);
1787 if (hdcpversion == WFD_HDCP_2_0) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup(STRING_WFD_HDCP2_0);
1788 else if (hdcpversion == WFD_HDCP_2_1) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup(STRING_WFD_HDCP2_1);
1789 char str[11] = {0, };
1790 snprintf(str, 11, "port=%d", TCPPort);
1791 msg->content_protection->hdcp2_spec->TCPPort = g_strdup(str);
1795 WFDResult wfdconfig_get_contentprotection_type(WFDMessage *msg, WFDHDCPProtection *hdcpversion, guint32 *TCPPort)
1797 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1798 if (msg->content_protection && msg->content_protection->hdcp2_spec) {
1799 char *result = NULL;
1801 if (!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion, STRING_WFD_NONE)) {
1802 wfd_warning("HDCP none");
1803 *hdcpversion = WFD_HDCP_NONE;
1807 if (!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion, STRING_WFD_HDCP2_0)) *hdcpversion = WFD_HDCP_2_0;
1808 else if (!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion, STRING_WFD_HDCP2_1)) *hdcpversion = WFD_HDCP_2_1;
1810 wfd_warning("Unknown protection type");
1811 *hdcpversion = WFD_HDCP_NONE;
1816 result = strtok_r(msg->content_protection->hdcp2_spec->TCPPort, "=", &ptr);
1817 while (result != NULL) {
1818 result = strtok_r(NULL, "=", &ptr);
1819 *TCPPort = atoi(result);
1822 } else *hdcpversion = WFD_HDCP_NONE;
1826 WFDResult wfdconfig_set_display_EDID(WFDMessage *msg, gboolean edid_supported, guint32 edid_blockcount, gchar *edid_playload)
1828 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1829 if (!msg->display_edid) msg->display_edid = g_new0(WFDDisplayEdid, 1);
1830 msg->display_edid->edid_supported = edid_supported;
1831 if (!edid_supported) return WFD_OK;
1832 msg->display_edid->edid_block_count = edid_blockcount;
1833 if (edid_blockcount) {
1834 msg->display_edid->edid_payload = g_malloc(128 * edid_blockcount);
1835 if (!msg->display_edid->edid_payload)
1836 memcpy(msg->display_edid->edid_payload, edid_playload, 128 * edid_blockcount);
1837 } else msg->display_edid->edid_payload = g_strdup(STRING_WFD_NONE);
1841 WFDResult wfdconfig_get_display_EDID(WFDMessage *msg, gboolean *edid_supported, guint32 *edid_blockcount, gchar **edid_playload)
1843 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1844 if (msg->display_edid) {
1845 if (msg->display_edid->edid_supported) {
1846 *edid_blockcount = msg->display_edid->edid_block_count;
1847 if (msg->display_edid->edid_block_count) {
1849 temp = g_malloc(EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
1851 memset(temp, 0, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
1852 memcpy(temp, msg->display_edid->edid_payload, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
1853 *edid_playload = temp;
1854 *edid_supported = TRUE;
1856 } else *edid_playload = g_strdup(STRING_WFD_NONE);
1858 } else *edid_supported = FALSE;
1862 WFDResult wfdconfig_set_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus status, gchar *sink_address)
1864 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1865 if (!msg->coupled_sink) msg->coupled_sink = g_new0(WFDCoupledSink, 1);
1866 if (status == WFD_SINK_UNKNOWN) return WFD_OK;
1867 msg->coupled_sink->coupled_sink_cap = g_new0(WFDCoupled_sink_cap, 1);
1868 msg->coupled_sink->coupled_sink_cap->status = status;
1869 msg->coupled_sink->coupled_sink_cap->sink_address = g_strdup(sink_address);
1873 WFDResult wfdconfig_get_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus *status, gchar **sink_address)
1875 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1876 if (msg->coupled_sink && msg->coupled_sink->coupled_sink_cap) {
1877 *status = msg->coupled_sink->coupled_sink_cap->status;
1878 *sink_address = g_strdup(msg->coupled_sink->coupled_sink_cap->sink_address);
1879 } else *status = WFD_SINK_UNKNOWN;
1883 WFDResult wfdconfig_set_trigger_type(WFDMessage *msg, WFDTrigger trigger)
1885 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1887 if (!msg->trigger_method)
1888 msg->trigger_method = g_new0(WFDTriggerMethod, 1);
1889 if (trigger == WFD_TRIGGER_SETUP)
1890 msg->trigger_method->wfd_trigger_method = g_strdup(STRING_WFD_SETUP);
1891 else if (trigger == WFD_TRIGGER_PAUSE)
1892 msg->trigger_method->wfd_trigger_method = g_strdup(STRING_WFD_PAUSE);
1893 else if (trigger == WFD_TRIGGER_TEARDOWN)
1894 msg->trigger_method->wfd_trigger_method = g_strdup(STRING_WFD_TEARDOWN);
1895 else if (trigger == WFD_TRIGGER_PLAY)
1896 msg->trigger_method->wfd_trigger_method = g_strdup(STRING_WFD_PLAY);
1902 WFDResult wfdconfig_get_trigger_type(WFDMessage *msg, WFDTrigger *trigger)
1904 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1905 if (!g_strcmp0(msg->trigger_method->wfd_trigger_method, STRING_WFD_SETUP))
1906 *trigger = WFD_TRIGGER_SETUP;
1907 else if (!g_strcmp0(msg->trigger_method->wfd_trigger_method, STRING_WFD_PAUSE))
1908 *trigger = WFD_TRIGGER_PAUSE;
1909 else if (!g_strcmp0(msg->trigger_method->wfd_trigger_method, STRING_WFD_TEARDOWN))
1910 *trigger = WFD_TRIGGER_TEARDOWN;
1911 else if (!g_strcmp0(msg->trigger_method->wfd_trigger_method, STRING_WFD_PLAY))
1912 *trigger = WFD_TRIGGER_PLAY;
1914 *trigger = WFD_TRIGGER_UNKNOWN;
1920 WFDResult wfdconfig_set_presentation_url(WFDMessage *msg, gchar *wfd_url0, gchar *wfd_url1)
1922 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1923 if (!msg->presentation_url) msg->presentation_url = g_new0(WFDPresentationUrl, 1);
1924 if (wfd_url0) msg->presentation_url->wfd_url0 = g_strdup(wfd_url0);
1925 if (wfd_url1) msg->presentation_url->wfd_url1 = g_strdup(wfd_url1);
1929 WFDResult wfdconfig_get_presentation_url(WFDMessage *msg, gchar **wfd_url0, gchar **wfd_url1)
1931 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1932 if (msg->presentation_url) {
1933 *wfd_url0 = g_strdup(msg->presentation_url->wfd_url0);
1934 *wfd_url1 = g_strdup(msg->presentation_url->wfd_url1);
1939 WFDResult wfdconfig_set_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode trans, WFDRTSPProfile profile,
1940 WFDRTSPLowerTrans lowertrans, guint32 rtp_port0, guint32 rtp_port1)
1943 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1945 if (!msg->client_rtp_ports)
1946 msg->client_rtp_ports = g_new0(WFDClientRtpPorts, 1);
1948 if (trans != WFD_RTSP_TRANS_UNKNOWN) {
1949 lines = g_string_new("");
1950 if (trans == WFD_RTSP_TRANS_RTP) g_string_append_printf(lines, STRING_WFD_RTP);
1951 else if (trans == WFD_RTSP_TRANS_RDT) g_string_append_printf(lines, STRING_WFD_RDT);
1953 if (profile != WFD_RTSP_PROFILE_UNKNOWN) g_string_append_printf(lines, "/");
1955 if (profile == WFD_RTSP_PROFILE_AVP) g_string_append_printf(lines, STRING_WFD_AVP);
1956 else if (profile == WFD_RTSP_PROFILE_SAVP) g_string_append_printf(lines, STRING_WFD_SAVP);
1958 if (lowertrans != WFD_RTSP_LOWER_TRANS_UNKNOWN) g_string_append_printf(lines, "/");
1960 if (lowertrans == WFD_RTSP_LOWER_TRANS_UDP) {
1961 g_string_append_printf(lines, STRING_WFD_UDP);
1962 g_string_append_printf(lines, ";");
1963 g_string_append_printf(lines, STRING_WFD_UNICAST);
1964 } else if (lowertrans == WFD_RTSP_LOWER_TRANS_UDP_MCAST) {
1965 g_string_append_printf(lines, STRING_WFD_UDP);
1966 g_string_append_printf(lines, ";");
1967 g_string_append_printf(lines, STRING_WFD_MULTICAST);
1968 } else if (lowertrans == WFD_RTSP_LOWER_TRANS_TCP) {
1969 g_string_append_printf(lines, STRING_WFD_TCP);
1970 g_string_append_printf(lines, ";");
1971 g_string_append_printf(lines, STRING_WFD_UNICAST);
1972 } else if (lowertrans == WFD_RTSP_LOWER_TRANS_HTTP) {
1973 g_string_append_printf(lines, STRING_WFD_TCP_HTTP);
1976 msg->client_rtp_ports->profile = g_string_free(lines, FALSE);
1977 msg->client_rtp_ports->rtp_port0 = rtp_port0;
1978 msg->client_rtp_ports->rtp_port1 = rtp_port1;
1979 msg->client_rtp_ports->mode = g_strdup("mode=play");
1984 WFDResult wfdconfig_get_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode *trans, WFDRTSPProfile *profile,
1985 WFDRTSPLowerTrans *lowertrans, guint32 *rtp_port0, guint32 *rtp_port1)
1987 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1988 g_return_val_if_fail(msg->client_rtp_ports != NULL, WFD_EINVAL);
1990 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_RTP)) *trans = WFD_RTSP_TRANS_RTP;
1991 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_RDT)) *trans = WFD_RTSP_TRANS_RDT;
1992 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_AVP)) *profile = WFD_RTSP_PROFILE_AVP;
1993 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_SAVP)) *profile = WFD_RTSP_PROFILE_SAVP;
1994 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_UDP) &&
1995 g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_UNICAST)) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP;
1996 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_UDP) &&
1997 g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_MULTICAST)) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP_MCAST;
1998 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_TCP) &&
1999 g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_UNICAST)) *lowertrans = WFD_RTSP_LOWER_TRANS_TCP;
2000 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_TCP_HTTP)) *lowertrans = WFD_RTSP_LOWER_TRANS_HTTP;
2002 *rtp_port0 = msg->client_rtp_ports->rtp_port0;
2003 *rtp_port1 = msg->client_rtp_ports->rtp_port1;
2008 WFDResult wfdconfig_set_audio_sink_type(WFDMessage *msg, WFDSinkType sinktype)
2010 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2011 if (!msg->route) msg->route = g_new0(WFDRoute, 1);
2012 if (sinktype == WFD_PRIMARY_SINK) msg->route->destination = g_strdup(STRING_WFD_PRIMARY);
2013 else if (sinktype == WFD_SECONDARY_SINK) msg->route->destination = g_strdup(STRING_WFD_SECONDARY);
2017 WFDResult wfdconfig_get_audio_sink_type(WFDMessage *msg, WFDSinkType *sinktype)
2019 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2021 if (!g_strcmp0(msg->route->destination, STRING_WFD_PRIMARY)) *sinktype = WFD_PRIMARY_SINK;
2022 else if (!g_strcmp0(msg->route->destination, STRING_WFD_SECONDARY)) *sinktype = WFD_SECONDARY_SINK;
2027 WFDResult wfdconfig_set_I2C_port(WFDMessage *msg, gboolean i2csupport, guint32 i2cport)
2029 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2030 if (!msg->I2C) msg->I2C = g_new0(WFDI2C, 1);
2031 msg->I2C->I2CPresent = i2csupport;
2032 msg->I2C->I2C_port = i2cport;
2036 WFDResult wfdconfig_get_I2C_port(WFDMessage *msg, gboolean *i2csupport, guint32 *i2cport)
2038 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2039 if (msg->I2C && msg->I2C->I2CPresent) {
2040 *i2csupport = msg->I2C->I2CPresent;
2041 *i2cport = msg->I2C->I2C_port;
2042 } else *i2csupport = FALSE;
2046 WFDResult wfdconfig_set_av_format_change_timing(WFDMessage *msg, guint64 PTS, guint64 DTS)
2048 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2049 if (!msg->av_format_change_timing) msg->av_format_change_timing = g_new0(WFDAVFormatChangeTiming, 1);
2050 msg->av_format_change_timing->PTS = PTS;
2051 msg->av_format_change_timing->DTS = DTS;
2055 WFDResult wfdconfig_get_av_format_change_timing(WFDMessage *msg, guint64 *PTS, guint64 *DTS)
2057 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2058 if (msg->av_format_change_timing) {
2059 *PTS = msg->av_format_change_timing->PTS;
2060 *DTS = msg->av_format_change_timing->DTS;
2065 WFDResult wfdconfig_set_uibc_capability(WFDMessage *msg, guint32 input_category, guint32 inp_type, WFDHIDCTypePathPair *inp_pair,
2066 guint32 inp_type_path_count, guint32 tcp_port)
2068 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2069 if (!msg->uibc_capability) msg->uibc_capability = g_new0(WFDUibcCapability, 1);
2070 msg->uibc_capability->uibcsupported = TRUE;
2071 msg->uibc_capability->input_category_list.input_cat = input_category;
2072 msg->uibc_capability->generic_cap_list.inp_type = inp_type;
2073 msg->uibc_capability->hidc_cap_list.cap_count = inp_type_path_count;
2074 if (msg->uibc_capability->hidc_cap_list.cap_count) {
2075 detailed_cap *temp_cap;
2077 msg->uibc_capability->hidc_cap_list.next = g_new0(detailed_cap, 1);
2078 temp_cap = msg->uibc_capability->hidc_cap_list.next;
2079 for (; i < inp_type_path_count;) {
2080 temp_cap->p.inp_type = inp_pair[i].inp_type;
2081 temp_cap->p.inp_path = inp_pair[i].inp_path;
2083 if (i < inp_type_path_count) {
2084 temp_cap->next = g_new0(detailed_cap, 1);
2085 temp_cap = temp_cap->next;
2089 msg->uibc_capability->tcp_port = tcp_port;
2093 WFDResult wfdconfig_get_uibc_capability(WFDMessage *msg, guint32 *input_category, guint32 *inp_type, WFDHIDCTypePathPair **inp_pair,
2094 guint32 *inp_type_path_count, guint32 *tcp_port)
2096 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2097 if (msg->uibc_capability && msg->uibc_capability->uibcsupported) {
2098 *input_category = msg->uibc_capability->input_category_list.input_cat;
2099 *inp_type = msg->uibc_capability->generic_cap_list.inp_type;
2100 *inp_type_path_count = msg->uibc_capability->hidc_cap_list.cap_count;
2101 if (msg->uibc_capability->hidc_cap_list.cap_count) {
2102 detailed_cap *temp_cap;
2104 *inp_pair = g_new0(WFDHIDCTypePathPair, msg->uibc_capability->hidc_cap_list.cap_count);
2105 temp_cap = msg->uibc_capability->hidc_cap_list.next;
2107 (*(inp_pair))[i].inp_type = temp_cap->p.inp_type;
2108 (*(inp_pair))[i].inp_path = temp_cap->p.inp_path;
2109 temp_cap = temp_cap->next;
2113 *tcp_port = msg->uibc_capability->tcp_port;
2118 WFDResult wfdconfig_set_uibc_status(WFDMessage *msg, gboolean uibc_enable)
2120 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2121 if (!msg->uibc_setting) msg->uibc_setting = g_new0(WFDUibcSetting, 1);
2122 msg->uibc_setting->uibc_setting = uibc_enable;
2126 WFDResult wfdconfig_get_uibc_status(WFDMessage *msg, gboolean *uibc_enable)
2128 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2129 if (msg->uibc_setting) *uibc_enable = msg->uibc_setting->uibc_setting;
2132 #ifdef STANDBY_RESUME_CAPABILITY
2133 WFDResult wfdconfig_set_standby_resume_capability(WFDMessage *msg, gboolean supported)
2135 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2136 if (!msg->standby_resume_capability) msg->standby_resume_capability = g_new0(WFDStandbyResumeCapability, 1);
2137 msg->standby_resume_capability->standby_resume_cap = supported;
2141 WFDResult wfdconfig_get_standby_resume_capability(WFDMessage *msg, gboolean *supported)
2143 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2144 if (msg->standby_resume_capability) *supported = msg->standby_resume_capability->standby_resume_cap;
2148 WFDResult wfdconfig_set_standby(WFDMessage *msg, gboolean standby_enable)
2150 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2151 if (!msg->standby) msg->standby = g_new0(WFDStandby, 1);
2152 msg->standby->wfd_standby = standby_enable;
2156 WFDResult wfdconfig_get_standby(WFDMessage *msg, gboolean *standby_enable)
2158 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2159 if (msg->standby) *standby_enable = msg->standby->wfd_standby;
2163 WFDResult wfdconfig_set_connector_type(WFDMessage *msg, WFDConnector connector)
2165 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2166 if (!msg->connector_type) msg->connector_type = g_new0(WFDConnectorType, 1);
2167 msg->connector_type->connector_type = connector;
2171 WFDResult wfdconfig_get_connector_type(WFDMessage *msg, WFDConnector *connector)
2173 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2174 if (msg->connector_type) *connector = msg->connector_type->connector_type;
2178 WFDResult wfdconfig_set_idr_request(WFDMessage *msg)
2180 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2181 if (!msg->idr_request) msg->idr_request = g_new0(WFDIdrRequest, 1);
2182 msg->idr_request->idr_request = TRUE;