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, STRING_WFD_COLON);
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, STRING_WFD_COMMA);
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, STRING_WFD_COLON);
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, STRING_WFD_COLON);
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, STRING_WFD_COLON);
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, STRING_WFD_COLON);
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, STRING_WFD_COLON);
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, STRING_WFD_COLON);
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, STRING_WFD_COLON);
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, STRING_WFD_COLON);
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, STRING_WFD_COLON);
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, STRING_WFD_COLON);
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, STRING_WFD_COLON);
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, STRING_WFD_COLON);
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, STRING_WFD_COLON);
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, STRING_WFD_EQUALS);
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, STRING_WFD_COMMA STRING_WFD_SPACE);
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, STRING_WFD_COMMA STRING_WFD_SPACE);
515 g_string_append_printf(lines, STRING_WFD_NONE);
517 g_string_append_printf(lines, STRING_WFD_SEMI_COLON);
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, STRING_WFD_EQUALS);
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)
527 g_string_append_printf(lines, STRING_WFD_COMMA STRING_WFD_SPACE);
529 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) {
530 tempcap |= WFD_UIBC_INPUT_TYPE_MOUSE;
531 g_string_append_printf(lines, STRING_WFD_MOUSE);
532 if (msg->uibc_capability->generic_cap_list.inp_type != tempcap)
533 g_string_append_printf(lines, STRING_WFD_COMMA STRING_WFD_SPACE);
535 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) {
536 tempcap |= WFD_UIBC_INPUT_TYPE_SINGLETOUCH;
537 g_string_append_printf(lines, STRING_WFD_SINGLE_TOUCH);
538 if (msg->uibc_capability->generic_cap_list.inp_type != tempcap)
539 g_string_append_printf(lines, STRING_WFD_COMMA STRING_WFD_SPACE);
541 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) {
542 tempcap |= WFD_UIBC_INPUT_TYPE_MULTITOUCH;
543 g_string_append_printf(lines, STRING_WFD_MULTI_TOUCH);
544 if (msg->uibc_capability->generic_cap_list.inp_type != tempcap)
545 g_string_append_printf(lines, STRING_WFD_COMMA STRING_WFD_SPACE);
547 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) {
548 tempcap |= WFD_UIBC_INPUT_TYPE_JOYSTICK;
549 g_string_append_printf(lines, STRING_WFD_JOYSTICK);
550 if (msg->uibc_capability->generic_cap_list.inp_type != tempcap)
551 g_string_append_printf(lines, STRING_WFD_COMMA STRING_WFD_SPACE);
553 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) {
554 tempcap |= WFD_UIBC_INPUT_TYPE_CAMERA;
555 g_string_append_printf(lines, STRING_WFD_CAMERA);
556 if (msg->uibc_capability->generic_cap_list.inp_type != tempcap)
557 g_string_append_printf(lines, STRING_WFD_COMMA STRING_WFD_SPACE);
559 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) {
560 tempcap |= WFD_UIBC_INPUT_TYPE_GESTURE;
561 g_string_append_printf(lines, STRING_WFD_GESTURE);
562 if (msg->uibc_capability->generic_cap_list.inp_type != tempcap)
563 g_string_append_printf(lines, STRING_WFD_COMMA STRING_WFD_SPACE);
565 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) {
566 tempcap |= WFD_UIBC_INPUT_TYPE_REMOTECONTROL;
567 g_string_append_printf(lines, STRING_WFD_REMOTE_CONTROL);
568 if (msg->uibc_capability->generic_cap_list.inp_type != tempcap)
569 g_string_append_printf(lines, STRING_WFD_COMMA STRING_WFD_SPACE);
572 g_string_append_printf(lines, STRING_WFD_NONE);
574 g_string_append_printf(lines, STRING_WFD_SEMI_COLON);
575 g_string_append_printf(lines, STRING_WFD_SPACE);
576 g_string_append_printf(lines, STRING_WFD_HIDC_CAP_LIST);
577 g_string_append_printf(lines, STRING_WFD_EQUALS);
578 if (msg->uibc_capability->hidc_cap_list.cap_count) {
579 detailed_cap *temp_cap = msg->uibc_capability->hidc_cap_list.next;
581 if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_KEYBOARD) g_string_append_printf(lines, STRING_WFD_KEYBOARD);
582 else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_MOUSE) g_string_append_printf(lines, STRING_WFD_MOUSE);
583 else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_SINGLETOUCH) g_string_append_printf(lines, STRING_WFD_SINGLE_TOUCH);
584 else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_MULTITOUCH) g_string_append_printf(lines, STRING_WFD_MULTI_TOUCH);
585 else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_JOYSTICK) g_string_append_printf(lines, STRING_WFD_JOYSTICK);
586 else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_CAMERA) g_string_append_printf(lines, STRING_WFD_CAMERA);
587 else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_GESTURE) g_string_append_printf(lines, STRING_WFD_GESTURE);
588 else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_REMOTECONTROL) g_string_append_printf(lines, STRING_WFD_REMOTE_CONTROL);
589 g_string_append_printf(lines, STRING_WFD_SLASH);
590 if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_INFRARED) g_string_append_printf(lines, STRING_WFD_INFRARED);
591 else if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_USB) g_string_append_printf(lines, STRING_WFD_USB);
592 else if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_BT) g_string_append_printf(lines, STRING_WFD_BT);
593 else if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_ZIGBEE) g_string_append_printf(lines, STRING_WFD_ZIGBEE);
594 else if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_WIFI) g_string_append_printf(lines, STRING_WFD_WIFI);
595 else if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_NOSP) g_string_append_printf(lines, STRING_WFD_NO_SP);
596 temp_cap = temp_cap->next;
597 if (temp_cap) g_string_append_printf(lines, STRING_WFD_COMMA STRING_WFD_SPACE);
600 g_string_append_printf(lines, STRING_WFD_NONE);
602 g_string_append_printf(lines, STRING_WFD_SEMI_COLON);
603 if (msg->uibc_capability->tcp_port) {
604 g_string_append_printf(lines, STRING_WFD_PORT);
605 g_string_append_printf(lines, STRING_WFD_EQUALS);
606 g_string_append_printf(lines, "%u", msg->uibc_capability->tcp_port);
608 g_string_append_printf(lines, STRING_WFD_PORT);
609 g_string_append_printf(lines, STRING_WFD_EQUALS);
610 g_string_append_printf(lines, STRING_WFD_NONE);
613 g_string_append_printf(lines, STRING_WFD_SPACE);
614 g_string_append_printf(lines, STRING_WFD_NONE);
616 g_string_append_printf(lines, STRING_WFD_CRLF);
619 if (msg->uibc_setting) {
620 g_string_append_printf(lines, STRING_WFD_UIBC_SETTING);
621 g_string_append_printf(lines, STRING_WFD_COLON);
622 g_string_append_printf(lines, STRING_WFD_SPACE);
623 if (msg->uibc_setting->uibc_setting)
624 g_string_append_printf(lines, STRING_WFD_ENABLE);
626 g_string_append_printf(lines, STRING_WFD_DISABLE);
627 g_string_append_printf(lines, STRING_WFD_CRLF);
630 if (msg->standby_resume_capability) {
631 g_string_append_printf(lines, STRING_WFD_STANDBY_RESUME_CAPABILITY);
632 g_string_append_printf(lines, STRING_WFD_COLON);
633 g_string_append_printf(lines, STRING_WFD_SPACE);
634 if (msg->standby_resume_capability->standby_resume_cap)
635 g_string_append_printf(lines, STRING_WFD_SUPPORTED);
637 g_string_append_printf(lines, STRING_WFD_NONE);
638 g_string_append_printf(lines, STRING_WFD_CRLF);
642 g_string_append_printf(lines, STRING_WFD_STANDBY);
643 g_string_append_printf(lines, STRING_WFD_CRLF);
646 if (msg->connector_type) {
647 g_string_append_printf(lines, STRING_WFD_CONNECTOR_TYPE);
648 g_string_append_printf(lines, STRING_WFD_COLON);
649 g_string_append_printf(lines, STRING_WFD_CRLF);
652 if (msg->idr_request) {
653 g_string_append_printf(lines, STRING_WFD_IDR_REQUEST);
654 g_string_append_printf(lines, STRING_WFD_CRLF);
657 /*g_string_append_printf (lines, "\0"); */
658 /*if(g_str_has_suffix (lines, "\r\n\0"))
660 guint32 length = g_strlen(lines);
661 lines[length-2] = '\0';
663 return g_string_free(lines, FALSE);
666 gchar *wfdconfig_parameter_names_as_text(const WFDMessage *msg)
668 /* change all vars so they match rfc? */
670 g_return_val_if_fail(msg != NULL, NULL);
672 lines = g_string_new("");
674 /* list of audio codecs */
675 if (msg->audio_codecs) {
676 g_string_append_printf(lines, STRING_WFD_AUDIO_CODECS);
677 g_string_append_printf(lines, STRING_WFD_CRLF);
679 /* list of video codecs */
680 if (msg->video_formats) {
681 g_string_append_printf(lines, STRING_WFD_VIDEO_FORMATS);
682 g_string_append_printf(lines, STRING_WFD_CRLF);
684 /* list of video 3D codecs */
685 if (msg->video_3d_formats) {
686 g_string_append_printf(lines, STRING_WFD_3D_VIDEO_FORMATS);
687 g_string_append_printf(lines, STRING_WFD_CRLF);
689 if (msg->content_protection) {
690 g_string_append_printf(lines, STRING_WFD_CONTENT_PROTECTION);
691 g_string_append_printf(lines, STRING_WFD_CRLF);
693 if (msg->display_edid) {
694 g_string_append_printf(lines, STRING_WFD_DISPLAY_EDID);
695 g_string_append_printf(lines, STRING_WFD_CRLF);
697 if (msg->coupled_sink) {
698 g_string_append_printf(lines, STRING_WFD_COUPLED_SINK);
699 g_string_append_printf(lines, STRING_WFD_CRLF);
701 if (msg->trigger_method) {
702 g_string_append_printf(lines, STRING_WFD_TRIGGER_METHOD);
703 g_string_append_printf(lines, STRING_WFD_CRLF);
705 if (msg->presentation_url) {
706 g_string_append_printf(lines, STRING_WFD_PRESENTATION_URL);
707 g_string_append_printf(lines, STRING_WFD_CRLF);
709 if (msg->client_rtp_ports) {
710 g_string_append_printf(lines, STRING_WFD_CLIENT_RTP_PORTS);
711 g_string_append_printf(lines, STRING_WFD_CRLF);
714 g_string_append_printf(lines, STRING_WFD_ROUTE);
715 g_string_append_printf(lines, STRING_WFD_CRLF);
718 g_string_append_printf(lines, STRING_WFD_I2C);
719 g_string_append_printf(lines, STRING_WFD_CRLF);
721 if (msg->av_format_change_timing) {
722 g_string_append_printf(lines, STRING_WFD_AV_FORMAT_CHANGE_TIMING);
723 g_string_append_printf(lines, STRING_WFD_CRLF);
725 if (msg->preferred_display_mode) {
726 g_string_append_printf(lines, STRING_WFD_PREFERRED_DISPLAY_MODE);
727 g_string_append_printf(lines, STRING_WFD_CRLF);
729 if (msg->uibc_capability) {
730 g_string_append_printf(lines, STRING_WFD_UIBC_CAPABILITY);
731 g_string_append_printf(lines, STRING_WFD_CRLF);
733 if (msg->uibc_setting) {
734 g_string_append_printf(lines, STRING_WFD_UIBC_SETTING);
735 g_string_append_printf(lines, STRING_WFD_CRLF);
737 if (msg->standby_resume_capability) {
738 g_string_append_printf(lines, STRING_WFD_STANDBY_RESUME_CAPABILITY);
739 g_string_append_printf(lines, STRING_WFD_CRLF);
742 g_string_append_printf(lines, STRING_WFD_STANDBY);
743 g_string_append_printf(lines, STRING_WFD_CRLF);
745 if (msg->connector_type) {
746 g_string_append_printf(lines, STRING_WFD_CONNECTOR_TYPE);
747 g_string_append_printf(lines, STRING_WFD_CRLF);
749 if (msg->idr_request) {
750 g_string_append_printf(lines, STRING_WFD_IDR_REQUEST);
751 g_string_append_printf(lines, STRING_WFD_CRLF);
753 return g_string_free(lines, FALSE);
757 read_string_space_ended(gchar *dest, guint size, gchar *src)
761 while (!g_ascii_isspace(*src) && *src != '\0') {
772 read_string_char_ended(gchar *dest, guint size, gchar del, gchar *src)
776 while (*src != del && *src != '\0') {
787 read_string_type_and_value(gchar *type, gchar *value, guint tsize, guint vsize, gchar del, gchar *src)
792 while (*src != del && *src != '\0') {
803 while (*src != '\0') {
813 wfdconfig_parse_line(WFDMessage *msg, gchar *buffer)
815 gchar type[8192] = {0};
816 gchar value[8192] = {0};
817 gchar temp[8192] = {0};
820 gchar *result = NULL;
822 #define WFD_SKIP_SPACE(q) if (*q && g_ascii_isspace(*q)) q++;
823 #define WFD_SKIP_EQUAL(q) if (*q && *q == '=') q++;
824 #define WFD_SKIP_COMMA(q) if (*q && g_ascii_ispunct(*q)) q++;
825 #define WFD_READ_STRING(field) read_string_space_ended(temp, sizeof(temp), v); v += strlen(temp); REPLACE_STRING(field, temp);
826 #define WFD_READ_CHAR_END_STRING(field, del) read_string_char_ended(temp, sizeof(temp), del, v); v += strlen(temp); REPLACE_STRING(field, temp);
827 #define WFD_READ_UINT32(field) read_string_space_ended(temp, sizeof(temp), v); v += strlen(temp); field = strtoul(temp, NULL, 16);
828 #define WFD_READ_UINT32_DIGIT(field) read_string_space_ended(temp, sizeof(temp), v); v += strlen(temp); field = strtoul(temp, NULL, 10);
830 /*g_print("wfdconfig_parse_line input: %s\n", buffer); */
831 read_string_type_and_value(type, value, sizeof(type), sizeof(value), ':', p);
832 /*g_print("wfdconfig_parse_line type:%s value:%s\n", type, value); */
833 if (!g_strcmp0(type, STRING_WFD_AUDIO_CODECS)) {
834 msg->audio_codecs = g_new0(WFDAudioCodeclist, 1);
837 msg->audio_codecs->count = strlen(v) / 16;
838 msg->audio_codecs->list = g_new0(WFDAudioCodec, msg->audio_codecs->count);
839 for (; i < msg->audio_codecs->count; i++) {
841 WFD_READ_STRING(msg->audio_codecs->list[i].audio_format);
843 WFD_READ_UINT32(msg->audio_codecs->list[i].modes);
845 WFD_READ_UINT32(msg->audio_codecs->list[i].latency);
849 } else if (!g_strcmp0(type, STRING_WFD_VIDEO_FORMATS)) {
850 msg->video_formats = g_new0(WFDVideoCodeclist, 1);
852 msg->video_formats->count = 1;
853 msg->video_formats->list = g_new0(WFDVideoCodec, 1);
855 WFD_READ_UINT32(msg->video_formats->list->native);
857 WFD_READ_UINT32(msg->video_formats->list->preferred_display_mode_supported);
859 WFD_READ_UINT32(msg->video_formats->list->H264_codec.profile);
861 WFD_READ_UINT32(msg->video_formats->list->H264_codec.level);
863 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.CEA_Support);
865 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.VESA_Support);
867 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.HH_Support);
869 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.latency);
871 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.min_slice_size);
873 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.slice_enc_params);
875 WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support);
877 if (msg->video_formats->list->preferred_display_mode_supported == 1) {
878 WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_hres);
880 WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_vres);
884 } else if (!g_strcmp0(type, STRING_WFD_3D_VIDEO_FORMATS)) {
885 msg->video_3d_formats = g_new0(WFD3DFormats, 1);
887 msg->video_3d_formats->count = 1;
888 msg->video_3d_formats->list = g_new0(WFD3dCapList, 1);
890 WFD_READ_UINT32(msg->video_3d_formats->list->native);
892 WFD_READ_UINT32(msg->video_3d_formats->list->preferred_display_mode_supported);
894 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.profile);
896 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.level);
898 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.video_3d_capability);
900 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.latency);
902 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.min_slice_size);
904 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.slice_enc_params);
906 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support);
908 if (msg->video_3d_formats->list->preferred_display_mode_supported == 1) {
909 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.max_hres);
911 WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.max_vres);
915 } else if (!g_strcmp0(type, STRING_WFD_CONTENT_PROTECTION)) {
916 msg->content_protection = g_new0(WFDContentProtection, 1);
919 msg->content_protection->hdcp2_spec = g_new0(WFDHdcp2Spec, 1);
920 if (strstr(v, STRING_WFD_NONE)) {
921 msg->content_protection->hdcp2_spec->hdcpversion = g_strdup(STRING_WFD_NONE);
923 WFD_READ_STRING(msg->content_protection->hdcp2_spec->hdcpversion);
925 WFD_READ_STRING(msg->content_protection->hdcp2_spec->TCPPort);
928 } else if (!g_strcmp0(type, STRING_WFD_DISPLAY_EDID)) {
929 msg->display_edid = g_new0(WFDDisplayEdid, 1);
932 if (strstr(v, STRING_WFD_NONE)) {
933 msg->display_edid->edid_supported = 0;
935 msg->display_edid->edid_supported = 1;
936 WFD_READ_UINT32(msg->display_edid->edid_block_count);
938 if (msg->display_edid->edid_block_count) {
939 gchar *edid_string = v;
940 int i = 0, j = 0, size = 0;
941 guint32 payload_size = EDID_BLOCK_SIZE * msg->display_edid->edid_block_count;
942 msg->display_edid->edid_payload = g_malloc(payload_size);
943 size = EDID_BLOCK_SIZE * msg->display_edid->edid_block_count * 2;
944 for (; i < size; j++) {
946 if (edid_string[i] > 0x29 && edid_string[i] < 0x40) k = edid_string[i] - 48;
947 else if (edid_string[i] > 0x60 && edid_string[i] < 0x67) k = edid_string[i] - 87;
948 else if (edid_string[i] > 0x40 && edid_string[i] < 0x47) k = edid_string[i] - 55;
950 if (edid_string[i + 1] > 0x29 && edid_string[i + 1] < 0x40) kk = edid_string[i + 1] - 48;
951 else if (edid_string[i + 1] > 0x60 && edid_string[i + 1] < 0x67) kk = edid_string[i + 1] - 87;
952 else if (edid_string[i + 1] > 0x40 && edid_string[i + 1] < 0x47) kk = edid_string[i + 1] - 55;
954 msg->display_edid->edid_payload[j] = (k << 4) | kk;
957 /*memcpy(msg->display_edid->edid_payload, v, payload_size); */
958 v += (payload_size * 2);
959 } else v += strlen(v);
962 } else if (!g_strcmp0(type, STRING_WFD_COUPLED_SINK)) {
963 msg->coupled_sink = g_new0(WFDCoupledSink, 1);
965 msg->coupled_sink->coupled_sink_cap = g_new0(WFDCoupled_sink_cap, 1);
967 WFD_READ_UINT32(msg->coupled_sink->coupled_sink_cap->status);
969 WFD_READ_STRING(msg->coupled_sink->coupled_sink_cap->sink_address);
971 } else if (!g_strcmp0(type, STRING_WFD_TRIGGER_METHOD)) {
972 msg->trigger_method = g_new0(WFDTriggerMethod, 1);
975 WFD_READ_STRING(msg->trigger_method->wfd_trigger_method);
977 } else if (!g_strcmp0(type, STRING_WFD_PRESENTATION_URL)) {
978 msg->presentation_url = g_new0(WFDPresentationUrl, 1);
981 WFD_READ_STRING(msg->presentation_url->wfd_url0);
983 WFD_READ_STRING(msg->presentation_url->wfd_url1);
985 } else if (!g_strcmp0(type, STRING_WFD_CLIENT_RTP_PORTS)) {
986 msg->client_rtp_ports = g_new0(WFDClientRtpPorts, 1);
989 WFD_READ_STRING(msg->client_rtp_ports->profile);
991 WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port0);
993 WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port1);
995 WFD_READ_STRING(msg->client_rtp_ports->mode);
997 } else if (!g_strcmp0(type, STRING_WFD_ROUTE)) {
998 msg->route = g_new0(WFDRoute, 1);
1001 WFD_READ_STRING(msg->route->destination);
1003 } else if (!g_strcmp0(type, STRING_WFD_I2C)) {
1004 msg->I2C = g_new0(WFDI2C, 1);
1006 msg->I2C->I2CPresent = TRUE;
1008 WFD_READ_UINT32_DIGIT(msg->I2C->I2C_port);
1009 if (msg->I2C->I2C_port) msg->I2C->I2CPresent = TRUE;
1011 } else if (!g_strcmp0(type, STRING_WFD_AV_FORMAT_CHANGE_TIMING)) {
1012 msg->av_format_change_timing = g_new0(WFDAVFormatChangeTiming, 1);
1015 WFD_READ_UINT32(msg->av_format_change_timing->PTS);
1017 WFD_READ_UINT32(msg->av_format_change_timing->DTS);
1019 } else if (!g_strcmp0(type, STRING_WFD_PREFERRED_DISPLAY_MODE)) {
1020 msg->preferred_display_mode = g_new0(WFDPreferredDisplayMode, 1);
1023 if (!strstr(v, STRING_WFD_NONE)) {
1024 msg->preferred_display_mode->displaymodesupported = FALSE;
1026 WFD_READ_UINT32(msg->preferred_display_mode->p_clock);
1028 WFD_READ_UINT32(msg->preferred_display_mode->H);
1030 WFD_READ_UINT32(msg->preferred_display_mode->HB);
1032 WFD_READ_UINT32(msg->preferred_display_mode->HSPOL_HSOFF);
1034 WFD_READ_UINT32(msg->preferred_display_mode->HSW);
1036 WFD_READ_UINT32(msg->preferred_display_mode->V);
1038 WFD_READ_UINT32(msg->preferred_display_mode->VB);
1040 WFD_READ_UINT32(msg->preferred_display_mode->VSPOL_VSOFF);
1042 WFD_READ_UINT32(msg->preferred_display_mode->VSW);
1044 WFD_READ_UINT32(msg->preferred_display_mode->VBS3D);
1046 WFD_READ_UINT32(msg->preferred_display_mode->V2d_s3d_modes);
1048 WFD_READ_UINT32(msg->preferred_display_mode->P_depth);
1050 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.profile);
1052 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.level);
1054 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.CEA_Support);
1056 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.VESA_Support);
1058 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.HH_Support);
1060 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.latency);
1062 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.min_slice_size);
1064 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.slice_enc_params);
1066 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.frame_rate_control_support);
1068 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_hres);
1070 WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_vres);
1074 } else if (!g_strcmp0(type, STRING_WFD_UIBC_CAPABILITY)) {
1075 msg->uibc_capability = g_new0(WFDUibcCapability, 1);
1076 if (strstr(v, STRING_WFD_INPUT_CATEGORY_LIST)) {
1077 gchar *tstring = NULL;
1078 msg->uibc_capability->uibcsupported = TRUE;
1080 WFD_READ_CHAR_END_STRING(tstring, '=');
1081 if (!g_strcmp0(tstring, STRING_WFD_INPUT_CATEGORY_LIST)) {
1082 gchar temp2[8192] = {0};
1083 guint rem_len = 0, read_len = 0;
1084 WFD_READ_CHAR_END_STRING(tstring, ';');
1085 rem_len = strlen(tstring);
1088 read_string_char_ended(temp2, 8192, ',', tstring + read_len);
1089 read_len += (strlen(temp2) + 1);
1090 if (strstr(temp2, STRING_WFD_GENERIC)) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_GENERIC;
1091 else if (strstr(temp2, STRING_WFD_HIDC)) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_HIDC;
1092 else msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_UNKNOWN;
1093 } while (read_len < rem_len);
1095 result = strstr(v, STRING_WFD_GENERIC_CAP_LIST);
1096 if (result != NULL) {
1097 memset(temp2, 0, 8192);
1101 WFD_READ_CHAR_END_STRING(tstring, '=');
1102 if (!g_strcmp0(tstring, STRING_WFD_GENERIC_CAP_LIST)) {
1104 WFD_READ_CHAR_END_STRING(tstring, ';');
1105 rem_len = strlen(tstring);
1107 read_string_char_ended(temp2, 8192, ',', tstring + read_len);
1108 read_len += (strlen(temp2) + 1);
1109 if (strstr(temp2, STRING_WFD_KEYBOARD)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_KEYBOARD;
1110 else if (strstr(temp2, STRING_WFD_MOUSE)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MOUSE;
1111 else if (strstr(temp2, STRING_WFD_SINGLE_TOUCH)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_SINGLETOUCH;
1112 else if (strstr(temp2, STRING_WFD_MULTI_TOUCH)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MULTITOUCH;
1113 else if (strstr(temp2, STRING_WFD_JOYSTICK)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_JOYSTICK;
1114 else if (strstr(temp2, STRING_WFD_CAMERA)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_CAMERA;
1115 else if (strstr(temp2, STRING_WFD_GESTURE)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_GESTURE;
1116 else if (strstr(temp2, STRING_WFD_REMOTE_CONTROL)) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_REMOTECONTROL;
1117 else msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_UNKNOWN;
1118 } while (read_len < rem_len);
1121 result = strstr(v, STRING_WFD_HIDC_CAP_LIST);
1122 if (result != NULL) {
1125 WFD_READ_CHAR_END_STRING(tstring, '=');
1126 if (!g_strcmp0(tstring, STRING_WFD_HIDC_CAP_LIST)) {
1127 gchar inp_type[8192];
1128 gchar inp_path[8192];
1129 memset(temp2, 0, 8192);
1132 detailed_cap *temp_cap;
1133 WFD_READ_CHAR_END_STRING(tstring, ';');
1134 rem_len = strlen(tstring);
1135 msg->uibc_capability->hidc_cap_list.next = g_new0(detailed_cap, 1);
1136 temp_cap = msg->uibc_capability->hidc_cap_list.next;
1138 msg->uibc_capability->hidc_cap_list.cap_count++;
1139 read_string_char_ended(temp2, 8192, ',', tstring + read_len);
1140 read_len += (strlen(temp2) + 1);
1141 read_string_type_and_value(inp_type, inp_path, sizeof(inp_type), sizeof(inp_path), '/', temp2);
1142 if (strstr(inp_type, STRING_WFD_KEYBOARD)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_KEYBOARD;
1143 else if (strstr(inp_type, STRING_WFD_MOUSE)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MOUSE;
1144 else if (strstr(inp_type, STRING_WFD_SINGLE_TOUCH)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_SINGLETOUCH;
1145 else if (strstr(inp_type, STRING_WFD_MULTI_TOUCH)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MULTITOUCH;
1146 else if (strstr(inp_type, STRING_WFD_JOYSTICK)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_JOYSTICK;
1147 else if (strstr(inp_type, STRING_WFD_CAMERA)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_CAMERA;
1148 else if (strstr(inp_type, STRING_WFD_GESTURE)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_GESTURE;
1149 else if (strstr(inp_type, STRING_WFD_REMOTE_CONTROL)) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_REMOTECONTROL;
1150 else temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_UNKNOWN;
1152 if (strstr(inp_path, STRING_WFD_INFRARED)) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_INFRARED;
1153 else if (strstr(inp_path, STRING_WFD_USB)) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_USB;
1154 else if (strstr(inp_path, STRING_WFD_BT)) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_BT;
1155 else if (strstr(inp_path, STRING_WFD_ZIGBEE)) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_ZIGBEE;
1156 else if (strstr(inp_path, STRING_WFD_WIFI)) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_WIFI;
1157 else if (strstr(inp_path, STRING_WFD_NO_SP)) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_NOSP;
1158 else temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_UNKNOWN;
1159 if (read_len < rem_len) {
1160 temp_cap->next = g_new0(detailed_cap, 1);
1161 temp_cap = temp_cap->next;
1163 } while (read_len < rem_len);
1166 result = strstr(v, STRING_WFD_PORT);
1167 if (result != NULL) {
1169 WFD_READ_CHAR_END_STRING(tstring, '=');
1170 if (!g_strcmp0(tstring, STRING_WFD_PORT)) {
1172 WFD_READ_CHAR_END_STRING(tstring, ';');
1173 if (!strstr(tstring, STRING_WFD_NONE)) {
1174 msg->uibc_capability->tcp_port = strtoul(tstring, NULL, 10);
1179 } else if (strstr(v, STRING_WFD_NONE)) {
1180 msg->uibc_capability->uibcsupported = FALSE;
1182 } else if (!g_strcmp0(type, STRING_WFD_UIBC_SETTING)) {
1183 msg->uibc_setting = g_new0(WFDUibcSetting, 1);
1186 if (!g_strcmp0(v, STRING_WFD_ENABLE))
1187 msg->uibc_setting->uibc_setting = TRUE;
1189 msg->uibc_setting->uibc_setting = FALSE;
1191 } else if (!g_strcmp0(type, STRING_WFD_STANDBY_RESUME_CAPABILITY)) {
1192 msg->standby_resume_capability = g_new0(WFDStandbyResumeCapability, 1);
1195 if (!g_strcmp0(v, STRING_WFD_SUPPORTED))
1196 msg->standby_resume_capability->standby_resume_cap = TRUE;
1198 msg->standby_resume_capability->standby_resume_cap = FALSE;
1200 } else if (!g_strcmp0(type, STRING_WFD_STANDBY)) {
1201 msg->standby = g_new0(WFDStandby, 1);
1202 msg->standby->wfd_standby = TRUE;
1203 } else if (!g_strcmp0(type, STRING_WFD_CONNECTOR_TYPE)) {
1204 msg->connector_type = g_new0(WFDConnectorType, 1);
1206 msg->connector_type->supported = TRUE;
1208 WFD_READ_UINT32(msg->connector_type->connector_type);
1210 } else if (!g_strcmp0(type, STRING_WFD_IDR_REQUEST)) {
1211 msg->idr_request = g_new0(WFDIdrRequest, 1);
1212 msg->idr_request->idr_request = TRUE;
1219 * wfdconfig_message_parse_buffer:
1220 * @data: the start of the buffer
1221 * @size: the size of the buffer
1222 * @msg: the result #WFDMessage
1224 * Parse the contents of @size bytes pointed to by @data and store the result in
1227 * Returns: #WFD_OK on success.
1230 wfdconfig_message_parse_buffer(const guint8 *data, guint size, WFDMessage *msg)
1233 gchar buffer[MAX_LINE_LEN] = {0};
1236 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1237 g_return_val_if_fail(data != NULL, WFD_EINVAL);
1238 g_return_val_if_fail(size != 0, WFD_EINVAL);
1240 p = (const gchar *) data;
1247 while (*p != '\n' && *p != '\r' && *p != '\0') {
1248 if (idx < sizeof(buffer) - 1)
1253 wfdconfig_parse_line(msg, buffer);
1264 * wfdconfig_message_dump:
1265 * @msg: a #WFDMessage
1267 * Dump the parsed contents of @msg to stdout.
1269 * Returns: a #WFDResult.
1272 wfdconfig_message_dump(const WFDMessage *msg)
1274 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1275 wfd_debug("===========WFD Message dump=========");
1277 if (msg->audio_codecs) {
1279 wfd_debug("Audio supported formats : ");
1280 for (; i < msg->audio_codecs->count; i++) {
1281 wfd_debug("Codec: %s", msg->audio_codecs->list[i].audio_format);
1282 if (!strcmp(msg->audio_codecs->list[i].audio_format, STRING_WFD_LPCM)) {
1283 if (msg->audio_codecs->list[i].modes & WFD_FREQ_44100)
1284 wfd_debug(" Freq: %d", 44100);
1285 if (msg->audio_codecs->list[i].modes & WFD_FREQ_48000)
1286 wfd_debug(" Freq: %d", 48000);
1287 wfd_debug(" Channels: %d", 2);
1289 if (!strcmp(msg->audio_codecs->list[i].audio_format, STRING_WFD_AAC)) {
1290 wfd_debug(" Freq: %d", 48000);
1291 if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_2)
1292 wfd_debug(" Channels: %d", 2);
1293 if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_4)
1294 wfd_debug(" Channels: %d", 4);
1295 if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_6)
1296 wfd_debug(" Channels: %d", 6);
1297 if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_8)
1298 wfd_debug(" Channels: %d", 8);
1300 if (!strcmp(msg->audio_codecs->list[i].audio_format, STRING_WFD_AC3)) {
1301 wfd_debug(" Freq: %d", 48000);
1302 if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_2)
1303 wfd_debug(" Channels: %d", 2);
1304 if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_4)
1305 wfd_debug(" Channels: %d", 4);
1306 if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_6)
1307 wfd_debug(" Channels: %d", 6);
1309 wfd_debug(" Bitwidth: %d", 16);
1310 wfd_debug(" Latency: %d", msg->audio_codecs->list[i].latency);
1315 if (msg->video_formats) {
1316 wfd_debug("Video supported formats : ");
1317 if (msg->video_formats->list) {
1318 wfd_debug("Codec: H264");
1319 guint nativeindex = 0;
1320 if ((msg->video_formats->list->native & 0x7) == WFD_VIDEO_CEA_RESOLUTION) {
1321 wfd_debug(" Native type: CEA");
1322 } else if ((msg->video_formats->list->native & 0x7) == WFD_VIDEO_VESA_RESOLUTION) {
1323 wfd_debug(" Native type: VESA");
1324 } else if ((msg->video_formats->list->native & 0x7) == WFD_VIDEO_HH_RESOLUTION) {
1325 wfd_debug(" Native type: HH");
1327 nativeindex = msg->video_formats->list->native >> 3;
1328 wfd_debug(" Resolution: %d", (1 << nativeindex));
1330 if (msg->video_formats->list->H264_codec.profile & WFD_H264_BASE_PROFILE) {
1331 wfd_debug(" Profile: BASE");
1332 } else if (msg->video_formats->list->H264_codec.profile & WFD_H264_HIGH_PROFILE) {
1333 wfd_debug(" Profile: HIGH");
1335 if (msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_1) {
1336 wfd_debug(" Level: 3.1");
1337 } else if (msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_2) {
1338 wfd_debug(" Level: 3.2");
1339 } else if (msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4) {
1340 wfd_debug(" Level: 4");
1341 } else if (msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_1) {
1342 wfd_debug(" Level: 4.1");
1343 } else if (msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_2) {
1344 wfd_debug(" Level: 4.2");
1346 wfd_debug(" Latency: %d", msg->video_formats->list->H264_codec.misc_params.latency);
1347 wfd_debug(" min_slice_size: %x", msg->video_formats->list->H264_codec.misc_params.min_slice_size);
1348 wfd_debug(" slice_enc_params: %x", msg->video_formats->list->H264_codec.misc_params.slice_enc_params);
1349 wfd_debug(" frame_rate_control_support: %x", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support);
1350 if (msg->video_formats->list->H264_codec.max_hres) {
1351 wfd_debug(" Max Width: %04d", msg->video_formats->list->H264_codec.max_hres);
1353 if (msg->video_formats->list->H264_codec.max_vres) {
1354 wfd_debug(" Max Height: %04d", msg->video_formats->list->H264_codec.max_vres);
1359 if (msg->video_3d_formats) {
1360 wfd_debug("wfd_3d_formats");
1363 if (msg->content_protection) {
1364 wfd_debug(STRING_WFD_CONTENT_PROTECTION);
1367 if (msg->display_edid) {
1368 wfd_debug(STRING_WFD_DISPLAY_EDID);
1371 if (msg->coupled_sink) {
1372 wfd_debug(STRING_WFD_COUPLED_SINK);
1375 if (msg->trigger_method) {
1376 wfd_debug(" Trigger type: %s", msg->trigger_method->wfd_trigger_method);
1379 if (msg->presentation_url) {
1380 wfd_debug(STRING_WFD_PRESENTATION_URL);
1383 if (msg->client_rtp_ports) {
1384 wfd_debug(" Client RTP Ports : ");
1385 if (msg->client_rtp_ports->profile) {
1386 wfd_debug("%s", msg->client_rtp_ports->profile);
1387 wfd_debug(" %d", msg->client_rtp_ports->rtp_port0);
1388 wfd_debug(" %d", msg->client_rtp_ports->rtp_port1);
1389 wfd_debug(" %s", msg->client_rtp_ports->mode);
1394 wfd_debug(STRING_WFD_ROUTE);
1398 wfd_debug(STRING_WFD_I2C);
1401 if (msg->av_format_change_timing) {
1402 wfd_debug(STRING_WFD_AV_FORMAT_CHANGE_TIMING);
1405 if (msg->preferred_display_mode) {
1406 wfd_debug(STRING_WFD_PREFERRED_DISPLAY_MODE);
1409 if (msg->uibc_capability) {
1410 wfd_debug("wfd_uibc_capability \r");
1411 wfd_debug("input category list:");
1412 if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC)
1413 wfd_debug(STRING_WFD_GENERIC);
1414 if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC)
1415 wfd_debug(STRING_WFD_HIDC);
1416 if (!msg->uibc_capability->input_category_list.input_cat)
1417 wfd_debug(STRING_WFD_NONE);
1418 if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) {
1419 wfd_debug("generic cap list: ");
1420 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD)
1421 wfd_debug("keyboard ");
1422 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE)
1423 wfd_debug("mouse ");
1424 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH)
1425 wfd_debug("single-touch ");
1426 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH)
1427 wfd_debug("multi-touch ");
1428 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK)
1429 wfd_debug("joystick ");
1430 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA)
1431 wfd_debug("camera ");
1432 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE)
1433 wfd_debug("gesture ");
1434 if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL)
1435 wfd_debug("remote control ");
1436 if (!msg->uibc_capability->generic_cap_list.inp_type)
1439 if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) {
1440 wfd_debug("hidc cap list:");
1441 if (msg->uibc_capability->hidc_cap_list.cap_count) {
1442 detailed_cap *temp_cap = msg->uibc_capability->hidc_cap_list.next;
1444 if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) {
1445 wfd_debug("keyboard ");
1446 } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) {
1447 wfd_debug("mouse ");
1448 } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) {
1449 wfd_debug("single-touch ");
1450 } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) {
1451 wfd_debug("multi-touch ");
1452 } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) {
1453 wfd_debug("joystick ");
1454 } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) {
1455 wfd_debug("camera ");
1456 } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) {
1457 wfd_debug("gesture ");
1458 } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) {
1459 wfd_debug("remote control ");
1460 } else if (!temp_cap->p.inp_type) {
1463 if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_INFRARED) {
1464 wfd_debug(STRING_WFD_INFRARED);
1465 } else if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_USB) {
1466 wfd_debug(STRING_WFD_USB);
1467 } else if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_BT) {
1468 wfd_debug(STRING_WFD_BT);
1469 } else if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_WIFI) {
1470 wfd_debug(STRING_WFD_WIFI);
1471 } else if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_ZIGBEE) {
1472 wfd_debug(STRING_WFD_ZIGBEE);
1473 } else if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_NOSP) {
1474 wfd_debug(STRING_WFD_NO_SP);
1475 } else if (!temp_cap->p.inp_path) {
1476 wfd_debug(STRING_WFD_NONE);
1478 temp_cap = temp_cap->next;
1482 if (msg->uibc_capability->tcp_port)
1483 wfd_debug("tcp port:%u", msg->uibc_capability->tcp_port);
1484 if (!msg->uibc_capability->tcp_port)
1485 wfd_debug("tcp port: none");
1488 if (msg->uibc_setting) {
1489 wfd_debug("wfd_uibc_setting: ");
1490 if (msg->uibc_setting->uibc_setting) {
1492 } else wfd_debug("false");
1495 if (msg->standby_resume_capability) {
1496 wfd_debug(STRING_WFD_STANDBY_RESUME_CAPABILITY);
1500 wfd_debug(STRING_WFD_STANDBY);
1503 if (msg->connector_type) {
1504 wfd_debug(STRING_WFD_CONNECTOR_TYPE);
1507 if (msg->idr_request) {
1508 wfd_debug(STRING_WFD_IDR_REQUEST);
1511 wfd_debug("===============================================");
1515 WFDResult wfdconfig_set_supported_audio_format(WFDMessage *msg, WFDAudioFormats aCodec, guint aFreq, guint aChanels,
1516 guint aBitwidth, guint32 aLatency)
1518 guint temp = aCodec;
1520 guint pcm = 0, aac = 0, ac3 = 0;
1522 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1524 if (!msg->audio_codecs)
1525 msg->audio_codecs = g_new0(WFDAudioCodeclist, 1);
1527 if (aCodec != WFD_AUDIO_UNKNOWN) {
1529 msg->audio_codecs->count++;
1532 msg->audio_codecs->list = g_new0(WFDAudioCodec, msg->audio_codecs->count);
1533 for (; i < msg->audio_codecs->count; i++) {
1534 if ((aCodec & WFD_AUDIO_LPCM) && (!pcm)) {
1535 msg->audio_codecs->list[i].audio_format = g_strdup(STRING_WFD_LPCM);
1536 msg->audio_codecs->list[i].modes = aFreq;
1537 msg->audio_codecs->list[i].latency = aLatency;
1539 } else if ((aCodec & WFD_AUDIO_AAC) && (!aac)) {
1540 msg->audio_codecs->list[i].audio_format = g_strdup(STRING_WFD_AAC);
1541 msg->audio_codecs->list[i].modes = aChanels;
1542 msg->audio_codecs->list[i].latency = aLatency;
1544 } else if ((aCodec & WFD_AUDIO_AC3) && (!ac3)) {
1545 msg->audio_codecs->list[i].audio_format = g_strdup(STRING_WFD_AC3);
1546 msg->audio_codecs->list[i].modes = aChanels;
1547 msg->audio_codecs->list[i].latency = aLatency;
1555 WFDResult wfdconfig_set_prefered_audio_format(WFDMessage *msg, WFDAudioFormats aCodec, WFDAudioFreq aFreq, WFDAudioChannels aChanels,
1556 guint aBitwidth, guint32 aLatency)
1559 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1561 if (!msg->audio_codecs)
1562 msg->audio_codecs = g_new0(WFDAudioCodeclist, 1);
1564 msg->audio_codecs->list = g_new0(WFDAudioCodec, 1);
1565 msg->audio_codecs->count = 1;
1566 if (aCodec == WFD_AUDIO_LPCM) {
1567 msg->audio_codecs->list->audio_format = g_strdup(STRING_WFD_LPCM);
1568 msg->audio_codecs->list->modes = aFreq;
1569 msg->audio_codecs->list->latency = aLatency;
1570 } else if (aCodec == WFD_AUDIO_AAC) {
1571 msg->audio_codecs->list->audio_format = g_strdup(STRING_WFD_AAC);
1572 msg->audio_codecs->list->modes = aChanels;
1573 msg->audio_codecs->list->latency = aLatency;
1574 } else if (aCodec == WFD_AUDIO_AC3) {
1575 msg->audio_codecs->list->audio_format = g_strdup(STRING_WFD_AC3);
1576 msg->audio_codecs->list->modes = aChanels;
1577 msg->audio_codecs->list->latency = aLatency;
1582 WFDResult wfdconfig_get_supported_audio_format(WFDMessage *msg, guint *aCodec, guint *aFreq, guint *aChanels,
1583 guint *aBitwidth, guint32 *aLatency)
1586 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1587 g_return_val_if_fail(msg->audio_codecs != NULL, WFD_EINVAL);
1589 for (; i < msg->audio_codecs->count; i++) {
1590 if (!g_strcmp0(msg->audio_codecs->list[i].audio_format, STRING_WFD_LPCM)) {
1591 *aCodec |= WFD_AUDIO_LPCM;
1592 *aFreq |= msg->audio_codecs->list[i].modes;
1593 *aChanels |= WFD_CHANNEL_2;
1595 *aLatency = msg->audio_codecs->list[i].latency;
1596 } else if (!g_strcmp0(msg->audio_codecs->list[i].audio_format, STRING_WFD_AAC)) {
1597 *aCodec |= WFD_AUDIO_AAC;
1598 *aFreq |= WFD_FREQ_48000;
1599 *aChanels |= msg->audio_codecs->list[i].modes;
1601 *aLatency = msg->audio_codecs->list[i].latency;
1602 } else if (!g_strcmp0(msg->audio_codecs->list[i].audio_format, STRING_WFD_AC3)) {
1603 *aCodec |= WFD_AUDIO_AC3;
1604 *aFreq |= WFD_FREQ_48000;
1605 *aChanels |= msg->audio_codecs->list[i].modes;
1607 *aLatency = msg->audio_codecs->list[i].latency;
1613 WFDResult wfdconfig_get_prefered_audio_format(WFDMessage *msg, WFDAudioFormats *aCodec, WFDAudioFreq *aFreq, WFDAudioChannels *aChanels,
1614 guint *aBitwidth, guint32 *aLatency)
1616 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1618 if (!g_strcmp0(msg->audio_codecs->list->audio_format, STRING_WFD_LPCM)) {
1619 *aCodec = WFD_AUDIO_LPCM;
1620 *aFreq = msg->audio_codecs->list->modes;
1621 *aChanels = WFD_CHANNEL_2;
1623 *aLatency = msg->audio_codecs->list->latency;
1624 } else if (!g_strcmp0(msg->audio_codecs->list->audio_format, STRING_WFD_AAC)) {
1625 *aCodec = WFD_AUDIO_AAC;
1626 *aFreq = WFD_FREQ_48000;
1627 *aChanels = msg->audio_codecs->list->modes;
1629 *aLatency = msg->audio_codecs->list->latency;
1630 } else if (!g_strcmp0(msg->audio_codecs->list->audio_format, STRING_WFD_AC3)) {
1631 *aCodec = WFD_AUDIO_AC3;
1632 *aFreq = WFD_FREQ_48000;
1633 *aChanels = msg->audio_codecs->list->modes;
1635 *aLatency = msg->audio_codecs->list->latency;
1640 WFDResult wfdconfig_set_supported_video_format(WFDMessage *msg, WFDVideoCodecs vCodec,
1641 WFDVideoNativeResolution vNative, guint64 vNativeResolution,
1642 guint64 vCEAResolution, guint64 vVESAResolution, guint64 vHHResolution,
1643 guint vProfile, guint vLevel, guint32 vLatency, guint32 vMaxHeight,
1644 guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control)
1646 guint nativeindex = 0;
1647 guint64 temp = vNativeResolution;
1649 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1651 if (!msg->video_formats)
1652 msg->video_formats = g_new0(WFDVideoCodeclist, 1);
1654 if (vCodec != WFD_VIDEO_UNKNOWN) {
1655 msg->video_formats->list = g_new0(WFDVideoCodec, 1);
1661 msg->video_formats->list->native = nativeindex - 1;
1662 msg->video_formats->list->native <<= 3;
1664 if (vNative == WFD_VIDEO_VESA_RESOLUTION)
1665 msg->video_formats->list->native |= 1;
1666 else if (vNative == WFD_VIDEO_HH_RESOLUTION)
1667 msg->video_formats->list->native |= 2;
1669 msg->video_formats->list->preferred_display_mode_supported = 1;
1670 msg->video_formats->list->H264_codec.profile = vProfile;
1671 msg->video_formats->list->H264_codec.level = vLevel;
1672 msg->video_formats->list->H264_codec.max_hres = vMaxWidth;
1673 msg->video_formats->list->H264_codec.max_vres = vMaxHeight;
1674 msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution;
1675 msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution;
1676 msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution;
1677 msg->video_formats->list->H264_codec.misc_params.latency = vLatency;
1678 msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size;
1679 msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params;
1680 msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control;
1685 WFDResult wfdconfig_set_prefered_video_format(WFDMessage *msg, WFDVideoCodecs vCodec,
1686 WFDVideoNativeResolution vNative, guint64 vNativeResolution,
1687 WFDVideoCEAResolution vCEAResolution, WFDVideoVESAResolution vVESAResolution,
1688 WFDVideoHHResolution vHHResolution, WFDVideoH264Profile vProfile,
1689 WFDVideoH264Level vLevel, guint32 vLatency, guint32 vMaxHeight,
1690 guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control)
1692 guint nativeindex = 0;
1693 guint64 temp = vNativeResolution;
1695 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1697 if (!msg->video_formats)
1698 msg->video_formats = g_new0(WFDVideoCodeclist, 1);
1699 msg->video_formats->list = g_new0(WFDVideoCodec, 1);
1706 if (nativeindex) msg->video_formats->list->native = nativeindex - 1;
1707 msg->video_formats->list->native <<= 3;
1709 if (vNative == WFD_VIDEO_VESA_RESOLUTION)
1710 msg->video_formats->list->native |= 1;
1711 else if (vNative == WFD_VIDEO_HH_RESOLUTION)
1712 msg->video_formats->list->native |= 2;
1714 msg->video_formats->list->preferred_display_mode_supported = 0;
1715 msg->video_formats->list->H264_codec.profile = vProfile;
1716 msg->video_formats->list->H264_codec.level = vLevel;
1717 msg->video_formats->list->H264_codec.max_hres = vMaxWidth;
1718 msg->video_formats->list->H264_codec.max_vres = vMaxHeight;
1719 msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution;
1720 msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution;
1721 msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution;
1722 msg->video_formats->list->H264_codec.misc_params.latency = vLatency;
1723 msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size;
1724 msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params;
1725 msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control;
1729 WFDResult wfdconfig_get_supported_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec,
1730 WFDVideoNativeResolution *vNative, guint64 *vNativeResolution,
1731 guint64 *vCEAResolution, guint64 *vVESAResolution, guint64 *vHHResolution,
1732 guint *vProfile, guint *vLevel, guint32 *vLatency, guint32 *vMaxHeight,
1733 guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control)
1735 guint nativeindex = 0;
1737 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1738 g_return_val_if_fail(msg->video_formats != NULL, WFD_EINVAL);
1739 g_return_val_if_fail(msg->video_formats->list != NULL, WFD_EINVAL);
1741 *vCodec = WFD_VIDEO_H264;
1742 *vNative = msg->video_formats->list->native & 0x7;
1743 nativeindex = msg->video_formats->list->native >> 3;
1744 *vNativeResolution = (guint64)1 << nativeindex;
1745 *vProfile = msg->video_formats->list->H264_codec.profile;
1746 *vLevel = msg->video_formats->list->H264_codec.level;
1747 *vMaxWidth = msg->video_formats->list->H264_codec.max_hres;
1748 *vMaxHeight = msg->video_formats->list->H264_codec.max_vres;
1749 *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support;
1750 *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support;
1751 *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support;
1752 *vLatency = msg->video_formats->list->H264_codec.misc_params.latency;
1753 *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size;
1754 *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params;
1755 *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support;
1759 WFDResult wfdconfig_get_prefered_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec,
1760 WFDVideoNativeResolution *vNative, guint64 *vNativeResolution,
1761 WFDVideoCEAResolution *vCEAResolution, WFDVideoVESAResolution *vVESAResolution,
1762 WFDVideoHHResolution *vHHResolution, WFDVideoH264Profile *vProfile,
1763 WFDVideoH264Level *vLevel, guint32 *vLatency, guint32 *vMaxHeight,
1764 guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control)
1766 guint nativeindex = 0;
1767 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1768 g_return_val_if_fail(msg->video_formats != NULL, WFD_EINVAL);
1769 g_return_val_if_fail(msg->video_formats->list != NULL, WFD_EINVAL);
1771 *vCodec = WFD_VIDEO_H264;
1772 *vNative = msg->video_formats->list->native & 0x7;
1773 nativeindex = msg->video_formats->list->native >> 3;
1774 *vNativeResolution = (guint64)1 << nativeindex;
1775 *vProfile = msg->video_formats->list->H264_codec.profile;
1776 *vLevel = msg->video_formats->list->H264_codec.level;
1777 *vMaxWidth = msg->video_formats->list->H264_codec.max_hres;
1778 *vMaxHeight = msg->video_formats->list->H264_codec.max_vres;
1779 *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support;
1780 *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support;
1781 *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support;
1782 *vLatency = msg->video_formats->list->H264_codec.misc_params.latency;
1783 *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size;
1784 *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params;
1785 *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support;
1789 WFDResult wfdconfig_set_contentprotection_type(WFDMessage *msg, WFDHDCPProtection hdcpversion, guint32 TCPPort)
1791 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1793 if (!msg->content_protection) msg->content_protection = g_new0(WFDContentProtection, 1);
1794 if (hdcpversion == WFD_HDCP_NONE) return WFD_OK;
1795 msg->content_protection->hdcp2_spec = g_new0(WFDHdcp2Spec, 1);
1796 if (hdcpversion == WFD_HDCP_2_0) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup(STRING_WFD_HDCP2_0);
1797 else if (hdcpversion == WFD_HDCP_2_1) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup(STRING_WFD_HDCP2_1);
1798 char str[11] = {0, };
1799 snprintf(str, 11, "port=%d", TCPPort);
1800 msg->content_protection->hdcp2_spec->TCPPort = g_strdup(str);
1804 WFDResult wfdconfig_get_contentprotection_type(WFDMessage *msg, WFDHDCPProtection *hdcpversion, guint32 *TCPPort)
1806 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1807 if (msg->content_protection && msg->content_protection->hdcp2_spec) {
1808 char *result = NULL;
1810 if (!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion, STRING_WFD_NONE)) {
1811 wfd_warning("HDCP none");
1812 *hdcpversion = WFD_HDCP_NONE;
1816 if (!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion, STRING_WFD_HDCP2_0)) *hdcpversion = WFD_HDCP_2_0;
1817 else if (!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion, STRING_WFD_HDCP2_1)) *hdcpversion = WFD_HDCP_2_1;
1819 wfd_warning("Unknown protection type");
1820 *hdcpversion = WFD_HDCP_NONE;
1825 result = strtok_r(msg->content_protection->hdcp2_spec->TCPPort, STRING_WFD_EQUALS, &ptr);
1826 while (result != NULL) {
1827 result = strtok_r(NULL, STRING_WFD_EQUALS, &ptr);
1828 *TCPPort = atoi(result);
1831 } else *hdcpversion = WFD_HDCP_NONE;
1835 WFDResult wfdconfig_set_display_EDID(WFDMessage *msg, gboolean edid_supported, guint32 edid_blockcount, gchar *edid_playload)
1837 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1838 if (!msg->display_edid) msg->display_edid = g_new0(WFDDisplayEdid, 1);
1839 msg->display_edid->edid_supported = edid_supported;
1840 if (!edid_supported) return WFD_OK;
1841 msg->display_edid->edid_block_count = edid_blockcount;
1842 if (edid_blockcount) {
1843 msg->display_edid->edid_payload = g_malloc(128 * edid_blockcount);
1844 if (!msg->display_edid->edid_payload)
1845 memcpy(msg->display_edid->edid_payload, edid_playload, 128 * edid_blockcount);
1846 } else msg->display_edid->edid_payload = g_strdup(STRING_WFD_NONE);
1850 WFDResult wfdconfig_get_display_EDID(WFDMessage *msg, gboolean *edid_supported, guint32 *edid_blockcount, gchar **edid_playload)
1852 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1853 if (msg->display_edid) {
1854 if (msg->display_edid->edid_supported) {
1855 *edid_blockcount = msg->display_edid->edid_block_count;
1856 if (msg->display_edid->edid_block_count) {
1858 temp = g_malloc(EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
1860 memset(temp, 0, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
1861 memcpy(temp, msg->display_edid->edid_payload, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count);
1862 *edid_playload = temp;
1863 *edid_supported = TRUE;
1865 } else *edid_playload = g_strdup(STRING_WFD_NONE);
1867 } else *edid_supported = FALSE;
1871 WFDResult wfdconfig_set_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus status, gchar *sink_address)
1873 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1874 if (!msg->coupled_sink) msg->coupled_sink = g_new0(WFDCoupledSink, 1);
1875 if (status == WFD_SINK_UNKNOWN) return WFD_OK;
1876 msg->coupled_sink->coupled_sink_cap = g_new0(WFDCoupled_sink_cap, 1);
1877 msg->coupled_sink->coupled_sink_cap->status = status;
1878 msg->coupled_sink->coupled_sink_cap->sink_address = g_strdup(sink_address);
1882 WFDResult wfdconfig_get_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus *status, gchar **sink_address)
1884 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1885 if (msg->coupled_sink && msg->coupled_sink->coupled_sink_cap) {
1886 *status = msg->coupled_sink->coupled_sink_cap->status;
1887 *sink_address = g_strdup(msg->coupled_sink->coupled_sink_cap->sink_address);
1888 } else *status = WFD_SINK_UNKNOWN;
1892 WFDResult wfdconfig_set_trigger_type(WFDMessage *msg, WFDTrigger trigger)
1894 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1896 if (!msg->trigger_method)
1897 msg->trigger_method = g_new0(WFDTriggerMethod, 1);
1898 if (trigger == WFD_TRIGGER_SETUP)
1899 msg->trigger_method->wfd_trigger_method = g_strdup(STRING_WFD_SETUP);
1900 else if (trigger == WFD_TRIGGER_PAUSE)
1901 msg->trigger_method->wfd_trigger_method = g_strdup(STRING_WFD_PAUSE);
1902 else if (trigger == WFD_TRIGGER_TEARDOWN)
1903 msg->trigger_method->wfd_trigger_method = g_strdup(STRING_WFD_TEARDOWN);
1904 else if (trigger == WFD_TRIGGER_PLAY)
1905 msg->trigger_method->wfd_trigger_method = g_strdup(STRING_WFD_PLAY);
1911 WFDResult wfdconfig_get_trigger_type(WFDMessage *msg, WFDTrigger *trigger)
1913 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1914 if (!g_strcmp0(msg->trigger_method->wfd_trigger_method, STRING_WFD_SETUP))
1915 *trigger = WFD_TRIGGER_SETUP;
1916 else if (!g_strcmp0(msg->trigger_method->wfd_trigger_method, STRING_WFD_PAUSE))
1917 *trigger = WFD_TRIGGER_PAUSE;
1918 else if (!g_strcmp0(msg->trigger_method->wfd_trigger_method, STRING_WFD_TEARDOWN))
1919 *trigger = WFD_TRIGGER_TEARDOWN;
1920 else if (!g_strcmp0(msg->trigger_method->wfd_trigger_method, STRING_WFD_PLAY))
1921 *trigger = WFD_TRIGGER_PLAY;
1923 *trigger = WFD_TRIGGER_UNKNOWN;
1929 WFDResult wfdconfig_set_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) msg->presentation_url = g_new0(WFDPresentationUrl, 1);
1933 if (wfd_url0) msg->presentation_url->wfd_url0 = g_strdup(wfd_url0);
1934 if (wfd_url1) msg->presentation_url->wfd_url1 = g_strdup(wfd_url1);
1938 WFDResult wfdconfig_get_presentation_url(WFDMessage *msg, gchar **wfd_url0, gchar **wfd_url1)
1940 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1941 if (msg->presentation_url) {
1942 *wfd_url0 = g_strdup(msg->presentation_url->wfd_url0);
1943 *wfd_url1 = g_strdup(msg->presentation_url->wfd_url1);
1948 WFDResult wfdconfig_set_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode trans, WFDRTSPProfile profile,
1949 WFDRTSPLowerTrans lowertrans, guint32 rtp_port0, guint32 rtp_port1)
1952 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1954 if (!msg->client_rtp_ports)
1955 msg->client_rtp_ports = g_new0(WFDClientRtpPorts, 1);
1957 if (trans != WFD_RTSP_TRANS_UNKNOWN) {
1958 lines = g_string_new("");
1959 if (trans == WFD_RTSP_TRANS_RTP) g_string_append_printf(lines, STRING_WFD_RTP);
1960 else if (trans == WFD_RTSP_TRANS_RDT) g_string_append_printf(lines, STRING_WFD_RDT);
1962 if (profile != WFD_RTSP_PROFILE_UNKNOWN) g_string_append_printf(lines, STRING_WFD_SLASH);
1964 if (profile == WFD_RTSP_PROFILE_AVP) g_string_append_printf(lines, STRING_WFD_AVP);
1965 else if (profile == WFD_RTSP_PROFILE_SAVP) g_string_append_printf(lines, STRING_WFD_SAVP);
1967 if (lowertrans != WFD_RTSP_LOWER_TRANS_UNKNOWN) g_string_append_printf(lines, STRING_WFD_SLASH);
1969 if (lowertrans == WFD_RTSP_LOWER_TRANS_UDP) {
1970 g_string_append_printf(lines, STRING_WFD_UDP);
1971 g_string_append_printf(lines, STRING_WFD_SEMI_COLON);
1972 g_string_append_printf(lines, STRING_WFD_UNICAST);
1973 } else if (lowertrans == WFD_RTSP_LOWER_TRANS_UDP_MCAST) {
1974 g_string_append_printf(lines, STRING_WFD_UDP);
1975 g_string_append_printf(lines, STRING_WFD_SEMI_COLON);
1976 g_string_append_printf(lines, STRING_WFD_MULTICAST);
1977 } else if (lowertrans == WFD_RTSP_LOWER_TRANS_TCP) {
1978 g_string_append_printf(lines, STRING_WFD_TCP);
1979 g_string_append_printf(lines, STRING_WFD_SEMI_COLON);
1980 g_string_append_printf(lines, STRING_WFD_UNICAST);
1981 } else if (lowertrans == WFD_RTSP_LOWER_TRANS_HTTP) {
1982 g_string_append_printf(lines, STRING_WFD_TCP_HTTP);
1985 msg->client_rtp_ports->profile = g_string_free(lines, FALSE);
1986 msg->client_rtp_ports->rtp_port0 = rtp_port0;
1987 msg->client_rtp_ports->rtp_port1 = rtp_port1;
1988 msg->client_rtp_ports->mode = g_strdup("mode=play");
1993 WFDResult wfdconfig_get_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode *trans, WFDRTSPProfile *profile,
1994 WFDRTSPLowerTrans *lowertrans, guint32 *rtp_port0, guint32 *rtp_port1)
1996 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
1997 g_return_val_if_fail(msg->client_rtp_ports != NULL, WFD_EINVAL);
1999 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_RTP)) *trans = WFD_RTSP_TRANS_RTP;
2000 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_RDT)) *trans = WFD_RTSP_TRANS_RDT;
2001 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_AVP)) *profile = WFD_RTSP_PROFILE_AVP;
2002 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_SAVP)) *profile = WFD_RTSP_PROFILE_SAVP;
2003 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_UDP) &&
2004 g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_UNICAST)) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP;
2005 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_UDP) &&
2006 g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_MULTICAST)) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP_MCAST;
2007 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_TCP) &&
2008 g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_UNICAST)) *lowertrans = WFD_RTSP_LOWER_TRANS_TCP;
2009 if (g_strrstr(msg->client_rtp_ports->profile, STRING_WFD_TCP_HTTP)) *lowertrans = WFD_RTSP_LOWER_TRANS_HTTP;
2011 *rtp_port0 = msg->client_rtp_ports->rtp_port0;
2012 *rtp_port1 = msg->client_rtp_ports->rtp_port1;
2017 WFDResult wfdconfig_set_audio_sink_type(WFDMessage *msg, WFDSinkType sinktype)
2019 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2020 if (!msg->route) msg->route = g_new0(WFDRoute, 1);
2021 if (sinktype == WFD_PRIMARY_SINK) msg->route->destination = g_strdup(STRING_WFD_PRIMARY);
2022 else if (sinktype == WFD_SECONDARY_SINK) msg->route->destination = g_strdup(STRING_WFD_SECONDARY);
2026 WFDResult wfdconfig_get_audio_sink_type(WFDMessage *msg, WFDSinkType *sinktype)
2028 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2030 if (!g_strcmp0(msg->route->destination, STRING_WFD_PRIMARY)) *sinktype = WFD_PRIMARY_SINK;
2031 else if (!g_strcmp0(msg->route->destination, STRING_WFD_SECONDARY)) *sinktype = WFD_SECONDARY_SINK;
2036 WFDResult wfdconfig_set_I2C_port(WFDMessage *msg, gboolean i2csupport, guint32 i2cport)
2038 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2039 if (!msg->I2C) msg->I2C = g_new0(WFDI2C, 1);
2040 msg->I2C->I2CPresent = i2csupport;
2041 msg->I2C->I2C_port = i2cport;
2045 WFDResult wfdconfig_get_I2C_port(WFDMessage *msg, gboolean *i2csupport, guint32 *i2cport)
2047 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2048 if (msg->I2C && msg->I2C->I2CPresent) {
2049 *i2csupport = msg->I2C->I2CPresent;
2050 *i2cport = msg->I2C->I2C_port;
2051 } else *i2csupport = FALSE;
2055 WFDResult wfdconfig_set_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) msg->av_format_change_timing = g_new0(WFDAVFormatChangeTiming, 1);
2059 msg->av_format_change_timing->PTS = PTS;
2060 msg->av_format_change_timing->DTS = DTS;
2064 WFDResult wfdconfig_get_av_format_change_timing(WFDMessage *msg, guint64 *PTS, guint64 *DTS)
2066 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2067 if (msg->av_format_change_timing) {
2068 *PTS = msg->av_format_change_timing->PTS;
2069 *DTS = msg->av_format_change_timing->DTS;
2074 WFDResult wfdconfig_set_uibc_capability(WFDMessage *msg, guint32 input_category, guint32 inp_type, WFDHIDCTypePathPair *inp_pair,
2075 guint32 inp_type_path_count, guint32 tcp_port)
2077 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2078 if (!msg->uibc_capability) msg->uibc_capability = g_new0(WFDUibcCapability, 1);
2079 msg->uibc_capability->uibcsupported = TRUE;
2080 msg->uibc_capability->input_category_list.input_cat = input_category;
2081 msg->uibc_capability->generic_cap_list.inp_type = inp_type;
2082 msg->uibc_capability->hidc_cap_list.cap_count = inp_type_path_count;
2083 if (msg->uibc_capability->hidc_cap_list.cap_count) {
2084 detailed_cap *temp_cap;
2086 msg->uibc_capability->hidc_cap_list.next = g_new0(detailed_cap, 1);
2087 temp_cap = msg->uibc_capability->hidc_cap_list.next;
2088 for (; i < inp_type_path_count;) {
2089 temp_cap->p.inp_type = inp_pair[i].inp_type;
2090 temp_cap->p.inp_path = inp_pair[i].inp_path;
2092 if (i < inp_type_path_count) {
2093 temp_cap->next = g_new0(detailed_cap, 1);
2094 temp_cap = temp_cap->next;
2098 msg->uibc_capability->tcp_port = tcp_port;
2102 WFDResult wfdconfig_get_uibc_capability(WFDMessage *msg, guint32 *input_category, guint32 *inp_type, WFDHIDCTypePathPair **inp_pair,
2103 guint32 *inp_type_path_count, guint32 *tcp_port)
2105 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2106 if (msg->uibc_capability && msg->uibc_capability->uibcsupported) {
2107 *input_category = msg->uibc_capability->input_category_list.input_cat;
2108 *inp_type = msg->uibc_capability->generic_cap_list.inp_type;
2109 *inp_type_path_count = msg->uibc_capability->hidc_cap_list.cap_count;
2110 if (msg->uibc_capability->hidc_cap_list.cap_count) {
2111 detailed_cap *temp_cap;
2113 *inp_pair = g_new0(WFDHIDCTypePathPair, msg->uibc_capability->hidc_cap_list.cap_count);
2114 temp_cap = msg->uibc_capability->hidc_cap_list.next;
2116 (*(inp_pair))[i].inp_type = temp_cap->p.inp_type;
2117 (*(inp_pair))[i].inp_path = temp_cap->p.inp_path;
2118 temp_cap = temp_cap->next;
2122 *tcp_port = msg->uibc_capability->tcp_port;
2127 WFDResult wfdconfig_set_uibc_status(WFDMessage *msg, gboolean uibc_enable)
2129 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2130 if (!msg->uibc_setting) msg->uibc_setting = g_new0(WFDUibcSetting, 1);
2131 msg->uibc_setting->uibc_setting = uibc_enable;
2135 WFDResult wfdconfig_get_uibc_status(WFDMessage *msg, gboolean *uibc_enable)
2137 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2138 if (msg->uibc_setting) *uibc_enable = msg->uibc_setting->uibc_setting;
2141 #ifdef STANDBY_RESUME_CAPABILITY
2142 WFDResult wfdconfig_set_standby_resume_capability(WFDMessage *msg, gboolean supported)
2144 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2145 if (!msg->standby_resume_capability) msg->standby_resume_capability = g_new0(WFDStandbyResumeCapability, 1);
2146 msg->standby_resume_capability->standby_resume_cap = supported;
2150 WFDResult wfdconfig_get_standby_resume_capability(WFDMessage *msg, gboolean *supported)
2152 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2153 if (msg->standby_resume_capability) *supported = msg->standby_resume_capability->standby_resume_cap;
2157 WFDResult wfdconfig_set_standby(WFDMessage *msg, gboolean standby_enable)
2159 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2160 if (!msg->standby) msg->standby = g_new0(WFDStandby, 1);
2161 msg->standby->wfd_standby = standby_enable;
2165 WFDResult wfdconfig_get_standby(WFDMessage *msg, gboolean *standby_enable)
2167 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2168 if (msg->standby) *standby_enable = msg->standby->wfd_standby;
2172 WFDResult wfdconfig_set_connector_type(WFDMessage *msg, WFDConnector connector)
2174 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2175 if (!msg->connector_type) msg->connector_type = g_new0(WFDConnectorType, 1);
2176 msg->connector_type->connector_type = connector;
2180 WFDResult wfdconfig_get_connector_type(WFDMessage *msg, WFDConnector *connector)
2182 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2183 if (msg->connector_type) *connector = msg->connector_type->connector_type;
2187 WFDResult wfdconfig_set_idr_request(WFDMessage *msg)
2189 g_return_val_if_fail(msg != NULL, WFD_EINVAL);
2190 if (!msg->idr_request) msg->idr_request = g_new0(WFDIdrRequest, 1);
2191 msg->idr_request->idr_request = TRUE;