From 7e5a938a6650b505c6a2e821682b11161638dfc0 Mon Sep 17 00:00:00 2001 From: Hyunjun Date: Thu, 5 Mar 2015 16:00:54 +0900 Subject: [PATCH 2/9] Initial release Change-Id: Iab4a9b9d789652aebe545312794463125374f776 --- AUTHORS | 4 + LICENSE.APLv2.0 | 201 +++ Makefile.am | 7 + NOTICE | 3 + autogen.sh | 6 + configure.ac | 56 + mm-scmirroring-common.pc.in | 11 + packaging/libmm-scmirroring-common.spec | 75 ++ wfdconfig/Makefile.am | 15 + wfdconfig/include/wfdconfigmessage.h | 577 +++++++++ wfdconfig/wfdconfigmessage.c | 2111 +++++++++++++++++++++++++++++++ 11 files changed, 3066 insertions(+) create mode 100755 AUTHORS create mode 100755 LICENSE.APLv2.0 create mode 100755 Makefile.am create mode 100755 NOTICE create mode 100755 autogen.sh create mode 100755 configure.ac create mode 100755 mm-scmirroring-common.pc.in create mode 100755 packaging/libmm-scmirroring-common.spec create mode 100755 wfdconfig/Makefile.am create mode 100755 wfdconfig/include/wfdconfigmessage.h create mode 100755 wfdconfig/wfdconfigmessage.c diff --git a/AUTHORS b/AUTHORS new file mode 100755 index 0000000..f1ea6c9 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,4 @@ +Hyunjun Ko +Taewan Kim +Yejun Cho +Sangkyu Park diff --git a/LICENSE.APLv2.0 b/LICENSE.APLv2.0 new file mode 100755 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE.APLv2.0 @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Makefile.am b/Makefile.am new file mode 100755 index 0000000..bfc6459 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,7 @@ +ACLOCAL_AMFLAGS='-I m4' +SUBDIRS = wfdconfig + +pcfiles = mm-scmirroring-common.pc +pkgconfigdir = $(libdir)/pkgconfig +pkgconfig_DATA = $(pcfiles) +EXTRA_DIST = $(pcfiles) diff --git a/NOTICE b/NOTICE new file mode 100755 index 0000000..ccdad52 --- /dev/null +++ b/NOTICE @@ -0,0 +1,3 @@ +Copyright (c) Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Apache License, Version 2. +Please, see the LICENSE file for Apache License terms and conditions. diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..b278e17 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,6 @@ +aclocal +libtoolize --copy -f +autoheader +autoconf +automake --add-missing --copy --foreign +#./configure --with-xo-machine=W1 diff --git a/configure.ac b/configure.ac new file mode 100755 index 0000000..03ff509 --- /dev/null +++ b/configure.ac @@ -0,0 +1,56 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.61) +AC_INIT([libmm-scmirroring-common],[0.0.1]) +AC_CONFIG_HEADER([config.h]) +AM_INIT_AUTOMAKE([-Wall -Werror foreign]) + +# Checks for programs. ++m4_pattern_allow([AM_PROG_AR]) +AM_PROG_AR +AC_PROG_CC +AC_PROG_LIBTOOL + +AC_FUNC_MMAP +AC_FUNC_REALLOC +AC_FUNC_SELECT_ARGTYPES +AC_FUNC_STAT +AC_HEADER_STDBOOL +AC_HEADER_STDC +AC_HEADER_TIME +AC_PROG_GCC_TRADITIONAL + +PKG_CHECK_MODULES(MMCOMMON,mm-common) +AC_SUBST(MMCOMMON_CFLAGS) +AC_SUBST(MMCOMMON_LIBS) + +PKG_CHECK_MODULES(GLIB, glib-2.0) +AC_SUBST(GLIB_CFLAGS) +AC_SUBST(GLIB_LIBS) + +# for testsuite + +AC_ARG_ENABLE(context-manager, AC_HELP_STRING([--enable-context-manager], [context manager]), +[ + case "${enableval}" in + yes) ENABLE_CONTEXT_MANAGER=yes ;; + no) ENABLE_CONTEXT_MANAGER=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-context-manager) ;; + esac + ], + [ENABLE_CONTEXT_MANAGER=no]) +AM_CONDITIONAL(ENABLE_CONTEXT_MANAGER, test "x$ENABLE_CONTEXT_MANAGER" = "xyes") + +if [test "x$ENABLE_CONTEXT_MANAGER" = "xyes"] +then +PKG_CHECK_MODULES(CONTEXT_MANAGER, capi-context-manager) +AC_SUBST(CONTEXT_MANAGER_CFLAGS) +AC_SUBST(CONTEXT_MANAGER_LIBS) +fi + +AC_CONFIG_FILES([Makefile + mm-scmirroring-common.pc + wfdconfig/Makefile +]) +AC_OUTPUT diff --git a/mm-scmirroring-common.pc.in b/mm-scmirroring-common.pc.in new file mode 100755 index 0000000..27e54f4 --- /dev/null +++ b/mm-scmirroring-common.pc.in @@ -0,0 +1,11 @@ +prefix = @prefix@ +exec_prefix=@exec_prefix@ +libdir = @libdir@ +includedir = @includedir@ + +Name : mm-scmirroring-common +Description : Multimedia Framework Screen Mirroring Library +Requires : mm-common +Version : @VERSION@ +Libs : -L${libdir} -lmmfwfdconfig +Cflags : -I${includedir}/mmf diff --git a/packaging/libmm-scmirroring-common.spec b/packaging/libmm-scmirroring-common.spec new file mode 100755 index 0000000..e04aaf7 --- /dev/null +++ b/packaging/libmm-scmirroring-common.spec @@ -0,0 +1,75 @@ +Name: libmm-scmirroring-common +Summary: Multimedia Framework Wifi-Display Common Library +Version: 0.0.27 +Release: 0 +Group: System/Libraries +License: Apache License 2.0 +Source0: %{name}-%{version}.tar.gz +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig +BuildRequires: pkgconfig(mm-common) + +BuildRoot: %{_tmppath}/%{name}-%{version}-build + +%description + +%package devel +Summary: Multimedia Framework Wifi-Display Common library (DEV) +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel + +%package factory +Summary: Multimedia Framework Wifi-Display Common Library (Factory) +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description factory + +%prep +%setup -q + +%build +export CFLAGS+=" -Wcast-align" +export CFLAGS+=" -Wextra -Wno-array-bounds" +export CFLAGS+=" -Wno-ignored-qualifiers -Wno-unused-parameter -Wshadow" +export CFLAGS+=" -Wwrite-strings -Wswitch-default" +export CFLAGS+=" -Wall -Wcast-qual -Wno-empty-body" +#export CFLAGS+=" -Werror" + +./autogen.sh + +# always enable sdk build. This option should go away +# to enable context manager add --enable-context-manager in following line +# postfix the '--define "sec_product_feature_mmfw_codec_qc 1"' to gbs compilation command to enable QC MSM specific changes. While building for target SCM will automatically take care of it +./configure --prefix=%{_prefix} --disable-static + +# Call make instruction with smp support +#make %{?jobs:-j%jobs} +make +%install +rm -rf %{buildroot} +%make_install +mkdir -p %{buildroot}/%{_datadir}/license +cp -rf %{_builddir}/%{name}-%{version}/LICENSE.APLv2.0 %{buildroot}%{_datadir}/license/%{name} + +%clean +rm -rf %{buildroot} + +%post +/sbin/ldconfig + +%postun +/sbin/ldconfig + +%files +%defattr(-,root,root,-) +%{_datadir}/license/%{name} +%{_libdir}/*.so.* + +%files devel +%defattr(-,root,root,-) +%{_libdir}/*.so +%{_includedir}/mmf/wfdconfigmessage.h +%{_libdir}/pkgconfig/* diff --git a/wfdconfig/Makefile.am b/wfdconfig/Makefile.am new file mode 100755 index 0000000..aa700aa --- /dev/null +++ b/wfdconfig/Makefile.am @@ -0,0 +1,15 @@ +lib_LTLIBRARIES = libmmfwfdconfig.la + +includelibmmfwfdconfigdir = $(includedir)/mmf + +includelibmmfwfdconfig_HEADERS = include/wfdconfigmessage.h + +libmmfwfdconfig_la_SOURCES = wfdconfigmessage.c + +libmmfwfdconfig_la_CFLAGS = -Werror -I$(srcdir)/include \ + $(GLIB_CFLAGS) \ + $(MMCOMMON_CFLAGS) + +libmmfwfdconfig_la_LIBADD = $(GLIB_LIBS) \ + $(GST_LIBS) \ + $(MMCOMMON_LIBS) diff --git a/wfdconfig/include/wfdconfigmessage.h b/wfdconfig/include/wfdconfigmessage.h new file mode 100755 index 0000000..59f08c4 --- /dev/null +++ b/wfdconfig/include/wfdconfigmessage.h @@ -0,0 +1,577 @@ +/* + * wfdconfig messages + * + * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: JongHyuk Choi , ByungWook Jang , + * Manoj Kumar K , Abhishek Bajaj , Nikhilesh Mittal + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef __GST_WFD_CONFIG_MESSAGE_H__ +#define __GST_WFD_CONFIG_MESSAGE_H__ + +#include + +G_BEGIN_DECLS + +/** + * WFDResult: + * @WFD_OK: A successful return value + * @WFD_EINVAL: a function was given invalid parameters + * + * Return values for the WFD_CONFIG functions. + */ +typedef enum { + WFD_OK = 0, + WFD_EINVAL = -1 +} WFDResult; + +typedef enum { + WFD_AUDIO_UNKNOWN = 0, + WFD_AUDIO_LPCM = (1 << 0), + WFD_AUDIO_AAC = (1 << 1), + WFD_AUDIO_AC3 = (1 << 2) +}WFDAudioFormats; + +typedef enum { + WFD_FREQ_UNKNOWN = 0, + WFD_FREQ_44100 = (1 << 0), + WFD_FREQ_48000 = (1 << 1) +}WFDAudioFreq; + +typedef enum { + WFD_CHANNEL_UNKNOWN = 0, + WFD_CHANNEL_2 = (1 << 0), + WFD_CHANNEL_4 = (1 << 1), + WFD_CHANNEL_6 = (1 << 2), + WFD_CHANNEL_8 = (1 << 3) +}WFDAudioChannels; + + +typedef enum { + WFD_VIDEO_UNKNOWN = 0, + WFD_VIDEO_H264 = (1 << 0) +}WFDVideoCodecs; + +typedef enum { + WFD_VIDEO_CEA_RESOLUTION = 0, + WFD_VIDEO_VESA_RESOLUTION, + WFD_VIDEO_HH_RESOLUTION +}WFDVideoNativeResolution; + +typedef enum { + WFD_CEA_UNKNOWN = 0, + WFD_CEA_640x480P60 = (1 << 0), + WFD_CEA_720x480P60 = (1 << 1), + WFD_CEA_720x480I60 = (1 << 2), + WFD_CEA_720x576P50 = (1 << 3), + WFD_CEA_720x576I50 = (1 << 4), + WFD_CEA_1280x720P30 = (1 << 5), + WFD_CEA_1280x720P60 = (1 << 6), + WFD_CEA_1920x1080P30= (1 << 7), + WFD_CEA_1920x1080P60= (1 << 8), + WFD_CEA_1920x1080I60= (1 << 9), + WFD_CEA_1280x720P25 = (1 << 10), + WFD_CEA_1280x720P50 = (1 << 11), + WFD_CEA_1920x1080P25= (1 << 12), + WFD_CEA_1920x1080P50= (1 << 13), + WFD_CEA_1920x1080I50= (1 << 14), + WFD_CEA_1280x720P24 = (1 << 15), + WFD_CEA_1920x1080P24= (1 << 16) +}WFDVideoCEAResolution; + +typedef enum { + WFD_VESA_UNKNOWN = 0, + WFD_VESA_800x600P30 = (1 << 0), + WFD_VESA_800x600P60 = (1 << 1), + WFD_VESA_1024x768P30 = (1 << 2), + WFD_VESA_1024x768P60 = (1 << 3), + WFD_VESA_1152x864P30 = (1 << 4), + WFD_VESA_1152x864P60 = (1 << 5), + WFD_VESA_1280x768P30 = (1 << 6), + WFD_VESA_1280x768P60 = (1 << 7), + WFD_VESA_1280x800P30 = (1 << 8), + WFD_VESA_1280x800P60 = (1 << 9), + WFD_VESA_1360x768P30 = (1 << 10), + WFD_VESA_1360x768P60 = (1 << 11), + WFD_VESA_1366x768P30 = (1 << 12), + WFD_VESA_1366x768P60 = (1 << 13), + WFD_VESA_1280x1024P30 = (1 << 14), + WFD_VESA_1280x1024P60 = (1 << 15), + WFD_VESA_1400x1050P30 = (1 << 16), + WFD_VESA_1400x1050P60 = (1 << 17), + WFD_VESA_1440x900P30 = (1 << 18), + WFD_VESA_1440x900P60 = (1 << 19), + WFD_VESA_1600x900P30 = (1 << 20), + WFD_VESA_1600x900P60 = (1 << 21), + WFD_VESA_1600x1200P30 = (1 << 22), + WFD_VESA_1600x1200P60 = (1 << 23), + WFD_VESA_1680x1024P30 = (1 << 24), + WFD_VESA_1680x1024P60 = (1 << 25), + WFD_VESA_1680x1050P30 = (1 << 26), + WFD_VESA_1680x1050P60 = (1 << 27), + WFD_VESA_1920x1200P30 = (1 << 28), + WFD_VESA_1920x1200P60 = (1 << 29) +}WFDVideoVESAResolution; + +typedef enum { + WFD_HH_UNKNOWN = 0, + WFD_HH_800x480P30 = (1 << 0), + WFD_HH_800x480P60 = (1 << 1), + WFD_HH_854x480P30 = (1 << 2), + WFD_HH_854x480P60 = (1 << 3), + WFD_HH_864x480P30 = (1 << 4), + WFD_HH_864x480P60 = (1 << 5), + WFD_HH_640x360P30 = (1 << 6), + WFD_HH_640x360P60 = (1 << 7), + WFD_HH_960x540P30 = (1 << 8), + WFD_HH_960x540P60 = (1 << 9), + WFD_HH_848x480P30 = (1 << 10), + WFD_HH_848x480P60 = (1 << 11) +}WFDVideoHHResolution; + +typedef enum { + WFD_H264_UNKNOWN_PROFILE= 0, + WFD_H264_BASE_PROFILE = (1 << 0), + WFD_H264_HIGH_PROFILE = (1 << 1) +}WFDVideoH264Profile; + +typedef enum { + WFD_H264_LEVEL_UNKNOWN = 0, + WFD_H264_LEVEL_3_1 = (1 << 0), + WFD_H264_LEVEL_3_2 = (1 << 1), + WFD_H264_LEVEL_4 = (1 << 2), + WFD_H264_LEVEL_4_1 = (1 << 3), + WFD_H264_LEVEL_4_2 = (1 << 4) +}WFDVideoH264Level; + +typedef enum { + WFD_HDCP_NONE = 0, + WFD_HDCP_2_0 = (1 << 0), + WFD_HDCP_2_1 = (1 << 1) +}WFDHDCPProtection; + +typedef enum { + WFD_SINK_UNKNOWN = -1, + WFD_SINK_NOT_COUPLED = 0, + WFD_SINK_COUPLED, + WFD_SINK_TEARDOWN_COUPLING, + WFD_SINK_RESERVED +}WFDCoupledSinkStatus; + +typedef enum { + WFD_TRIGGER_UNKNOWN = 0, + WFD_TRIGGER_SETUP, + WFD_TRIGGER_PAUSE, + WFD_TRIGGER_TEARDOWN, + WFD_TRIGGER_PLAY +}WFDTrigger; + +typedef enum { + WFD_RTSP_TRANS_UNKNOWN = 0, + WFD_RTSP_TRANS_RTP = (1 << 0), + WFD_RTSP_TRANS_RDT = (1 << 1) +} WFDRTSPTransMode; + +typedef enum { + WFD_RTSP_PROFILE_UNKNOWN = 0, + WFD_RTSP_PROFILE_AVP = (1 << 0), + WFD_RTSP_PROFILE_SAVP = (1 << 1) +} WFDRTSPProfile; + +typedef enum { + WFD_RTSP_LOWER_TRANS_UNKNOWN = 0, + WFD_RTSP_LOWER_TRANS_UDP = (1 << 0), + WFD_RTSP_LOWER_TRANS_UDP_MCAST = (1 << 1), + WFD_RTSP_LOWER_TRANS_TCP = (1 << 2), + WFD_RTSP_LOWER_TRANS_HTTP = (1 << 3) +} WFDRTSPLowerTrans; + +typedef enum { + WFD_PRIMARY_SINK = 0, + WFD_SECONDARY_SINK +}WFDSinkType; + +typedef enum { + WFD_UIBC_INPUT_CAT_UNKNOWN = 0, + WFD_UIBC_INPUT_CAT_GENERIC = (1 << 0), + WFD_UIBC_INPUT_CAT_HIDC = (1 << 1), +}WFDUibcinput_cat; + +typedef enum { + WFD_UIBC_INPUT_TYPE_UNKNOWN = 0, + WFD_UIBC_INPUT_TYPE_KEYBOARD = (1 << 0), + WFD_UIBC_INPUT_TYPE_MOUSE = (1 << 1), + WFD_UIBC_INPUT_TYPE_SINGLETOUCH = (1 << 2), + WFD_UIBC_INPUT_TYPE_MULTITOUCH = (1 << 3), + WFD_UIBC_INPUT_TYPE_JOYSTICK = (1 << 4), + WFD_UIBC_INPUT_TYPE_CAMERA = (1 << 5), + WFD_UIBC_INPUT_TYPE_GESTURE = (1 << 6), + WFD_UIBC_INPUT_TYPE_REMOTECONTROL = (1 << 7) +}WFDUibcinp_type; + +typedef enum { + WFD_UIBC_INPUT_PATH_UNKNOWN = 0, + WFD_UIBC_INPUT_PATH_INFRARED = (1 << 0), + WFD_UIBC_INPUT_PATH_USB = (1 << 1), + WFD_UIBC_INPUT_PATH_BT = (1 << 2), + WFD_UIBC_INPUT_PATH_ZIGBEE = (1 << 3), + WFD_UIBC_INPUT_PATH_WIFI = (1 << 4), + WFD_UIBC_INPUT_PATH_NOSP = (1 << 5) +}WFDUibcinp_path; + +typedef enum { + WFD_CONNECTOR_VGA = 0, + WFD_CONNECTOR_S, + WFD_CONNECTOR_COMPOSITE, + WFD_CONNECTOR_COMPONENT, + WFD_CONNECTOR_DVI, + WFD_CONNECTOR_HDMI, + WFD_CONNECTOR_LVDS, + WFD_CONNECTOR_RESERVED_7, + WFD_CONNECTOR_JAPANESE_D, + WFD_CONNECTOR_SDI, + WFD_CONNECTOR_DP, + WFD_CONNECTOR_RESERVED_11, + WFD_CONNECTOR_UDI, + WFD_CONNECTOR_NO = 254, + WFD_CONNECTOR_PHYSICAL = 255 +}WFDConnector; + + +typedef struct { + gchar *audio_format; + guint32 modes; + guint latency; +} WFDAudioCodec; + +typedef struct { + guint count; + WFDAudioCodec *list; +} WFDAudioCodeclist; + + +typedef struct { + guint CEA_Support; + guint VESA_Support; + guint HH_Support; + guint latency; + guint min_slice_size; + guint slice_enc_params; + guint frame_rate_control_support; +} WFDVideoH264MiscParams; + +typedef struct { + guint profile; + guint level; + guint max_hres; + guint max_vres; + WFDVideoH264MiscParams misc_params; +} WFDVideoH264Codec; + +typedef struct { + guint native; + guint preferred_display_mode_supported; + WFDVideoH264Codec H264_codec; +} WFDVideoCodec; + +typedef struct { + guint count; + WFDVideoCodec *list; +} WFDVideoCodeclist; + +typedef struct { + guint video_3d_capability; + guint latency; + guint min_slice_size; + guint slice_enc_params; + guint frame_rate_control_support; +} WFD3DVideoH264MiscParams; + +typedef struct { + guint profile; + guint level; + WFD3DVideoH264MiscParams misc_params; + guint max_hres; + guint max_vres; +} WFD3DVideoH264Codec; + +typedef struct { + guint native; + guint preferred_display_mode_supported; + WFD3DVideoH264Codec H264_codec; +} WFD3dCapList; + +typedef struct { + guint count; + WFD3dCapList *list; +} WFD3DFormats; + +typedef struct { + gchar *hdcpversion; + gchar *TCPPort; +} WFDHdcp2Spec; + +typedef struct { + WFDHdcp2Spec *hdcp2_spec; +} WFDContentProtection; + +typedef struct { + guint edid_supported; + guint edid_block_count; + gchar *edid_payload; +} WFDDisplayEdid; + + +typedef struct { + guint status; + gchar *sink_address; +} WFDCoupled_sink_cap; + +typedef struct { + WFDCoupled_sink_cap *coupled_sink_cap; +} WFDCoupledSink; + +typedef struct { + gchar *wfd_trigger_method; +} WFDTriggerMethod; + +typedef struct { + gchar *wfd_url0; + gchar *wfd_url1; +} WFDPresentationUrl; + +typedef struct { + gchar *profile; + guint32 rtp_port0; + guint32 rtp_port1; + gchar *mode; +} WFDClientRtpPorts; + +typedef struct { + gchar *destination; +} WFDRoute; + +typedef struct { + gboolean I2CPresent; + guint32 I2C_port; +} WFDI2C; + +typedef struct { + guint64 PTS; + guint64 DTS; +} WFDAVFormatChangeTiming; + +typedef struct { + gboolean displaymodesupported; + guint64 p_clock; + guint32 H; + guint32 HB; + guint32 HSPOL_HSOFF; + guint32 HSW; + guint32 V; + guint32 VB; + guint32 VSPOL_VSOFF; + guint32 VSW; + guint VBS3D; + guint R; + guint V2d_s3d_modes; + guint P_depth; + WFDVideoH264Codec H264_codec; +} WFDPreferredDisplayMode; + +typedef struct { + guint32 input_cat; +}WFDInputCategoryList; + +typedef struct { + guint32 inp_type; +}WFDGenericCategoryList; + +typedef struct _detailed_cap detailed_cap; + +typedef struct { + WFDUibcinp_type inp_type; + WFDUibcinp_path inp_path; +}WFDHIDCTypePathPair; + +struct _detailed_cap { + WFDHIDCTypePathPair p; + detailed_cap *next; +}; + +typedef struct { + guint cap_count; + detailed_cap *next; +}WFDHIDCCategoryList; + +typedef struct { + gboolean uibcsupported; + WFDInputCategoryList input_category_list; + WFDGenericCategoryList generic_cap_list; + WFDHIDCCategoryList hidc_cap_list; + guint32 tcp_port; +} WFDUibcCapability; + +typedef struct { + gboolean uibc_setting; +} WFDUibcSetting; + +typedef struct { + gboolean standby_resume_cap; +} WFDStandbyResumeCapability; + +typedef struct { + gboolean wfd_standby; +} WFDStandby; + +typedef struct { + gboolean supported; + gint32 connector_type; +} WFDConnectorType; + +typedef struct { + gboolean idr_request; +} WFDIdrRequest; + +/***********************************************************/ + +typedef struct { + + WFDAudioCodeclist *audio_codecs; + WFDVideoCodeclist *video_formats; + WFD3DFormats *video_3d_formats; + WFDContentProtection *content_protection; + WFDDisplayEdid *display_edid; + WFDCoupledSink *coupled_sink; + WFDTriggerMethod *trigger_method; + WFDPresentationUrl *presentation_url; + WFDClientRtpPorts *client_rtp_ports; + WFDRoute *route; + WFDI2C *I2C; + WFDAVFormatChangeTiming *av_format_change_timing; + WFDPreferredDisplayMode *preferred_display_mode; + WFDUibcCapability *uibc_capability; + WFDUibcSetting *uibc_setting; + WFDStandbyResumeCapability *standby_resume_capability; + WFDStandby *standby; + WFDConnectorType *connector_type; + WFDIdrRequest *idr_request; +} WFDMessage; + +/* Session descriptions */ +WFDResult wfdconfig_message_new (WFDMessage **msg); +WFDResult wfdconfig_message_init (WFDMessage *msg); +WFDResult wfdconfig_message_uninit (WFDMessage *msg); +WFDResult wfdconfig_message_free (WFDMessage *msg); +WFDResult wfdconfig_message_parse_buffer (const guint8 *data, guint size, WFDMessage *msg); +gchar* wfdconfig_message_as_text (const WFDMessage *msg); +gchar* wfdconfig_parameter_names_as_text (const WFDMessage *msg); +WFDResult wfdconfig_message_dump (const WFDMessage *msg); + + +WFDResult wfdconfig_set_supported_audio_format(WFDMessage *msg, + guint aCodec, guint aFreq, guint aChanels, + guint aBitwidth, guint32 aLatency); +WFDResult wfdconfig_set_prefered_audio_format(WFDMessage *msg, + WFDAudioFormats aCodec, WFDAudioFreq aFreq, WFDAudioChannels aChanels, + guint aBitwidth, guint32 aLatency); +WFDResult wfdconfig_get_supported_audio_format(WFDMessage *msg, + guint *aCodec, guint *aFreq, guint *aChanels, + guint *aBitwidth, guint32 *aLatency); +WFDResult wfdconfig_get_prefered_audio_format(WFDMessage *msg, + WFDAudioFormats *aCodec, WFDAudioFreq *aFreq, WFDAudioChannels *aChanels, + guint *aBitwidth, guint32 *aLatency); + +WFDResult wfdconfig_set_supported_video_format(WFDMessage *msg, WFDVideoCodecs vCodec, + WFDVideoNativeResolution vNative, guint64 vNativeResolution, + guint64 vCEAResolution, guint64 vVESAResolution, guint64 vHHResolution, + guint vProfile, guint vLevel, guint32 vLatency, guint32 vMaxHeight, + guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control); +WFDResult wfdconfig_set_prefered_video_format(WFDMessage *msg, WFDVideoCodecs vCodec, + WFDVideoNativeResolution vNative, guint64 vNativeResolution, + WFDVideoCEAResolution vCEAResolution, WFDVideoVESAResolution vVESAResolution, + WFDVideoHHResolution vHHResolution, WFDVideoH264Profile vProfile, + WFDVideoH264Level vLevel, guint32 vLatency, guint32 vMaxHeight, + guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control); +WFDResult wfdconfig_get_supported_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec, + WFDVideoNativeResolution *vNative, guint64 *vNativeResolution, + guint64 *vCEAResolution, guint64 *vVESAResolution, guint64 *vHHResolution, + guint *vProfile, guint *vLevel, guint32 *vLatency, guint32 *vMaxHeight, + guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control); +WFDResult wfdconfig_get_prefered_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec, + WFDVideoNativeResolution *vNative, guint64 *vNativeResolution, + WFDVideoCEAResolution *vCEAResolution, WFDVideoVESAResolution *vVESAResolution, + WFDVideoHHResolution *vHHResolution, WFDVideoH264Profile *vProfile, + WFDVideoH264Level *vLevel, guint32 *vLatency, guint32 *vMaxHeight, + guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control); + +// Todo wfd-3d-formats + +WFDResult wfdconfig_set_contentprotection_type(WFDMessage *msg, WFDHDCPProtection hdcpversion, guint32 TCPPort); +WFDResult wfdconfig_get_contentprotection_type(WFDMessage *msg, WFDHDCPProtection *hdcpversion, guint32 *TCPPort); + +WFDResult wfdconfig_set_display_EDID(WFDMessage *msg, gboolean edid_supported, guint32 edid_blockcount, gchar *edid_playload); +WFDResult wfdconfig_get_display_EDID(WFDMessage *msg, gboolean *edid_supported, guint32 *edid_blockcount, gchar **edid_playload); + + +WFDResult wfdconfig_set_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus status, gchar *sink_address); +WFDResult wfdconfig_get_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus *status, gchar **sink_address); + +WFDResult wfdconfig_set_trigger_type(WFDMessage *msg, WFDTrigger trigger); +WFDResult wfdconfig_get_trigger_type(WFDMessage *msg, WFDTrigger *trigger); + +WFDResult wfdconfig_set_presentation_url(WFDMessage *msg, gchar *wfd_url0, gchar *wfd_url1); +WFDResult wfdconfig_get_presentation_url(WFDMessage *msg, gchar **wfd_url0, gchar **wfd_url1); + +WFDResult wfdconfig_set_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode trans, WFDRTSPProfile profile, + WFDRTSPLowerTrans lowertrans, guint32 rtp_port0, guint32 rtp_port1); +WFDResult wfdconfig_get_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode *trans, WFDRTSPProfile *profile, + WFDRTSPLowerTrans *lowertrans, guint32 *rtp_port0, guint32 *rtp_port1); + +WFDResult wfdconfig_set_audio_sink_type(WFDMessage *msg, WFDSinkType sinktype); +WFDResult wfdconfig_get_audio_sink_type(WFDMessage *msg, WFDSinkType *sinktype); + +WFDResult wfdconfig_set_I2C_port(WFDMessage *msg, gboolean i2csupport, guint32 i2cport); +WFDResult wfdconfig_get_I2C_port(WFDMessage *msg, gboolean *i2csupport, guint32 *i2cport); + +WFDResult wfdconfig_set_av_format_change_timing(WFDMessage *msg, guint64 PTS, guint64 DTS); +WFDResult wfdconfig_get_av_format_change_timing(WFDMessage *msg, guint64 *PTS, guint64 *DTS); + +// Todo wfd-preferred-display-mode + +WFDResult wfdconfig_set_uibc_capability(WFDMessage *msg, guint32 input_category, guint32 inp_type, WFDHIDCTypePathPair *inp_pair, + guint32 inp_type_path_count, guint32 tcp_port); +WFDResult wfdconfig_get_uibc_capability(WFDMessage *msg, guint32 *input_category, guint32 *inp_type, WFDHIDCTypePathPair **inp_pair, + guint32 *inp_type_path_count, guint32 *tcp_port); + +WFDResult wfdconfig_set_uibc_status(WFDMessage *msg, gboolean uibc_enable); +WFDResult wfdconfig_get_uibc_status(WFDMessage *msg, gboolean *uibc_enable); + +WFDResult wfdconfig_set_standby_resume_capability(WFDMessage *msg, gboolean supported); +WFDResult wfdconfig_get_standby_resume_capability(WFDMessage *msg, gboolean *supported); + +WFDResult wfdconfig_set_standby(WFDMessage *msg, gboolean standby_enable); +WFDResult wfdconfig_get_standby(WFDMessage *msg, gboolean *standby_enable); + +WFDResult wfdconfig_set_connector_type(WFDMessage *msg, WFDConnector connector); +WFDResult wfdconfig_get_connector_type(WFDMessage *msg, WFDConnector *connector); + +WFDResult wfdconfig_set_idr_request(WFDMessage *msg); + +G_END_DECLS + +#endif /* __GST_WFD_CONFIG_MESSAGE_H__ */ diff --git a/wfdconfig/wfdconfigmessage.c b/wfdconfig/wfdconfigmessage.c new file mode 100755 index 0000000..bb0803e --- /dev/null +++ b/wfdconfig/wfdconfigmessage.c @@ -0,0 +1,2111 @@ +/* + * wfdconfig messages + * + * Copyright (c) 2011 - 2013 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: JongHyuk Choi , ByungWook Jang , + * Manoj Kumar K , Abhishek Bajaj , Nikhilesh Mittal + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +#include /* for G_OS_WIN32 */ +#include "wfdconfigmessage.h" +#include + +/* FIXME, is currently allocated on the stack */ +#define MAX_LINE_LEN 1024 * 16 + +#define FREE_STRING(field) if(field != NULL) g_free (field); (field) = NULL +#define REPLACE_STRING(field, val) FREE_STRING(field); (field) = g_strdup (val) +#define EDID_BLOCK_SIZE 128 +enum +{ + WFD_SESSION, + WFD_MEDIA, +}; + +typedef struct +{ + guint state; + WFDMessage *msg; +} WFDContext; + +/** +* wfdconfig_message_new: +* @msg: pointer to new #WFDMessage +* +* Allocate a new WFDMessage and store the result in @msg. +* +* Returns: a #WFDResult. +*/ +WFDResult +wfdconfig_message_new (WFDMessage ** msg) +{ + WFDMessage *newmsg; + + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + + newmsg = g_new0 (WFDMessage, 1); + + *msg = newmsg; + + return wfdconfig_message_init (newmsg); +} + +/** +* wfdconfig_message_init: +* @msg: a #WFDMessage +* +* Initialize @msg so that its contents are as if it was freshly allocated +* with wfdconfig_message_new(). This function is mostly used to initialize a message +* allocated on the stack. wfdconfig_message_uninit() undoes this operation. +* +* When this function is invoked on newly allocated data (with malloc or on the +* stack), its contents should be set to 0 before calling this function. +* +* Returns: a #WFDResult. +*/ +WFDResult +wfdconfig_message_init (WFDMessage * msg) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + + return WFD_OK; +} + +/** +* wfdconfig_message_uninit: +* @msg: a #WFDMessage +* +* Free all resources allocated in @msg. @msg should not be used anymore after +* this function. This function should be used when @msg was allocated on the +* stack and initialized with wfdconfig_message_init(). +* +* Returns: a #WFDResult. +*/ +WFDResult +wfdconfig_message_uninit (WFDMessage * msg) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + + if(msg->audio_codecs) { + guint i=0; + if(msg->audio_codecs->list) { + for(; iaudio_codecs->count; i++) { + FREE_STRING(msg->audio_codecs->list[i].audio_format); + msg->audio_codecs->list[i].modes=0; + msg->audio_codecs->list[i].latency=0; + } + FREE_STRING(msg->audio_codecs->list); + } + FREE_STRING(msg->audio_codecs); + } + + if(msg->video_formats) { + FREE_STRING(msg->video_formats->list); + FREE_STRING(msg->video_formats); + } + + if(msg->video_3d_formats) { + FREE_STRING(msg->video_3d_formats); + } + + if(msg->content_protection) { + FREE_STRING(msg->content_protection); + } + + if(msg->display_edid) { + if(msg->display_edid->edid_payload) + FREE_STRING(msg->display_edid->edid_payload); + FREE_STRING(msg->display_edid); + } + + if(msg->coupled_sink) { + FREE_STRING(msg->coupled_sink); + } + + if(msg->trigger_method) { + FREE_STRING(msg->trigger_method->wfd_trigger_method); + FREE_STRING(msg->trigger_method); + } + + if(msg->presentation_url) { + FREE_STRING(msg->trigger_method); + } + + if(msg->client_rtp_ports) { + FREE_STRING(msg->client_rtp_ports->profile); + FREE_STRING(msg->client_rtp_ports->mode); + FREE_STRING(msg->client_rtp_ports); + } + + if(msg->route) { + FREE_STRING(msg->route); + } + + if(msg->I2C) { + FREE_STRING(msg->I2C); + } + + if(msg->av_format_change_timing) { + FREE_STRING(msg->av_format_change_timing); + } + + if(msg->preferred_display_mode) { + FREE_STRING(msg->preferred_display_mode); + } + + if(msg->uibc_capability) { + FREE_STRING(msg->uibc_capability); + } + + if(msg->uibc_setting) { + FREE_STRING(msg->uibc_setting); + } + + if(msg->standby_resume_capability) { + FREE_STRING(msg->standby_resume_capability); + } + + if(msg->standby) { + FREE_STRING(msg->standby); + } + + if(msg->connector_type) { + FREE_STRING(msg->connector_type); + } + + if(msg->idr_request) { + FREE_STRING(msg->idr_request); + } + + return WFD_OK; +} + +/** +* wfdconfig_message_free: +* @msg: a #WFDMessage +* +* Free all resources allocated by @msg. @msg should not be used anymore after +* this function. This function should be used when @msg was dynamically +* allocated with wfdconfig_message_new(). +* +* Returns: a #WFDResult. +*/ +WFDResult +wfdconfig_message_free (WFDMessage * msg) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + + wfdconfig_message_uninit (msg); + g_free (msg); + + return WFD_OK; +} + +/** +* wfdconfig_message_as_text: +* @msg: a #WFDMessage +* +* Convert the contents of @msg to a text string. +* +* Returns: A dynamically allocated string representing the WFD description. +*/ +gchar * +wfdconfig_message_as_text (const WFDMessage * msg) +{ + /* change all vars so they match rfc? */ + GString *lines; + g_return_val_if_fail (msg != NULL, NULL); + + lines = g_string_new (""); + + /* list of audio codecs */ + if(msg->audio_codecs) { + guint i=0; + g_string_append_printf (lines,"wfd_audio_codecs"); + if(msg->audio_codecs->list) { + g_string_append_printf (lines,":"); + for(; iaudio_codecs->count; i++) { + g_string_append_printf (lines," %s",msg->audio_codecs->list[i].audio_format); + g_string_append_printf (lines," %08x",msg->audio_codecs->list[i].modes); + g_string_append_printf (lines," %02x",msg->audio_codecs->list[i].latency); + if((i+1)audio_codecs->count) + g_string_append_printf (lines,","); + } + } + g_string_append_printf (lines,"\r\n"); + } + + /* list of video codecs */ + if(msg->video_formats) { + g_string_append_printf (lines,"wfd_video_formats"); + if(msg->video_formats->list) { + g_string_append_printf (lines,":"); + g_string_append_printf (lines," %02x", msg->video_formats->list->native); + g_string_append_printf (lines," %02x", msg->video_formats->list->preferred_display_mode_supported); + g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.profile); + g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.level); + g_string_append_printf (lines," %08x", msg->video_formats->list->H264_codec.misc_params.CEA_Support); + g_string_append_printf (lines," %08x", msg->video_formats->list->H264_codec.misc_params.VESA_Support); + g_string_append_printf (lines," %08x", msg->video_formats->list->H264_codec.misc_params.HH_Support); + g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.misc_params.latency); + g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.misc_params.min_slice_size); + g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.misc_params.slice_enc_params); + g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support); + + if(msg->video_formats->list->H264_codec.max_hres) + g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_hres); + else + g_string_append_printf (lines," none"); + + if(msg->video_formats->list->H264_codec.max_vres) + g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_vres); + else + g_string_append_printf (lines," none"); + } + g_string_append_printf (lines,"\r\n"); + } + + /* list of video 3D codecs */ + if(msg->video_3d_formats) { + g_string_append_printf (lines,"wfd_3d_video_formats"); + g_string_append_printf (lines,":"); + if(msg->video_3d_formats->list) { + g_string_append_printf (lines," %02x", msg->video_3d_formats->list->native); + g_string_append_printf (lines," %02x", msg->video_3d_formats->list->preferred_display_mode_supported); + g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.profile); + g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.level); + g_string_append_printf (lines," %16x", msg->video_3d_formats->list->H264_codec.misc_params.video_3d_capability); + g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.misc_params.latency); + g_string_append_printf (lines," %04x", msg->video_3d_formats->list->H264_codec.misc_params.min_slice_size); + g_string_append_printf (lines," %04x", msg->video_3d_formats->list->H264_codec.misc_params.slice_enc_params); + g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support); + if(msg->video_3d_formats->list->H264_codec.max_hres) + g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_hres); + else + g_string_append_printf (lines," none"); + if(msg->video_3d_formats->list->H264_codec.max_vres) + g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_vres); + else + g_string_append_printf (lines," none"); + } else { + g_string_append_printf (lines," none"); + } + g_string_append_printf (lines,"\r\n"); + } + + if(msg->content_protection) { + g_string_append_printf (lines,"wfd_content_protection"); + g_string_append_printf (lines,":"); + if(msg->content_protection->hdcp2_spec) { + if( msg->content_protection->hdcp2_spec->hdcpversion) { + g_string_append_printf (lines," %s", msg->content_protection->hdcp2_spec->hdcpversion); + g_string_append_printf (lines," %s", msg->content_protection->hdcp2_spec->TCPPort); + } else { + g_string_append_printf (lines," none"); + } + } else { + g_string_append_printf (lines," none"); + } + g_string_append_printf (lines,"\r\n"); + } + + if(msg->display_edid) { + g_string_append_printf (lines,"wfd_display_edid"); + g_string_append_printf (lines,":"); + if(msg->display_edid->edid_supported) { + g_string_append_printf (lines," %d", msg->display_edid->edid_supported); + if(msg->display_edid->edid_block_count) + g_string_append_printf (lines," %d", msg->display_edid->edid_block_count); + else + g_string_append_printf (lines," none"); + } else { + g_string_append_printf (lines," none"); + } + g_string_append_printf (lines,"\r\n"); + } + + if(msg->coupled_sink) { + g_string_append_printf (lines,"wfd_coupled_sink"); + g_string_append_printf (lines,":"); + if(msg->coupled_sink->coupled_sink_cap) { + g_string_append_printf (lines," %02x", msg->coupled_sink->coupled_sink_cap->status); + if(msg->coupled_sink->coupled_sink_cap->sink_address) + g_string_append_printf (lines," %s", msg->coupled_sink->coupled_sink_cap->sink_address); + else + g_string_append_printf (lines," none"); + } else { + g_string_append_printf (lines," none"); + } + g_string_append_printf (lines,"\r\n"); + } + + if(msg->trigger_method) { + g_string_append_printf (lines,"wfd_trigger_method"); + g_string_append_printf (lines,":"); + g_string_append_printf (lines," %s", msg->trigger_method->wfd_trigger_method); + g_string_append_printf (lines,"\r\n"); + } + + if(msg->presentation_url) { + g_string_append_printf (lines,"wfd_presentation_URL"); + g_string_append_printf (lines,":"); + if(msg->presentation_url->wfd_url0) + g_string_append_printf (lines," %s", msg->presentation_url->wfd_url0); + else + g_string_append_printf (lines," none"); + if(msg->presentation_url->wfd_url1) + g_string_append_printf (lines," %s", msg->presentation_url->wfd_url1); + else + g_string_append_printf (lines," none"); + g_string_append_printf (lines,"\r\n"); + } + + if(msg->client_rtp_ports) { + g_string_append_printf (lines,"wfd_client_rtp_ports"); + if(msg->client_rtp_ports->profile) { + g_string_append_printf (lines,":"); + g_string_append_printf (lines," %s", msg->client_rtp_ports->profile); + g_string_append_printf (lines," %d", msg->client_rtp_ports->rtp_port0); + g_string_append_printf (lines," %d", msg->client_rtp_ports->rtp_port1); + g_string_append_printf (lines," %s", msg->client_rtp_ports->mode); + } + g_string_append_printf (lines,"\r\n"); + } + + if(msg->route) { + g_string_append_printf (lines,"wfd_route"); + g_string_append_printf (lines,":"); + g_string_append_printf (lines," %s", msg->route->destination); + g_string_append_printf (lines,"\r\n"); + } + + if(msg->I2C) { + g_string_append_printf (lines,"wfd_I2C"); + g_string_append_printf (lines,":"); + if(msg->I2C->I2CPresent) + g_string_append_printf (lines," %x", msg->I2C->I2C_port); + else + g_string_append_printf (lines," none"); + g_string_append_printf (lines,"\r\n"); + } + + if(msg->av_format_change_timing) { + g_string_append_printf (lines,"wfd_av_format_change_timing"); + g_string_append_printf (lines,":"); + g_string_append_printf (lines," %10llu", msg->av_format_change_timing->PTS); + g_string_append_printf (lines," %10llu", msg->av_format_change_timing->DTS); + g_string_append_printf (lines,"\r\n"); + } + + if(msg->preferred_display_mode) { + g_string_append_printf (lines,"wfd_preferred_display_mode"); + g_string_append_printf (lines,":"); + if(msg->preferred_display_mode->displaymodesupported) { + g_string_append_printf (lines," %06llu", msg->preferred_display_mode->p_clock); + g_string_append_printf (lines," %04x", msg->preferred_display_mode->H); + g_string_append_printf (lines," %04x", msg->preferred_display_mode->HB); + g_string_append_printf (lines," %04x", msg->preferred_display_mode->HSPOL_HSOFF); + g_string_append_printf (lines," %04x", msg->preferred_display_mode->HSW); + g_string_append_printf (lines," %04x", msg->preferred_display_mode->V); + g_string_append_printf (lines," %04x", msg->preferred_display_mode->VB); + g_string_append_printf (lines," %04x", msg->preferred_display_mode->VSPOL_VSOFF); + g_string_append_printf (lines," %04x", msg->preferred_display_mode->VSW); + g_string_append_printf (lines," %02x", msg->preferred_display_mode->VBS3D); + g_string_append_printf (lines," %02x", msg->preferred_display_mode->V2d_s3d_modes); + g_string_append_printf (lines," %02x", msg->preferred_display_mode->P_depth); + } else g_string_append_printf (lines," none"); + g_string_append_printf (lines,"\r\n"); + } + + if(msg->uibc_capability) { + g_string_append_printf (lines,"wfd_uibc_capability"); + g_string_append_printf (lines,":"); + if(msg->uibc_capability->uibcsupported) { + g_string_append_printf (lines," input_category_list="); + if(msg->uibc_capability->input_category_list.input_cat) { + guint32 tempcap = 0; + if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) { + tempcap |= WFD_UIBC_INPUT_CAT_GENERIC; + g_string_append_printf (lines,"GENERIC"); + if(msg->uibc_capability->input_category_list.input_cat != tempcap) g_string_append_printf (lines,", "); + } + if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) { + tempcap |= WFD_UIBC_INPUT_CAT_HIDC; + g_string_append_printf (lines,"HIDC"); + if(msg->uibc_capability->input_category_list.input_cat != tempcap) g_string_append_printf (lines,", "); + } + } + else g_string_append_printf (lines,"none"); + g_string_append_printf (lines,";"); + g_string_append_printf (lines," generic_cap_list="); + if(msg->uibc_capability->generic_cap_list.inp_type) { + guint32 tempcap = 0; + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) { + tempcap |= WFD_UIBC_INPUT_TYPE_KEYBOARD; + g_string_append_printf (lines,"Keyboard"); + if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); + } + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) { + tempcap |= WFD_UIBC_INPUT_TYPE_MOUSE; + g_string_append_printf (lines,"Mouse"); + if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); + } + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) { + tempcap |= WFD_UIBC_INPUT_TYPE_SINGLETOUCH; + g_string_append_printf (lines,"SingleTouch"); + if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); + } + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) { + tempcap |= WFD_UIBC_INPUT_TYPE_MULTITOUCH; + g_string_append_printf (lines,"MultiTouch"); + if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); + } + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) { + tempcap |= WFD_UIBC_INPUT_TYPE_JOYSTICK; + g_string_append_printf (lines,"Joystick"); + if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); + } + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) { + tempcap |= WFD_UIBC_INPUT_TYPE_CAMERA; + g_string_append_printf (lines,"Camera"); + if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); + } + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) { + tempcap |= WFD_UIBC_INPUT_TYPE_GESTURE; + g_string_append_printf (lines,"Gesture"); + if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); + } + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) { + tempcap |= WFD_UIBC_INPUT_TYPE_REMOTECONTROL; + g_string_append_printf (lines,"RemoteControl"); + if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); + } + } + else g_string_append_printf (lines,"none"); + g_string_append_printf (lines,";"); + g_string_append_printf (lines," hidc_cap_list="); + if(msg->uibc_capability->hidc_cap_list.cap_count) { + detailed_cap *temp_cap = msg->uibc_capability->hidc_cap_list.next; + while(temp_cap) + { + if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_KEYBOARD) g_string_append_printf (lines,"Keyboard"); + else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_MOUSE) g_string_append_printf (lines,"Mouse"); + else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_SINGLETOUCH) g_string_append_printf (lines,"SingleTouch"); + else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_MULTITOUCH) g_string_append_printf (lines,"MultiTouch"); + else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_JOYSTICK) g_string_append_printf (lines,"Joystick"); + else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_CAMERA) g_string_append_printf (lines,"Camera"); + else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_GESTURE) g_string_append_printf (lines,"Gesture"); + else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_REMOTECONTROL) g_string_append_printf (lines,"RemoteControl"); + g_string_append_printf (lines,"/"); + if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_INFRARED) g_string_append_printf (lines,"Infrared"); + else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_USB) g_string_append_printf (lines,"USB"); + else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_BT) g_string_append_printf (lines,"BT"); + else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_ZIGBEE) g_string_append_printf (lines,"Zigbee"); + else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_WIFI) g_string_append_printf (lines,"Wi-Fi"); + else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_NOSP) g_string_append_printf (lines,"No-SP"); + temp_cap = temp_cap->next; + if(temp_cap) g_string_append_printf (lines,", "); + } + } else g_string_append_printf (lines,"none"); + g_string_append_printf (lines,";"); + if(msg->uibc_capability->tcp_port) g_string_append_printf (lines,"port=%u", msg->uibc_capability->tcp_port); + else g_string_append_printf (lines,"port=none"); + } else g_string_append_printf (lines," none"); + g_string_append_printf (lines,"\r\n"); + } + + if(msg->uibc_setting) { + g_string_append_printf (lines,"wfd_uibc_setting"); + g_string_append_printf (lines,":"); + if(msg->uibc_setting->uibc_setting) + g_string_append_printf (lines," enable"); + else + g_string_append_printf (lines," disable"); + g_string_append_printf (lines,"\r\n"); + } + + if(msg->standby_resume_capability) { + g_string_append_printf (lines,"wfd_standby_resume_capability"); + g_string_append_printf (lines,":"); + if(msg->standby_resume_capability->standby_resume_cap) + g_string_append_printf (lines," supported"); + else + g_string_append_printf (lines," none"); + g_string_append_printf (lines,"\r\n"); + } + + if(msg->standby) { + g_string_append_printf (lines,"wfd_standby"); + g_string_append_printf (lines,"\r\n"); + } + + if(msg->connector_type) { + g_string_append_printf (lines,"wfd_connector_type"); + g_string_append_printf (lines,":"); + g_string_append_printf (lines,"\r\n"); + } + + if(msg->idr_request) { + g_string_append_printf (lines,"wfd_idr_request"); + g_string_append_printf (lines,"\r\n"); + } + + //g_string_append_printf (lines,"\0"); + /*if(g_str_has_suffix (lines,"\r\n\0")) + { + guint32 length = g_strlen(lines); + lines[length-2] = '\0'; + }*/ + return g_string_free (lines, FALSE); +} + +gchar* wfdconfig_parameter_names_as_text (const WFDMessage *msg) +{ + /* change all vars so they match rfc? */ + GString *lines; + g_return_val_if_fail (msg != NULL, NULL); + + lines = g_string_new (""); + + /* list of audio codecs */ + if(msg->audio_codecs) { + g_string_append_printf (lines,"wfd_audio_codecs"); + g_string_append_printf (lines,"\r\n"); + } + /* list of video codecs */ + if(msg->video_formats) { + g_string_append_printf (lines,"wfd_video_formats"); + g_string_append_printf (lines,"\r\n"); + } + /* list of video 3D codecs */ + if(msg->video_3d_formats) { + g_string_append_printf (lines,"wfd_3d_video_formats"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->content_protection) { + g_string_append_printf (lines,"wfd_content_protection"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->display_edid) { + g_string_append_printf (lines,"wfd_display_edid"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->coupled_sink) { + g_string_append_printf (lines,"wfd_coupled_sink"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->trigger_method) { + g_string_append_printf (lines,"wfd_trigger_method"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->presentation_url) { + g_string_append_printf (lines,"wfd_presentation_URL"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->client_rtp_ports) { + g_string_append_printf (lines,"wfd_client_rtp_ports"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->route) { + g_string_append_printf (lines,"wfd_route"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->I2C) { + g_string_append_printf (lines,"wfd_I2C"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->av_format_change_timing) { + g_string_append_printf (lines,"wfd_av_format_change_timing"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->preferred_display_mode) { + g_string_append_printf (lines,"wfd_preferred_display_mode"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->uibc_capability) { + g_string_append_printf (lines,"wfd_uibc_capability"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->uibc_setting) { + g_string_append_printf (lines,"wfd_uibc_setting"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->standby_resume_capability) { + g_string_append_printf (lines,"wfd_standby_resume_capability"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->standby) { + g_string_append_printf (lines,"wfd_standby"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->connector_type) { + g_string_append_printf (lines,"wfd_connector_type"); + g_string_append_printf (lines,"\r\n"); + } + if(msg->idr_request) { + g_string_append_printf (lines,"wfd_idr_request"); + g_string_append_printf (lines,"\r\n"); + } + return g_string_free (lines, FALSE); +} + +static void +read_string_space_ended (gchar * dest, guint size, gchar * src) +{ + guint idx = 0; + + while (!g_ascii_isspace (*src) && *src != '\0') { + if (idx < size - 1) + dest[idx++] = *src; + src++; + } + + if (size > 0) + dest[idx] = '\0'; +} + +static void +read_string_char_ended (gchar * dest, guint size, gchar del, gchar * src) +{ + guint idx = 0; + + while (*src != del && *src != '\0') { + if (idx < size - 1) + dest[idx++] = *src; + src++; + } + + if (size > 0) + dest[idx] = '\0'; +} + +static void +read_string_type_and_value (gchar * type, gchar * value, guint tsize, guint vsize, gchar del, gchar * src) +{ + guint idx; + + idx = 0; + while (*src != del && *src != '\0') { + if (idx < tsize - 1) + type[idx++] = *src; + src++; + } + + if (tsize > 0) + type[idx] = '\0'; + + src++; + idx = 0; + while (*src != '\0') { + if (idx < vsize - 1) + value[idx++] = *src; + src++; + } + if (vsize > 0) + value[idx] = '\0'; +} + +static gboolean +wfdconfig_parse_line (WFDMessage * msg, gchar * buffer) +{ + gchar type[8192] = {0}; + gchar value[8192] = {0}; + gchar temp[8192] = {0}; + gchar *p = buffer; + gchar *v = value; + gchar *result = NULL; + + #define WFD_SKIP_SPACE(q) if (*q && g_ascii_isspace (*q)) q++ + #define WFD_SKIP_EQUAL(q) if (*q && *q == '=') q++ + #define WFD_SKIP_COMMA(q) if (*q && g_ascii_ispunct (*q)) q++ + #define WFD_READ_STRING(field) read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); REPLACE_STRING (field, temp) + #define WFD_READ_CHAR_END_STRING(field, del) read_string_char_ended (temp, sizeof (temp), del, v); v+=strlen(temp); REPLACE_STRING (field, temp) + #define WFD_READ_UINT32(field) read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); field = strtoul (temp, NULL, 16) + #define WFD_READ_UINT32_DIGIT(field) read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); field = strtoul (temp, NULL, 10) + + //g_print("wfdconfig_parse_line input: %s\n", buffer); + read_string_type_and_value (type, value, sizeof(type), sizeof(value), ':', p); + //g_print("wfdconfig_parse_line type:%s value:%s\n", type, value); + if(!g_strcmp0(type,"wfd_audio_codecs")) { + msg->audio_codecs = g_new0 (WFDAudioCodeclist, 1); + if(strlen(v)) { + guint i=0; + msg->audio_codecs->count= strlen(v)/16; + msg->audio_codecs->list = g_new0 (WFDAudioCodec, msg->audio_codecs->count); + for(;iaudio_codecs->count;i++) { + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->audio_codecs->list[i].audio_format); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->audio_codecs->list[i].modes); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->audio_codecs->list[i].latency); + WFD_SKIP_COMMA(v); + } + } + } else if(!g_strcmp0(type,"wfd_video_formats")) { + msg->video_formats = g_new0 (WFDVideoCodeclist, 1); + if(strlen(v)) { + msg->video_formats->count = 1; + msg->video_formats->list = g_new0 (WFDVideoCodec, 1); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->native); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->preferred_display_mode_supported); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.profile); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.level); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.CEA_Support); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.VESA_Support); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.HH_Support); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.latency); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.min_slice_size); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.slice_enc_params); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support); + WFD_SKIP_SPACE(v); + if(msg->video_formats->list->preferred_display_mode_supported == 1) { + WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_hres); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_vres); + WFD_SKIP_SPACE(v); + } + } + }else if(!g_strcmp0(type,"wfd_3d_video_formats")) { + msg->video_3d_formats = g_new0 (WFD3DFormats, 1); + if(strlen(v)) { + msg->video_3d_formats->count = 1; + msg->video_3d_formats->list = g_new0 (WFD3dCapList, 1); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->native); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->preferred_display_mode_supported); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.profile); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.level); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.video_3d_capability); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.latency); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.min_slice_size); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.slice_enc_params); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support); + WFD_SKIP_SPACE(v); + if(msg->video_3d_formats->list->preferred_display_mode_supported == 1) { + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.max_hres); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.max_vres); + WFD_SKIP_SPACE(v); + } + } + } else if(!g_strcmp0(type,"wfd_content_protection")) { + msg->content_protection = g_new0 (WFDContentProtection, 1); + if(strlen(v)) { + WFD_SKIP_SPACE(v); + msg->content_protection->hdcp2_spec = g_new0 (WFDHdcp2Spec, 1); + if(strstr(v,"none")) { + msg->content_protection->hdcp2_spec->hdcpversion=g_strdup("none"); + } else { + WFD_READ_STRING(msg->content_protection->hdcp2_spec->hdcpversion); + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->content_protection->hdcp2_spec->TCPPort); + } + } + } else if(!g_strcmp0(type,"wfd_display_edid")) { + msg->display_edid = g_new0 (WFDDisplayEdid, 1); + if(strlen(v)) { + WFD_SKIP_SPACE(v); + if(strstr(v,"none")) { + msg->display_edid->edid_supported = 0; + } else { + msg->display_edid->edid_supported = 1; + WFD_READ_UINT32(msg->display_edid->edid_block_count); + WFD_SKIP_SPACE(v); + if(msg->display_edid->edid_block_count) { + gchar *edid_string = v; + int i=0, j=0, size =0; + guint32 payload_size = EDID_BLOCK_SIZE * msg->display_edid->edid_block_count; + msg->display_edid->edid_payload = g_malloc(payload_size); + size = EDID_BLOCK_SIZE*msg->display_edid->edid_block_count*2; + for (;i0x29 && edid_string[i]<0x40) k=edid_string[i]-48; + else if(edid_string[i]>0x60 && edid_string[i]<0x67) k=edid_string[i]-87; + else if(edid_string[i]>0x40 && edid_string[i]<0x47) k=edid_string[i]-55; + + if(edid_string[i+1]>0x29 && edid_string[i+1]<0x40) kk=edid_string[i+1]-48; + else if(edid_string[i+1]>0x60 && edid_string[i+1]<0x67) kk=edid_string[i+1]-87; + else if(edid_string[i+1]>0x40 && edid_string[i+1]<0x47) kk=edid_string[i+1]-55; + + msg->display_edid->edid_payload[j] = (k<<4)|kk; + i+=2; + } + //memcpy(msg->display_edid->edid_payload, v, payload_size); + v += (payload_size*2); + } else v += strlen(v); + } + } + } else if(!g_strcmp0(type,"wfd_coupled_sink")) { + msg->coupled_sink = g_new0 (WFDCoupledSink, 1); + if(strlen(v)) { + msg->coupled_sink->coupled_sink_cap = g_new0 (WFDCoupled_sink_cap, 1); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->coupled_sink->coupled_sink_cap->status); + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->coupled_sink->coupled_sink_cap->sink_address); + } + } else if(!g_strcmp0(type,"wfd_trigger_method")) { + msg->trigger_method = g_new0 (WFDTriggerMethod, 1); + if(strlen(v)) { + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->trigger_method->wfd_trigger_method); + } + } else if(!g_strcmp0(type,"wfd_presentation_URL")) { + msg->presentation_url = g_new0 (WFDPresentationUrl, 1); + if(strlen(v)) { + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->presentation_url->wfd_url0); + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->presentation_url->wfd_url1); + } + } else if(!g_strcmp0(type,"wfd_client_rtp_ports")) { + msg->client_rtp_ports = g_new0 (WFDClientRtpPorts, 1); + if(strlen(v)) { + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->client_rtp_ports->profile); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port0); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port1); + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->client_rtp_ports->mode); + } + } else if(!g_strcmp0(type,"wfd_route")) { + msg->route = g_new0 (WFDRoute, 1); + if(strlen(v)) { + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->route->destination); + } + } else if(!g_strcmp0(type,"wfd_I2C")) { + msg->I2C = g_new0 (WFDI2C, 1); + if(strlen(v)) { + msg->I2C->I2CPresent = TRUE; + WFD_SKIP_SPACE(v); + WFD_READ_UINT32_DIGIT(msg->I2C->I2C_port); + if(msg->I2C->I2C_port) msg->I2C->I2CPresent = TRUE; + } + } else if(!g_strcmp0(type,"wfd_av_format_change_timing")) { + msg->av_format_change_timing = g_new0 (WFDAVFormatChangeTiming, 1); + if(strlen(v)) { + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->av_format_change_timing->PTS); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->av_format_change_timing->DTS); + } + } else if(!g_strcmp0(type,"wfd_preferred_display_mode")) { + msg->preferred_display_mode = g_new0 (WFDPreferredDisplayMode, 1); + if(strlen(v)) { + WFD_SKIP_SPACE(v); + if(!strstr(v,"none")) { + msg->preferred_display_mode->displaymodesupported = FALSE; + } else { + WFD_READ_UINT32(msg->preferred_display_mode->p_clock); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->HB); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->HSPOL_HSOFF); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->HSW); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->V); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->VB); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->VSPOL_VSOFF); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->VSW); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->VBS3D); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->V2d_s3d_modes); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->P_depth); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.profile); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.level); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.CEA_Support); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.VESA_Support); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.HH_Support); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.latency); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.min_slice_size); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.slice_enc_params); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.frame_rate_control_support); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_hres); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_vres); + WFD_SKIP_SPACE(v); + } + } + } else if(!g_strcmp0(type,"wfd_uibc_capability")) { + msg->uibc_capability = g_new0 (WFDUibcCapability, 1); + if(strstr(v,"input_category_list")) { + gchar *tstring = NULL; + msg->uibc_capability->uibcsupported = TRUE; + WFD_SKIP_SPACE(v); + WFD_READ_CHAR_END_STRING(tstring, '='); + if(!g_strcmp0(tstring,"input_category_list")) { + gchar temp2[8192]={0}; + guint rem_len=0, read_len=0; + WFD_READ_CHAR_END_STRING(tstring, ';'); + rem_len = strlen(tstring); + do { + WFD_SKIP_SPACE(v); + read_string_char_ended (temp2, 8192, ',', tstring+read_len); + read_len += (strlen(temp2)+1); + if(strstr(temp2,"GENERIC")) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_GENERIC; + else if(strstr(temp2,"HIDC")) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_HIDC; + else msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_UNKNOWN; + } while(read_len < rem_len); + + result = strstr(v,"generic_cap_list"); + if(result != NULL){ + memset(temp2, 0, 8192); + rem_len=0; + read_len=0; + v = result; + WFD_READ_CHAR_END_STRING(tstring, '='); + if(!g_strcmp0(tstring,"generic_cap_list")) { + WFD_SKIP_SPACE(v); + WFD_READ_CHAR_END_STRING(tstring, ';'); + rem_len = strlen(tstring); + do { + read_string_char_ended (temp2, 8192, ',', tstring+read_len); + read_len += (strlen(temp2)+1); + if(strstr(temp2,"Keyboard")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_KEYBOARD; + else if(strstr(temp2,"Mouse")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MOUSE; + else if(strstr(temp2,"SingleTouch")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_SINGLETOUCH; + else if(strstr(temp2,"MultiTouch")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MULTITOUCH; + else if(strstr(temp2,"Joystick")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_JOYSTICK; + else if(strstr(temp2,"Camera")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_CAMERA; + else if(strstr(temp2,"Gesture")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_GESTURE; + else if(strstr(temp2,"RemoteControl")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_REMOTECONTROL; + else msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_UNKNOWN; + } while(read_len < rem_len); + } + } + result = strstr (v, "hidc_cap_list"); + if(result != NULL){ + v = result; + WFD_SKIP_SPACE(v); + WFD_READ_CHAR_END_STRING(tstring, '='); + if(!g_strcmp0(tstring,"hidc_cap_list")) { + gchar inp_type[8192]; + gchar inp_path[8192]; + memset(temp2, 0, 8192); + rem_len=0; + read_len=0; + detailed_cap *temp_cap; + WFD_READ_CHAR_END_STRING(tstring, ';'); + rem_len = strlen(tstring); + msg->uibc_capability->hidc_cap_list.next = g_new0 (detailed_cap, 1); + temp_cap = msg->uibc_capability->hidc_cap_list.next; + do { + msg->uibc_capability->hidc_cap_list.cap_count++; + read_string_char_ended (temp2, 8192, ',', tstring+read_len); + read_len += (strlen(temp2)+1); + read_string_type_and_value (inp_type, inp_path, sizeof(inp_type), sizeof(inp_path), '/',temp2); + if(strstr(inp_type,"Keyboard")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_KEYBOARD; + else if(strstr(inp_type,"Mouse")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MOUSE; + else if(strstr(inp_type,"SingleTouch")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_SINGLETOUCH; + else if(strstr(inp_type,"MultiTouch")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MULTITOUCH; + else if(strstr(inp_type,"Joystick")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_JOYSTICK; + else if(strstr(inp_type,"Camera")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_CAMERA; + else if(strstr(inp_type,"Gesture")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_GESTURE; + else if(strstr(inp_type,"RemoteControl")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_REMOTECONTROL; + else temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_UNKNOWN; + + if(strstr(inp_path,"Infrared")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_INFRARED; + else if(strstr(inp_path,"USB")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_USB; + else if(strstr(inp_path,"BT")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_BT; + else if(strstr(inp_path,"Zigbee")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_ZIGBEE; + else if(strstr(inp_path,"Wi-Fi")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_WIFI; + else if(strstr(inp_path,"No-SP")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_NOSP; + else temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_UNKNOWN; + if(read_len < rem_len) { + temp_cap->next = g_new0 (detailed_cap, 1); + temp_cap = temp_cap->next; + } + } while(read_len < rem_len); + } + } + result = strstr(v,"port"); + if(result != NULL) { + v = result; + WFD_READ_CHAR_END_STRING(tstring, '='); + if(!g_strcmp0(tstring,"port")) { + WFD_SKIP_EQUAL(v); + WFD_READ_CHAR_END_STRING(tstring, ';'); + if(!strstr(tstring,"none")) { + msg->uibc_capability->tcp_port = strtoul (tstring, NULL, 10); + } + } + } + } + } else if (strstr(v,"none")) { + msg->uibc_capability->uibcsupported = FALSE; + } + } else if(!g_strcmp0(type,"wfd_uibc_setting")) { + msg->uibc_setting = g_new0 (WFDUibcSetting, 1); + if(strlen(v)) { + WFD_SKIP_SPACE(v); + if(!g_strcmp0(v, "enable")) + msg->uibc_setting->uibc_setting = TRUE; + else + msg->uibc_setting->uibc_setting = FALSE; + } + } else if(!g_strcmp0(type,"wfd_standby_resume_capability")) { + msg->standby_resume_capability = g_new0 (WFDStandbyResumeCapability, 1); + if(strlen(v)) { + WFD_SKIP_SPACE(v); + if(!g_strcmp0(v, "supported")) + msg->standby_resume_capability->standby_resume_cap = TRUE; + else + msg->standby_resume_capability->standby_resume_cap = FALSE; + } + } else if(!g_strcmp0(type,"wfd_standby")) { + msg->standby = g_new0 (WFDStandby, 1); + msg->standby->wfd_standby = TRUE; + } else if(!g_strcmp0(type,"wfd_connector_type")) { + msg->connector_type = g_new0 (WFDConnectorType, 1); + if(strlen(v)) { + msg->connector_type->supported = TRUE; + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->connector_type->connector_type); + } + } else if(!g_strcmp0(type,"wfd_idr_request")) { + msg->idr_request = g_new0 (WFDIdrRequest, 1); + msg->idr_request->idr_request = TRUE; + } + + return TRUE; +} + +/** +* wfdconfig_message_parse_buffer: +* @data: the start of the buffer +* @size: the size of the buffer +* @msg: the result #WFDMessage +* +* Parse the contents of @size bytes pointed to by @data and store the result in +* @msg. +* +* Returns: #WFD_OK on success. +*/ +WFDResult +wfdconfig_message_parse_buffer (const guint8 * data, guint size, WFDMessage * msg) +{ + const gchar *p; + gchar buffer[MAX_LINE_LEN] = {0}; + guint idx = 0; + + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + g_return_val_if_fail (data != NULL, WFD_EINVAL); + g_return_val_if_fail (size != 0, WFD_EINVAL); + + p = (const gchar *) data; + while (TRUE) { + + if (*p == '\0') + break; + + idx = 0; + while (*p != '\n' && *p != '\r' && *p != '\0') { + if (idx < sizeof (buffer) - 1) + buffer[idx++] = *p; + p++; + } + buffer[idx] = '\0'; + wfdconfig_parse_line (msg, buffer); + + if (*p == '\0') + break; + p+=2; + } + + return WFD_OK; +} + +/** +* wfdconfig_message_dump: +* @msg: a #WFDMessage +* +* Dump the parsed contents of @msg to stdout. +* +* Returns: a #WFDResult. +*/ +WFDResult +wfdconfig_message_dump (const WFDMessage * msg) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + debug_log("===========WFD Message dump========="); + + if(msg->audio_codecs) { + guint i=0; + debug_log("Audio supported formats : \n"); + for(;iaudio_codecs->count;i++) { + debug_log("Codec: %s\n",msg->audio_codecs->list[i].audio_format); + if(!strcmp(msg->audio_codecs->list[i].audio_format,"LPCM")) { + if(msg->audio_codecs->list[i].modes & WFD_FREQ_44100) + debug_log(" Freq: %d\n", 44100); + if(msg->audio_codecs->list[i].modes & WFD_FREQ_48000) + debug_log(" Freq: %d\n", 48000); + debug_log(" Channels: %d\n", 2); + } + if(!strcmp(msg->audio_codecs->list[i].audio_format,"AAC")) { + debug_log(" Freq: %d\n", 48000); + if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_2) + debug_log(" Channels: %d\n", 2); + if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_4) + debug_log(" Channels: %d\n", 4); + if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_6) + debug_log(" Channels: %d\n", 6); + if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_8) + debug_log(" Channels: %d\n", 8); + } + if(!strcmp(msg->audio_codecs->list[i].audio_format,"AC3")) { + debug_log(" Freq: %d\n", 48000); + if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_2) + debug_log(" Channels: %d\n", 2); + if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_4) + debug_log(" Channels: %d\n", 4); + if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_6) + debug_log(" Channels: %d\n", 6); + } + debug_log(" Bitwidth: %d\n", 16); + debug_log(" Latency: %d\n", msg->audio_codecs->list[i].latency); + } + } + + + if(msg->video_formats) { + debug_log("Video supported formats : \n"); + if(msg->video_formats->list) { + debug_log("Codec: H264\n"); + guint nativeindex = 0; + if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_CEA_RESOLUTION) { + debug_log (" Native type: CEA\n"); + } else if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_VESA_RESOLUTION) { + debug_log (" Native type: VESA\n"); + } else if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_HH_RESOLUTION) { + debug_log (" Native type: HH\n"); + } + nativeindex = msg->video_formats->list->native >> 3; + debug_log (" Resolution: %d\n", (1 << nativeindex)); + + if(msg->video_formats->list->H264_codec.profile & WFD_H264_BASE_PROFILE) { + debug_log (" Profile: BASE\n"); + } else if(msg->video_formats->list->H264_codec.profile & WFD_H264_HIGH_PROFILE) { + debug_log (" Profile: HIGH\n"); + } if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_1) { + debug_log (" Level: 3.1\n"); + } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_2) { + debug_log (" Level: 3.2\n"); + } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4) { + debug_log (" Level: 4\n"); + } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_1) { + debug_log (" Level: 4.1\n"); + } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_2) { + debug_log (" Level: 4.2\n"); + } + debug_log (" Latency: %d\n", msg->video_formats->list->H264_codec.misc_params.latency); + debug_log (" min_slice_size: %x\n", msg->video_formats->list->H264_codec.misc_params.min_slice_size); + debug_log (" slice_enc_params: %x\n", msg->video_formats->list->H264_codec.misc_params.slice_enc_params); + debug_log (" frame_rate_control_support: %x\n", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support); + if(msg->video_formats->list->H264_codec.max_hres) { + debug_log (" Max Height: %04d\n", msg->video_formats->list->H264_codec.max_hres); + } + if(msg->video_formats->list->H264_codec.max_vres) { + debug_log (" Max Width: %04d\n", msg->video_formats->list->H264_codec.max_vres); + } + } + } + + if(msg->video_3d_formats) { + debug_log ("wfd_3d_formats"); + debug_log ("\r\n"); + } + + if(msg->content_protection) { + debug_log ("wfd_content_protection"); + debug_log ("\r\n"); + } + + if(msg->display_edid) { + debug_log ("wfd_display_edid"); + debug_log ("\r\n"); + } + + if(msg->coupled_sink) { + debug_log ("wfd_coupled_sink"); + debug_log ("\r\n"); + } + + if(msg->trigger_method) { + debug_log (" Trigger type: %s\n", msg->trigger_method->wfd_trigger_method); + } + + if(msg->presentation_url) { + debug_log ("wfd_presentation_URL"); + debug_log ("\r\n"); + } + + if(msg->client_rtp_ports) { + debug_log(" Client RTP Ports : \n"); + if(msg->client_rtp_ports->profile) { + debug_log ("%s\n", msg->client_rtp_ports->profile); + debug_log (" %d\n", msg->client_rtp_ports->rtp_port0); + debug_log (" %d\n", msg->client_rtp_ports->rtp_port1); + debug_log (" %s\n", msg->client_rtp_ports->mode); + } + debug_log("\r\n"); + } + + if(msg->route) { + debug_log ("wfd_route"); + debug_log ("\r\n"); + } + + if(msg->I2C) { + debug_log ("wfd_I2C"); + debug_log ("\r\n"); + } + + if(msg->av_format_change_timing) { + debug_log ("wfd_av_format_change_timing"); + debug_log ("\r\n"); + } + + if(msg->preferred_display_mode) { + debug_log ("wfd_preferred_display_mode"); + debug_log ("\r\n"); + } + + if(msg->uibc_capability) { + debug_log ("wfd_uibc_capability \r\n"); + debug_log ("input category list:"); + if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) + debug_log ("GENERIC"); + if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) + debug_log ("HIDC"); + if(!msg->uibc_capability->input_category_list.input_cat) + debug_log ("none"); + if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) { + debug_log ("generic cap list: "); + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) + debug_log("keyboard "); + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) + debug_log("mouse "); + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) + debug_log("single-touch "); + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) + debug_log("multi-touch "); + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) + debug_log("joystick "); + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) + debug_log("camera "); + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) + debug_log("gesture "); + if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) + debug_log("remote control "); + if(!msg->uibc_capability->generic_cap_list.inp_type) + debug_log("none "); + } + if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) { + debug_log ("hidc cap list:"); + if(msg->uibc_capability->hidc_cap_list.cap_count) { + detailed_cap *temp_cap = msg->uibc_capability->hidc_cap_list.next; + while (temp_cap) { + if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) { + debug_log("keyboard "); + } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) { + debug_log("mouse "); + } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) { + debug_log("single-touch "); + } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) { + debug_log("multi-touch "); + } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) { + debug_log("joystick "); + } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) { + debug_log("camera "); + } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) { + debug_log("gesture "); + } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) { + debug_log("remote control "); + } else if(!temp_cap->p.inp_type) { + debug_log("none "); + } + if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_INFRARED) { + debug_log("infrared"); + } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_USB) { + debug_log("usb"); + } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_BT) { + debug_log("bluetooth"); + } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_WIFI) { + debug_log("Wi-Fi"); + } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_ZIGBEE) { + debug_log("Zigbee"); + } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_NOSP) { + debug_log("No-SP"); + } else if(!temp_cap->p.inp_path) { + debug_log("none"); + } + temp_cap = temp_cap->next; + } + } + } + if(msg->uibc_capability->tcp_port) + debug_log("tcp port:%u", msg->uibc_capability->tcp_port); + if(!msg->uibc_capability->tcp_port) + debug_log ("tcp port: none"); + debug_log ("\r\n"); + } + + if(msg->uibc_setting) { + debug_log ("wfd_uibc_setting: "); + if(msg->uibc_setting->uibc_setting) { + debug_log("true"); + } else debug_log("false"); + debug_log ("\r\n"); + } + + if(msg->standby_resume_capability) { + debug_log ("wfd_standby_resume_capability"); + debug_log ("\r\n"); + } + + if(msg->standby) { + debug_log ("wfd_standby"); + debug_log ("\r\n"); + } + + if(msg->connector_type) { + debug_log ("wfd_connector_type"); + debug_log ("\r\n"); + } + + if(msg->idr_request) { + debug_log ("wfd_idr_request"); + debug_log ("\r\n"); + } + + debug_log("===============================================\n"); + return WFD_OK; +} + +WFDResult wfdconfig_set_supported_audio_format(WFDMessage *msg, WFDAudioFormats aCodec, guint aFreq, guint aChanels, + guint aBitwidth, guint32 aLatency) +{ + guint temp = aCodec; + guint i = 0; + guint pcm = 0, aac = 0, ac3 = 0; + + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + + if(!msg->audio_codecs) + msg->audio_codecs = g_new0 (WFDAudioCodeclist, 1); + + if(aCodec != WFD_AUDIO_UNKNOWN) { + while(temp) { + msg->audio_codecs->count++; + temp >>= 1; + } + msg->audio_codecs->list = g_new0 (WFDAudioCodec, msg->audio_codecs->count); + for(; iaudio_codecs->count; i++) { + if((aCodec & WFD_AUDIO_LPCM) && (!pcm)) { + msg->audio_codecs->list[i].audio_format = g_strdup("LPCM"); + msg->audio_codecs->list[i].modes = aFreq; + msg->audio_codecs->list[i].latency = aLatency; + pcm = 1; + } else if((aCodec & WFD_AUDIO_AAC) && (!aac)) { + msg->audio_codecs->list[i].audio_format = g_strdup("AAC"); + msg->audio_codecs->list[i].modes = aChanels; + msg->audio_codecs->list[i].latency = aLatency; + aac = 1; + } else if((aCodec & WFD_AUDIO_AC3) && (!ac3)) { + msg->audio_codecs->list[i].audio_format = g_strdup("AC3"); + msg->audio_codecs->list[i].modes = aChanels; + msg->audio_codecs->list[i].latency = aLatency; + ac3 = 1; + } + } + } + return WFD_OK; +} + +WFDResult wfdconfig_set_prefered_audio_format(WFDMessage *msg, WFDAudioFormats aCodec, WFDAudioFreq aFreq, WFDAudioChannels aChanels, + guint aBitwidth, guint32 aLatency) +{ + + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + + if(!msg->audio_codecs) + msg->audio_codecs = g_new0 (WFDAudioCodeclist, 1); + + msg->audio_codecs->list = g_new0 (WFDAudioCodec, 1); + msg->audio_codecs->count = 1; + if(aCodec == WFD_AUDIO_LPCM) { + msg->audio_codecs->list->audio_format = g_strdup("LPCM"); + msg->audio_codecs->list->modes = aFreq; + msg->audio_codecs->list->latency = aLatency; + } else if(aCodec == WFD_AUDIO_AAC) { + msg->audio_codecs->list->audio_format = g_strdup("AAC"); + msg->audio_codecs->list->modes = aChanels; + msg->audio_codecs->list->latency = aLatency; + } else if(aCodec == WFD_AUDIO_AC3) { + msg->audio_codecs->list->audio_format = g_strdup("AC3"); + msg->audio_codecs->list->modes = aChanels; + msg->audio_codecs->list->latency = aLatency; + } + return WFD_OK; +} + +WFDResult wfdconfig_get_supported_audio_format(WFDMessage *msg, guint *aCodec, guint *aFreq, guint *aChanels, + guint *aBitwidth, guint32 *aLatency) +{ + guint i = 0; + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + g_return_val_if_fail (msg->audio_codecs != NULL, WFD_EINVAL); + + for(; iaudio_codecs->count; i++) { + if(!g_strcmp0(msg->audio_codecs->list[i].audio_format,"LPCM")) { + *aCodec |= WFD_AUDIO_LPCM; + *aFreq |= msg->audio_codecs->list[i].modes; + *aChanels |= WFD_CHANNEL_2; + *aBitwidth = 16; + *aLatency = msg->audio_codecs->list[i].latency; + } else if(!g_strcmp0(msg->audio_codecs->list[i].audio_format,"AAC")) { + *aCodec |= WFD_AUDIO_AAC; + *aFreq |= WFD_FREQ_48000; + *aChanels |= msg->audio_codecs->list[i].modes; + *aBitwidth = 16; + *aLatency = msg->audio_codecs->list[i].latency; + } else if(!g_strcmp0(msg->audio_codecs->list[i].audio_format,"AC3")) { + *aCodec |= WFD_AUDIO_AC3; + *aFreq |= WFD_FREQ_48000; + *aChanels |= msg->audio_codecs->list[i].modes; + *aBitwidth = 16; + *aLatency = msg->audio_codecs->list[i].latency; + } + } + return WFD_OK; +} + +WFDResult wfdconfig_get_prefered_audio_format(WFDMessage *msg, WFDAudioFormats *aCodec, WFDAudioFreq *aFreq, WFDAudioChannels *aChanels, + guint *aBitwidth, guint32 *aLatency) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + + if(!g_strcmp0(msg->audio_codecs->list->audio_format,"LPCM")) { + *aCodec = WFD_AUDIO_LPCM; + *aFreq = msg->audio_codecs->list->modes; + *aChanels = WFD_CHANNEL_2; + *aBitwidth = 16; + *aLatency = msg->audio_codecs->list->latency; + } else if(!g_strcmp0(msg->audio_codecs->list->audio_format,"AAC")) { + *aCodec = WFD_AUDIO_AAC; + *aFreq = WFD_FREQ_48000; + *aChanels = msg->audio_codecs->list->modes; + *aBitwidth = 16; + *aLatency = msg->audio_codecs->list->latency; + } else if(!g_strcmp0(msg->audio_codecs->list->audio_format,"AC3")) { + *aCodec = WFD_AUDIO_AC3; + *aFreq = WFD_FREQ_48000; + *aChanels = msg->audio_codecs->list->modes; + *aBitwidth = 16; + *aLatency = msg->audio_codecs->list->latency; + } + return WFD_OK; +} + +WFDResult wfdconfig_set_supported_video_format(WFDMessage *msg, WFDVideoCodecs vCodec, + WFDVideoNativeResolution vNative, guint64 vNativeResolution, + guint64 vCEAResolution, guint64 vVESAResolution, guint64 vHHResolution, + guint vProfile, guint vLevel, guint32 vLatency, guint32 vMaxHeight, + guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control) +{ + guint nativeindex = 0; + guint64 temp = vNativeResolution; + + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + + if(!msg->video_formats) + msg->video_formats = g_new0 (WFDVideoCodeclist, 1); + + if(vCodec != WFD_VIDEO_UNKNOWN) { + msg->video_formats->list = g_new0 (WFDVideoCodec, 1); + while(temp) { + nativeindex++; + temp >>= 1; + } + + msg->video_formats->list->native = nativeindex-1; + msg->video_formats->list->native <<= 3; + + if(vNative == WFD_VIDEO_VESA_RESOLUTION) + msg->video_formats->list->native |= 1; + else if(vNative == WFD_VIDEO_HH_RESOLUTION) + msg->video_formats->list->native |= 2; + + msg->video_formats->list->preferred_display_mode_supported = 1; + msg->video_formats->list->H264_codec.profile = vProfile; + msg->video_formats->list->H264_codec.level = vLevel; + msg->video_formats->list->H264_codec.max_hres = vMaxHeight; + msg->video_formats->list->H264_codec.max_vres = vMaxWidth; + msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution; + msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution; + msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution; + msg->video_formats->list->H264_codec.misc_params.latency = vLatency; + msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size; + msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params; + msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control; + } + return WFD_OK; +} + +WFDResult wfdconfig_set_prefered_video_format(WFDMessage *msg, WFDVideoCodecs vCodec, + WFDVideoNativeResolution vNative, guint64 vNativeResolution, + WFDVideoCEAResolution vCEAResolution, WFDVideoVESAResolution vVESAResolution, + WFDVideoHHResolution vHHResolution, WFDVideoH264Profile vProfile, + WFDVideoH264Level vLevel, guint32 vLatency, guint32 vMaxHeight, + guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control) +{ + guint nativeindex = 0; + guint64 temp = vNativeResolution; + + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + + if(!msg->video_formats) + msg->video_formats = g_new0 (WFDVideoCodeclist, 1); + msg->video_formats->list = g_new0 (WFDVideoCodec, 1); + + while(temp) { + nativeindex++; + temp >>= 1; + } + + if(nativeindex) msg->video_formats->list->native = nativeindex-1; + msg->video_formats->list->native <<= 3; + + if(vNative == WFD_VIDEO_VESA_RESOLUTION) + msg->video_formats->list->native |= 1; + else if(vNative == WFD_VIDEO_HH_RESOLUTION) + msg->video_formats->list->native |= 2; + + msg->video_formats->list->preferred_display_mode_supported = 0; + msg->video_formats->list->H264_codec.profile = vProfile; + msg->video_formats->list->H264_codec.level = vLevel; + msg->video_formats->list->H264_codec.max_hres = vMaxHeight; + msg->video_formats->list->H264_codec.max_vres = vMaxWidth; + msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution; + msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution; + msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution; + msg->video_formats->list->H264_codec.misc_params.latency = vLatency; + msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size; + msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params; + msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control; + return WFD_OK; +} + +WFDResult wfdconfig_get_supported_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec, + WFDVideoNativeResolution *vNative, guint64 *vNativeResolution, + guint64 *vCEAResolution, guint64 *vVESAResolution, guint64 *vHHResolution, + guint *vProfile, guint *vLevel, guint32 *vLatency, guint32 *vMaxHeight, + guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control) +{ + guint nativeindex = 0; + + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + g_return_val_if_fail (msg->video_formats != NULL, WFD_EINVAL); + g_return_val_if_fail (msg->video_formats->list != NULL, WFD_EINVAL); + + *vCodec = WFD_VIDEO_H264; + *vNative = msg->video_formats->list->native & 0x7; + nativeindex = msg->video_formats->list->native >> 3; + *vNativeResolution = (guint64)1 << nativeindex; + *vProfile = msg->video_formats->list->H264_codec.profile; + *vLevel = msg->video_formats->list->H264_codec.level; + *vMaxHeight = msg->video_formats->list->H264_codec.max_hres; + *vMaxWidth = msg->video_formats->list->H264_codec.max_vres; + *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support; + *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support; + *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support; + *vLatency = msg->video_formats->list->H264_codec.misc_params.latency; + *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size; + *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params; + *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support; + return WFD_OK; +} + +WFDResult wfdconfig_get_prefered_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec, + WFDVideoNativeResolution *vNative, guint64 *vNativeResolution, + WFDVideoCEAResolution *vCEAResolution, WFDVideoVESAResolution *vVESAResolution, + WFDVideoHHResolution *vHHResolution, WFDVideoH264Profile *vProfile, + WFDVideoH264Level *vLevel, guint32 *vLatency, guint32 *vMaxHeight, + guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control) +{ + guint nativeindex = 0; + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + g_return_val_if_fail (msg->video_formats != NULL, WFD_EINVAL); + g_return_val_if_fail (msg->video_formats->list != NULL, WFD_EINVAL); + + *vCodec = WFD_VIDEO_H264; + *vNative = msg->video_formats->list->native & 0x7; + nativeindex = msg->video_formats->list->native >> 3; + *vNativeResolution = (guint64)1 << nativeindex; + *vProfile = msg->video_formats->list->H264_codec.profile; + *vLevel = msg->video_formats->list->H264_codec.level; + *vMaxHeight = msg->video_formats->list->H264_codec.max_hres; + *vMaxWidth = msg->video_formats->list->H264_codec.max_vres; + *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support; + *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support; + *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support; + *vLatency = msg->video_formats->list->H264_codec.misc_params.latency; + *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size; + *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params; + *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support; + return WFD_OK; +} + +WFDResult wfdconfig_set_contentprotection_type(WFDMessage *msg, WFDHDCPProtection hdcpversion, guint32 TCPPort) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + + if(!msg->content_protection) msg->content_protection = g_new0 (WFDContentProtection, 1); + if(hdcpversion == WFD_HDCP_NONE) return WFD_OK; + msg->content_protection->hdcp2_spec = g_new0 (WFDHdcp2Spec, 1); + if(hdcpversion == WFD_HDCP_2_0) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup("HDCP2.0"); + else if(hdcpversion == WFD_HDCP_2_1) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup("HDCP2.1"); + char str[11]={0,}; + snprintf(str, 11, "port=%d", TCPPort); + msg->content_protection->hdcp2_spec->TCPPort = g_strdup(str); + return WFD_OK; +} + +WFDResult wfdconfig_get_contentprotection_type(WFDMessage *msg, WFDHDCPProtection *hdcpversion, guint32 *TCPPort) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(msg->content_protection && msg->content_protection->hdcp2_spec) { + char *result = NULL; + char *ptr = NULL; + if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"none")) { + debug_warning("HDCP none"); + *hdcpversion = WFD_HDCP_NONE; + *TCPPort = 0; + return WFD_OK; + } + if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"HDCP2.0")) *hdcpversion = WFD_HDCP_2_0; + else if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"HDCP2.1")) *hdcpversion = WFD_HDCP_2_1; + else { + debug_warning("Unknown protection type"); + *hdcpversion = WFD_HDCP_NONE; + *TCPPort = 0; + return WFD_OK; + } + + result = strtok_r(msg->content_protection->hdcp2_spec->TCPPort, "=", &ptr); + while (result !=NULL) { + result = strtok_r(NULL, "=", &ptr); + *TCPPort = atoi (result); + break; + } + } else *hdcpversion = WFD_HDCP_NONE; + return WFD_OK; +} + +WFDResult wfdconfig_set_display_EDID(WFDMessage *msg, gboolean edid_supported, guint32 edid_blockcount, gchar *edid_playload) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(!msg->display_edid) msg->display_edid = g_new0 (WFDDisplayEdid, 1); + msg->display_edid->edid_supported = edid_supported; + if(!edid_supported) return WFD_OK; + msg->display_edid->edid_block_count = edid_blockcount; + if(edid_blockcount) { + msg->display_edid->edid_payload = g_malloc(128 * edid_blockcount); + if(!msg->display_edid->edid_payload) + memcpy(msg->display_edid->edid_payload, edid_playload, 128 * edid_blockcount); + } else msg->display_edid->edid_payload = g_strdup("none"); + return WFD_OK; +} + +WFDResult wfdconfig_get_display_EDID(WFDMessage *msg, gboolean *edid_supported, guint32 *edid_blockcount, gchar **edid_playload) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(msg->display_edid ) { + if(msg->display_edid->edid_supported) { + *edid_blockcount = msg->display_edid->edid_block_count; + if(msg->display_edid->edid_block_count) { + char * temp; + temp = g_malloc(EDID_BLOCK_SIZE * msg->display_edid->edid_block_count); + if(temp) { + memset(temp, 0, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count); + memcpy(temp, msg->display_edid->edid_payload, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count); + *edid_playload = temp; + *edid_supported = TRUE; + } + } else *edid_playload = g_strdup("none"); + } + } else *edid_supported = FALSE; + return WFD_OK; +} + +WFDResult wfdconfig_set_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus status, gchar *sink_address) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(!msg->coupled_sink) msg->coupled_sink = g_new0 (WFDCoupledSink, 1); + if(status == WFD_SINK_UNKNOWN) return WFD_OK; + msg->coupled_sink->coupled_sink_cap = g_new0 (WFDCoupled_sink_cap, 1); + msg->coupled_sink->coupled_sink_cap->status = status; + msg->coupled_sink->coupled_sink_cap->sink_address = g_strdup(sink_address); + return WFD_OK; +} + +WFDResult wfdconfig_get_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus *status, gchar **sink_address) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(msg->coupled_sink && msg->coupled_sink->coupled_sink_cap) { + *status = msg->coupled_sink->coupled_sink_cap->status; + *sink_address = g_strdup(msg->coupled_sink->coupled_sink_cap->sink_address); + } else *status = WFD_SINK_UNKNOWN; + return WFD_OK; +} + +WFDResult wfdconfig_set_trigger_type(WFDMessage *msg, WFDTrigger trigger) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + + if(!msg->trigger_method) + msg->trigger_method = g_new0 (WFDTriggerMethod, 1); + if(trigger == WFD_TRIGGER_SETUP) + msg->trigger_method->wfd_trigger_method = g_strdup("SETUP"); + else if(trigger == WFD_TRIGGER_PAUSE) + msg->trigger_method->wfd_trigger_method = g_strdup("PAUSE"); + else if(trigger == WFD_TRIGGER_TEARDOWN) + msg->trigger_method->wfd_trigger_method = g_strdup("TEARDOWN"); + else if(trigger == WFD_TRIGGER_PLAY) + msg->trigger_method->wfd_trigger_method = g_strdup("PLAY"); + else + return WFD_EINVAL; + return WFD_OK; +} + +WFDResult wfdconfig_get_trigger_type(WFDMessage *msg, WFDTrigger *trigger) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "SETUP")) + *trigger = WFD_TRIGGER_SETUP; + else if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "PAUSE")) + *trigger = WFD_TRIGGER_PAUSE; + else if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "TEARDOWN")) + *trigger = WFD_TRIGGER_TEARDOWN; + else if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "PLAY")) + *trigger = WFD_TRIGGER_PLAY; + else { + *trigger = WFD_TRIGGER_UNKNOWN; + return WFD_EINVAL; + } + return WFD_OK; +} + +WFDResult wfdconfig_set_presentation_url(WFDMessage *msg, gchar *wfd_url0, gchar *wfd_url1) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(!msg->presentation_url) msg->presentation_url = g_new0 (WFDPresentationUrl, 1); + if(wfd_url0) msg->presentation_url->wfd_url0 = g_strdup(wfd_url0); + if(wfd_url1) msg->presentation_url->wfd_url1 = g_strdup(wfd_url1); + return WFD_OK; +} + +WFDResult wfdconfig_get_presentation_url(WFDMessage *msg, gchar **wfd_url0, gchar **wfd_url1) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(msg->presentation_url) { + *wfd_url0 = g_strdup(msg->presentation_url->wfd_url0); + *wfd_url1 = g_strdup(msg->presentation_url->wfd_url1); + } + return WFD_OK; +} + +WFDResult wfdconfig_set_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode trans, WFDRTSPProfile profile, + WFDRTSPLowerTrans lowertrans, guint32 rtp_port0, guint32 rtp_port1) +{ + GString *lines; + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + + if(!msg->client_rtp_ports) + msg->client_rtp_ports = g_new0 (WFDClientRtpPorts, 1); + + if(trans != WFD_RTSP_TRANS_UNKNOWN) { + lines = g_string_new (""); + if(trans == WFD_RTSP_TRANS_RTP) g_string_append_printf (lines,"RTP"); + else if(trans == WFD_RTSP_TRANS_RDT) g_string_append_printf (lines,"RDT"); + + if(profile == WFD_RTSP_PROFILE_AVP) g_string_append_printf (lines,"/AVP"); + else if(profile == WFD_RTSP_PROFILE_SAVP) g_string_append_printf (lines,"/SAVP"); + + if(lowertrans == WFD_RTSP_LOWER_TRANS_UDP) g_string_append_printf (lines,"/UDP;unicast"); + else if(lowertrans == WFD_RTSP_LOWER_TRANS_UDP_MCAST) g_string_append_printf (lines,"/UDP;multicast"); + else if(lowertrans == WFD_RTSP_LOWER_TRANS_TCP) g_string_append_printf (lines,"/TCP;unicast"); + else if(lowertrans == WFD_RTSP_LOWER_TRANS_HTTP) g_string_append_printf (lines,"/HTTP"); + + msg->client_rtp_ports->profile = g_string_free (lines, FALSE); + msg->client_rtp_ports->rtp_port0 = rtp_port0; + msg->client_rtp_ports->rtp_port1 = rtp_port1; + msg->client_rtp_ports->mode = g_strdup("mode=play"); + } + return WFD_OK; +} + +WFDResult wfdconfig_get_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode *trans, WFDRTSPProfile *profile, + WFDRTSPLowerTrans *lowertrans, guint32 *rtp_port0, guint32 *rtp_port1) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + g_return_val_if_fail (msg->client_rtp_ports != NULL, WFD_EINVAL); + + if(g_strrstr(msg->client_rtp_ports->profile, "RTP")) *trans = WFD_RTSP_TRANS_RTP; + if(g_strrstr(msg->client_rtp_ports->profile, "RDT")) *trans = WFD_RTSP_TRANS_RDT; + if(g_strrstr(msg->client_rtp_ports->profile, "AVP")) *profile = WFD_RTSP_PROFILE_AVP; + if(g_strrstr(msg->client_rtp_ports->profile, "SAVP")) *profile = WFD_RTSP_PROFILE_SAVP; + if(g_strrstr(msg->client_rtp_ports->profile, "UDP;unicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP; + if(g_strrstr(msg->client_rtp_ports->profile, "UDP;multicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP_MCAST; + if(g_strrstr(msg->client_rtp_ports->profile, "TCP;unicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_TCP; + if(g_strrstr(msg->client_rtp_ports->profile, "HTTP")) *lowertrans = WFD_RTSP_LOWER_TRANS_HTTP; + + *rtp_port0 = msg->client_rtp_ports->rtp_port0; + *rtp_port1 = msg->client_rtp_ports->rtp_port1; + + return WFD_OK; +} + +WFDResult wfdconfig_set_audio_sink_type(WFDMessage *msg, WFDSinkType sinktype) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(!msg->route) msg->route = g_new0 (WFDRoute, 1); + if(sinktype == WFD_PRIMARY_SINK) msg->route->destination = g_strdup("primary"); + else if(sinktype == WFD_SECONDARY_SINK) msg->route->destination = g_strdup("secondary"); + return WFD_OK; +} + +WFDResult wfdconfig_get_audio_sink_type(WFDMessage *msg, WFDSinkType *sinktype) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(msg->route) { + if(!g_strcmp0(msg->route->destination,"primary")) *sinktype = WFD_PRIMARY_SINK; + else if(!g_strcmp0(msg->route->destination,"secondary")) *sinktype = WFD_SECONDARY_SINK; + } + return WFD_OK; +} + +WFDResult wfdconfig_set_I2C_port(WFDMessage *msg, gboolean i2csupport, guint32 i2cport) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(!msg->I2C) msg->I2C = g_new0 (WFDI2C, 1); + msg->I2C->I2CPresent = i2csupport; + msg->I2C->I2C_port = i2cport; + return WFD_OK; +} + +WFDResult wfdconfig_get_I2C_port(WFDMessage *msg, gboolean *i2csupport, guint32 *i2cport) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(msg->I2C && msg->I2C->I2CPresent) { + *i2csupport = msg->I2C->I2CPresent; + *i2cport = msg->I2C->I2C_port; + } else *i2csupport = FALSE; + return WFD_OK; +} + +WFDResult wfdconfig_set_av_format_change_timing(WFDMessage *msg, guint64 PTS, guint64 DTS) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(!msg->av_format_change_timing) msg->av_format_change_timing = g_new0 (WFDAVFormatChangeTiming, 1); + msg->av_format_change_timing->PTS = PTS; + msg->av_format_change_timing->DTS = DTS; + return WFD_OK; +} + +WFDResult wfdconfig_get_av_format_change_timing(WFDMessage *msg, guint64 *PTS, guint64 *DTS) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(msg->av_format_change_timing) { + *PTS = msg->av_format_change_timing->PTS; + *DTS = msg->av_format_change_timing->DTS; + } + return WFD_OK; +} + +WFDResult wfdconfig_set_uibc_capability(WFDMessage *msg, guint32 input_category, guint32 inp_type, WFDHIDCTypePathPair *inp_pair, + guint32 inp_type_path_count, guint32 tcp_port) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(!msg->uibc_capability) msg->uibc_capability = g_new0 (WFDUibcCapability, 1); + msg->uibc_capability->uibcsupported = TRUE; + msg->uibc_capability->input_category_list.input_cat = input_category; + msg->uibc_capability->generic_cap_list.inp_type = inp_type; + msg->uibc_capability->hidc_cap_list.cap_count = inp_type_path_count; + if(msg->uibc_capability->hidc_cap_list.cap_count) { + detailed_cap *temp_cap; + guint i=0; + msg->uibc_capability->hidc_cap_list.next = g_new0 (detailed_cap, 1); + temp_cap = msg->uibc_capability->hidc_cap_list.next; + for(;ip.inp_type = inp_pair[i].inp_type; + temp_cap->p.inp_path = inp_pair[i].inp_path; + i++; + if(inext = g_new0 (detailed_cap, 1); + temp_cap = temp_cap->next; + } + } + } + msg->uibc_capability->tcp_port = tcp_port; + return WFD_OK; +} + +WFDResult wfdconfig_get_uibc_capability(WFDMessage *msg, guint32 *input_category, guint32 *inp_type, WFDHIDCTypePathPair **inp_pair, + guint32 *inp_type_path_count, guint32 *tcp_port) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(msg->uibc_capability && msg->uibc_capability->uibcsupported) { + *input_category = msg->uibc_capability->input_category_list.input_cat; + *inp_type = msg->uibc_capability->generic_cap_list.inp_type; + *inp_type_path_count = msg->uibc_capability->hidc_cap_list.cap_count; + if(msg->uibc_capability->hidc_cap_list.cap_count) { + detailed_cap *temp_cap; + guint i = 0; + *inp_pair = g_new0 (WFDHIDCTypePathPair, msg->uibc_capability->hidc_cap_list.cap_count); + temp_cap = msg->uibc_capability->hidc_cap_list.next; + while(temp_cap) { + (*(inp_pair))[i].inp_type = temp_cap->p.inp_type; + (*(inp_pair))[i].inp_path = temp_cap->p.inp_path; + temp_cap = temp_cap->next; + i++; + } + } + *tcp_port = msg->uibc_capability->tcp_port; + } + return WFD_OK; +} + +WFDResult wfdconfig_set_uibc_status(WFDMessage *msg, gboolean uibc_enable) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(!msg->uibc_setting) msg->uibc_setting = g_new0 (WFDUibcSetting, 1); + msg->uibc_setting->uibc_setting = uibc_enable; + return WFD_OK; +} + +WFDResult wfdconfig_get_uibc_status(WFDMessage *msg, gboolean *uibc_enable) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(msg->uibc_setting) *uibc_enable = msg->uibc_setting->uibc_setting; + return WFD_OK; +} +#ifdef STANDBY_RESUME_CAPABILITY +WFDResult wfdconfig_set_standby_resume_capability(WFDMessage *msg, gboolean supported) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(!msg->standby_resume_capability) msg->standby_resume_capability = g_new0 (WFDStandbyResumeCapability, 1); + msg->standby_resume_capability->standby_resume_cap = supported; + return WFD_OK; +} + +WFDResult wfdconfig_get_standby_resume_capability(WFDMessage *msg, gboolean *supported) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(msg->standby_resume_capability) *supported = msg->standby_resume_capability->standby_resume_cap; + return WFD_OK; +} +#endif +WFDResult wfdconfig_set_standby(WFDMessage *msg, gboolean standby_enable) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(!msg->standby) msg->standby = g_new0 (WFDStandby, 1); + msg->standby->wfd_standby = standby_enable; + return WFD_OK; +} + +WFDResult wfdconfig_get_standby(WFDMessage *msg, gboolean *standby_enable) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(msg->standby) *standby_enable = msg->standby->wfd_standby; + return WFD_OK; +} + +WFDResult wfdconfig_set_connector_type(WFDMessage *msg, WFDConnector connector) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(!msg->connector_type) msg->connector_type = g_new0 (WFDConnectorType, 1); + msg->connector_type->connector_type = connector; + return WFD_OK; +} + +WFDResult wfdconfig_get_connector_type(WFDMessage *msg, WFDConnector *connector) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(msg->connector_type) *connector = msg->connector_type->connector_type; + return WFD_OK; +} + +WFDResult wfdconfig_set_idr_request(WFDMessage *msg) +{ + g_return_val_if_fail (msg != NULL, WFD_EINVAL); + if(!msg->idr_request) msg->idr_request = g_new0 (WFDIdrRequest, 1); + msg->idr_request->idr_request = TRUE; + return WFD_OK; +} -- 2.7.4 From cc61ca238b6900d512a5253864045881048ac28e Mon Sep 17 00:00:00 2001 From: Hyunjun Date: Tue, 10 Mar 2015 15:53:50 +0900 Subject: [PATCH 3/9] Fix build break and warnings on 64bit system Change-Id: I40ba889e9ca04caf903c2ed4f0cf7fd170fd2886 --- packaging/libmm-scmirroring-common.spec | 6 +++--- wfdconfig/Makefile.am | 2 +- wfdconfig/wfdconfigmessage.c | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packaging/libmm-scmirroring-common.spec b/packaging/libmm-scmirroring-common.spec index e04aaf7..a189770 100755 --- a/packaging/libmm-scmirroring-common.spec +++ b/packaging/libmm-scmirroring-common.spec @@ -43,11 +43,11 @@ export CFLAGS+=" -Wall -Wcast-qual -Wno-empty-body" # always enable sdk build. This option should go away # to enable context manager add --enable-context-manager in following line # postfix the '--define "sec_product_feature_mmfw_codec_qc 1"' to gbs compilation command to enable QC MSM specific changes. While building for target SCM will automatically take care of it -./configure --prefix=%{_prefix} --disable-static +%configure --disable-static # Call make instruction with smp support -#make %{?jobs:-j%jobs} -make +make %{?jobs:-j%jobs} + %install rm -rf %{buildroot} %make_install diff --git a/wfdconfig/Makefile.am b/wfdconfig/Makefile.am index aa700aa..075faa0 100755 --- a/wfdconfig/Makefile.am +++ b/wfdconfig/Makefile.am @@ -6,7 +6,7 @@ includelibmmfwfdconfig_HEADERS = include/wfdconfigmessage.h libmmfwfdconfig_la_SOURCES = wfdconfigmessage.c -libmmfwfdconfig_la_CFLAGS = -Werror -I$(srcdir)/include \ +libmmfwfdconfig_la_CFLAGS = -I$(srcdir)/include \ $(GLIB_CFLAGS) \ $(MMCOMMON_CFLAGS) diff --git a/wfdconfig/wfdconfigmessage.c b/wfdconfig/wfdconfigmessage.c index bb0803e..a01cd5c 100755 --- a/wfdconfig/wfdconfigmessage.c +++ b/wfdconfig/wfdconfigmessage.c @@ -417,8 +417,8 @@ wfdconfig_message_as_text (const WFDMessage * msg) if(msg->av_format_change_timing) { g_string_append_printf (lines,"wfd_av_format_change_timing"); g_string_append_printf (lines,":"); - g_string_append_printf (lines," %10llu", msg->av_format_change_timing->PTS); - g_string_append_printf (lines," %10llu", msg->av_format_change_timing->DTS); + g_string_append_printf (lines," %10"G_GUINT64_FORMAT, msg->av_format_change_timing->PTS); + g_string_append_printf (lines," %10"G_GUINT64_FORMAT, msg->av_format_change_timing->DTS); g_string_append_printf (lines,"\r\n"); } @@ -426,7 +426,7 @@ wfdconfig_message_as_text (const WFDMessage * msg) g_string_append_printf (lines,"wfd_preferred_display_mode"); g_string_append_printf (lines,":"); if(msg->preferred_display_mode->displaymodesupported) { - g_string_append_printf (lines," %06llu", msg->preferred_display_mode->p_clock); + g_string_append_printf (lines," %06"G_GUINT64_FORMAT, msg->preferred_display_mode->p_clock); g_string_append_printf (lines," %04x", msg->preferred_display_mode->H); g_string_append_printf (lines," %04x", msg->preferred_display_mode->HB); g_string_append_printf (lines," %04x", msg->preferred_display_mode->HSPOL_HSOFF); -- 2.7.4 From 4fa56f865fd45191abaea26b60231090e99d01df Mon Sep 17 00:00:00 2001 From: Sangkyu Park Date: Thu, 28 May 2015 14:38:19 +0900 Subject: [PATCH 4/9] Merge the latest code. Change-Id: I02e1ec3a81ce27ef753825368d078d122df3085f Signed-off-by: Sangkyu Park --- configure.ac | 3 + include/mm_wfd_common_private.h | 78 +++++++++++ packaging/libmm-scmirroring-common.spec | 3 +- wfdconfig/Makefile.am | 3 +- wfdconfig/wfdconfigmessage.c | 240 ++++++++++++++++---------------- 5 files changed, 205 insertions(+), 122 deletions(-) create mode 100755 include/mm_wfd_common_private.h diff --git a/configure.ac b/configure.ac index 03ff509..5138893 100755 --- a/configure.ac +++ b/configure.ac @@ -29,6 +29,9 @@ PKG_CHECK_MODULES(GLIB, glib-2.0) AC_SUBST(GLIB_CFLAGS) AC_SUBST(GLIB_LIBS) +PKG_CHECK_MODULES(DLOG, dlog) +AC_SUBST(DLOG_CFLAGS) +AC_SUBST(DLOG_LIBS) # for testsuite AC_ARG_ENABLE(context-manager, AC_HELP_STRING([--enable-context-manager], [context manager]), diff --git a/include/mm_wfd_common_private.h b/include/mm_wfd_common_private.h new file mode 100755 index 0000000..92d33c7 --- /dev/null +++ b/include/mm_wfd_common_private.h @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef __MM_WFD_COMMON_PRIVATE_H__ +#define __MM_WFD_COMMON_PRIVATE_H__ + +#include + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "MM_WFD_COMMON" + +#define wfd_debug(fmt, arg...) do { \ + LOGD(""fmt"", ##arg); \ + } while (0) + +#define wfd_info(fmt, arg...) do { \ + LOGI(""fmt"", ##arg); \ + } while (0) + +#define wfd_error(fmt, arg...) do { \ + LOGE(""fmt"", ##arg); \ + } while (0) + +#define wfd_warning(fmt, arg...) do { \ + LOGW(""fmt"", ##arg); \ + } while (0) + +#define wfd_debug_fenter() do { \ + LOGD(""); \ + } while (0) + +#define wfd_debug_fleave() do { \ + LOGD(""); \ + } while (0) + +#define wfd_error_fenter() do { \ + LOGE("NO-ERROR : "); \ + } while (0) + +#define wfd_error_fleave() do { \ + LOGE("NO-ERROR : "); \ + } while (0) + +#define wfd_sucure_info(fmt, arg...) do { \ + SECURE_LOGI(""fmt"", ##arg); \ + } while (0) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __MM_WFD_COMMON_PRIVATE_H__ */ diff --git a/packaging/libmm-scmirroring-common.spec b/packaging/libmm-scmirroring-common.spec index a189770..4eb900e 100755 --- a/packaging/libmm-scmirroring-common.spec +++ b/packaging/libmm-scmirroring-common.spec @@ -1,6 +1,6 @@ Name: libmm-scmirroring-common Summary: Multimedia Framework Wifi-Display Common Library -Version: 0.0.27 +Version: 0.0.35 Release: 0 Group: System/Libraries License: Apache License 2.0 @@ -8,6 +8,7 @@ Source0: %{name}-%{version}.tar.gz Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig BuildRequires: pkgconfig(mm-common) +BuildRequires: pkgconfig(dlog) BuildRoot: %{_tmppath}/%{name}-%{version}-build diff --git a/wfdconfig/Makefile.am b/wfdconfig/Makefile.am index 075faa0..c846644 100755 --- a/wfdconfig/Makefile.am +++ b/wfdconfig/Makefile.am @@ -8,7 +8,8 @@ libmmfwfdconfig_la_SOURCES = wfdconfigmessage.c libmmfwfdconfig_la_CFLAGS = -I$(srcdir)/include \ $(GLIB_CFLAGS) \ - $(MMCOMMON_CFLAGS) + $(MMCOMMON_CFLAGS) \ + -I$(top_builddir)/include libmmfwfdconfig_la_LIBADD = $(GLIB_LIBS) \ $(GST_LIBS) \ diff --git a/wfdconfig/wfdconfigmessage.c b/wfdconfig/wfdconfigmessage.c index a01cd5c..4ff1627 100755 --- a/wfdconfig/wfdconfigmessage.c +++ b/wfdconfig/wfdconfigmessage.c @@ -33,7 +33,7 @@ #include /* for G_OS_WIN32 */ #include "wfdconfigmessage.h" -#include +#include "mm_wfd_common_private.h" /* FIXME, is currently allocated on the stack */ #define MAX_LINE_LEN 1024 * 16 @@ -1193,258 +1193,258 @@ WFDResult wfdconfig_message_dump (const WFDMessage * msg) { g_return_val_if_fail (msg != NULL, WFD_EINVAL); - debug_log("===========WFD Message dump========="); + wfd_debug("===========WFD Message dump========="); if(msg->audio_codecs) { guint i=0; - debug_log("Audio supported formats : \n"); + wfd_debug("Audio supported formats : \n"); for(;iaudio_codecs->count;i++) { - debug_log("Codec: %s\n",msg->audio_codecs->list[i].audio_format); + wfd_debug("Codec: %s\n",msg->audio_codecs->list[i].audio_format); if(!strcmp(msg->audio_codecs->list[i].audio_format,"LPCM")) { if(msg->audio_codecs->list[i].modes & WFD_FREQ_44100) - debug_log(" Freq: %d\n", 44100); + wfd_debug(" Freq: %d\n", 44100); if(msg->audio_codecs->list[i].modes & WFD_FREQ_48000) - debug_log(" Freq: %d\n", 48000); - debug_log(" Channels: %d\n", 2); + wfd_debug(" Freq: %d\n", 48000); + wfd_debug(" Channels: %d\n", 2); } if(!strcmp(msg->audio_codecs->list[i].audio_format,"AAC")) { - debug_log(" Freq: %d\n", 48000); + wfd_debug(" Freq: %d\n", 48000); if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_2) - debug_log(" Channels: %d\n", 2); + wfd_debug(" Channels: %d\n", 2); if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_4) - debug_log(" Channels: %d\n", 4); + wfd_debug(" Channels: %d\n", 4); if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_6) - debug_log(" Channels: %d\n", 6); + wfd_debug(" Channels: %d\n", 6); if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_8) - debug_log(" Channels: %d\n", 8); + wfd_debug(" Channels: %d\n", 8); } if(!strcmp(msg->audio_codecs->list[i].audio_format,"AC3")) { - debug_log(" Freq: %d\n", 48000); + wfd_debug(" Freq: %d\n", 48000); if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_2) - debug_log(" Channels: %d\n", 2); + wfd_debug(" Channels: %d\n", 2); if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_4) - debug_log(" Channels: %d\n", 4); + wfd_debug(" Channels: %d\n", 4); if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_6) - debug_log(" Channels: %d\n", 6); + wfd_debug(" Channels: %d\n", 6); } - debug_log(" Bitwidth: %d\n", 16); - debug_log(" Latency: %d\n", msg->audio_codecs->list[i].latency); + wfd_debug(" Bitwidth: %d\n", 16); + wfd_debug(" Latency: %d\n", msg->audio_codecs->list[i].latency); } } if(msg->video_formats) { - debug_log("Video supported formats : \n"); + wfd_debug("Video supported formats : \n"); if(msg->video_formats->list) { - debug_log("Codec: H264\n"); + wfd_debug("Codec: H264\n"); guint nativeindex = 0; if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_CEA_RESOLUTION) { - debug_log (" Native type: CEA\n"); + wfd_debug (" Native type: CEA\n"); } else if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_VESA_RESOLUTION) { - debug_log (" Native type: VESA\n"); + wfd_debug (" Native type: VESA\n"); } else if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_HH_RESOLUTION) { - debug_log (" Native type: HH\n"); + wfd_debug (" Native type: HH\n"); } nativeindex = msg->video_formats->list->native >> 3; - debug_log (" Resolution: %d\n", (1 << nativeindex)); + wfd_debug (" Resolution: %d\n", (1 << nativeindex)); if(msg->video_formats->list->H264_codec.profile & WFD_H264_BASE_PROFILE) { - debug_log (" Profile: BASE\n"); + wfd_debug (" Profile: BASE\n"); } else if(msg->video_formats->list->H264_codec.profile & WFD_H264_HIGH_PROFILE) { - debug_log (" Profile: HIGH\n"); + wfd_debug (" Profile: HIGH\n"); } if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_1) { - debug_log (" Level: 3.1\n"); + wfd_debug (" Level: 3.1\n"); } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_2) { - debug_log (" Level: 3.2\n"); + wfd_debug (" Level: 3.2\n"); } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4) { - debug_log (" Level: 4\n"); + wfd_debug (" Level: 4\n"); } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_1) { - debug_log (" Level: 4.1\n"); + wfd_debug (" Level: 4.1\n"); } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_2) { - debug_log (" Level: 4.2\n"); + wfd_debug (" Level: 4.2\n"); } - debug_log (" Latency: %d\n", msg->video_formats->list->H264_codec.misc_params.latency); - debug_log (" min_slice_size: %x\n", msg->video_formats->list->H264_codec.misc_params.min_slice_size); - debug_log (" slice_enc_params: %x\n", msg->video_formats->list->H264_codec.misc_params.slice_enc_params); - debug_log (" frame_rate_control_support: %x\n", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support); + wfd_debug (" Latency: %d\n", msg->video_formats->list->H264_codec.misc_params.latency); + wfd_debug (" min_slice_size: %x\n", msg->video_formats->list->H264_codec.misc_params.min_slice_size); + wfd_debug (" slice_enc_params: %x\n", msg->video_formats->list->H264_codec.misc_params.slice_enc_params); + wfd_debug (" frame_rate_control_support: %x\n", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support); if(msg->video_formats->list->H264_codec.max_hres) { - debug_log (" Max Height: %04d\n", msg->video_formats->list->H264_codec.max_hres); + wfd_debug (" Max Width: %04d\n", msg->video_formats->list->H264_codec.max_hres); } if(msg->video_formats->list->H264_codec.max_vres) { - debug_log (" Max Width: %04d\n", msg->video_formats->list->H264_codec.max_vres); + wfd_debug (" Max Height: %04d\n", msg->video_formats->list->H264_codec.max_vres); } } } if(msg->video_3d_formats) { - debug_log ("wfd_3d_formats"); - debug_log ("\r\n"); + wfd_debug ("wfd_3d_formats"); + wfd_debug ("\r\n"); } if(msg->content_protection) { - debug_log ("wfd_content_protection"); - debug_log ("\r\n"); + wfd_debug ("wfd_content_protection"); + wfd_debug ("\r\n"); } if(msg->display_edid) { - debug_log ("wfd_display_edid"); - debug_log ("\r\n"); + wfd_debug ("wfd_display_edid"); + wfd_debug ("\r\n"); } if(msg->coupled_sink) { - debug_log ("wfd_coupled_sink"); - debug_log ("\r\n"); + wfd_debug ("wfd_coupled_sink"); + wfd_debug ("\r\n"); } if(msg->trigger_method) { - debug_log (" Trigger type: %s\n", msg->trigger_method->wfd_trigger_method); + wfd_debug (" Trigger type: %s\n", msg->trigger_method->wfd_trigger_method); } if(msg->presentation_url) { - debug_log ("wfd_presentation_URL"); - debug_log ("\r\n"); + wfd_debug ("wfd_presentation_URL"); + wfd_debug ("\r\n"); } if(msg->client_rtp_ports) { - debug_log(" Client RTP Ports : \n"); + wfd_debug(" Client RTP Ports : \n"); if(msg->client_rtp_ports->profile) { - debug_log ("%s\n", msg->client_rtp_ports->profile); - debug_log (" %d\n", msg->client_rtp_ports->rtp_port0); - debug_log (" %d\n", msg->client_rtp_ports->rtp_port1); - debug_log (" %s\n", msg->client_rtp_ports->mode); + wfd_debug ("%s\n", msg->client_rtp_ports->profile); + wfd_debug (" %d\n", msg->client_rtp_ports->rtp_port0); + wfd_debug (" %d\n", msg->client_rtp_ports->rtp_port1); + wfd_debug (" %s\n", msg->client_rtp_ports->mode); } - debug_log("\r\n"); + wfd_debug("\r\n"); } if(msg->route) { - debug_log ("wfd_route"); - debug_log ("\r\n"); + wfd_debug ("wfd_route"); + wfd_debug ("\r\n"); } if(msg->I2C) { - debug_log ("wfd_I2C"); - debug_log ("\r\n"); + wfd_debug ("wfd_I2C"); + wfd_debug ("\r\n"); } if(msg->av_format_change_timing) { - debug_log ("wfd_av_format_change_timing"); - debug_log ("\r\n"); + wfd_debug ("wfd_av_format_change_timing"); + wfd_debug ("\r\n"); } if(msg->preferred_display_mode) { - debug_log ("wfd_preferred_display_mode"); - debug_log ("\r\n"); + wfd_debug ("wfd_preferred_display_mode"); + wfd_debug ("\r\n"); } if(msg->uibc_capability) { - debug_log ("wfd_uibc_capability \r\n"); - debug_log ("input category list:"); + wfd_debug ("wfd_uibc_capability \r\n"); + wfd_debug ("input category list:"); if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) - debug_log ("GENERIC"); + wfd_debug ("GENERIC"); if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) - debug_log ("HIDC"); + wfd_debug ("HIDC"); if(!msg->uibc_capability->input_category_list.input_cat) - debug_log ("none"); + wfd_debug ("none"); if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) { - debug_log ("generic cap list: "); + wfd_debug ("generic cap list: "); if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) - debug_log("keyboard "); + wfd_debug("keyboard "); if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) - debug_log("mouse "); + wfd_debug("mouse "); if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) - debug_log("single-touch "); + wfd_debug("single-touch "); if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) - debug_log("multi-touch "); + wfd_debug("multi-touch "); if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) - debug_log("joystick "); + wfd_debug("joystick "); if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) - debug_log("camera "); + wfd_debug("camera "); if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) - debug_log("gesture "); + wfd_debug("gesture "); if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) - debug_log("remote control "); + wfd_debug("remote control "); if(!msg->uibc_capability->generic_cap_list.inp_type) - debug_log("none "); + wfd_debug("none "); } if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) { - debug_log ("hidc cap list:"); + wfd_debug ("hidc cap list:"); if(msg->uibc_capability->hidc_cap_list.cap_count) { detailed_cap *temp_cap = msg->uibc_capability->hidc_cap_list.next; while (temp_cap) { if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) { - debug_log("keyboard "); + wfd_debug("keyboard "); } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) { - debug_log("mouse "); + wfd_debug("mouse "); } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) { - debug_log("single-touch "); + wfd_debug("single-touch "); } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) { - debug_log("multi-touch "); + wfd_debug("multi-touch "); } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) { - debug_log("joystick "); + wfd_debug("joystick "); } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) { - debug_log("camera "); + wfd_debug("camera "); } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) { - debug_log("gesture "); + wfd_debug("gesture "); } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) { - debug_log("remote control "); + wfd_debug("remote control "); } else if(!temp_cap->p.inp_type) { - debug_log("none "); + wfd_debug("none "); } if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_INFRARED) { - debug_log("infrared"); + wfd_debug("infrared"); } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_USB) { - debug_log("usb"); + wfd_debug("usb"); } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_BT) { - debug_log("bluetooth"); + wfd_debug("bluetooth"); } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_WIFI) { - debug_log("Wi-Fi"); + wfd_debug("Wi-Fi"); } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_ZIGBEE) { - debug_log("Zigbee"); + wfd_debug("Zigbee"); } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_NOSP) { - debug_log("No-SP"); + wfd_debug("No-SP"); } else if(!temp_cap->p.inp_path) { - debug_log("none"); + wfd_debug("none"); } temp_cap = temp_cap->next; } } } if(msg->uibc_capability->tcp_port) - debug_log("tcp port:%u", msg->uibc_capability->tcp_port); + wfd_debug("tcp port:%u", msg->uibc_capability->tcp_port); if(!msg->uibc_capability->tcp_port) - debug_log ("tcp port: none"); - debug_log ("\r\n"); + wfd_debug ("tcp port: none"); + wfd_debug ("\r\n"); } if(msg->uibc_setting) { - debug_log ("wfd_uibc_setting: "); + wfd_debug ("wfd_uibc_setting: "); if(msg->uibc_setting->uibc_setting) { - debug_log("true"); - } else debug_log("false"); - debug_log ("\r\n"); + wfd_debug("true"); + } else wfd_debug("false"); + wfd_debug ("\r\n"); } if(msg->standby_resume_capability) { - debug_log ("wfd_standby_resume_capability"); - debug_log ("\r\n"); + wfd_debug ("wfd_standby_resume_capability"); + wfd_debug ("\r\n"); } if(msg->standby) { - debug_log ("wfd_standby"); - debug_log ("\r\n"); + wfd_debug ("wfd_standby"); + wfd_debug ("\r\n"); } if(msg->connector_type) { - debug_log ("wfd_connector_type"); - debug_log ("\r\n"); + wfd_debug ("wfd_connector_type"); + wfd_debug ("\r\n"); } if(msg->idr_request) { - debug_log ("wfd_idr_request"); - debug_log ("\r\n"); + wfd_debug ("wfd_idr_request"); + wfd_debug ("\r\n"); } - debug_log("===============================================\n"); + wfd_debug("===============================================\n"); return WFD_OK; } @@ -1605,8 +1605,8 @@ WFDResult wfdconfig_set_supported_video_format(WFDMessage *msg, WFDVideoCodecs v msg->video_formats->list->preferred_display_mode_supported = 1; msg->video_formats->list->H264_codec.profile = vProfile; msg->video_formats->list->H264_codec.level = vLevel; - msg->video_formats->list->H264_codec.max_hres = vMaxHeight; - msg->video_formats->list->H264_codec.max_vres = vMaxWidth; + msg->video_formats->list->H264_codec.max_hres = vMaxWidth; + msg->video_formats->list->H264_codec.max_vres = vMaxHeight; msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution; msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution; msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution; @@ -1650,8 +1650,8 @@ WFDResult wfdconfig_set_prefered_video_format(WFDMessage *msg, WFDVideoCodecs vC msg->video_formats->list->preferred_display_mode_supported = 0; msg->video_formats->list->H264_codec.profile = vProfile; msg->video_formats->list->H264_codec.level = vLevel; - msg->video_formats->list->H264_codec.max_hres = vMaxHeight; - msg->video_formats->list->H264_codec.max_vres = vMaxWidth; + msg->video_formats->list->H264_codec.max_hres = vMaxWidth; + msg->video_formats->list->H264_codec.max_vres = vMaxHeight; msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution; msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution; msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution; @@ -1680,8 +1680,8 @@ WFDResult wfdconfig_get_supported_video_format(WFDMessage *msg, WFDVideoCodecs * *vNativeResolution = (guint64)1 << nativeindex; *vProfile = msg->video_formats->list->H264_codec.profile; *vLevel = msg->video_formats->list->H264_codec.level; - *vMaxHeight = msg->video_formats->list->H264_codec.max_hres; - *vMaxWidth = msg->video_formats->list->H264_codec.max_vres; + *vMaxWidth = msg->video_formats->list->H264_codec.max_hres; + *vMaxHeight = msg->video_formats->list->H264_codec.max_vres; *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support; *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support; *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support; @@ -1710,8 +1710,8 @@ WFDResult wfdconfig_get_prefered_video_format(WFDMessage *msg, WFDVideoCodecs *v *vNativeResolution = (guint64)1 << nativeindex; *vProfile = msg->video_formats->list->H264_codec.profile; *vLevel = msg->video_formats->list->H264_codec.level; - *vMaxHeight = msg->video_formats->list->H264_codec.max_hres; - *vMaxWidth = msg->video_formats->list->H264_codec.max_vres; + *vMaxWidth = msg->video_formats->list->H264_codec.max_hres; + *vMaxHeight = msg->video_formats->list->H264_codec.max_vres; *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support; *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support; *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support; @@ -1744,7 +1744,7 @@ WFDResult wfdconfig_get_contentprotection_type(WFDMessage *msg, WFDHDCPProtectio char *result = NULL; char *ptr = NULL; if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"none")) { - debug_warning("HDCP none"); + wfd_warning("HDCP none"); *hdcpversion = WFD_HDCP_NONE; *TCPPort = 0; return WFD_OK; @@ -1752,7 +1752,7 @@ WFDResult wfdconfig_get_contentprotection_type(WFDMessage *msg, WFDHDCPProtectio if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"HDCP2.0")) *hdcpversion = WFD_HDCP_2_0; else if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"HDCP2.1")) *hdcpversion = WFD_HDCP_2_1; else { - debug_warning("Unknown protection type"); + wfd_warning("Unknown protection type"); *hdcpversion = WFD_HDCP_NONE; *TCPPort = 0; return WFD_OK; -- 2.7.4 From 72d928daf88bdec5ee4acf53b3695cb7a16acffa Mon Sep 17 00:00:00 2001 From: Sangkyu Park Date: Fri, 5 Jun 2015 10:37:32 +0900 Subject: [PATCH 5/9] 1. Add the log color. 2. Add config message enum for error Change-Id: I4c8cdf91133448a33fc1037e20ba72345acfcb88 Signed-off-by: Sangkyu Park --- include/mm_wfd_common_private.h | 29 +++++++++++++++++++---------- packaging/libmm-scmirroring-common.spec | 2 +- wfdconfig/include/wfdconfigmessage.h | 4 +++- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/include/mm_wfd_common_private.h b/include/mm_wfd_common_private.h index 92d33c7..14f0247 100755 --- a/include/mm_wfd_common_private.h +++ b/include/mm_wfd_common_private.h @@ -33,42 +33,51 @@ extern "C" { #ifdef LOG_TAG #undef LOG_TAG #endif -#define LOG_TAG "MM_WFD_COMMON" +#define LOG_TAG "MM_SCMIRRORING_COMMON" + +#define FONT_COLOR_RESET "\033[0m" +#define FONT_COLOR_RED "\033[31m" +#define FONT_COLOR_GREEN "\033[32m" +#define FONT_COLOR_YELLOW "\033[33m" +#define FONT_COLOR_BLUE "\033[34m" +#define FONT_COLOR_PURPLE "\033[35m" +#define FONT_COLOR_CYAN "\033[36m" +#define FONT_COLOR_GRAY "\033[37m" #define wfd_debug(fmt, arg...) do { \ - LOGD(""fmt"", ##arg); \ + LOGD(FONT_COLOR_RESET""fmt"", ##arg); \ } while (0) #define wfd_info(fmt, arg...) do { \ - LOGI(""fmt"", ##arg); \ + LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg); \ } while (0) #define wfd_error(fmt, arg...) do { \ - LOGE(""fmt"", ##arg); \ + LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \ } while (0) #define wfd_warning(fmt, arg...) do { \ - LOGW(""fmt"", ##arg); \ + LOGW(FONT_COLOR_YELLOW""fmt""FONT_COLOR_RESET, ##arg); \ } while (0) #define wfd_debug_fenter() do { \ - LOGD(""); \ + LOGD(FONT_COLOR_RESET""); \ } while (0) #define wfd_debug_fleave() do { \ - LOGD(""); \ + LOGD(FONT_COLOR_RESET""); \ } while (0) #define wfd_error_fenter() do { \ - LOGE("NO-ERROR : "); \ + LOGE(FONT_COLOR_RESET"NO-ERROR : "); \ } while (0) #define wfd_error_fleave() do { \ - LOGE("NO-ERROR : "); \ + LOGE(FONT_COLOR_RESET"NO-ERROR : "); \ } while (0) #define wfd_sucure_info(fmt, arg...) do { \ - SECURE_LOGI(""fmt"", ##arg); \ + SECURE_LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg); \ } while (0) #ifdef __cplusplus diff --git a/packaging/libmm-scmirroring-common.spec b/packaging/libmm-scmirroring-common.spec index 4eb900e..056114a 100755 --- a/packaging/libmm-scmirroring-common.spec +++ b/packaging/libmm-scmirroring-common.spec @@ -1,6 +1,6 @@ Name: libmm-scmirroring-common Summary: Multimedia Framework Wifi-Display Common Library -Version: 0.0.35 +Version: 0.0.36 Release: 0 Group: System/Libraries License: Apache License 2.0 diff --git a/wfdconfig/include/wfdconfigmessage.h b/wfdconfig/include/wfdconfigmessage.h index 59f08c4..d02d597 100755 --- a/wfdconfig/include/wfdconfigmessage.h +++ b/wfdconfig/include/wfdconfigmessage.h @@ -36,7 +36,9 @@ G_BEGIN_DECLS */ typedef enum { WFD_OK = 0, - WFD_EINVAL = -1 + WFD_EINVAL = -1, + WFD_NOT_IMPLEMENTED = -2, + WFD_NOT_SUPPORTED = -3 } WFDResult; typedef enum { -- 2.7.4 From 88c3cb18ed64729ec1be641a3d4f16e65b0d5ee9 Mon Sep 17 00:00:00 2001 From: Sangkyu Park Date: Tue, 16 Jun 2015 13:38:56 +0900 Subject: [PATCH 6/9] Update code by tizen coding convention. Change-Id: I3a77e4dd6268d962bbabd4f1d953db4657c5e9c6 Signed-off-by: Sangkyu Park --- include/mm_wfd_common_private.h | 36 +- packaging/libmm-scmirroring-common.spec | 2 +- wfdconfig/include/wfdconfigmessage.h | 654 +++--- wfdconfig/wfdconfigmessage.c | 3584 +++++++++++++++---------------- 4 files changed, 2136 insertions(+), 2140 deletions(-) diff --git a/include/mm_wfd_common_private.h b/include/mm_wfd_common_private.h index 14f0247..ac4127e 100755 --- a/include/mm_wfd_common_private.h +++ b/include/mm_wfd_common_private.h @@ -45,40 +45,40 @@ extern "C" { #define FONT_COLOR_GRAY "\033[37m" #define wfd_debug(fmt, arg...) do { \ - LOGD(FONT_COLOR_RESET""fmt"", ##arg); \ - } while (0) + LOGD(FONT_COLOR_RESET""fmt"", ##arg); \ + } while (0) #define wfd_info(fmt, arg...) do { \ - LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg); \ - } while (0) + LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg); \ + } while (0) #define wfd_error(fmt, arg...) do { \ - LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \ - } while (0) + LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \ + } while (0) #define wfd_warning(fmt, arg...) do { \ - LOGW(FONT_COLOR_YELLOW""fmt""FONT_COLOR_RESET, ##arg); \ - } while (0) + LOGW(FONT_COLOR_YELLOW""fmt""FONT_COLOR_RESET, ##arg); \ + } while (0) #define wfd_debug_fenter() do { \ - LOGD(FONT_COLOR_RESET""); \ - } while (0) + LOGD(FONT_COLOR_RESET""); \ + } while (0) #define wfd_debug_fleave() do { \ - LOGD(FONT_COLOR_RESET""); \ - } while (0) + LOGD(FONT_COLOR_RESET""); \ + } while (0) #define wfd_error_fenter() do { \ - LOGE(FONT_COLOR_RESET"NO-ERROR : "); \ - } while (0) + LOGE(FONT_COLOR_RESET"NO-ERROR : "); \ + } while (0) #define wfd_error_fleave() do { \ - LOGE(FONT_COLOR_RESET"NO-ERROR : "); \ - } while (0) + LOGE(FONT_COLOR_RESET"NO-ERROR : "); \ + } while (0) #define wfd_sucure_info(fmt, arg...) do { \ - SECURE_LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg); \ - } while (0) + SECURE_LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg); \ + } while (0) #ifdef __cplusplus } diff --git a/packaging/libmm-scmirroring-common.spec b/packaging/libmm-scmirroring-common.spec index 056114a..66252cd 100755 --- a/packaging/libmm-scmirroring-common.spec +++ b/packaging/libmm-scmirroring-common.spec @@ -1,6 +1,6 @@ Name: libmm-scmirroring-common Summary: Multimedia Framework Wifi-Display Common Library -Version: 0.0.36 +Version: 0.0.37 Release: 0 Group: System/Libraries License: Apache License 2.0 diff --git a/wfdconfig/include/wfdconfigmessage.h b/wfdconfig/include/wfdconfigmessage.h index d02d597..afabba3 100755 --- a/wfdconfig/include/wfdconfigmessage.h +++ b/wfdconfig/include/wfdconfigmessage.h @@ -35,312 +35,312 @@ G_BEGIN_DECLS * Return values for the WFD_CONFIG functions. */ typedef enum { - WFD_OK = 0, - WFD_EINVAL = -1, - WFD_NOT_IMPLEMENTED = -2, - WFD_NOT_SUPPORTED = -3 + WFD_OK = 0, + WFD_EINVAL = -1, + WFD_NOT_IMPLEMENTED = -2, + WFD_NOT_SUPPORTED = -3 } WFDResult; typedef enum { - WFD_AUDIO_UNKNOWN = 0, - WFD_AUDIO_LPCM = (1 << 0), - WFD_AUDIO_AAC = (1 << 1), - WFD_AUDIO_AC3 = (1 << 2) -}WFDAudioFormats; + WFD_AUDIO_UNKNOWN = 0, + WFD_AUDIO_LPCM = (1 << 0), + WFD_AUDIO_AAC = (1 << 1), + WFD_AUDIO_AC3 = (1 << 2) +} WFDAudioFormats; typedef enum { - WFD_FREQ_UNKNOWN = 0, - WFD_FREQ_44100 = (1 << 0), - WFD_FREQ_48000 = (1 << 1) -}WFDAudioFreq; + WFD_FREQ_UNKNOWN = 0, + WFD_FREQ_44100 = (1 << 0), + WFD_FREQ_48000 = (1 << 1) +} WFDAudioFreq; typedef enum { - WFD_CHANNEL_UNKNOWN = 0, - WFD_CHANNEL_2 = (1 << 0), - WFD_CHANNEL_4 = (1 << 1), - WFD_CHANNEL_6 = (1 << 2), - WFD_CHANNEL_8 = (1 << 3) -}WFDAudioChannels; + WFD_CHANNEL_UNKNOWN = 0, + WFD_CHANNEL_2 = (1 << 0), + WFD_CHANNEL_4 = (1 << 1), + WFD_CHANNEL_6 = (1 << 2), + WFD_CHANNEL_8 = (1 << 3) +} WFDAudioChannels; typedef enum { - WFD_VIDEO_UNKNOWN = 0, - WFD_VIDEO_H264 = (1 << 0) -}WFDVideoCodecs; + WFD_VIDEO_UNKNOWN = 0, + WFD_VIDEO_H264 = (1 << 0) +} WFDVideoCodecs; typedef enum { - WFD_VIDEO_CEA_RESOLUTION = 0, - WFD_VIDEO_VESA_RESOLUTION, - WFD_VIDEO_HH_RESOLUTION -}WFDVideoNativeResolution; + WFD_VIDEO_CEA_RESOLUTION = 0, + WFD_VIDEO_VESA_RESOLUTION, + WFD_VIDEO_HH_RESOLUTION +} WFDVideoNativeResolution; typedef enum { - WFD_CEA_UNKNOWN = 0, - WFD_CEA_640x480P60 = (1 << 0), - WFD_CEA_720x480P60 = (1 << 1), - WFD_CEA_720x480I60 = (1 << 2), - WFD_CEA_720x576P50 = (1 << 3), - WFD_CEA_720x576I50 = (1 << 4), - WFD_CEA_1280x720P30 = (1 << 5), - WFD_CEA_1280x720P60 = (1 << 6), - WFD_CEA_1920x1080P30= (1 << 7), - WFD_CEA_1920x1080P60= (1 << 8), - WFD_CEA_1920x1080I60= (1 << 9), - WFD_CEA_1280x720P25 = (1 << 10), - WFD_CEA_1280x720P50 = (1 << 11), - WFD_CEA_1920x1080P25= (1 << 12), - WFD_CEA_1920x1080P50= (1 << 13), - WFD_CEA_1920x1080I50= (1 << 14), - WFD_CEA_1280x720P24 = (1 << 15), - WFD_CEA_1920x1080P24= (1 << 16) -}WFDVideoCEAResolution; + WFD_CEA_UNKNOWN = 0, + WFD_CEA_640x480P60 = (1 << 0), + WFD_CEA_720x480P60 = (1 << 1), + WFD_CEA_720x480I60 = (1 << 2), + WFD_CEA_720x576P50 = (1 << 3), + WFD_CEA_720x576I50 = (1 << 4), + WFD_CEA_1280x720P30 = (1 << 5), + WFD_CEA_1280x720P60 = (1 << 6), + WFD_CEA_1920x1080P30 = (1 << 7), + WFD_CEA_1920x1080P60 = (1 << 8), + WFD_CEA_1920x1080I60 = (1 << 9), + WFD_CEA_1280x720P25 = (1 << 10), + WFD_CEA_1280x720P50 = (1 << 11), + WFD_CEA_1920x1080P25 = (1 << 12), + WFD_CEA_1920x1080P50 = (1 << 13), + WFD_CEA_1920x1080I50 = (1 << 14), + WFD_CEA_1280x720P24 = (1 << 15), + WFD_CEA_1920x1080P24 = (1 << 16) +} WFDVideoCEAResolution; typedef enum { - WFD_VESA_UNKNOWN = 0, - WFD_VESA_800x600P30 = (1 << 0), - WFD_VESA_800x600P60 = (1 << 1), - WFD_VESA_1024x768P30 = (1 << 2), - WFD_VESA_1024x768P60 = (1 << 3), - WFD_VESA_1152x864P30 = (1 << 4), - WFD_VESA_1152x864P60 = (1 << 5), - WFD_VESA_1280x768P30 = (1 << 6), - WFD_VESA_1280x768P60 = (1 << 7), - WFD_VESA_1280x800P30 = (1 << 8), - WFD_VESA_1280x800P60 = (1 << 9), - WFD_VESA_1360x768P30 = (1 << 10), - WFD_VESA_1360x768P60 = (1 << 11), - WFD_VESA_1366x768P30 = (1 << 12), - WFD_VESA_1366x768P60 = (1 << 13), - WFD_VESA_1280x1024P30 = (1 << 14), - WFD_VESA_1280x1024P60 = (1 << 15), - WFD_VESA_1400x1050P30 = (1 << 16), - WFD_VESA_1400x1050P60 = (1 << 17), - WFD_VESA_1440x900P30 = (1 << 18), - WFD_VESA_1440x900P60 = (1 << 19), - WFD_VESA_1600x900P30 = (1 << 20), - WFD_VESA_1600x900P60 = (1 << 21), - WFD_VESA_1600x1200P30 = (1 << 22), - WFD_VESA_1600x1200P60 = (1 << 23), - WFD_VESA_1680x1024P30 = (1 << 24), - WFD_VESA_1680x1024P60 = (1 << 25), - WFD_VESA_1680x1050P30 = (1 << 26), - WFD_VESA_1680x1050P60 = (1 << 27), - WFD_VESA_1920x1200P30 = (1 << 28), - WFD_VESA_1920x1200P60 = (1 << 29) -}WFDVideoVESAResolution; + WFD_VESA_UNKNOWN = 0, + WFD_VESA_800x600P30 = (1 << 0), + WFD_VESA_800x600P60 = (1 << 1), + WFD_VESA_1024x768P30 = (1 << 2), + WFD_VESA_1024x768P60 = (1 << 3), + WFD_VESA_1152x864P30 = (1 << 4), + WFD_VESA_1152x864P60 = (1 << 5), + WFD_VESA_1280x768P30 = (1 << 6), + WFD_VESA_1280x768P60 = (1 << 7), + WFD_VESA_1280x800P30 = (1 << 8), + WFD_VESA_1280x800P60 = (1 << 9), + WFD_VESA_1360x768P30 = (1 << 10), + WFD_VESA_1360x768P60 = (1 << 11), + WFD_VESA_1366x768P30 = (1 << 12), + WFD_VESA_1366x768P60 = (1 << 13), + WFD_VESA_1280x1024P30 = (1 << 14), + WFD_VESA_1280x1024P60 = (1 << 15), + WFD_VESA_1400x1050P30 = (1 << 16), + WFD_VESA_1400x1050P60 = (1 << 17), + WFD_VESA_1440x900P30 = (1 << 18), + WFD_VESA_1440x900P60 = (1 << 19), + WFD_VESA_1600x900P30 = (1 << 20), + WFD_VESA_1600x900P60 = (1 << 21), + WFD_VESA_1600x1200P30 = (1 << 22), + WFD_VESA_1600x1200P60 = (1 << 23), + WFD_VESA_1680x1024P30 = (1 << 24), + WFD_VESA_1680x1024P60 = (1 << 25), + WFD_VESA_1680x1050P30 = (1 << 26), + WFD_VESA_1680x1050P60 = (1 << 27), + WFD_VESA_1920x1200P30 = (1 << 28), + WFD_VESA_1920x1200P60 = (1 << 29) +} WFDVideoVESAResolution; typedef enum { - WFD_HH_UNKNOWN = 0, - WFD_HH_800x480P30 = (1 << 0), - WFD_HH_800x480P60 = (1 << 1), - WFD_HH_854x480P30 = (1 << 2), - WFD_HH_854x480P60 = (1 << 3), - WFD_HH_864x480P30 = (1 << 4), - WFD_HH_864x480P60 = (1 << 5), - WFD_HH_640x360P30 = (1 << 6), - WFD_HH_640x360P60 = (1 << 7), - WFD_HH_960x540P30 = (1 << 8), - WFD_HH_960x540P60 = (1 << 9), - WFD_HH_848x480P30 = (1 << 10), - WFD_HH_848x480P60 = (1 << 11) -}WFDVideoHHResolution; + WFD_HH_UNKNOWN = 0, + WFD_HH_800x480P30 = (1 << 0), + WFD_HH_800x480P60 = (1 << 1), + WFD_HH_854x480P30 = (1 << 2), + WFD_HH_854x480P60 = (1 << 3), + WFD_HH_864x480P30 = (1 << 4), + WFD_HH_864x480P60 = (1 << 5), + WFD_HH_640x360P30 = (1 << 6), + WFD_HH_640x360P60 = (1 << 7), + WFD_HH_960x540P30 = (1 << 8), + WFD_HH_960x540P60 = (1 << 9), + WFD_HH_848x480P30 = (1 << 10), + WFD_HH_848x480P60 = (1 << 11) +} WFDVideoHHResolution; typedef enum { - WFD_H264_UNKNOWN_PROFILE= 0, - WFD_H264_BASE_PROFILE = (1 << 0), - WFD_H264_HIGH_PROFILE = (1 << 1) -}WFDVideoH264Profile; + WFD_H264_UNKNOWN_PROFILE = 0, + WFD_H264_BASE_PROFILE = (1 << 0), + WFD_H264_HIGH_PROFILE = (1 << 1) +} WFDVideoH264Profile; typedef enum { - WFD_H264_LEVEL_UNKNOWN = 0, - WFD_H264_LEVEL_3_1 = (1 << 0), - WFD_H264_LEVEL_3_2 = (1 << 1), - WFD_H264_LEVEL_4 = (1 << 2), - WFD_H264_LEVEL_4_1 = (1 << 3), - WFD_H264_LEVEL_4_2 = (1 << 4) -}WFDVideoH264Level; + WFD_H264_LEVEL_UNKNOWN = 0, + WFD_H264_LEVEL_3_1 = (1 << 0), + WFD_H264_LEVEL_3_2 = (1 << 1), + WFD_H264_LEVEL_4 = (1 << 2), + WFD_H264_LEVEL_4_1 = (1 << 3), + WFD_H264_LEVEL_4_2 = (1 << 4) +} WFDVideoH264Level; typedef enum { - WFD_HDCP_NONE = 0, - WFD_HDCP_2_0 = (1 << 0), - WFD_HDCP_2_1 = (1 << 1) -}WFDHDCPProtection; + WFD_HDCP_NONE = 0, + WFD_HDCP_2_0 = (1 << 0), + WFD_HDCP_2_1 = (1 << 1) +} WFDHDCPProtection; typedef enum { - WFD_SINK_UNKNOWN = -1, - WFD_SINK_NOT_COUPLED = 0, - WFD_SINK_COUPLED, - WFD_SINK_TEARDOWN_COUPLING, - WFD_SINK_RESERVED -}WFDCoupledSinkStatus; + WFD_SINK_UNKNOWN = -1, + WFD_SINK_NOT_COUPLED = 0, + WFD_SINK_COUPLED, + WFD_SINK_TEARDOWN_COUPLING, + WFD_SINK_RESERVED +} WFDCoupledSinkStatus; typedef enum { - WFD_TRIGGER_UNKNOWN = 0, - WFD_TRIGGER_SETUP, - WFD_TRIGGER_PAUSE, - WFD_TRIGGER_TEARDOWN, - WFD_TRIGGER_PLAY -}WFDTrigger; + WFD_TRIGGER_UNKNOWN = 0, + WFD_TRIGGER_SETUP, + WFD_TRIGGER_PAUSE, + WFD_TRIGGER_TEARDOWN, + WFD_TRIGGER_PLAY +} WFDTrigger; typedef enum { - WFD_RTSP_TRANS_UNKNOWN = 0, - WFD_RTSP_TRANS_RTP = (1 << 0), - WFD_RTSP_TRANS_RDT = (1 << 1) + WFD_RTSP_TRANS_UNKNOWN = 0, + WFD_RTSP_TRANS_RTP = (1 << 0), + WFD_RTSP_TRANS_RDT = (1 << 1) } WFDRTSPTransMode; typedef enum { - WFD_RTSP_PROFILE_UNKNOWN = 0, - WFD_RTSP_PROFILE_AVP = (1 << 0), - WFD_RTSP_PROFILE_SAVP = (1 << 1) + WFD_RTSP_PROFILE_UNKNOWN = 0, + WFD_RTSP_PROFILE_AVP = (1 << 0), + WFD_RTSP_PROFILE_SAVP = (1 << 1) } WFDRTSPProfile; typedef enum { - WFD_RTSP_LOWER_TRANS_UNKNOWN = 0, - WFD_RTSP_LOWER_TRANS_UDP = (1 << 0), - WFD_RTSP_LOWER_TRANS_UDP_MCAST = (1 << 1), - WFD_RTSP_LOWER_TRANS_TCP = (1 << 2), - WFD_RTSP_LOWER_TRANS_HTTP = (1 << 3) + WFD_RTSP_LOWER_TRANS_UNKNOWN = 0, + WFD_RTSP_LOWER_TRANS_UDP = (1 << 0), + WFD_RTSP_LOWER_TRANS_UDP_MCAST = (1 << 1), + WFD_RTSP_LOWER_TRANS_TCP = (1 << 2), + WFD_RTSP_LOWER_TRANS_HTTP = (1 << 3) } WFDRTSPLowerTrans; typedef enum { - WFD_PRIMARY_SINK = 0, - WFD_SECONDARY_SINK -}WFDSinkType; + WFD_PRIMARY_SINK = 0, + WFD_SECONDARY_SINK +} WFDSinkType; typedef enum { - WFD_UIBC_INPUT_CAT_UNKNOWN = 0, - WFD_UIBC_INPUT_CAT_GENERIC = (1 << 0), - WFD_UIBC_INPUT_CAT_HIDC = (1 << 1), -}WFDUibcinput_cat; + WFD_UIBC_INPUT_CAT_UNKNOWN = 0, + WFD_UIBC_INPUT_CAT_GENERIC = (1 << 0), + WFD_UIBC_INPUT_CAT_HIDC = (1 << 1), +} WFDUibcinput_cat; typedef enum { - WFD_UIBC_INPUT_TYPE_UNKNOWN = 0, - WFD_UIBC_INPUT_TYPE_KEYBOARD = (1 << 0), - WFD_UIBC_INPUT_TYPE_MOUSE = (1 << 1), - WFD_UIBC_INPUT_TYPE_SINGLETOUCH = (1 << 2), - WFD_UIBC_INPUT_TYPE_MULTITOUCH = (1 << 3), - WFD_UIBC_INPUT_TYPE_JOYSTICK = (1 << 4), - WFD_UIBC_INPUT_TYPE_CAMERA = (1 << 5), - WFD_UIBC_INPUT_TYPE_GESTURE = (1 << 6), - WFD_UIBC_INPUT_TYPE_REMOTECONTROL = (1 << 7) -}WFDUibcinp_type; + WFD_UIBC_INPUT_TYPE_UNKNOWN = 0, + WFD_UIBC_INPUT_TYPE_KEYBOARD = (1 << 0), + WFD_UIBC_INPUT_TYPE_MOUSE = (1 << 1), + WFD_UIBC_INPUT_TYPE_SINGLETOUCH = (1 << 2), + WFD_UIBC_INPUT_TYPE_MULTITOUCH = (1 << 3), + WFD_UIBC_INPUT_TYPE_JOYSTICK = (1 << 4), + WFD_UIBC_INPUT_TYPE_CAMERA = (1 << 5), + WFD_UIBC_INPUT_TYPE_GESTURE = (1 << 6), + WFD_UIBC_INPUT_TYPE_REMOTECONTROL = (1 << 7) +} WFDUibcinp_type; typedef enum { - WFD_UIBC_INPUT_PATH_UNKNOWN = 0, - WFD_UIBC_INPUT_PATH_INFRARED = (1 << 0), - WFD_UIBC_INPUT_PATH_USB = (1 << 1), - WFD_UIBC_INPUT_PATH_BT = (1 << 2), - WFD_UIBC_INPUT_PATH_ZIGBEE = (1 << 3), - WFD_UIBC_INPUT_PATH_WIFI = (1 << 4), - WFD_UIBC_INPUT_PATH_NOSP = (1 << 5) -}WFDUibcinp_path; + WFD_UIBC_INPUT_PATH_UNKNOWN = 0, + WFD_UIBC_INPUT_PATH_INFRARED = (1 << 0), + WFD_UIBC_INPUT_PATH_USB = (1 << 1), + WFD_UIBC_INPUT_PATH_BT = (1 << 2), + WFD_UIBC_INPUT_PATH_ZIGBEE = (1 << 3), + WFD_UIBC_INPUT_PATH_WIFI = (1 << 4), + WFD_UIBC_INPUT_PATH_NOSP = (1 << 5) +} WFDUibcinp_path; typedef enum { - WFD_CONNECTOR_VGA = 0, - WFD_CONNECTOR_S, - WFD_CONNECTOR_COMPOSITE, - WFD_CONNECTOR_COMPONENT, - WFD_CONNECTOR_DVI, - WFD_CONNECTOR_HDMI, - WFD_CONNECTOR_LVDS, - WFD_CONNECTOR_RESERVED_7, - WFD_CONNECTOR_JAPANESE_D, - WFD_CONNECTOR_SDI, - WFD_CONNECTOR_DP, - WFD_CONNECTOR_RESERVED_11, - WFD_CONNECTOR_UDI, - WFD_CONNECTOR_NO = 254, - WFD_CONNECTOR_PHYSICAL = 255 -}WFDConnector; - - -typedef struct { - gchar *audio_format; - guint32 modes; - guint latency; + WFD_CONNECTOR_VGA = 0, + WFD_CONNECTOR_S, + WFD_CONNECTOR_COMPOSITE, + WFD_CONNECTOR_COMPONENT, + WFD_CONNECTOR_DVI, + WFD_CONNECTOR_HDMI, + WFD_CONNECTOR_LVDS, + WFD_CONNECTOR_RESERVED_7, + WFD_CONNECTOR_JAPANESE_D, + WFD_CONNECTOR_SDI, + WFD_CONNECTOR_DP, + WFD_CONNECTOR_RESERVED_11, + WFD_CONNECTOR_UDI, + WFD_CONNECTOR_NO = 254, + WFD_CONNECTOR_PHYSICAL = 255 +} WFDConnector; + + +typedef struct { + gchar *audio_format; + guint32 modes; + guint latency; } WFDAudioCodec; typedef struct { - guint count; - WFDAudioCodec *list; + guint count; + WFDAudioCodec *list; } WFDAudioCodeclist; typedef struct { - guint CEA_Support; - guint VESA_Support; - guint HH_Support; - guint latency; - guint min_slice_size; - guint slice_enc_params; - guint frame_rate_control_support; + guint CEA_Support; + guint VESA_Support; + guint HH_Support; + guint latency; + guint min_slice_size; + guint slice_enc_params; + guint frame_rate_control_support; } WFDVideoH264MiscParams; typedef struct { - guint profile; - guint level; - guint max_hres; - guint max_vres; - WFDVideoH264MiscParams misc_params; + guint profile; + guint level; + guint max_hres; + guint max_vres; + WFDVideoH264MiscParams misc_params; } WFDVideoH264Codec; typedef struct { - guint native; - guint preferred_display_mode_supported; - WFDVideoH264Codec H264_codec; + guint native; + guint preferred_display_mode_supported; + WFDVideoH264Codec H264_codec; } WFDVideoCodec; typedef struct { - guint count; - WFDVideoCodec *list; + guint count; + WFDVideoCodec *list; } WFDVideoCodeclist; typedef struct { - guint video_3d_capability; - guint latency; - guint min_slice_size; - guint slice_enc_params; - guint frame_rate_control_support; + guint video_3d_capability; + guint latency; + guint min_slice_size; + guint slice_enc_params; + guint frame_rate_control_support; } WFD3DVideoH264MiscParams; typedef struct { - guint profile; - guint level; - WFD3DVideoH264MiscParams misc_params; - guint max_hres; - guint max_vres; + guint profile; + guint level; + WFD3DVideoH264MiscParams misc_params; + guint max_hres; + guint max_vres; } WFD3DVideoH264Codec; typedef struct { - guint native; - guint preferred_display_mode_supported; - WFD3DVideoH264Codec H264_codec; + guint native; + guint preferred_display_mode_supported; + WFD3DVideoH264Codec H264_codec; } WFD3dCapList; typedef struct { - guint count; - WFD3dCapList *list; + guint count; + WFD3dCapList *list; } WFD3DFormats; typedef struct { - gchar *hdcpversion; - gchar *TCPPort; + gchar *hdcpversion; + gchar *TCPPort; } WFDHdcp2Spec; typedef struct { - WFDHdcp2Spec *hdcp2_spec; + WFDHdcp2Spec *hdcp2_spec; } WFDContentProtection; typedef struct { - guint edid_supported; - guint edid_block_count; - gchar *edid_payload; + guint edid_supported; + guint edid_block_count; + gchar *edid_payload; } WFDDisplayEdid; typedef struct { - guint status; - gchar *sink_address; + guint status; + gchar *sink_address; } WFDCoupled_sink_cap; typedef struct { @@ -348,180 +348,180 @@ typedef struct { } WFDCoupledSink; typedef struct { - gchar *wfd_trigger_method; + gchar *wfd_trigger_method; } WFDTriggerMethod; typedef struct { - gchar *wfd_url0; - gchar *wfd_url1; + gchar *wfd_url0; + gchar *wfd_url1; } WFDPresentationUrl; typedef struct { - gchar *profile; - guint32 rtp_port0; - guint32 rtp_port1; - gchar *mode; + gchar *profile; + guint32 rtp_port0; + guint32 rtp_port1; + gchar *mode; } WFDClientRtpPorts; typedef struct { - gchar *destination; + gchar *destination; } WFDRoute; typedef struct { - gboolean I2CPresent; - guint32 I2C_port; + gboolean I2CPresent; + guint32 I2C_port; } WFDI2C; typedef struct { - guint64 PTS; - guint64 DTS; + guint64 PTS; + guint64 DTS; } WFDAVFormatChangeTiming; typedef struct { - gboolean displaymodesupported; - guint64 p_clock; - guint32 H; - guint32 HB; - guint32 HSPOL_HSOFF; - guint32 HSW; - guint32 V; - guint32 VB; - guint32 VSPOL_VSOFF; - guint32 VSW; - guint VBS3D; - guint R; - guint V2d_s3d_modes; - guint P_depth; - WFDVideoH264Codec H264_codec; + gboolean displaymodesupported; + guint64 p_clock; + guint32 H; + guint32 HB; + guint32 HSPOL_HSOFF; + guint32 HSW; + guint32 V; + guint32 VB; + guint32 VSPOL_VSOFF; + guint32 VSW; + guint VBS3D; + guint R; + guint V2d_s3d_modes; + guint P_depth; + WFDVideoH264Codec H264_codec; } WFDPreferredDisplayMode; typedef struct { - guint32 input_cat; -}WFDInputCategoryList; + guint32 input_cat; +} WFDInputCategoryList; typedef struct { - guint32 inp_type; -}WFDGenericCategoryList; + guint32 inp_type; +} WFDGenericCategoryList; typedef struct _detailed_cap detailed_cap; typedef struct { - WFDUibcinp_type inp_type; - WFDUibcinp_path inp_path; -}WFDHIDCTypePathPair; + WFDUibcinp_type inp_type; + WFDUibcinp_path inp_path; +} WFDHIDCTypePathPair; struct _detailed_cap { - WFDHIDCTypePathPair p; - detailed_cap *next; + WFDHIDCTypePathPair p; + detailed_cap *next; }; typedef struct { - guint cap_count; - detailed_cap *next; -}WFDHIDCCategoryList; + guint cap_count; + detailed_cap *next; +} WFDHIDCCategoryList; typedef struct { - gboolean uibcsupported; - WFDInputCategoryList input_category_list; - WFDGenericCategoryList generic_cap_list; - WFDHIDCCategoryList hidc_cap_list; - guint32 tcp_port; + gboolean uibcsupported; + WFDInputCategoryList input_category_list; + WFDGenericCategoryList generic_cap_list; + WFDHIDCCategoryList hidc_cap_list; + guint32 tcp_port; } WFDUibcCapability; typedef struct { - gboolean uibc_setting; + gboolean uibc_setting; } WFDUibcSetting; typedef struct { - gboolean standby_resume_cap; + gboolean standby_resume_cap; } WFDStandbyResumeCapability; typedef struct { - gboolean wfd_standby; + gboolean wfd_standby; } WFDStandby; typedef struct { - gboolean supported; - gint32 connector_type; + gboolean supported; + gint32 connector_type; } WFDConnectorType; typedef struct { - gboolean idr_request; + gboolean idr_request; } WFDIdrRequest; /***********************************************************/ typedef struct { - WFDAudioCodeclist *audio_codecs; - WFDVideoCodeclist *video_formats; - WFD3DFormats *video_3d_formats; - WFDContentProtection *content_protection; - WFDDisplayEdid *display_edid; - WFDCoupledSink *coupled_sink; - WFDTriggerMethod *trigger_method; - WFDPresentationUrl *presentation_url; - WFDClientRtpPorts *client_rtp_ports; - WFDRoute *route; - WFDI2C *I2C; - WFDAVFormatChangeTiming *av_format_change_timing; - WFDPreferredDisplayMode *preferred_display_mode; - WFDUibcCapability *uibc_capability; - WFDUibcSetting *uibc_setting; - WFDStandbyResumeCapability *standby_resume_capability; - WFDStandby *standby; - WFDConnectorType *connector_type; - WFDIdrRequest *idr_request; + WFDAudioCodeclist *audio_codecs; + WFDVideoCodeclist *video_formats; + WFD3DFormats *video_3d_formats; + WFDContentProtection *content_protection; + WFDDisplayEdid *display_edid; + WFDCoupledSink *coupled_sink; + WFDTriggerMethod *trigger_method; + WFDPresentationUrl *presentation_url; + WFDClientRtpPorts *client_rtp_ports; + WFDRoute *route; + WFDI2C *I2C; + WFDAVFormatChangeTiming *av_format_change_timing; + WFDPreferredDisplayMode *preferred_display_mode; + WFDUibcCapability *uibc_capability; + WFDUibcSetting *uibc_setting; + WFDStandbyResumeCapability *standby_resume_capability; + WFDStandby *standby; + WFDConnectorType *connector_type; + WFDIdrRequest *idr_request; } WFDMessage; /* Session descriptions */ -WFDResult wfdconfig_message_new (WFDMessage **msg); -WFDResult wfdconfig_message_init (WFDMessage *msg); -WFDResult wfdconfig_message_uninit (WFDMessage *msg); -WFDResult wfdconfig_message_free (WFDMessage *msg); -WFDResult wfdconfig_message_parse_buffer (const guint8 *data, guint size, WFDMessage *msg); -gchar* wfdconfig_message_as_text (const WFDMessage *msg); -gchar* wfdconfig_parameter_names_as_text (const WFDMessage *msg); -WFDResult wfdconfig_message_dump (const WFDMessage *msg); +WFDResult wfdconfig_message_new(WFDMessage **msg); +WFDResult wfdconfig_message_init(WFDMessage *msg); +WFDResult wfdconfig_message_uninit(WFDMessage *msg); +WFDResult wfdconfig_message_free(WFDMessage *msg); +WFDResult wfdconfig_message_parse_buffer(const guint8 *data, guint size, WFDMessage *msg); +gchar *wfdconfig_message_as_text(const WFDMessage *msg); +gchar *wfdconfig_parameter_names_as_text(const WFDMessage *msg); +WFDResult wfdconfig_message_dump(const WFDMessage *msg); WFDResult wfdconfig_set_supported_audio_format(WFDMessage *msg, - guint aCodec, guint aFreq, guint aChanels, - guint aBitwidth, guint32 aLatency); + guint aCodec, guint aFreq, guint aChanels, + guint aBitwidth, guint32 aLatency); WFDResult wfdconfig_set_prefered_audio_format(WFDMessage *msg, - WFDAudioFormats aCodec, WFDAudioFreq aFreq, WFDAudioChannels aChanels, - guint aBitwidth, guint32 aLatency); + WFDAudioFormats aCodec, WFDAudioFreq aFreq, WFDAudioChannels aChanels, + guint aBitwidth, guint32 aLatency); WFDResult wfdconfig_get_supported_audio_format(WFDMessage *msg, - guint *aCodec, guint *aFreq, guint *aChanels, - guint *aBitwidth, guint32 *aLatency); + guint *aCodec, guint *aFreq, guint *aChanels, + guint *aBitwidth, guint32 *aLatency); WFDResult wfdconfig_get_prefered_audio_format(WFDMessage *msg, - WFDAudioFormats *aCodec, WFDAudioFreq *aFreq, WFDAudioChannels *aChanels, - guint *aBitwidth, guint32 *aLatency); + WFDAudioFormats *aCodec, WFDAudioFreq *aFreq, WFDAudioChannels *aChanels, + guint *aBitwidth, guint32 *aLatency); WFDResult wfdconfig_set_supported_video_format(WFDMessage *msg, WFDVideoCodecs vCodec, - WFDVideoNativeResolution vNative, guint64 vNativeResolution, - guint64 vCEAResolution, guint64 vVESAResolution, guint64 vHHResolution, - guint vProfile, guint vLevel, guint32 vLatency, guint32 vMaxHeight, - guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control); + WFDVideoNativeResolution vNative, guint64 vNativeResolution, + guint64 vCEAResolution, guint64 vVESAResolution, guint64 vHHResolution, + guint vProfile, guint vLevel, guint32 vLatency, guint32 vMaxHeight, + guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control); WFDResult wfdconfig_set_prefered_video_format(WFDMessage *msg, WFDVideoCodecs vCodec, - WFDVideoNativeResolution vNative, guint64 vNativeResolution, - WFDVideoCEAResolution vCEAResolution, WFDVideoVESAResolution vVESAResolution, - WFDVideoHHResolution vHHResolution, WFDVideoH264Profile vProfile, - WFDVideoH264Level vLevel, guint32 vLatency, guint32 vMaxHeight, - guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control); + WFDVideoNativeResolution vNative, guint64 vNativeResolution, + WFDVideoCEAResolution vCEAResolution, WFDVideoVESAResolution vVESAResolution, + WFDVideoHHResolution vHHResolution, WFDVideoH264Profile vProfile, + WFDVideoH264Level vLevel, guint32 vLatency, guint32 vMaxHeight, + guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control); WFDResult wfdconfig_get_supported_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec, - WFDVideoNativeResolution *vNative, guint64 *vNativeResolution, - guint64 *vCEAResolution, guint64 *vVESAResolution, guint64 *vHHResolution, - guint *vProfile, guint *vLevel, guint32 *vLatency, guint32 *vMaxHeight, - guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control); + WFDVideoNativeResolution *vNative, guint64 *vNativeResolution, + guint64 *vCEAResolution, guint64 *vVESAResolution, guint64 *vHHResolution, + guint *vProfile, guint *vLevel, guint32 *vLatency, guint32 *vMaxHeight, + guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control); WFDResult wfdconfig_get_prefered_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec, - WFDVideoNativeResolution *vNative, guint64 *vNativeResolution, - WFDVideoCEAResolution *vCEAResolution, WFDVideoVESAResolution *vVESAResolution, - WFDVideoHHResolution *vHHResolution, WFDVideoH264Profile *vProfile, - WFDVideoH264Level *vLevel, guint32 *vLatency, guint32 *vMaxHeight, - guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control); + WFDVideoNativeResolution *vNative, guint64 *vNativeResolution, + WFDVideoCEAResolution *vCEAResolution, WFDVideoVESAResolution *vVESAResolution, + WFDVideoHHResolution *vHHResolution, WFDVideoH264Profile *vProfile, + WFDVideoH264Level *vLevel, guint32 *vLatency, guint32 *vMaxHeight, + guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control); -// Todo wfd-3d-formats +/* Todo wfd-3d-formats */ WFDResult wfdconfig_set_contentprotection_type(WFDMessage *msg, WFDHDCPProtection hdcpversion, guint32 TCPPort); WFDResult wfdconfig_get_contentprotection_type(WFDMessage *msg, WFDHDCPProtection *hdcpversion, guint32 *TCPPort); @@ -540,9 +540,9 @@ WFDResult wfdconfig_set_presentation_url(WFDMessage *msg, gchar *wfd_url0, gchar WFDResult wfdconfig_get_presentation_url(WFDMessage *msg, gchar **wfd_url0, gchar **wfd_url1); WFDResult wfdconfig_set_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode trans, WFDRTSPProfile profile, - WFDRTSPLowerTrans lowertrans, guint32 rtp_port0, guint32 rtp_port1); + WFDRTSPLowerTrans lowertrans, guint32 rtp_port0, guint32 rtp_port1); WFDResult wfdconfig_get_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode *trans, WFDRTSPProfile *profile, - WFDRTSPLowerTrans *lowertrans, guint32 *rtp_port0, guint32 *rtp_port1); + WFDRTSPLowerTrans *lowertrans, guint32 *rtp_port0, guint32 *rtp_port1); WFDResult wfdconfig_set_audio_sink_type(WFDMessage *msg, WFDSinkType sinktype); WFDResult wfdconfig_get_audio_sink_type(WFDMessage *msg, WFDSinkType *sinktype); @@ -553,12 +553,12 @@ WFDResult wfdconfig_get_I2C_port(WFDMessage *msg, gboolean *i2csupport, guint32 WFDResult wfdconfig_set_av_format_change_timing(WFDMessage *msg, guint64 PTS, guint64 DTS); WFDResult wfdconfig_get_av_format_change_timing(WFDMessage *msg, guint64 *PTS, guint64 *DTS); -// Todo wfd-preferred-display-mode +/* Todo wfd-preferred-display-mode */ WFDResult wfdconfig_set_uibc_capability(WFDMessage *msg, guint32 input_category, guint32 inp_type, WFDHIDCTypePathPair *inp_pair, - guint32 inp_type_path_count, guint32 tcp_port); + guint32 inp_type_path_count, guint32 tcp_port); WFDResult wfdconfig_get_uibc_capability(WFDMessage *msg, guint32 *input_category, guint32 *inp_type, WFDHIDCTypePathPair **inp_pair, - guint32 *inp_type_path_count, guint32 *tcp_port); + guint32 *inp_type_path_count, guint32 *tcp_port); WFDResult wfdconfig_set_uibc_status(WFDMessage *msg, gboolean uibc_enable); WFDResult wfdconfig_get_uibc_status(WFDMessage *msg, gboolean *uibc_enable); diff --git a/wfdconfig/wfdconfigmessage.c b/wfdconfig/wfdconfigmessage.c index 4ff1627..f6229f6 100755 --- a/wfdconfig/wfdconfigmessage.c +++ b/wfdconfig/wfdconfigmessage.c @@ -36,21 +36,19 @@ #include "mm_wfd_common_private.h" /* FIXME, is currently allocated on the stack */ -#define MAX_LINE_LEN 1024 * 16 +#define MAX_LINE_LEN (1024 * 16) -#define FREE_STRING(field) if(field != NULL) g_free (field); (field) = NULL -#define REPLACE_STRING(field, val) FREE_STRING(field); (field) = g_strdup (val) +#define FREE_STRING(field) if (field != NULL) g_free(field); (field) = NULL; +#define REPLACE_STRING(field, val) FREE_STRING(field); (field) = g_strdup(val); #define EDID_BLOCK_SIZE 128 -enum -{ - WFD_SESSION, - WFD_MEDIA, +enum { + WFD_SESSION, + WFD_MEDIA, }; -typedef struct -{ - guint state; - WFDMessage *msg; +typedef struct { + guint state; + WFDMessage *msg; } WFDContext; /** @@ -62,17 +60,17 @@ typedef struct * Returns: a #WFDResult. */ WFDResult -wfdconfig_message_new (WFDMessage ** msg) +wfdconfig_message_new(WFDMessage **msg) { - WFDMessage *newmsg; + WFDMessage *newmsg; - g_return_val_if_fail (msg != NULL, WFD_EINVAL); + g_return_val_if_fail(msg != NULL, WFD_EINVAL); - newmsg = g_new0 (WFDMessage, 1); + newmsg = g_new0(WFDMessage, 1); - *msg = newmsg; + *msg = newmsg; - return wfdconfig_message_init (newmsg); + return wfdconfig_message_init(newmsg); } /** @@ -83,17 +81,17 @@ wfdconfig_message_new (WFDMessage ** msg) * with wfdconfig_message_new(). This function is mostly used to initialize a message * allocated on the stack. wfdconfig_message_uninit() undoes this operation. * -* When this function is invoked on newly allocated data (with malloc or on the +* When this function is invoked on newly allocated data(with malloc or on the * stack), its contents should be set to 0 before calling this function. * * Returns: a #WFDResult. */ WFDResult -wfdconfig_message_init (WFDMessage * msg) +wfdconfig_message_init(WFDMessage *msg) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); + g_return_val_if_fail(msg != NULL, WFD_EINVAL); - return WFD_OK; + return WFD_OK; } /** @@ -107,102 +105,102 @@ wfdconfig_message_init (WFDMessage * msg) * Returns: a #WFDResult. */ WFDResult -wfdconfig_message_uninit (WFDMessage * msg) +wfdconfig_message_uninit(WFDMessage *msg) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - - if(msg->audio_codecs) { - guint i=0; - if(msg->audio_codecs->list) { - for(; iaudio_codecs->count; i++) { - FREE_STRING(msg->audio_codecs->list[i].audio_format); - msg->audio_codecs->list[i].modes=0; - msg->audio_codecs->list[i].latency=0; - } - FREE_STRING(msg->audio_codecs->list); - } - FREE_STRING(msg->audio_codecs); - } - - if(msg->video_formats) { - FREE_STRING(msg->video_formats->list); - FREE_STRING(msg->video_formats); - } - - if(msg->video_3d_formats) { - FREE_STRING(msg->video_3d_formats); - } - - if(msg->content_protection) { - FREE_STRING(msg->content_protection); - } - - if(msg->display_edid) { - if(msg->display_edid->edid_payload) - FREE_STRING(msg->display_edid->edid_payload); - FREE_STRING(msg->display_edid); - } - - if(msg->coupled_sink) { - FREE_STRING(msg->coupled_sink); - } - - if(msg->trigger_method) { - FREE_STRING(msg->trigger_method->wfd_trigger_method); - FREE_STRING(msg->trigger_method); - } - - if(msg->presentation_url) { - FREE_STRING(msg->trigger_method); - } - - if(msg->client_rtp_ports) { - FREE_STRING(msg->client_rtp_ports->profile); - FREE_STRING(msg->client_rtp_ports->mode); - FREE_STRING(msg->client_rtp_ports); - } - - if(msg->route) { - FREE_STRING(msg->route); - } - - if(msg->I2C) { - FREE_STRING(msg->I2C); - } - - if(msg->av_format_change_timing) { - FREE_STRING(msg->av_format_change_timing); - } - - if(msg->preferred_display_mode) { - FREE_STRING(msg->preferred_display_mode); - } - - if(msg->uibc_capability) { - FREE_STRING(msg->uibc_capability); - } - - if(msg->uibc_setting) { - FREE_STRING(msg->uibc_setting); - } - - if(msg->standby_resume_capability) { - FREE_STRING(msg->standby_resume_capability); - } - - if(msg->standby) { - FREE_STRING(msg->standby); - } - - if(msg->connector_type) { - FREE_STRING(msg->connector_type); - } - - if(msg->idr_request) { - FREE_STRING(msg->idr_request); - } - - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + + if (msg->audio_codecs) { + guint i = 0; + if (msg->audio_codecs->list) { + for (; i < msg->audio_codecs->count; i++) { + FREE_STRING(msg->audio_codecs->list[i].audio_format); + msg->audio_codecs->list[i].modes = 0; + msg->audio_codecs->list[i].latency = 0; + } + FREE_STRING(msg->audio_codecs->list); + } + FREE_STRING(msg->audio_codecs); + } + + if (msg->video_formats) { + FREE_STRING(msg->video_formats->list); + FREE_STRING(msg->video_formats); + } + + if (msg->video_3d_formats) { + FREE_STRING(msg->video_3d_formats); + } + + if (msg->content_protection) { + FREE_STRING(msg->content_protection); + } + + if (msg->display_edid) { + if (msg->display_edid->edid_payload) + FREE_STRING(msg->display_edid->edid_payload); + FREE_STRING(msg->display_edid); + } + + if (msg->coupled_sink) { + FREE_STRING(msg->coupled_sink); + } + + if (msg->trigger_method) { + FREE_STRING(msg->trigger_method->wfd_trigger_method); + FREE_STRING(msg->trigger_method); + } + + if (msg->presentation_url) { + FREE_STRING(msg->trigger_method); + } + + if (msg->client_rtp_ports) { + FREE_STRING(msg->client_rtp_ports->profile); + FREE_STRING(msg->client_rtp_ports->mode); + FREE_STRING(msg->client_rtp_ports); + } + + if (msg->route) { + FREE_STRING(msg->route); + } + + if (msg->I2C) { + FREE_STRING(msg->I2C); + } + + if (msg->av_format_change_timing) { + FREE_STRING(msg->av_format_change_timing); + } + + if (msg->preferred_display_mode) { + FREE_STRING(msg->preferred_display_mode); + } + + if (msg->uibc_capability) { + FREE_STRING(msg->uibc_capability); + } + + if (msg->uibc_setting) { + FREE_STRING(msg->uibc_setting); + } + + if (msg->standby_resume_capability) { + FREE_STRING(msg->standby_resume_capability); + } + + if (msg->standby) { + FREE_STRING(msg->standby); + } + + if (msg->connector_type) { + FREE_STRING(msg->connector_type); + } + + if (msg->idr_request) { + FREE_STRING(msg->idr_request); + } + + return WFD_OK; } /** @@ -216,14 +214,14 @@ wfdconfig_message_uninit (WFDMessage * msg) * Returns: a #WFDResult. */ WFDResult -wfdconfig_message_free (WFDMessage * msg) +wfdconfig_message_free(WFDMessage *msg) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); + g_return_val_if_fail(msg != NULL, WFD_EINVAL); - wfdconfig_message_uninit (msg); - g_free (msg); + wfdconfig_message_uninit(msg); + g_free(msg); - return WFD_OK; + return WFD_OK; } /** @@ -235,905 +233,902 @@ wfdconfig_message_free (WFDMessage * msg) * Returns: A dynamically allocated string representing the WFD description. */ gchar * -wfdconfig_message_as_text (const WFDMessage * msg) +wfdconfig_message_as_text(const WFDMessage *msg) { - /* change all vars so they match rfc? */ - GString *lines; - g_return_val_if_fail (msg != NULL, NULL); - - lines = g_string_new (""); - - /* list of audio codecs */ - if(msg->audio_codecs) { - guint i=0; - g_string_append_printf (lines,"wfd_audio_codecs"); - if(msg->audio_codecs->list) { - g_string_append_printf (lines,":"); - for(; iaudio_codecs->count; i++) { - g_string_append_printf (lines," %s",msg->audio_codecs->list[i].audio_format); - g_string_append_printf (lines," %08x",msg->audio_codecs->list[i].modes); - g_string_append_printf (lines," %02x",msg->audio_codecs->list[i].latency); - if((i+1)audio_codecs->count) - g_string_append_printf (lines,","); - } - } - g_string_append_printf (lines,"\r\n"); - } - - /* list of video codecs */ - if(msg->video_formats) { - g_string_append_printf (lines,"wfd_video_formats"); - if(msg->video_formats->list) { - g_string_append_printf (lines,":"); - g_string_append_printf (lines," %02x", msg->video_formats->list->native); - g_string_append_printf (lines," %02x", msg->video_formats->list->preferred_display_mode_supported); - g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.profile); - g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.level); - g_string_append_printf (lines," %08x", msg->video_formats->list->H264_codec.misc_params.CEA_Support); - g_string_append_printf (lines," %08x", msg->video_formats->list->H264_codec.misc_params.VESA_Support); - g_string_append_printf (lines," %08x", msg->video_formats->list->H264_codec.misc_params.HH_Support); - g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.misc_params.latency); - g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.misc_params.min_slice_size); - g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.misc_params.slice_enc_params); - g_string_append_printf (lines," %02x", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support); - - if(msg->video_formats->list->H264_codec.max_hres) - g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_hres); - else - g_string_append_printf (lines," none"); - - if(msg->video_formats->list->H264_codec.max_vres) - g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_vres); - else - g_string_append_printf (lines," none"); - } - g_string_append_printf (lines,"\r\n"); - } - - /* list of video 3D codecs */ - if(msg->video_3d_formats) { - g_string_append_printf (lines,"wfd_3d_video_formats"); - g_string_append_printf (lines,":"); - if(msg->video_3d_formats->list) { - g_string_append_printf (lines," %02x", msg->video_3d_formats->list->native); - g_string_append_printf (lines," %02x", msg->video_3d_formats->list->preferred_display_mode_supported); - g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.profile); - g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.level); - g_string_append_printf (lines," %16x", msg->video_3d_formats->list->H264_codec.misc_params.video_3d_capability); - g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.misc_params.latency); - g_string_append_printf (lines," %04x", msg->video_3d_formats->list->H264_codec.misc_params.min_slice_size); - g_string_append_printf (lines," %04x", msg->video_3d_formats->list->H264_codec.misc_params.slice_enc_params); - g_string_append_printf (lines," %02x", msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support); - if(msg->video_3d_formats->list->H264_codec.max_hres) - g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_hres); - else - g_string_append_printf (lines," none"); - if(msg->video_3d_formats->list->H264_codec.max_vres) - g_string_append_printf (lines," %04x", msg->video_formats->list->H264_codec.max_vres); - else - g_string_append_printf (lines," none"); - } else { - g_string_append_printf (lines," none"); - } - g_string_append_printf (lines,"\r\n"); - } - - if(msg->content_protection) { - g_string_append_printf (lines,"wfd_content_protection"); - g_string_append_printf (lines,":"); - if(msg->content_protection->hdcp2_spec) { - if( msg->content_protection->hdcp2_spec->hdcpversion) { - g_string_append_printf (lines," %s", msg->content_protection->hdcp2_spec->hdcpversion); - g_string_append_printf (lines," %s", msg->content_protection->hdcp2_spec->TCPPort); - } else { - g_string_append_printf (lines," none"); - } - } else { - g_string_append_printf (lines," none"); - } - g_string_append_printf (lines,"\r\n"); - } - - if(msg->display_edid) { - g_string_append_printf (lines,"wfd_display_edid"); - g_string_append_printf (lines,":"); - if(msg->display_edid->edid_supported) { - g_string_append_printf (lines," %d", msg->display_edid->edid_supported); - if(msg->display_edid->edid_block_count) - g_string_append_printf (lines," %d", msg->display_edid->edid_block_count); - else - g_string_append_printf (lines," none"); - } else { - g_string_append_printf (lines," none"); - } - g_string_append_printf (lines,"\r\n"); - } - - if(msg->coupled_sink) { - g_string_append_printf (lines,"wfd_coupled_sink"); - g_string_append_printf (lines,":"); - if(msg->coupled_sink->coupled_sink_cap) { - g_string_append_printf (lines," %02x", msg->coupled_sink->coupled_sink_cap->status); - if(msg->coupled_sink->coupled_sink_cap->sink_address) - g_string_append_printf (lines," %s", msg->coupled_sink->coupled_sink_cap->sink_address); - else - g_string_append_printf (lines," none"); - } else { - g_string_append_printf (lines," none"); - } - g_string_append_printf (lines,"\r\n"); - } - - if(msg->trigger_method) { - g_string_append_printf (lines,"wfd_trigger_method"); - g_string_append_printf (lines,":"); - g_string_append_printf (lines," %s", msg->trigger_method->wfd_trigger_method); - g_string_append_printf (lines,"\r\n"); - } - - if(msg->presentation_url) { - g_string_append_printf (lines,"wfd_presentation_URL"); - g_string_append_printf (lines,":"); - if(msg->presentation_url->wfd_url0) - g_string_append_printf (lines," %s", msg->presentation_url->wfd_url0); - else - g_string_append_printf (lines," none"); - if(msg->presentation_url->wfd_url1) - g_string_append_printf (lines," %s", msg->presentation_url->wfd_url1); - else - g_string_append_printf (lines," none"); - g_string_append_printf (lines,"\r\n"); - } - - if(msg->client_rtp_ports) { - g_string_append_printf (lines,"wfd_client_rtp_ports"); - if(msg->client_rtp_ports->profile) { - g_string_append_printf (lines,":"); - g_string_append_printf (lines," %s", msg->client_rtp_ports->profile); - g_string_append_printf (lines," %d", msg->client_rtp_ports->rtp_port0); - g_string_append_printf (lines," %d", msg->client_rtp_ports->rtp_port1); - g_string_append_printf (lines," %s", msg->client_rtp_ports->mode); - } - g_string_append_printf (lines,"\r\n"); - } - - if(msg->route) { - g_string_append_printf (lines,"wfd_route"); - g_string_append_printf (lines,":"); - g_string_append_printf (lines," %s", msg->route->destination); - g_string_append_printf (lines,"\r\n"); - } - - if(msg->I2C) { - g_string_append_printf (lines,"wfd_I2C"); - g_string_append_printf (lines,":"); - if(msg->I2C->I2CPresent) - g_string_append_printf (lines," %x", msg->I2C->I2C_port); - else - g_string_append_printf (lines," none"); - g_string_append_printf (lines,"\r\n"); - } - - if(msg->av_format_change_timing) { - g_string_append_printf (lines,"wfd_av_format_change_timing"); - g_string_append_printf (lines,":"); - g_string_append_printf (lines," %10"G_GUINT64_FORMAT, msg->av_format_change_timing->PTS); - g_string_append_printf (lines," %10"G_GUINT64_FORMAT, msg->av_format_change_timing->DTS); - g_string_append_printf (lines,"\r\n"); - } - - if(msg->preferred_display_mode) { - g_string_append_printf (lines,"wfd_preferred_display_mode"); - g_string_append_printf (lines,":"); - if(msg->preferred_display_mode->displaymodesupported) { - g_string_append_printf (lines," %06"G_GUINT64_FORMAT, msg->preferred_display_mode->p_clock); - g_string_append_printf (lines," %04x", msg->preferred_display_mode->H); - g_string_append_printf (lines," %04x", msg->preferred_display_mode->HB); - g_string_append_printf (lines," %04x", msg->preferred_display_mode->HSPOL_HSOFF); - g_string_append_printf (lines," %04x", msg->preferred_display_mode->HSW); - g_string_append_printf (lines," %04x", msg->preferred_display_mode->V); - g_string_append_printf (lines," %04x", msg->preferred_display_mode->VB); - g_string_append_printf (lines," %04x", msg->preferred_display_mode->VSPOL_VSOFF); - g_string_append_printf (lines," %04x", msg->preferred_display_mode->VSW); - g_string_append_printf (lines," %02x", msg->preferred_display_mode->VBS3D); - g_string_append_printf (lines," %02x", msg->preferred_display_mode->V2d_s3d_modes); - g_string_append_printf (lines," %02x", msg->preferred_display_mode->P_depth); - } else g_string_append_printf (lines," none"); - g_string_append_printf (lines,"\r\n"); - } - - if(msg->uibc_capability) { - g_string_append_printf (lines,"wfd_uibc_capability"); - g_string_append_printf (lines,":"); - if(msg->uibc_capability->uibcsupported) { - g_string_append_printf (lines," input_category_list="); - if(msg->uibc_capability->input_category_list.input_cat) { - guint32 tempcap = 0; - if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) { - tempcap |= WFD_UIBC_INPUT_CAT_GENERIC; - g_string_append_printf (lines,"GENERIC"); - if(msg->uibc_capability->input_category_list.input_cat != tempcap) g_string_append_printf (lines,", "); - } - if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) { - tempcap |= WFD_UIBC_INPUT_CAT_HIDC; - g_string_append_printf (lines,"HIDC"); - if(msg->uibc_capability->input_category_list.input_cat != tempcap) g_string_append_printf (lines,", "); - } - } - else g_string_append_printf (lines,"none"); - g_string_append_printf (lines,";"); - g_string_append_printf (lines," generic_cap_list="); - if(msg->uibc_capability->generic_cap_list.inp_type) { - guint32 tempcap = 0; - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) { - tempcap |= WFD_UIBC_INPUT_TYPE_KEYBOARD; - g_string_append_printf (lines,"Keyboard"); - if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); - } - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) { - tempcap |= WFD_UIBC_INPUT_TYPE_MOUSE; - g_string_append_printf (lines,"Mouse"); - if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); - } - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) { - tempcap |= WFD_UIBC_INPUT_TYPE_SINGLETOUCH; - g_string_append_printf (lines,"SingleTouch"); - if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); - } - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) { - tempcap |= WFD_UIBC_INPUT_TYPE_MULTITOUCH; - g_string_append_printf (lines,"MultiTouch"); - if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); - } - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) { - tempcap |= WFD_UIBC_INPUT_TYPE_JOYSTICK; - g_string_append_printf (lines,"Joystick"); - if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); - } - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) { - tempcap |= WFD_UIBC_INPUT_TYPE_CAMERA; - g_string_append_printf (lines,"Camera"); - if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); - } - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) { - tempcap |= WFD_UIBC_INPUT_TYPE_GESTURE; - g_string_append_printf (lines,"Gesture"); - if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); - } - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) { - tempcap |= WFD_UIBC_INPUT_TYPE_REMOTECONTROL; - g_string_append_printf (lines,"RemoteControl"); - if(msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf (lines,", "); - } - } - else g_string_append_printf (lines,"none"); - g_string_append_printf (lines,";"); - g_string_append_printf (lines," hidc_cap_list="); - if(msg->uibc_capability->hidc_cap_list.cap_count) { - detailed_cap *temp_cap = msg->uibc_capability->hidc_cap_list.next; - while(temp_cap) - { - if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_KEYBOARD) g_string_append_printf (lines,"Keyboard"); - else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_MOUSE) g_string_append_printf (lines,"Mouse"); - else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_SINGLETOUCH) g_string_append_printf (lines,"SingleTouch"); - else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_MULTITOUCH) g_string_append_printf (lines,"MultiTouch"); - else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_JOYSTICK) g_string_append_printf (lines,"Joystick"); - else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_CAMERA) g_string_append_printf (lines,"Camera"); - else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_GESTURE) g_string_append_printf (lines,"Gesture"); - else if(temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_REMOTECONTROL) g_string_append_printf (lines,"RemoteControl"); - g_string_append_printf (lines,"/"); - if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_INFRARED) g_string_append_printf (lines,"Infrared"); - else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_USB) g_string_append_printf (lines,"USB"); - else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_BT) g_string_append_printf (lines,"BT"); - else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_ZIGBEE) g_string_append_printf (lines,"Zigbee"); - else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_WIFI) g_string_append_printf (lines,"Wi-Fi"); - else if(temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_NOSP) g_string_append_printf (lines,"No-SP"); - temp_cap = temp_cap->next; - if(temp_cap) g_string_append_printf (lines,", "); - } - } else g_string_append_printf (lines,"none"); - g_string_append_printf (lines,";"); - if(msg->uibc_capability->tcp_port) g_string_append_printf (lines,"port=%u", msg->uibc_capability->tcp_port); - else g_string_append_printf (lines,"port=none"); - } else g_string_append_printf (lines," none"); - g_string_append_printf (lines,"\r\n"); - } - - if(msg->uibc_setting) { - g_string_append_printf (lines,"wfd_uibc_setting"); - g_string_append_printf (lines,":"); - if(msg->uibc_setting->uibc_setting) - g_string_append_printf (lines," enable"); - else - g_string_append_printf (lines," disable"); - g_string_append_printf (lines,"\r\n"); - } - - if(msg->standby_resume_capability) { - g_string_append_printf (lines,"wfd_standby_resume_capability"); - g_string_append_printf (lines,":"); - if(msg->standby_resume_capability->standby_resume_cap) - g_string_append_printf (lines," supported"); - else - g_string_append_printf (lines," none"); - g_string_append_printf (lines,"\r\n"); - } - - if(msg->standby) { - g_string_append_printf (lines,"wfd_standby"); - g_string_append_printf (lines,"\r\n"); - } - - if(msg->connector_type) { - g_string_append_printf (lines,"wfd_connector_type"); - g_string_append_printf (lines,":"); - g_string_append_printf (lines,"\r\n"); - } - - if(msg->idr_request) { - g_string_append_printf (lines,"wfd_idr_request"); - g_string_append_printf (lines,"\r\n"); - } - - //g_string_append_printf (lines,"\0"); - /*if(g_str_has_suffix (lines,"\r\n\0")) - { - guint32 length = g_strlen(lines); - lines[length-2] = '\0'; - }*/ - return g_string_free (lines, FALSE); + /* change all vars so they match rfc? */ + GString *lines; + g_return_val_if_fail(msg != NULL, NULL); + + lines = g_string_new(""); + + /* list of audio codecs */ + if (msg->audio_codecs) { + guint i = 0; + g_string_append_printf(lines, "wfd_audio_codecs"); + if (msg->audio_codecs->list) { + g_string_append_printf(lines, ":"); + for (; i < msg->audio_codecs->count; i++) { + g_string_append_printf(lines, " %s", msg->audio_codecs->list[i].audio_format); + g_string_append_printf(lines, " %08x", msg->audio_codecs->list[i].modes); + g_string_append_printf(lines, " %02x", msg->audio_codecs->list[i].latency); + if ((i + 1) < msg->audio_codecs->count) + g_string_append_printf(lines, ", "); + } + } + g_string_append_printf(lines, "\r\n"); + } + + /* list of video codecs */ + if (msg->video_formats) { + g_string_append_printf(lines, "wfd_video_formats"); + if (msg->video_formats->list) { + g_string_append_printf(lines, ":"); + g_string_append_printf(lines, " %02x", msg->video_formats->list->native); + g_string_append_printf(lines, " %02x", msg->video_formats->list->preferred_display_mode_supported); + g_string_append_printf(lines, " %02x", msg->video_formats->list->H264_codec.profile); + g_string_append_printf(lines, " %02x", msg->video_formats->list->H264_codec.level); + g_string_append_printf(lines, " %08x", msg->video_formats->list->H264_codec.misc_params.CEA_Support); + g_string_append_printf(lines, " %08x", msg->video_formats->list->H264_codec.misc_params.VESA_Support); + g_string_append_printf(lines, " %08x", msg->video_formats->list->H264_codec.misc_params.HH_Support); + g_string_append_printf(lines, " %02x", msg->video_formats->list->H264_codec.misc_params.latency); + g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.misc_params.min_slice_size); + g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.misc_params.slice_enc_params); + g_string_append_printf(lines, " %02x", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support); + + if (msg->video_formats->list->H264_codec.max_hres) + g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.max_hres); + else + g_string_append_printf(lines, " none"); + + if (msg->video_formats->list->H264_codec.max_vres) + g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.max_vres); + else + g_string_append_printf(lines, " none"); + } + g_string_append_printf(lines, "\r\n"); + } + + /* list of video 3D codecs */ + if (msg->video_3d_formats) { + g_string_append_printf(lines, "wfd_3d_video_formats"); + g_string_append_printf(lines, ":"); + if (msg->video_3d_formats->list) { + g_string_append_printf(lines, " %02x", msg->video_3d_formats->list->native); + g_string_append_printf(lines, " %02x", msg->video_3d_formats->list->preferred_display_mode_supported); + g_string_append_printf(lines, " %02x", msg->video_3d_formats->list->H264_codec.profile); + g_string_append_printf(lines, " %02x", msg->video_3d_formats->list->H264_codec.level); + g_string_append_printf(lines, " %16x", msg->video_3d_formats->list->H264_codec.misc_params.video_3d_capability); + g_string_append_printf(lines, " %02x", msg->video_3d_formats->list->H264_codec.misc_params.latency); + g_string_append_printf(lines, " %04x", msg->video_3d_formats->list->H264_codec.misc_params.min_slice_size); + g_string_append_printf(lines, " %04x", msg->video_3d_formats->list->H264_codec.misc_params.slice_enc_params); + g_string_append_printf(lines, " %02x", msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support); + if (msg->video_3d_formats->list->H264_codec.max_hres) + g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.max_hres); + else + g_string_append_printf(lines, " none"); + if (msg->video_3d_formats->list->H264_codec.max_vres) + g_string_append_printf(lines, " %04x", msg->video_formats->list->H264_codec.max_vres); + else + g_string_append_printf(lines, " none"); + } else { + g_string_append_printf(lines, " none"); + } + g_string_append_printf(lines, "\r\n"); + } + + if (msg->content_protection) { + g_string_append_printf(lines, "wfd_content_protection"); + g_string_append_printf(lines, ":"); + if (msg->content_protection->hdcp2_spec) { + if (msg->content_protection->hdcp2_spec->hdcpversion) { + g_string_append_printf(lines, " %s", msg->content_protection->hdcp2_spec->hdcpversion); + g_string_append_printf(lines, " %s", msg->content_protection->hdcp2_spec->TCPPort); + } else { + g_string_append_printf(lines, " none"); + } + } else { + g_string_append_printf(lines, " none"); + } + g_string_append_printf(lines, "\r\n"); + } + + if (msg->display_edid) { + g_string_append_printf(lines, "wfd_display_edid"); + g_string_append_printf(lines, ":"); + if (msg->display_edid->edid_supported) { + g_string_append_printf(lines, " %d", msg->display_edid->edid_supported); + if (msg->display_edid->edid_block_count) + g_string_append_printf(lines, " %d", msg->display_edid->edid_block_count); + else + g_string_append_printf(lines, " none"); + } else { + g_string_append_printf(lines, " none"); + } + g_string_append_printf(lines, "\r\n"); + } + + if (msg->coupled_sink) { + g_string_append_printf(lines, "wfd_coupled_sink"); + g_string_append_printf(lines, ":"); + if (msg->coupled_sink->coupled_sink_cap) { + g_string_append_printf(lines, " %02x", msg->coupled_sink->coupled_sink_cap->status); + if (msg->coupled_sink->coupled_sink_cap->sink_address) + g_string_append_printf(lines, " %s", msg->coupled_sink->coupled_sink_cap->sink_address); + else + g_string_append_printf(lines, " none"); + } else { + g_string_append_printf(lines, " none"); + } + g_string_append_printf(lines, "\r\n"); + } + + if (msg->trigger_method) { + g_string_append_printf(lines, "wfd_trigger_method"); + g_string_append_printf(lines, ":"); + g_string_append_printf(lines, " %s", msg->trigger_method->wfd_trigger_method); + g_string_append_printf(lines, "\r\n"); + } + + if (msg->presentation_url) { + g_string_append_printf(lines, "wfd_presentation_URL"); + g_string_append_printf(lines, ":"); + if (msg->presentation_url->wfd_url0) + g_string_append_printf(lines, " %s", msg->presentation_url->wfd_url0); + else + g_string_append_printf(lines, " none"); + if (msg->presentation_url->wfd_url1) + g_string_append_printf(lines, " %s", msg->presentation_url->wfd_url1); + else + g_string_append_printf(lines, " none"); + g_string_append_printf(lines, "\r\n"); + } + + if (msg->client_rtp_ports) { + g_string_append_printf(lines, "wfd_client_rtp_ports"); + if (msg->client_rtp_ports->profile) { + g_string_append_printf(lines, ":"); + g_string_append_printf(lines, " %s", msg->client_rtp_ports->profile); + g_string_append_printf(lines, " %d", msg->client_rtp_ports->rtp_port0); + g_string_append_printf(lines, " %d", msg->client_rtp_ports->rtp_port1); + g_string_append_printf(lines, " %s", msg->client_rtp_ports->mode); + } + g_string_append_printf(lines, "\r\n"); + } + + if (msg->route) { + g_string_append_printf(lines, "wfd_route"); + g_string_append_printf(lines, ":"); + g_string_append_printf(lines, " %s", msg->route->destination); + g_string_append_printf(lines, "\r\n"); + } + + if (msg->I2C) { + g_string_append_printf(lines, "wfd_I2C"); + g_string_append_printf(lines, ":"); + if (msg->I2C->I2CPresent) + g_string_append_printf(lines, " %x", msg->I2C->I2C_port); + else + g_string_append_printf(lines, " none"); + g_string_append_printf(lines, "\r\n"); + } + + if (msg->av_format_change_timing) { + g_string_append_printf(lines, "wfd_av_format_change_timing"); + g_string_append_printf(lines, ":"); + g_string_append_printf(lines, " %10"G_GUINT64_FORMAT, msg->av_format_change_timing->PTS); + g_string_append_printf(lines, " %10"G_GUINT64_FORMAT, msg->av_format_change_timing->DTS); + g_string_append_printf(lines, "\r\n"); + } + + if (msg->preferred_display_mode) { + g_string_append_printf(lines, "wfd_preferred_display_mode"); + g_string_append_printf(lines, ":"); + if (msg->preferred_display_mode->displaymodesupported) { + g_string_append_printf(lines, " %06"G_GUINT64_FORMAT, msg->preferred_display_mode->p_clock); + g_string_append_printf(lines, " %04x", msg->preferred_display_mode->H); + g_string_append_printf(lines, " %04x", msg->preferred_display_mode->HB); + g_string_append_printf(lines, " %04x", msg->preferred_display_mode->HSPOL_HSOFF); + g_string_append_printf(lines, " %04x", msg->preferred_display_mode->HSW); + g_string_append_printf(lines, " %04x", msg->preferred_display_mode->V); + g_string_append_printf(lines, " %04x", msg->preferred_display_mode->VB); + g_string_append_printf(lines, " %04x", msg->preferred_display_mode->VSPOL_VSOFF); + g_string_append_printf(lines, " %04x", msg->preferred_display_mode->VSW); + g_string_append_printf(lines, " %02x", msg->preferred_display_mode->VBS3D); + g_string_append_printf(lines, " %02x", msg->preferred_display_mode->V2d_s3d_modes); + g_string_append_printf(lines, " %02x", msg->preferred_display_mode->P_depth); + } else g_string_append_printf(lines, " none"); + g_string_append_printf(lines, "\r\n"); + } + + if (msg->uibc_capability) { + g_string_append_printf(lines, "wfd_uibc_capability"); + g_string_append_printf(lines, ":"); + if (msg->uibc_capability->uibcsupported) { + g_string_append_printf(lines, " input_category_list="); + if (msg->uibc_capability->input_category_list.input_cat) { + guint32 tempcap = 0; + if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) { + tempcap |= WFD_UIBC_INPUT_CAT_GENERIC; + g_string_append_printf(lines, "GENERIC"); + if (msg->uibc_capability->input_category_list.input_cat != tempcap) g_string_append_printf(lines, ", "); + } + if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) { + tempcap |= WFD_UIBC_INPUT_CAT_HIDC; + g_string_append_printf(lines, "HIDC"); + if (msg->uibc_capability->input_category_list.input_cat != tempcap) g_string_append_printf(lines, ", "); + } + } else g_string_append_printf(lines, "none"); + g_string_append_printf(lines, ";"); + g_string_append_printf(lines, " generic_cap_list="); + if (msg->uibc_capability->generic_cap_list.inp_type) { + guint32 tempcap = 0; + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) { + tempcap |= WFD_UIBC_INPUT_TYPE_KEYBOARD; + g_string_append_printf(lines, "Keyboard"); + if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", "); + } + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) { + tempcap |= WFD_UIBC_INPUT_TYPE_MOUSE; + g_string_append_printf(lines, "Mouse"); + if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", "); + } + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) { + tempcap |= WFD_UIBC_INPUT_TYPE_SINGLETOUCH; + g_string_append_printf(lines, "SingleTouch"); + if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", "); + } + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) { + tempcap |= WFD_UIBC_INPUT_TYPE_MULTITOUCH; + g_string_append_printf(lines, "MultiTouch"); + if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", "); + } + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) { + tempcap |= WFD_UIBC_INPUT_TYPE_JOYSTICK; + g_string_append_printf(lines, "Joystick"); + if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", "); + } + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) { + tempcap |= WFD_UIBC_INPUT_TYPE_CAMERA; + g_string_append_printf(lines, "Camera"); + if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", "); + } + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) { + tempcap |= WFD_UIBC_INPUT_TYPE_GESTURE; + g_string_append_printf(lines, "Gesture"); + if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", "); + } + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) { + tempcap |= WFD_UIBC_INPUT_TYPE_REMOTECONTROL; + g_string_append_printf(lines, "RemoteControl"); + if (msg->uibc_capability->generic_cap_list.inp_type != tempcap) g_string_append_printf(lines, ", "); + } + } else g_string_append_printf(lines, "none"); + g_string_append_printf(lines, ";"); + g_string_append_printf(lines, " hidc_cap_list="); + if (msg->uibc_capability->hidc_cap_list.cap_count) { + detailed_cap *temp_cap = msg->uibc_capability->hidc_cap_list.next; + while (temp_cap) { + if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_KEYBOARD) g_string_append_printf(lines, "Keyboard"); + else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_MOUSE) g_string_append_printf(lines, "Mouse"); + else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_SINGLETOUCH) g_string_append_printf(lines, "SingleTouch"); + else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_MULTITOUCH) g_string_append_printf(lines, "MultiTouch"); + else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_JOYSTICK) g_string_append_printf(lines, "Joystick"); + else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_CAMERA) g_string_append_printf(lines, "Camera"); + else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_GESTURE) g_string_append_printf(lines, "Gesture"); + else if (temp_cap->p.inp_type == WFD_UIBC_INPUT_TYPE_REMOTECONTROL) g_string_append_printf(lines, "RemoteControl"); + g_string_append_printf(lines, "/"); + if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_INFRARED) g_string_append_printf(lines, "Infrared"); + else if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_USB) g_string_append_printf(lines, "USB"); + else if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_BT) g_string_append_printf(lines, "BT"); + else if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_ZIGBEE) g_string_append_printf(lines, "Zigbee"); + else if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_WIFI) g_string_append_printf(lines, "Wi-Fi"); + else if (temp_cap->p.inp_path == WFD_UIBC_INPUT_PATH_NOSP) g_string_append_printf(lines, "No-SP"); + temp_cap = temp_cap->next; + if (temp_cap) g_string_append_printf(lines, ", "); + } + } else g_string_append_printf(lines, "none"); + g_string_append_printf(lines, ";"); + if (msg->uibc_capability->tcp_port) g_string_append_printf(lines, "port=%u", msg->uibc_capability->tcp_port); + else g_string_append_printf(lines, "port=none"); + } else g_string_append_printf(lines, " none"); + g_string_append_printf(lines, "\r\n"); + } + + if (msg->uibc_setting) { + g_string_append_printf(lines, "wfd_uibc_setting"); + g_string_append_printf(lines, ":"); + if (msg->uibc_setting->uibc_setting) + g_string_append_printf(lines, " enable"); + else + g_string_append_printf(lines, " disable"); + g_string_append_printf(lines, "\r\n"); + } + + if (msg->standby_resume_capability) { + g_string_append_printf(lines, "wfd_standby_resume_capability"); + g_string_append_printf(lines, ":"); + if (msg->standby_resume_capability->standby_resume_cap) + g_string_append_printf(lines, " supported"); + else + g_string_append_printf(lines, " none"); + g_string_append_printf(lines, "\r\n"); + } + + if (msg->standby) { + g_string_append_printf(lines, "wfd_standby"); + g_string_append_printf(lines, "\r\n"); + } + + if (msg->connector_type) { + g_string_append_printf(lines, "wfd_connector_type"); + g_string_append_printf(lines, ":"); + g_string_append_printf(lines, "\r\n"); + } + + if (msg->idr_request) { + g_string_append_printf(lines, "wfd_idr_request"); + g_string_append_printf(lines, "\r\n"); + } + + /*g_string_append_printf (lines, "\0"); */ + /*if(g_str_has_suffix (lines, "\r\n\0")) + { + guint32 length = g_strlen(lines); + lines[length-2] = '\0'; + }*/ + return g_string_free(lines, FALSE); } -gchar* wfdconfig_parameter_names_as_text (const WFDMessage *msg) +gchar *wfdconfig_parameter_names_as_text(const WFDMessage *msg) { - /* change all vars so they match rfc? */ - GString *lines; - g_return_val_if_fail (msg != NULL, NULL); - - lines = g_string_new (""); - - /* list of audio codecs */ - if(msg->audio_codecs) { - g_string_append_printf (lines,"wfd_audio_codecs"); - g_string_append_printf (lines,"\r\n"); - } - /* list of video codecs */ - if(msg->video_formats) { - g_string_append_printf (lines,"wfd_video_formats"); - g_string_append_printf (lines,"\r\n"); - } - /* list of video 3D codecs */ - if(msg->video_3d_formats) { - g_string_append_printf (lines,"wfd_3d_video_formats"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->content_protection) { - g_string_append_printf (lines,"wfd_content_protection"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->display_edid) { - g_string_append_printf (lines,"wfd_display_edid"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->coupled_sink) { - g_string_append_printf (lines,"wfd_coupled_sink"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->trigger_method) { - g_string_append_printf (lines,"wfd_trigger_method"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->presentation_url) { - g_string_append_printf (lines,"wfd_presentation_URL"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->client_rtp_ports) { - g_string_append_printf (lines,"wfd_client_rtp_ports"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->route) { - g_string_append_printf (lines,"wfd_route"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->I2C) { - g_string_append_printf (lines,"wfd_I2C"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->av_format_change_timing) { - g_string_append_printf (lines,"wfd_av_format_change_timing"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->preferred_display_mode) { - g_string_append_printf (lines,"wfd_preferred_display_mode"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->uibc_capability) { - g_string_append_printf (lines,"wfd_uibc_capability"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->uibc_setting) { - g_string_append_printf (lines,"wfd_uibc_setting"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->standby_resume_capability) { - g_string_append_printf (lines,"wfd_standby_resume_capability"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->standby) { - g_string_append_printf (lines,"wfd_standby"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->connector_type) { - g_string_append_printf (lines,"wfd_connector_type"); - g_string_append_printf (lines,"\r\n"); - } - if(msg->idr_request) { - g_string_append_printf (lines,"wfd_idr_request"); - g_string_append_printf (lines,"\r\n"); - } - return g_string_free (lines, FALSE); + /* change all vars so they match rfc? */ + GString *lines; + g_return_val_if_fail(msg != NULL, NULL); + + lines = g_string_new(""); + + /* list of audio codecs */ + if (msg->audio_codecs) { + g_string_append_printf(lines, "wfd_audio_codecs"); + g_string_append_printf(lines, "\r\n"); + } + /* list of video codecs */ + if (msg->video_formats) { + g_string_append_printf(lines, "wfd_video_formats"); + g_string_append_printf(lines, "\r\n"); + } + /* list of video 3D codecs */ + if (msg->video_3d_formats) { + g_string_append_printf(lines, "wfd_3d_video_formats"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->content_protection) { + g_string_append_printf(lines, "wfd_content_protection"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->display_edid) { + g_string_append_printf(lines, "wfd_display_edid"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->coupled_sink) { + g_string_append_printf(lines, "wfd_coupled_sink"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->trigger_method) { + g_string_append_printf(lines, "wfd_trigger_method"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->presentation_url) { + g_string_append_printf(lines, "wfd_presentation_URL"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->client_rtp_ports) { + g_string_append_printf(lines, "wfd_client_rtp_ports"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->route) { + g_string_append_printf(lines, "wfd_route"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->I2C) { + g_string_append_printf(lines, "wfd_I2C"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->av_format_change_timing) { + g_string_append_printf(lines, "wfd_av_format_change_timing"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->preferred_display_mode) { + g_string_append_printf(lines, "wfd_preferred_display_mode"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->uibc_capability) { + g_string_append_printf(lines, "wfd_uibc_capability"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->uibc_setting) { + g_string_append_printf(lines, "wfd_uibc_setting"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->standby_resume_capability) { + g_string_append_printf(lines, "wfd_standby_resume_capability"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->standby) { + g_string_append_printf(lines, "wfd_standby"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->connector_type) { + g_string_append_printf(lines, "wfd_connector_type"); + g_string_append_printf(lines, "\r\n"); + } + if (msg->idr_request) { + g_string_append_printf(lines, "wfd_idr_request"); + g_string_append_printf(lines, "\r\n"); + } + return g_string_free(lines, FALSE); } static void -read_string_space_ended (gchar * dest, guint size, gchar * src) +read_string_space_ended(gchar *dest, guint size, gchar *src) { - guint idx = 0; + guint idx = 0; - while (!g_ascii_isspace (*src) && *src != '\0') { - if (idx < size - 1) - dest[idx++] = *src; - src++; - } + while (!g_ascii_isspace(*src) && *src != '\0') { + if (idx < size - 1) + dest[idx++] = *src; + src++; + } - if (size > 0) - dest[idx] = '\0'; + if (size > 0) + dest[idx] = '\0'; } static void -read_string_char_ended (gchar * dest, guint size, gchar del, gchar * src) +read_string_char_ended(gchar *dest, guint size, gchar del, gchar *src) { - guint idx = 0; + guint idx = 0; - while (*src != del && *src != '\0') { - if (idx < size - 1) - dest[idx++] = *src; - src++; - } + while (*src != del && *src != '\0') { + if (idx < size - 1) + dest[idx++] = *src; + src++; + } - if (size > 0) - dest[idx] = '\0'; + if (size > 0) + dest[idx] = '\0'; } static void -read_string_type_and_value (gchar * type, gchar * value, guint tsize, guint vsize, gchar del, gchar * src) +read_string_type_and_value(gchar *type, gchar *value, guint tsize, guint vsize, gchar del, gchar *src) { - guint idx; - - idx = 0; - while (*src != del && *src != '\0') { - if (idx < tsize - 1) - type[idx++] = *src; - src++; - } - - if (tsize > 0) - type[idx] = '\0'; - - src++; - idx = 0; - while (*src != '\0') { - if (idx < vsize - 1) - value[idx++] = *src; - src++; - } - if (vsize > 0) - value[idx] = '\0'; + guint idx; + + idx = 0; + while (*src != del && *src != '\0') { + if (idx < tsize - 1) + type[idx++] = *src; + src++; + } + + if (tsize > 0) + type[idx] = '\0'; + + src++; + idx = 0; + while (*src != '\0') { + if (idx < vsize - 1) + value[idx++] = *src; + src++; + } + if (vsize > 0) + value[idx] = '\0'; } static gboolean -wfdconfig_parse_line (WFDMessage * msg, gchar * buffer) +wfdconfig_parse_line(WFDMessage *msg, gchar *buffer) { - gchar type[8192] = {0}; - gchar value[8192] = {0}; - gchar temp[8192] = {0}; - gchar *p = buffer; - gchar *v = value; - gchar *result = NULL; - - #define WFD_SKIP_SPACE(q) if (*q && g_ascii_isspace (*q)) q++ - #define WFD_SKIP_EQUAL(q) if (*q && *q == '=') q++ - #define WFD_SKIP_COMMA(q) if (*q && g_ascii_ispunct (*q)) q++ - #define WFD_READ_STRING(field) read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); REPLACE_STRING (field, temp) - #define WFD_READ_CHAR_END_STRING(field, del) read_string_char_ended (temp, sizeof (temp), del, v); v+=strlen(temp); REPLACE_STRING (field, temp) - #define WFD_READ_UINT32(field) read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); field = strtoul (temp, NULL, 16) - #define WFD_READ_UINT32_DIGIT(field) read_string_space_ended (temp, sizeof (temp), v); v+=strlen(temp); field = strtoul (temp, NULL, 10) - - //g_print("wfdconfig_parse_line input: %s\n", buffer); - read_string_type_and_value (type, value, sizeof(type), sizeof(value), ':', p); - //g_print("wfdconfig_parse_line type:%s value:%s\n", type, value); - if(!g_strcmp0(type,"wfd_audio_codecs")) { - msg->audio_codecs = g_new0 (WFDAudioCodeclist, 1); - if(strlen(v)) { - guint i=0; - msg->audio_codecs->count= strlen(v)/16; - msg->audio_codecs->list = g_new0 (WFDAudioCodec, msg->audio_codecs->count); - for(;iaudio_codecs->count;i++) { - WFD_SKIP_SPACE(v); - WFD_READ_STRING(msg->audio_codecs->list[i].audio_format); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->audio_codecs->list[i].modes); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->audio_codecs->list[i].latency); - WFD_SKIP_COMMA(v); - } - } - } else if(!g_strcmp0(type,"wfd_video_formats")) { - msg->video_formats = g_new0 (WFDVideoCodeclist, 1); - if(strlen(v)) { - msg->video_formats->count = 1; - msg->video_formats->list = g_new0 (WFDVideoCodec, 1); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_formats->list->native); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_formats->list->preferred_display_mode_supported); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_formats->list->H264_codec.profile); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_formats->list->H264_codec.level); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.CEA_Support); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.VESA_Support); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.HH_Support); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.latency); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.min_slice_size); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.slice_enc_params); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support); - WFD_SKIP_SPACE(v); - if(msg->video_formats->list->preferred_display_mode_supported == 1) { - WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_hres); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_vres); - WFD_SKIP_SPACE(v); - } - } - }else if(!g_strcmp0(type,"wfd_3d_video_formats")) { - msg->video_3d_formats = g_new0 (WFD3DFormats, 1); - if(strlen(v)) { - msg->video_3d_formats->count = 1; - msg->video_3d_formats->list = g_new0 (WFD3dCapList, 1); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_3d_formats->list->native); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_3d_formats->list->preferred_display_mode_supported); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.profile); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.level); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.video_3d_capability); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.latency); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.min_slice_size); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.slice_enc_params); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support); - WFD_SKIP_SPACE(v); - if(msg->video_3d_formats->list->preferred_display_mode_supported == 1) { - WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.max_hres); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.max_vres); - WFD_SKIP_SPACE(v); - } - } - } else if(!g_strcmp0(type,"wfd_content_protection")) { - msg->content_protection = g_new0 (WFDContentProtection, 1); - if(strlen(v)) { - WFD_SKIP_SPACE(v); - msg->content_protection->hdcp2_spec = g_new0 (WFDHdcp2Spec, 1); - if(strstr(v,"none")) { - msg->content_protection->hdcp2_spec->hdcpversion=g_strdup("none"); - } else { - WFD_READ_STRING(msg->content_protection->hdcp2_spec->hdcpversion); - WFD_SKIP_SPACE(v); - WFD_READ_STRING(msg->content_protection->hdcp2_spec->TCPPort); - } - } - } else if(!g_strcmp0(type,"wfd_display_edid")) { - msg->display_edid = g_new0 (WFDDisplayEdid, 1); - if(strlen(v)) { - WFD_SKIP_SPACE(v); - if(strstr(v,"none")) { - msg->display_edid->edid_supported = 0; - } else { - msg->display_edid->edid_supported = 1; - WFD_READ_UINT32(msg->display_edid->edid_block_count); - WFD_SKIP_SPACE(v); - if(msg->display_edid->edid_block_count) { - gchar *edid_string = v; - int i=0, j=0, size =0; - guint32 payload_size = EDID_BLOCK_SIZE * msg->display_edid->edid_block_count; - msg->display_edid->edid_payload = g_malloc(payload_size); - size = EDID_BLOCK_SIZE*msg->display_edid->edid_block_count*2; - for (;i0x29 && edid_string[i]<0x40) k=edid_string[i]-48; - else if(edid_string[i]>0x60 && edid_string[i]<0x67) k=edid_string[i]-87; - else if(edid_string[i]>0x40 && edid_string[i]<0x47) k=edid_string[i]-55; - - if(edid_string[i+1]>0x29 && edid_string[i+1]<0x40) kk=edid_string[i+1]-48; - else if(edid_string[i+1]>0x60 && edid_string[i+1]<0x67) kk=edid_string[i+1]-87; - else if(edid_string[i+1]>0x40 && edid_string[i+1]<0x47) kk=edid_string[i+1]-55; - - msg->display_edid->edid_payload[j] = (k<<4)|kk; - i+=2; - } - //memcpy(msg->display_edid->edid_payload, v, payload_size); - v += (payload_size*2); - } else v += strlen(v); - } - } - } else if(!g_strcmp0(type,"wfd_coupled_sink")) { - msg->coupled_sink = g_new0 (WFDCoupledSink, 1); - if(strlen(v)) { - msg->coupled_sink->coupled_sink_cap = g_new0 (WFDCoupled_sink_cap, 1); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->coupled_sink->coupled_sink_cap->status); - WFD_SKIP_SPACE(v); - WFD_READ_STRING(msg->coupled_sink->coupled_sink_cap->sink_address); - } - } else if(!g_strcmp0(type,"wfd_trigger_method")) { - msg->trigger_method = g_new0 (WFDTriggerMethod, 1); - if(strlen(v)) { - WFD_SKIP_SPACE(v); - WFD_READ_STRING(msg->trigger_method->wfd_trigger_method); - } - } else if(!g_strcmp0(type,"wfd_presentation_URL")) { - msg->presentation_url = g_new0 (WFDPresentationUrl, 1); - if(strlen(v)) { - WFD_SKIP_SPACE(v); - WFD_READ_STRING(msg->presentation_url->wfd_url0); - WFD_SKIP_SPACE(v); - WFD_READ_STRING(msg->presentation_url->wfd_url1); - } - } else if(!g_strcmp0(type,"wfd_client_rtp_ports")) { - msg->client_rtp_ports = g_new0 (WFDClientRtpPorts, 1); - if(strlen(v)) { - WFD_SKIP_SPACE(v); - WFD_READ_STRING(msg->client_rtp_ports->profile); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port0); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port1); - WFD_SKIP_SPACE(v); - WFD_READ_STRING(msg->client_rtp_ports->mode); - } - } else if(!g_strcmp0(type,"wfd_route")) { - msg->route = g_new0 (WFDRoute, 1); - if(strlen(v)) { - WFD_SKIP_SPACE(v); - WFD_READ_STRING(msg->route->destination); - } - } else if(!g_strcmp0(type,"wfd_I2C")) { - msg->I2C = g_new0 (WFDI2C, 1); - if(strlen(v)) { - msg->I2C->I2CPresent = TRUE; - WFD_SKIP_SPACE(v); - WFD_READ_UINT32_DIGIT(msg->I2C->I2C_port); - if(msg->I2C->I2C_port) msg->I2C->I2CPresent = TRUE; - } - } else if(!g_strcmp0(type,"wfd_av_format_change_timing")) { - msg->av_format_change_timing = g_new0 (WFDAVFormatChangeTiming, 1); - if(strlen(v)) { - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->av_format_change_timing->PTS); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->av_format_change_timing->DTS); - } - } else if(!g_strcmp0(type,"wfd_preferred_display_mode")) { - msg->preferred_display_mode = g_new0 (WFDPreferredDisplayMode, 1); - if(strlen(v)) { - WFD_SKIP_SPACE(v); - if(!strstr(v,"none")) { - msg->preferred_display_mode->displaymodesupported = FALSE; - } else { - WFD_READ_UINT32(msg->preferred_display_mode->p_clock); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->H); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->HB); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->HSPOL_HSOFF); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->HSW); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->V); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->VB); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->VSPOL_VSOFF); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->VSW); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->VBS3D); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->V2d_s3d_modes); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->P_depth); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.profile); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.level); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.CEA_Support); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.VESA_Support); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.HH_Support); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.latency); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.min_slice_size); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.slice_enc_params); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.frame_rate_control_support); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_hres); - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_vres); - WFD_SKIP_SPACE(v); - } - } - } else if(!g_strcmp0(type,"wfd_uibc_capability")) { - msg->uibc_capability = g_new0 (WFDUibcCapability, 1); - if(strstr(v,"input_category_list")) { - gchar *tstring = NULL; - msg->uibc_capability->uibcsupported = TRUE; - WFD_SKIP_SPACE(v); - WFD_READ_CHAR_END_STRING(tstring, '='); - if(!g_strcmp0(tstring,"input_category_list")) { - gchar temp2[8192]={0}; - guint rem_len=0, read_len=0; - WFD_READ_CHAR_END_STRING(tstring, ';'); - rem_len = strlen(tstring); - do { - WFD_SKIP_SPACE(v); - read_string_char_ended (temp2, 8192, ',', tstring+read_len); - read_len += (strlen(temp2)+1); - if(strstr(temp2,"GENERIC")) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_GENERIC; - else if(strstr(temp2,"HIDC")) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_HIDC; - else msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_UNKNOWN; - } while(read_len < rem_len); - - result = strstr(v,"generic_cap_list"); - if(result != NULL){ - memset(temp2, 0, 8192); - rem_len=0; - read_len=0; - v = result; - WFD_READ_CHAR_END_STRING(tstring, '='); - if(!g_strcmp0(tstring,"generic_cap_list")) { - WFD_SKIP_SPACE(v); - WFD_READ_CHAR_END_STRING(tstring, ';'); - rem_len = strlen(tstring); - do { - read_string_char_ended (temp2, 8192, ',', tstring+read_len); - read_len += (strlen(temp2)+1); - if(strstr(temp2,"Keyboard")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_KEYBOARD; - else if(strstr(temp2,"Mouse")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MOUSE; - else if(strstr(temp2,"SingleTouch")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_SINGLETOUCH; - else if(strstr(temp2,"MultiTouch")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MULTITOUCH; - else if(strstr(temp2,"Joystick")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_JOYSTICK; - else if(strstr(temp2,"Camera")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_CAMERA; - else if(strstr(temp2,"Gesture")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_GESTURE; - else if(strstr(temp2,"RemoteControl")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_REMOTECONTROL; - else msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_UNKNOWN; - } while(read_len < rem_len); - } - } - result = strstr (v, "hidc_cap_list"); - if(result != NULL){ - v = result; - WFD_SKIP_SPACE(v); - WFD_READ_CHAR_END_STRING(tstring, '='); - if(!g_strcmp0(tstring,"hidc_cap_list")) { - gchar inp_type[8192]; - gchar inp_path[8192]; - memset(temp2, 0, 8192); - rem_len=0; - read_len=0; - detailed_cap *temp_cap; - WFD_READ_CHAR_END_STRING(tstring, ';'); - rem_len = strlen(tstring); - msg->uibc_capability->hidc_cap_list.next = g_new0 (detailed_cap, 1); - temp_cap = msg->uibc_capability->hidc_cap_list.next; - do { - msg->uibc_capability->hidc_cap_list.cap_count++; - read_string_char_ended (temp2, 8192, ',', tstring+read_len); - read_len += (strlen(temp2)+1); - read_string_type_and_value (inp_type, inp_path, sizeof(inp_type), sizeof(inp_path), '/',temp2); - if(strstr(inp_type,"Keyboard")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_KEYBOARD; - else if(strstr(inp_type,"Mouse")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MOUSE; - else if(strstr(inp_type,"SingleTouch")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_SINGLETOUCH; - else if(strstr(inp_type,"MultiTouch")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MULTITOUCH; - else if(strstr(inp_type,"Joystick")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_JOYSTICK; - else if(strstr(inp_type,"Camera")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_CAMERA; - else if(strstr(inp_type,"Gesture")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_GESTURE; - else if(strstr(inp_type,"RemoteControl")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_REMOTECONTROL; - else temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_UNKNOWN; - - if(strstr(inp_path,"Infrared")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_INFRARED; - else if(strstr(inp_path,"USB")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_USB; - else if(strstr(inp_path,"BT")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_BT; - else if(strstr(inp_path,"Zigbee")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_ZIGBEE; - else if(strstr(inp_path,"Wi-Fi")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_WIFI; - else if(strstr(inp_path,"No-SP")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_NOSP; - else temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_UNKNOWN; - if(read_len < rem_len) { - temp_cap->next = g_new0 (detailed_cap, 1); - temp_cap = temp_cap->next; - } - } while(read_len < rem_len); - } - } - result = strstr(v,"port"); - if(result != NULL) { - v = result; - WFD_READ_CHAR_END_STRING(tstring, '='); - if(!g_strcmp0(tstring,"port")) { - WFD_SKIP_EQUAL(v); - WFD_READ_CHAR_END_STRING(tstring, ';'); - if(!strstr(tstring,"none")) { - msg->uibc_capability->tcp_port = strtoul (tstring, NULL, 10); - } - } - } - } - } else if (strstr(v,"none")) { - msg->uibc_capability->uibcsupported = FALSE; - } - } else if(!g_strcmp0(type,"wfd_uibc_setting")) { - msg->uibc_setting = g_new0 (WFDUibcSetting, 1); - if(strlen(v)) { - WFD_SKIP_SPACE(v); - if(!g_strcmp0(v, "enable")) - msg->uibc_setting->uibc_setting = TRUE; - else - msg->uibc_setting->uibc_setting = FALSE; - } - } else if(!g_strcmp0(type,"wfd_standby_resume_capability")) { - msg->standby_resume_capability = g_new0 (WFDStandbyResumeCapability, 1); - if(strlen(v)) { - WFD_SKIP_SPACE(v); - if(!g_strcmp0(v, "supported")) - msg->standby_resume_capability->standby_resume_cap = TRUE; - else - msg->standby_resume_capability->standby_resume_cap = FALSE; - } - } else if(!g_strcmp0(type,"wfd_standby")) { - msg->standby = g_new0 (WFDStandby, 1); - msg->standby->wfd_standby = TRUE; - } else if(!g_strcmp0(type,"wfd_connector_type")) { - msg->connector_type = g_new0 (WFDConnectorType, 1); - if(strlen(v)) { - msg->connector_type->supported = TRUE; - WFD_SKIP_SPACE(v); - WFD_READ_UINT32(msg->connector_type->connector_type); - } - } else if(!g_strcmp0(type,"wfd_idr_request")) { - msg->idr_request = g_new0 (WFDIdrRequest, 1); - msg->idr_request->idr_request = TRUE; - } - - return TRUE; + gchar type[8192] = {0}; + gchar value[8192] = {0}; + gchar temp[8192] = {0}; + gchar *p = buffer; + gchar *v = value; + gchar *result = NULL; + +#define WFD_SKIP_SPACE(q) if (*q && g_ascii_isspace(*q)) q++; +#define WFD_SKIP_EQUAL(q) if (*q && *q == '=') q++; +#define WFD_SKIP_COMMA(q) if (*q && g_ascii_ispunct(*q)) q++; +#define WFD_READ_STRING(field) read_string_space_ended(temp, sizeof(temp), v); v += strlen(temp); REPLACE_STRING(field, temp); +#define WFD_READ_CHAR_END_STRING(field, del) read_string_char_ended(temp, sizeof(temp), del, v); v += strlen(temp); REPLACE_STRING(field, temp); +#define WFD_READ_UINT32(field) read_string_space_ended(temp, sizeof(temp), v); v += strlen(temp); field = strtoul(temp, NULL, 16); +#define WFD_READ_UINT32_DIGIT(field) read_string_space_ended(temp, sizeof(temp), v); v += strlen(temp); field = strtoul(temp, NULL, 10); + + /*g_print("wfdconfig_parse_line input: %s\n", buffer); */ + read_string_type_and_value(type, value, sizeof(type), sizeof(value), ':', p); + /*g_print("wfdconfig_parse_line type:%s value:%s\n", type, value); */ + if (!g_strcmp0(type, "wfd_audio_codecs")) { + msg->audio_codecs = g_new0(WFDAudioCodeclist, 1); + if (strlen(v)) { + guint i = 0; + msg->audio_codecs->count = strlen(v) / 16; + msg->audio_codecs->list = g_new0(WFDAudioCodec, msg->audio_codecs->count); + for (; i < msg->audio_codecs->count; i++) { + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->audio_codecs->list[i].audio_format); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->audio_codecs->list[i].modes); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->audio_codecs->list[i].latency); + WFD_SKIP_COMMA(v); + } + } + } else if (!g_strcmp0(type, "wfd_video_formats")) { + msg->video_formats = g_new0(WFDVideoCodeclist, 1); + if (strlen(v)) { + msg->video_formats->count = 1; + msg->video_formats->list = g_new0(WFDVideoCodec, 1); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->native); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->preferred_display_mode_supported); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.profile); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.level); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.CEA_Support); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.VESA_Support); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.HH_Support); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.latency); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.min_slice_size); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.slice_enc_params); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support); + WFD_SKIP_SPACE(v); + if (msg->video_formats->list->preferred_display_mode_supported == 1) { + WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_hres); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_formats->list->H264_codec.max_vres); + WFD_SKIP_SPACE(v); + } + } + } else if (!g_strcmp0(type, "wfd_3d_video_formats")) { + msg->video_3d_formats = g_new0(WFD3DFormats, 1); + if (strlen(v)) { + msg->video_3d_formats->count = 1; + msg->video_3d_formats->list = g_new0(WFD3dCapList, 1); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->native); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->preferred_display_mode_supported); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.profile); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.level); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.video_3d_capability); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.latency); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.min_slice_size); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.slice_enc_params); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.misc_params.frame_rate_control_support); + WFD_SKIP_SPACE(v); + if (msg->video_3d_formats->list->preferred_display_mode_supported == 1) { + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.max_hres); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->video_3d_formats->list->H264_codec.max_vres); + WFD_SKIP_SPACE(v); + } + } + } else if (!g_strcmp0(type, "wfd_content_protection")) { + msg->content_protection = g_new0(WFDContentProtection, 1); + if (strlen(v)) { + WFD_SKIP_SPACE(v); + msg->content_protection->hdcp2_spec = g_new0(WFDHdcp2Spec, 1); + if (strstr(v, "none")) { + msg->content_protection->hdcp2_spec->hdcpversion = g_strdup("none"); + } else { + WFD_READ_STRING(msg->content_protection->hdcp2_spec->hdcpversion); + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->content_protection->hdcp2_spec->TCPPort); + } + } + } else if (!g_strcmp0(type, "wfd_display_edid")) { + msg->display_edid = g_new0(WFDDisplayEdid, 1); + if (strlen(v)) { + WFD_SKIP_SPACE(v); + if (strstr(v, "none")) { + msg->display_edid->edid_supported = 0; + } else { + msg->display_edid->edid_supported = 1; + WFD_READ_UINT32(msg->display_edid->edid_block_count); + WFD_SKIP_SPACE(v); + if (msg->display_edid->edid_block_count) { + gchar *edid_string = v; + int i = 0, j = 0, size = 0; + guint32 payload_size = EDID_BLOCK_SIZE * msg->display_edid->edid_block_count; + msg->display_edid->edid_payload = g_malloc(payload_size); + size = EDID_BLOCK_SIZE * msg->display_edid->edid_block_count * 2; + for (; i < size; j++) { + int k = 0, kk = 0; + if (edid_string[i] > 0x29 && edid_string[i] < 0x40) k = edid_string[i] - 48; + else if (edid_string[i] > 0x60 && edid_string[i] < 0x67) k = edid_string[i] - 87; + else if (edid_string[i] > 0x40 && edid_string[i] < 0x47) k = edid_string[i] - 55; + + if (edid_string[i + 1] > 0x29 && edid_string[i + 1] < 0x40) kk = edid_string[i + 1] - 48; + else if (edid_string[i + 1] > 0x60 && edid_string[i + 1] < 0x67) kk = edid_string[i + 1] - 87; + else if (edid_string[i + 1] > 0x40 && edid_string[i + 1] < 0x47) kk = edid_string[i + 1] - 55; + + msg->display_edid->edid_payload[j] = (k << 4) | kk; + i += 2; + } + /*memcpy(msg->display_edid->edid_payload, v, payload_size); */ + v += (payload_size * 2); + } else v += strlen(v); + } + } + } else if (!g_strcmp0(type, "wfd_coupled_sink")) { + msg->coupled_sink = g_new0(WFDCoupledSink, 1); + if (strlen(v)) { + msg->coupled_sink->coupled_sink_cap = g_new0(WFDCoupled_sink_cap, 1); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->coupled_sink->coupled_sink_cap->status); + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->coupled_sink->coupled_sink_cap->sink_address); + } + } else if (!g_strcmp0(type, "wfd_trigger_method")) { + msg->trigger_method = g_new0(WFDTriggerMethod, 1); + if (strlen(v)) { + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->trigger_method->wfd_trigger_method); + } + } else if (!g_strcmp0(type, "wfd_presentation_URL")) { + msg->presentation_url = g_new0(WFDPresentationUrl, 1); + if (strlen(v)) { + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->presentation_url->wfd_url0); + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->presentation_url->wfd_url1); + } + } else if (!g_strcmp0(type, "wfd_client_rtp_ports")) { + msg->client_rtp_ports = g_new0(WFDClientRtpPorts, 1); + if (strlen(v)) { + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->client_rtp_ports->profile); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port0); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32_DIGIT(msg->client_rtp_ports->rtp_port1); + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->client_rtp_ports->mode); + } + } else if (!g_strcmp0(type, "wfd_route")) { + msg->route = g_new0(WFDRoute, 1); + if (strlen(v)) { + WFD_SKIP_SPACE(v); + WFD_READ_STRING(msg->route->destination); + } + } else if (!g_strcmp0(type, "wfd_I2C")) { + msg->I2C = g_new0(WFDI2C, 1); + if (strlen(v)) { + msg->I2C->I2CPresent = TRUE; + WFD_SKIP_SPACE(v); + WFD_READ_UINT32_DIGIT(msg->I2C->I2C_port); + if (msg->I2C->I2C_port) msg->I2C->I2CPresent = TRUE; + } + } else if (!g_strcmp0(type, "wfd_av_format_change_timing")) { + msg->av_format_change_timing = g_new0(WFDAVFormatChangeTiming, 1); + if (strlen(v)) { + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->av_format_change_timing->PTS); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->av_format_change_timing->DTS); + } + } else if (!g_strcmp0(type, "wfd_preferred_display_mode")) { + msg->preferred_display_mode = g_new0(WFDPreferredDisplayMode, 1); + if (strlen(v)) { + WFD_SKIP_SPACE(v); + if (!strstr(v, "none")) { + msg->preferred_display_mode->displaymodesupported = FALSE; + } else { + WFD_READ_UINT32(msg->preferred_display_mode->p_clock); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->HB); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->HSPOL_HSOFF); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->HSW); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->V); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->VB); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->VSPOL_VSOFF); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->VSW); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->VBS3D); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->V2d_s3d_modes); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->P_depth); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.profile); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.level); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.CEA_Support); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.VESA_Support); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.HH_Support); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.latency); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.min_slice_size); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.slice_enc_params); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.misc_params.frame_rate_control_support); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_hres); + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->preferred_display_mode->H264_codec.max_vres); + WFD_SKIP_SPACE(v); + } + } + } else if (!g_strcmp0(type, "wfd_uibc_capability")) { + msg->uibc_capability = g_new0(WFDUibcCapability, 1); + if (strstr(v, "input_category_list")) { + gchar *tstring = NULL; + msg->uibc_capability->uibcsupported = TRUE; + WFD_SKIP_SPACE(v); + WFD_READ_CHAR_END_STRING(tstring, '='); + if (!g_strcmp0(tstring, "input_category_list")) { + gchar temp2[8192] = {0}; + guint rem_len = 0, read_len = 0; + WFD_READ_CHAR_END_STRING(tstring, ';'); + rem_len = strlen(tstring); + do { + WFD_SKIP_SPACE(v); + read_string_char_ended(temp2, 8192, ',', tstring + read_len); + read_len += (strlen(temp2) + 1); + if (strstr(temp2, "GENERIC")) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_GENERIC; + else if (strstr(temp2, "HIDC")) msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_HIDC; + else msg->uibc_capability->input_category_list.input_cat |= WFD_UIBC_INPUT_CAT_UNKNOWN; + } while (read_len < rem_len); + + result = strstr(v, "generic_cap_list"); + if (result != NULL) { + memset(temp2, 0, 8192); + rem_len = 0; + read_len = 0; + v = result; + WFD_READ_CHAR_END_STRING(tstring, '='); + if (!g_strcmp0(tstring, "generic_cap_list")) { + WFD_SKIP_SPACE(v); + WFD_READ_CHAR_END_STRING(tstring, ';'); + rem_len = strlen(tstring); + do { + read_string_char_ended(temp2, 8192, ',', tstring + read_len); + read_len += (strlen(temp2) + 1); + if (strstr(temp2, "Keyboard")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_KEYBOARD; + else if (strstr(temp2, "Mouse")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MOUSE; + else if (strstr(temp2, "SingleTouch")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_SINGLETOUCH; + else if (strstr(temp2, "MultiTouch")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_MULTITOUCH; + else if (strstr(temp2, "Joystick")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_JOYSTICK; + else if (strstr(temp2, "Camera")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_CAMERA; + else if (strstr(temp2, "Gesture")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_GESTURE; + else if (strstr(temp2, "RemoteControl")) msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_REMOTECONTROL; + else msg->uibc_capability->generic_cap_list.inp_type |= WFD_UIBC_INPUT_TYPE_UNKNOWN; + } while (read_len < rem_len); + } + } + result = strstr(v, "hidc_cap_list"); + if (result != NULL) { + v = result; + WFD_SKIP_SPACE(v); + WFD_READ_CHAR_END_STRING(tstring, '='); + if (!g_strcmp0(tstring, "hidc_cap_list")) { + gchar inp_type[8192]; + gchar inp_path[8192]; + memset(temp2, 0, 8192); + rem_len = 0; + read_len = 0; + detailed_cap *temp_cap; + WFD_READ_CHAR_END_STRING(tstring, ';'); + rem_len = strlen(tstring); + msg->uibc_capability->hidc_cap_list.next = g_new0(detailed_cap, 1); + temp_cap = msg->uibc_capability->hidc_cap_list.next; + do { + msg->uibc_capability->hidc_cap_list.cap_count++; + read_string_char_ended(temp2, 8192, ',', tstring + read_len); + read_len += (strlen(temp2) + 1); + read_string_type_and_value(inp_type, inp_path, sizeof(inp_type), sizeof(inp_path), '/', temp2); + if (strstr(inp_type, "Keyboard")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_KEYBOARD; + else if (strstr(inp_type, "Mouse")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MOUSE; + else if (strstr(inp_type, "SingleTouch")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_SINGLETOUCH; + else if (strstr(inp_type, "MultiTouch")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_MULTITOUCH; + else if (strstr(inp_type, "Joystick")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_JOYSTICK; + else if (strstr(inp_type, "Camera")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_CAMERA; + else if (strstr(inp_type, "Gesture")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_GESTURE; + else if (strstr(inp_type, "RemoteControl")) temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_REMOTECONTROL; + else temp_cap->p.inp_type = WFD_UIBC_INPUT_TYPE_UNKNOWN; + + if (strstr(inp_path, "Infrared")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_INFRARED; + else if (strstr(inp_path, "USB")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_USB; + else if (strstr(inp_path, "BT")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_BT; + else if (strstr(inp_path, "Zigbee")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_ZIGBEE; + else if (strstr(inp_path, "Wi-Fi")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_WIFI; + else if (strstr(inp_path, "No-SP")) temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_NOSP; + else temp_cap->p.inp_path = WFD_UIBC_INPUT_PATH_UNKNOWN; + if (read_len < rem_len) { + temp_cap->next = g_new0(detailed_cap, 1); + temp_cap = temp_cap->next; + } + } while (read_len < rem_len); + } + } + result = strstr(v, "port"); + if (result != NULL) { + v = result; + WFD_READ_CHAR_END_STRING(tstring, '='); + if (!g_strcmp0(tstring, "port")) { + WFD_SKIP_EQUAL(v); + WFD_READ_CHAR_END_STRING(tstring, ';'); + if (!strstr(tstring, "none")) { + msg->uibc_capability->tcp_port = strtoul(tstring, NULL, 10); + } + } + } + } + } else if (strstr(v, "none")) { + msg->uibc_capability->uibcsupported = FALSE; + } + } else if (!g_strcmp0(type, "wfd_uibc_setting")) { + msg->uibc_setting = g_new0(WFDUibcSetting, 1); + if (strlen(v)) { + WFD_SKIP_SPACE(v); + if (!g_strcmp0(v, "enable")) + msg->uibc_setting->uibc_setting = TRUE; + else + msg->uibc_setting->uibc_setting = FALSE; + } + } else if (!g_strcmp0(type, "wfd_standby_resume_capability")) { + msg->standby_resume_capability = g_new0(WFDStandbyResumeCapability, 1); + if (strlen(v)) { + WFD_SKIP_SPACE(v); + if (!g_strcmp0(v, "supported")) + msg->standby_resume_capability->standby_resume_cap = TRUE; + else + msg->standby_resume_capability->standby_resume_cap = FALSE; + } + } else if (!g_strcmp0(type, "wfd_standby")) { + msg->standby = g_new0(WFDStandby, 1); + msg->standby->wfd_standby = TRUE; + } else if (!g_strcmp0(type, "wfd_connector_type")) { + msg->connector_type = g_new0(WFDConnectorType, 1); + if (strlen(v)) { + msg->connector_type->supported = TRUE; + WFD_SKIP_SPACE(v); + WFD_READ_UINT32(msg->connector_type->connector_type); + } + } else if (!g_strcmp0(type, "wfd_idr_request")) { + msg->idr_request = g_new0(WFDIdrRequest, 1); + msg->idr_request->idr_request = TRUE; + } + + return TRUE; } /** @@ -1148,37 +1143,37 @@ wfdconfig_parse_line (WFDMessage * msg, gchar * buffer) * Returns: #WFD_OK on success. */ WFDResult -wfdconfig_message_parse_buffer (const guint8 * data, guint size, WFDMessage * msg) +wfdconfig_message_parse_buffer(const guint8 *data, guint size, WFDMessage *msg) { - const gchar *p; - gchar buffer[MAX_LINE_LEN] = {0}; - guint idx = 0; - - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - g_return_val_if_fail (data != NULL, WFD_EINVAL); - g_return_val_if_fail (size != 0, WFD_EINVAL); - - p = (const gchar *) data; - while (TRUE) { - - if (*p == '\0') - break; - - idx = 0; - while (*p != '\n' && *p != '\r' && *p != '\0') { - if (idx < sizeof (buffer) - 1) - buffer[idx++] = *p; - p++; - } - buffer[idx] = '\0'; - wfdconfig_parse_line (msg, buffer); - - if (*p == '\0') - break; - p+=2; - } - - return WFD_OK; + const gchar *p; + gchar buffer[MAX_LINE_LEN] = {0}; + guint idx = 0; + + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + g_return_val_if_fail(data != NULL, WFD_EINVAL); + g_return_val_if_fail(size != 0, WFD_EINVAL); + + p = (const gchar *) data; + while (TRUE) { + + if (*p == '\0') + break; + + idx = 0; + while (*p != '\n' && *p != '\r' && *p != '\0') { + if (idx < sizeof(buffer) - 1) + buffer[idx++] = *p; + p++; + } + buffer[idx] = '\0'; + wfdconfig_parse_line(msg, buffer); + + if (*p == '\0') + break; + p += 2; + } + + return WFD_OK; } /** @@ -1190,922 +1185,923 @@ wfdconfig_message_parse_buffer (const guint8 * data, guint size, WFDMessage * ms * Returns: a #WFDResult. */ WFDResult -wfdconfig_message_dump (const WFDMessage * msg) +wfdconfig_message_dump(const WFDMessage *msg) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - wfd_debug("===========WFD Message dump========="); - - if(msg->audio_codecs) { - guint i=0; - wfd_debug("Audio supported formats : \n"); - for(;iaudio_codecs->count;i++) { - wfd_debug("Codec: %s\n",msg->audio_codecs->list[i].audio_format); - if(!strcmp(msg->audio_codecs->list[i].audio_format,"LPCM")) { - if(msg->audio_codecs->list[i].modes & WFD_FREQ_44100) - wfd_debug(" Freq: %d\n", 44100); - if(msg->audio_codecs->list[i].modes & WFD_FREQ_48000) - wfd_debug(" Freq: %d\n", 48000); - wfd_debug(" Channels: %d\n", 2); - } - if(!strcmp(msg->audio_codecs->list[i].audio_format,"AAC")) { - wfd_debug(" Freq: %d\n", 48000); - if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_2) - wfd_debug(" Channels: %d\n", 2); - if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_4) - wfd_debug(" Channels: %d\n", 4); - if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_6) - wfd_debug(" Channels: %d\n", 6); - if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_8) - wfd_debug(" Channels: %d\n", 8); - } - if(!strcmp(msg->audio_codecs->list[i].audio_format,"AC3")) { - wfd_debug(" Freq: %d\n", 48000); - if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_2) - wfd_debug(" Channels: %d\n", 2); - if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_4) - wfd_debug(" Channels: %d\n", 4); - if(msg->audio_codecs->list[i].modes & WFD_CHANNEL_6) - wfd_debug(" Channels: %d\n", 6); - } - wfd_debug(" Bitwidth: %d\n", 16); - wfd_debug(" Latency: %d\n", msg->audio_codecs->list[i].latency); - } - } - - - if(msg->video_formats) { - wfd_debug("Video supported formats : \n"); - if(msg->video_formats->list) { - wfd_debug("Codec: H264\n"); - guint nativeindex = 0; - if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_CEA_RESOLUTION) { - wfd_debug (" Native type: CEA\n"); - } else if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_VESA_RESOLUTION) { - wfd_debug (" Native type: VESA\n"); - } else if((msg->video_formats->list->native & 0x7) == WFD_VIDEO_HH_RESOLUTION) { - wfd_debug (" Native type: HH\n"); - } - nativeindex = msg->video_formats->list->native >> 3; - wfd_debug (" Resolution: %d\n", (1 << nativeindex)); - - if(msg->video_formats->list->H264_codec.profile & WFD_H264_BASE_PROFILE) { - wfd_debug (" Profile: BASE\n"); - } else if(msg->video_formats->list->H264_codec.profile & WFD_H264_HIGH_PROFILE) { - wfd_debug (" Profile: HIGH\n"); - } if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_1) { - wfd_debug (" Level: 3.1\n"); - } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_2) { - wfd_debug (" Level: 3.2\n"); - } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4) { - wfd_debug (" Level: 4\n"); - } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_1) { - wfd_debug (" Level: 4.1\n"); - } else if(msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_2) { - wfd_debug (" Level: 4.2\n"); - } - wfd_debug (" Latency: %d\n", msg->video_formats->list->H264_codec.misc_params.latency); - wfd_debug (" min_slice_size: %x\n", msg->video_formats->list->H264_codec.misc_params.min_slice_size); - wfd_debug (" slice_enc_params: %x\n", msg->video_formats->list->H264_codec.misc_params.slice_enc_params); - wfd_debug (" frame_rate_control_support: %x\n", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support); - if(msg->video_formats->list->H264_codec.max_hres) { - wfd_debug (" Max Width: %04d\n", msg->video_formats->list->H264_codec.max_hres); - } - if(msg->video_formats->list->H264_codec.max_vres) { - wfd_debug (" Max Height: %04d\n", msg->video_formats->list->H264_codec.max_vres); - } - } - } - - if(msg->video_3d_formats) { - wfd_debug ("wfd_3d_formats"); - wfd_debug ("\r\n"); - } - - if(msg->content_protection) { - wfd_debug ("wfd_content_protection"); - wfd_debug ("\r\n"); - } - - if(msg->display_edid) { - wfd_debug ("wfd_display_edid"); - wfd_debug ("\r\n"); - } - - if(msg->coupled_sink) { - wfd_debug ("wfd_coupled_sink"); - wfd_debug ("\r\n"); - } - - if(msg->trigger_method) { - wfd_debug (" Trigger type: %s\n", msg->trigger_method->wfd_trigger_method); - } - - if(msg->presentation_url) { - wfd_debug ("wfd_presentation_URL"); - wfd_debug ("\r\n"); - } - - if(msg->client_rtp_ports) { - wfd_debug(" Client RTP Ports : \n"); - if(msg->client_rtp_ports->profile) { - wfd_debug ("%s\n", msg->client_rtp_ports->profile); - wfd_debug (" %d\n", msg->client_rtp_ports->rtp_port0); - wfd_debug (" %d\n", msg->client_rtp_ports->rtp_port1); - wfd_debug (" %s\n", msg->client_rtp_ports->mode); - } - wfd_debug("\r\n"); - } - - if(msg->route) { - wfd_debug ("wfd_route"); - wfd_debug ("\r\n"); - } - - if(msg->I2C) { - wfd_debug ("wfd_I2C"); - wfd_debug ("\r\n"); - } - - if(msg->av_format_change_timing) { - wfd_debug ("wfd_av_format_change_timing"); - wfd_debug ("\r\n"); - } - - if(msg->preferred_display_mode) { - wfd_debug ("wfd_preferred_display_mode"); - wfd_debug ("\r\n"); - } - - if(msg->uibc_capability) { - wfd_debug ("wfd_uibc_capability \r\n"); - wfd_debug ("input category list:"); - if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) - wfd_debug ("GENERIC"); - if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) - wfd_debug ("HIDC"); - if(!msg->uibc_capability->input_category_list.input_cat) - wfd_debug ("none"); - if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) { - wfd_debug ("generic cap list: "); - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) - wfd_debug("keyboard "); - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) - wfd_debug("mouse "); - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) - wfd_debug("single-touch "); - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) - wfd_debug("multi-touch "); - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) - wfd_debug("joystick "); - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) - wfd_debug("camera "); - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) - wfd_debug("gesture "); - if(msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) - wfd_debug("remote control "); - if(!msg->uibc_capability->generic_cap_list.inp_type) - wfd_debug("none "); - } - if(msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) { - wfd_debug ("hidc cap list:"); - if(msg->uibc_capability->hidc_cap_list.cap_count) { - detailed_cap *temp_cap = msg->uibc_capability->hidc_cap_list.next; - while (temp_cap) { - if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) { - wfd_debug("keyboard "); - } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) { - wfd_debug("mouse "); - } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) { - wfd_debug("single-touch "); - } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) { - wfd_debug("multi-touch "); - } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) { - wfd_debug("joystick "); - } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) { - wfd_debug("camera "); - } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) { - wfd_debug("gesture "); - } else if(temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) { - wfd_debug("remote control "); - } else if(!temp_cap->p.inp_type) { - wfd_debug("none "); - } - if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_INFRARED) { - wfd_debug("infrared"); - } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_USB) { - wfd_debug("usb"); - } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_BT) { - wfd_debug("bluetooth"); - } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_WIFI) { - wfd_debug("Wi-Fi"); - } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_ZIGBEE) { - wfd_debug("Zigbee"); - } else if(temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_NOSP) { - wfd_debug("No-SP"); - } else if(!temp_cap->p.inp_path) { - wfd_debug("none"); - } - temp_cap = temp_cap->next; - } - } - } - if(msg->uibc_capability->tcp_port) - wfd_debug("tcp port:%u", msg->uibc_capability->tcp_port); - if(!msg->uibc_capability->tcp_port) - wfd_debug ("tcp port: none"); - wfd_debug ("\r\n"); - } - - if(msg->uibc_setting) { - wfd_debug ("wfd_uibc_setting: "); - if(msg->uibc_setting->uibc_setting) { - wfd_debug("true"); - } else wfd_debug("false"); - wfd_debug ("\r\n"); - } - - if(msg->standby_resume_capability) { - wfd_debug ("wfd_standby_resume_capability"); - wfd_debug ("\r\n"); - } - - if(msg->standby) { - wfd_debug ("wfd_standby"); - wfd_debug ("\r\n"); - } - - if(msg->connector_type) { - wfd_debug ("wfd_connector_type"); - wfd_debug ("\r\n"); - } - - if(msg->idr_request) { - wfd_debug ("wfd_idr_request"); - wfd_debug ("\r\n"); - } - - wfd_debug("===============================================\n"); - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + wfd_debug("===========WFD Message dump========="); + + if (msg->audio_codecs) { + guint i = 0; + wfd_debug("Audio supported formats : \n"); + for (; i < msg->audio_codecs->count; i++) { + wfd_debug("Codec: %s\n", msg->audio_codecs->list[i].audio_format); + if (!strcmp(msg->audio_codecs->list[i].audio_format, "LPCM")) { + if (msg->audio_codecs->list[i].modes & WFD_FREQ_44100) + wfd_debug(" Freq: %d\n", 44100); + if (msg->audio_codecs->list[i].modes & WFD_FREQ_48000) + wfd_debug(" Freq: %d\n", 48000); + wfd_debug(" Channels: %d\n", 2); + } + if (!strcmp(msg->audio_codecs->list[i].audio_format, "AAC")) { + wfd_debug(" Freq: %d\n", 48000); + if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_2) + wfd_debug(" Channels: %d\n", 2); + if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_4) + wfd_debug(" Channels: %d\n", 4); + if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_6) + wfd_debug(" Channels: %d\n", 6); + if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_8) + wfd_debug(" Channels: %d\n", 8); + } + if (!strcmp(msg->audio_codecs->list[i].audio_format, "AC3")) { + wfd_debug(" Freq: %d\n", 48000); + if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_2) + wfd_debug(" Channels: %d\n", 2); + if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_4) + wfd_debug(" Channels: %d\n", 4); + if (msg->audio_codecs->list[i].modes & WFD_CHANNEL_6) + wfd_debug(" Channels: %d\n", 6); + } + wfd_debug(" Bitwidth: %d\n", 16); + wfd_debug(" Latency: %d\n", msg->audio_codecs->list[i].latency); + } + } + + + if (msg->video_formats) { + wfd_debug("Video supported formats : \n"); + if (msg->video_formats->list) { + wfd_debug("Codec: H264\n"); + guint nativeindex = 0; + if ((msg->video_formats->list->native & 0x7) == WFD_VIDEO_CEA_RESOLUTION) { + wfd_debug(" Native type: CEA\n"); + } else if ((msg->video_formats->list->native & 0x7) == WFD_VIDEO_VESA_RESOLUTION) { + wfd_debug(" Native type: VESA\n"); + } else if ((msg->video_formats->list->native & 0x7) == WFD_VIDEO_HH_RESOLUTION) { + wfd_debug(" Native type: HH\n"); + } + nativeindex = msg->video_formats->list->native >> 3; + wfd_debug(" Resolution: %d\n", (1 << nativeindex)); + + if (msg->video_formats->list->H264_codec.profile & WFD_H264_BASE_PROFILE) { + wfd_debug(" Profile: BASE\n"); + } else if (msg->video_formats->list->H264_codec.profile & WFD_H264_HIGH_PROFILE) { + wfd_debug(" Profile: HIGH\n"); + } + if (msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_1) { + wfd_debug(" Level: 3.1\n"); + } else if (msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_3_2) { + wfd_debug(" Level: 3.2\n"); + } else if (msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4) { + wfd_debug(" Level: 4\n"); + } else if (msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_1) { + wfd_debug(" Level: 4.1\n"); + } else if (msg->video_formats->list->H264_codec.level & WFD_H264_LEVEL_4_2) { + wfd_debug(" Level: 4.2\n"); + } + wfd_debug(" Latency: %d\n", msg->video_formats->list->H264_codec.misc_params.latency); + wfd_debug(" min_slice_size: %x\n", msg->video_formats->list->H264_codec.misc_params.min_slice_size); + wfd_debug(" slice_enc_params: %x\n", msg->video_formats->list->H264_codec.misc_params.slice_enc_params); + wfd_debug(" frame_rate_control_support: %x\n", msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support); + if (msg->video_formats->list->H264_codec.max_hres) { + wfd_debug(" Max Width: %04d\n", msg->video_formats->list->H264_codec.max_hres); + } + if (msg->video_formats->list->H264_codec.max_vres) { + wfd_debug(" Max Height: %04d\n", msg->video_formats->list->H264_codec.max_vres); + } + } + } + + if (msg->video_3d_formats) { + wfd_debug("wfd_3d_formats"); + wfd_debug("\r\n"); + } + + if (msg->content_protection) { + wfd_debug("wfd_content_protection"); + wfd_debug("\r\n"); + } + + if (msg->display_edid) { + wfd_debug("wfd_display_edid"); + wfd_debug("\r\n"); + } + + if (msg->coupled_sink) { + wfd_debug("wfd_coupled_sink"); + wfd_debug("\r\n"); + } + + if (msg->trigger_method) { + wfd_debug(" Trigger type: %s\n", msg->trigger_method->wfd_trigger_method); + } + + if (msg->presentation_url) { + wfd_debug("wfd_presentation_URL"); + wfd_debug("\r\n"); + } + + if (msg->client_rtp_ports) { + wfd_debug(" Client RTP Ports : \n"); + if (msg->client_rtp_ports->profile) { + wfd_debug("%s\n", msg->client_rtp_ports->profile); + wfd_debug(" %d\n", msg->client_rtp_ports->rtp_port0); + wfd_debug(" %d\n", msg->client_rtp_ports->rtp_port1); + wfd_debug(" %s\n", msg->client_rtp_ports->mode); + } + wfd_debug("\r\n"); + } + + if (msg->route) { + wfd_debug("wfd_route"); + wfd_debug("\r\n"); + } + + if (msg->I2C) { + wfd_debug("wfd_I2C"); + wfd_debug("\r\n"); + } + + if (msg->av_format_change_timing) { + wfd_debug("wfd_av_format_change_timing"); + wfd_debug("\r\n"); + } + + if (msg->preferred_display_mode) { + wfd_debug("wfd_preferred_display_mode"); + wfd_debug("\r\n"); + } + + if (msg->uibc_capability) { + wfd_debug("wfd_uibc_capability \r\n"); + wfd_debug("input category list:"); + if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) + wfd_debug("GENERIC"); + if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) + wfd_debug("HIDC"); + if (!msg->uibc_capability->input_category_list.input_cat) + wfd_debug("none"); + if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_GENERIC) { + wfd_debug("generic cap list: "); + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) + wfd_debug("keyboard "); + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) + wfd_debug("mouse "); + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) + wfd_debug("single-touch "); + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) + wfd_debug("multi-touch "); + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) + wfd_debug("joystick "); + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) + wfd_debug("camera "); + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) + wfd_debug("gesture "); + if (msg->uibc_capability->generic_cap_list.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) + wfd_debug("remote control "); + if (!msg->uibc_capability->generic_cap_list.inp_type) + wfd_debug("none "); + } + if (msg->uibc_capability->input_category_list.input_cat & WFD_UIBC_INPUT_CAT_HIDC) { + wfd_debug("hidc cap list:"); + if (msg->uibc_capability->hidc_cap_list.cap_count) { + detailed_cap *temp_cap = msg->uibc_capability->hidc_cap_list.next; + while (temp_cap) { + if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_KEYBOARD) { + wfd_debug("keyboard "); + } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_MOUSE) { + wfd_debug("mouse "); + } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_SINGLETOUCH) { + wfd_debug("single-touch "); + } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_MULTITOUCH) { + wfd_debug("multi-touch "); + } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_JOYSTICK) { + wfd_debug("joystick "); + } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_CAMERA) { + wfd_debug("camera "); + } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_GESTURE) { + wfd_debug("gesture "); + } else if (temp_cap->p.inp_type & WFD_UIBC_INPUT_TYPE_REMOTECONTROL) { + wfd_debug("remote control "); + } else if (!temp_cap->p.inp_type) { + wfd_debug("none "); + } + if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_INFRARED) { + wfd_debug("infrared"); + } else if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_USB) { + wfd_debug("usb"); + } else if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_BT) { + wfd_debug("bluetooth"); + } else if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_WIFI) { + wfd_debug("Wi-Fi"); + } else if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_ZIGBEE) { + wfd_debug("Zigbee"); + } else if (temp_cap->p.inp_path & WFD_UIBC_INPUT_PATH_NOSP) { + wfd_debug("No-SP"); + } else if (!temp_cap->p.inp_path) { + wfd_debug("none"); + } + temp_cap = temp_cap->next; + } + } + } + if (msg->uibc_capability->tcp_port) + wfd_debug("tcp port:%u", msg->uibc_capability->tcp_port); + if (!msg->uibc_capability->tcp_port) + wfd_debug("tcp port: none"); + wfd_debug("\r\n"); + } + + if (msg->uibc_setting) { + wfd_debug("wfd_uibc_setting: "); + if (msg->uibc_setting->uibc_setting) { + wfd_debug("true"); + } else wfd_debug("false"); + wfd_debug("\r\n"); + } + + if (msg->standby_resume_capability) { + wfd_debug("wfd_standby_resume_capability"); + wfd_debug("\r\n"); + } + + if (msg->standby) { + wfd_debug("wfd_standby"); + wfd_debug("\r\n"); + } + + if (msg->connector_type) { + wfd_debug("wfd_connector_type"); + wfd_debug("\r\n"); + } + + if (msg->idr_request) { + wfd_debug("wfd_idr_request"); + wfd_debug("\r\n"); + } + + wfd_debug("===============================================\n"); + return WFD_OK; } WFDResult wfdconfig_set_supported_audio_format(WFDMessage *msg, WFDAudioFormats aCodec, guint aFreq, guint aChanels, - guint aBitwidth, guint32 aLatency) + guint aBitwidth, guint32 aLatency) { - guint temp = aCodec; - guint i = 0; - guint pcm = 0, aac = 0, ac3 = 0; - - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - - if(!msg->audio_codecs) - msg->audio_codecs = g_new0 (WFDAudioCodeclist, 1); - - if(aCodec != WFD_AUDIO_UNKNOWN) { - while(temp) { - msg->audio_codecs->count++; - temp >>= 1; - } - msg->audio_codecs->list = g_new0 (WFDAudioCodec, msg->audio_codecs->count); - for(; iaudio_codecs->count; i++) { - if((aCodec & WFD_AUDIO_LPCM) && (!pcm)) { - msg->audio_codecs->list[i].audio_format = g_strdup("LPCM"); - msg->audio_codecs->list[i].modes = aFreq; - msg->audio_codecs->list[i].latency = aLatency; - pcm = 1; - } else if((aCodec & WFD_AUDIO_AAC) && (!aac)) { - msg->audio_codecs->list[i].audio_format = g_strdup("AAC"); - msg->audio_codecs->list[i].modes = aChanels; - msg->audio_codecs->list[i].latency = aLatency; - aac = 1; - } else if((aCodec & WFD_AUDIO_AC3) && (!ac3)) { - msg->audio_codecs->list[i].audio_format = g_strdup("AC3"); - msg->audio_codecs->list[i].modes = aChanels; - msg->audio_codecs->list[i].latency = aLatency; - ac3 = 1; - } - } - } - return WFD_OK; + guint temp = aCodec; + guint i = 0; + guint pcm = 0, aac = 0, ac3 = 0; + + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + + if (!msg->audio_codecs) + msg->audio_codecs = g_new0(WFDAudioCodeclist, 1); + + if (aCodec != WFD_AUDIO_UNKNOWN) { + while (temp) { + msg->audio_codecs->count++; + temp >>= 1; + } + msg->audio_codecs->list = g_new0(WFDAudioCodec, msg->audio_codecs->count); + for (; i < msg->audio_codecs->count; i++) { + if ((aCodec & WFD_AUDIO_LPCM) && (!pcm)) { + msg->audio_codecs->list[i].audio_format = g_strdup("LPCM"); + msg->audio_codecs->list[i].modes = aFreq; + msg->audio_codecs->list[i].latency = aLatency; + pcm = 1; + } else if ((aCodec & WFD_AUDIO_AAC) && (!aac)) { + msg->audio_codecs->list[i].audio_format = g_strdup("AAC"); + msg->audio_codecs->list[i].modes = aChanels; + msg->audio_codecs->list[i].latency = aLatency; + aac = 1; + } else if ((aCodec & WFD_AUDIO_AC3) && (!ac3)) { + msg->audio_codecs->list[i].audio_format = g_strdup("AC3"); + msg->audio_codecs->list[i].modes = aChanels; + msg->audio_codecs->list[i].latency = aLatency; + ac3 = 1; + } + } + } + return WFD_OK; } WFDResult wfdconfig_set_prefered_audio_format(WFDMessage *msg, WFDAudioFormats aCodec, WFDAudioFreq aFreq, WFDAudioChannels aChanels, - guint aBitwidth, guint32 aLatency) + guint aBitwidth, guint32 aLatency) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - - if(!msg->audio_codecs) - msg->audio_codecs = g_new0 (WFDAudioCodeclist, 1); - - msg->audio_codecs->list = g_new0 (WFDAudioCodec, 1); - msg->audio_codecs->count = 1; - if(aCodec == WFD_AUDIO_LPCM) { - msg->audio_codecs->list->audio_format = g_strdup("LPCM"); - msg->audio_codecs->list->modes = aFreq; - msg->audio_codecs->list->latency = aLatency; - } else if(aCodec == WFD_AUDIO_AAC) { - msg->audio_codecs->list->audio_format = g_strdup("AAC"); - msg->audio_codecs->list->modes = aChanels; - msg->audio_codecs->list->latency = aLatency; - } else if(aCodec == WFD_AUDIO_AC3) { - msg->audio_codecs->list->audio_format = g_strdup("AC3"); - msg->audio_codecs->list->modes = aChanels; - msg->audio_codecs->list->latency = aLatency; - } - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + + if (!msg->audio_codecs) + msg->audio_codecs = g_new0(WFDAudioCodeclist, 1); + + msg->audio_codecs->list = g_new0(WFDAudioCodec, 1); + msg->audio_codecs->count = 1; + if (aCodec == WFD_AUDIO_LPCM) { + msg->audio_codecs->list->audio_format = g_strdup("LPCM"); + msg->audio_codecs->list->modes = aFreq; + msg->audio_codecs->list->latency = aLatency; + } else if (aCodec == WFD_AUDIO_AAC) { + msg->audio_codecs->list->audio_format = g_strdup("AAC"); + msg->audio_codecs->list->modes = aChanels; + msg->audio_codecs->list->latency = aLatency; + } else if (aCodec == WFD_AUDIO_AC3) { + msg->audio_codecs->list->audio_format = g_strdup("AC3"); + msg->audio_codecs->list->modes = aChanels; + msg->audio_codecs->list->latency = aLatency; + } + return WFD_OK; } WFDResult wfdconfig_get_supported_audio_format(WFDMessage *msg, guint *aCodec, guint *aFreq, guint *aChanels, - guint *aBitwidth, guint32 *aLatency) + guint *aBitwidth, guint32 *aLatency) { - guint i = 0; - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - g_return_val_if_fail (msg->audio_codecs != NULL, WFD_EINVAL); - - for(; iaudio_codecs->count; i++) { - if(!g_strcmp0(msg->audio_codecs->list[i].audio_format,"LPCM")) { - *aCodec |= WFD_AUDIO_LPCM; - *aFreq |= msg->audio_codecs->list[i].modes; - *aChanels |= WFD_CHANNEL_2; - *aBitwidth = 16; - *aLatency = msg->audio_codecs->list[i].latency; - } else if(!g_strcmp0(msg->audio_codecs->list[i].audio_format,"AAC")) { - *aCodec |= WFD_AUDIO_AAC; - *aFreq |= WFD_FREQ_48000; - *aChanels |= msg->audio_codecs->list[i].modes; - *aBitwidth = 16; - *aLatency = msg->audio_codecs->list[i].latency; - } else if(!g_strcmp0(msg->audio_codecs->list[i].audio_format,"AC3")) { - *aCodec |= WFD_AUDIO_AC3; - *aFreq |= WFD_FREQ_48000; - *aChanels |= msg->audio_codecs->list[i].modes; - *aBitwidth = 16; - *aLatency = msg->audio_codecs->list[i].latency; - } - } - return WFD_OK; + guint i = 0; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + g_return_val_if_fail(msg->audio_codecs != NULL, WFD_EINVAL); + + for (; i < msg->audio_codecs->count; i++) { + if (!g_strcmp0(msg->audio_codecs->list[i].audio_format, "LPCM")) { + *aCodec |= WFD_AUDIO_LPCM; + *aFreq |= msg->audio_codecs->list[i].modes; + *aChanels |= WFD_CHANNEL_2; + *aBitwidth = 16; + *aLatency = msg->audio_codecs->list[i].latency; + } else if (!g_strcmp0(msg->audio_codecs->list[i].audio_format, "AAC")) { + *aCodec |= WFD_AUDIO_AAC; + *aFreq |= WFD_FREQ_48000; + *aChanels |= msg->audio_codecs->list[i].modes; + *aBitwidth = 16; + *aLatency = msg->audio_codecs->list[i].latency; + } else if (!g_strcmp0(msg->audio_codecs->list[i].audio_format, "AC3")) { + *aCodec |= WFD_AUDIO_AC3; + *aFreq |= WFD_FREQ_48000; + *aChanels |= msg->audio_codecs->list[i].modes; + *aBitwidth = 16; + *aLatency = msg->audio_codecs->list[i].latency; + } + } + return WFD_OK; } WFDResult wfdconfig_get_prefered_audio_format(WFDMessage *msg, WFDAudioFormats *aCodec, WFDAudioFreq *aFreq, WFDAudioChannels *aChanels, - guint *aBitwidth, guint32 *aLatency) + guint *aBitwidth, guint32 *aLatency) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - - if(!g_strcmp0(msg->audio_codecs->list->audio_format,"LPCM")) { - *aCodec = WFD_AUDIO_LPCM; - *aFreq = msg->audio_codecs->list->modes; - *aChanels = WFD_CHANNEL_2; - *aBitwidth = 16; - *aLatency = msg->audio_codecs->list->latency; - } else if(!g_strcmp0(msg->audio_codecs->list->audio_format,"AAC")) { - *aCodec = WFD_AUDIO_AAC; - *aFreq = WFD_FREQ_48000; - *aChanels = msg->audio_codecs->list->modes; - *aBitwidth = 16; - *aLatency = msg->audio_codecs->list->latency; - } else if(!g_strcmp0(msg->audio_codecs->list->audio_format,"AC3")) { - *aCodec = WFD_AUDIO_AC3; - *aFreq = WFD_FREQ_48000; - *aChanels = msg->audio_codecs->list->modes; - *aBitwidth = 16; - *aLatency = msg->audio_codecs->list->latency; - } - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + + if (!g_strcmp0(msg->audio_codecs->list->audio_format, "LPCM")) { + *aCodec = WFD_AUDIO_LPCM; + *aFreq = msg->audio_codecs->list->modes; + *aChanels = WFD_CHANNEL_2; + *aBitwidth = 16; + *aLatency = msg->audio_codecs->list->latency; + } else if (!g_strcmp0(msg->audio_codecs->list->audio_format, "AAC")) { + *aCodec = WFD_AUDIO_AAC; + *aFreq = WFD_FREQ_48000; + *aChanels = msg->audio_codecs->list->modes; + *aBitwidth = 16; + *aLatency = msg->audio_codecs->list->latency; + } else if (!g_strcmp0(msg->audio_codecs->list->audio_format, "AC3")) { + *aCodec = WFD_AUDIO_AC3; + *aFreq = WFD_FREQ_48000; + *aChanels = msg->audio_codecs->list->modes; + *aBitwidth = 16; + *aLatency = msg->audio_codecs->list->latency; + } + return WFD_OK; } WFDResult wfdconfig_set_supported_video_format(WFDMessage *msg, WFDVideoCodecs vCodec, - WFDVideoNativeResolution vNative, guint64 vNativeResolution, - guint64 vCEAResolution, guint64 vVESAResolution, guint64 vHHResolution, - guint vProfile, guint vLevel, guint32 vLatency, guint32 vMaxHeight, - guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control) + WFDVideoNativeResolution vNative, guint64 vNativeResolution, + guint64 vCEAResolution, guint64 vVESAResolution, guint64 vHHResolution, + guint vProfile, guint vLevel, guint32 vLatency, guint32 vMaxHeight, + guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control) { - guint nativeindex = 0; - guint64 temp = vNativeResolution; - - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - - if(!msg->video_formats) - msg->video_formats = g_new0 (WFDVideoCodeclist, 1); - - if(vCodec != WFD_VIDEO_UNKNOWN) { - msg->video_formats->list = g_new0 (WFDVideoCodec, 1); - while(temp) { - nativeindex++; - temp >>= 1; - } - - msg->video_formats->list->native = nativeindex-1; - msg->video_formats->list->native <<= 3; - - if(vNative == WFD_VIDEO_VESA_RESOLUTION) - msg->video_formats->list->native |= 1; - else if(vNative == WFD_VIDEO_HH_RESOLUTION) - msg->video_formats->list->native |= 2; - - msg->video_formats->list->preferred_display_mode_supported = 1; - msg->video_formats->list->H264_codec.profile = vProfile; - msg->video_formats->list->H264_codec.level = vLevel; - msg->video_formats->list->H264_codec.max_hres = vMaxWidth; - msg->video_formats->list->H264_codec.max_vres = vMaxHeight; - msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution; - msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution; - msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution; - msg->video_formats->list->H264_codec.misc_params.latency = vLatency; - msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size; - msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params; - msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control; - } - return WFD_OK; + guint nativeindex = 0; + guint64 temp = vNativeResolution; + + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + + if (!msg->video_formats) + msg->video_formats = g_new0(WFDVideoCodeclist, 1); + + if (vCodec != WFD_VIDEO_UNKNOWN) { + msg->video_formats->list = g_new0(WFDVideoCodec, 1); + while (temp) { + nativeindex++; + temp >>= 1; + } + + msg->video_formats->list->native = nativeindex - 1; + msg->video_formats->list->native <<= 3; + + if (vNative == WFD_VIDEO_VESA_RESOLUTION) + msg->video_formats->list->native |= 1; + else if (vNative == WFD_VIDEO_HH_RESOLUTION) + msg->video_formats->list->native |= 2; + + msg->video_formats->list->preferred_display_mode_supported = 1; + msg->video_formats->list->H264_codec.profile = vProfile; + msg->video_formats->list->H264_codec.level = vLevel; + msg->video_formats->list->H264_codec.max_hres = vMaxWidth; + msg->video_formats->list->H264_codec.max_vres = vMaxHeight; + msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution; + msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution; + msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution; + msg->video_formats->list->H264_codec.misc_params.latency = vLatency; + msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size; + msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params; + msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control; + } + return WFD_OK; } WFDResult wfdconfig_set_prefered_video_format(WFDMessage *msg, WFDVideoCodecs vCodec, - WFDVideoNativeResolution vNative, guint64 vNativeResolution, - WFDVideoCEAResolution vCEAResolution, WFDVideoVESAResolution vVESAResolution, - WFDVideoHHResolution vHHResolution, WFDVideoH264Profile vProfile, - WFDVideoH264Level vLevel, guint32 vLatency, guint32 vMaxHeight, - guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control) + WFDVideoNativeResolution vNative, guint64 vNativeResolution, + WFDVideoCEAResolution vCEAResolution, WFDVideoVESAResolution vVESAResolution, + WFDVideoHHResolution vHHResolution, WFDVideoH264Profile vProfile, + WFDVideoH264Level vLevel, guint32 vLatency, guint32 vMaxHeight, + guint32 vMaxWidth, guint32 min_slice_size, guint32 slice_enc_params, guint frame_rate_control) { - guint nativeindex = 0; - guint64 temp = vNativeResolution; - - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - - if(!msg->video_formats) - msg->video_formats = g_new0 (WFDVideoCodeclist, 1); - msg->video_formats->list = g_new0 (WFDVideoCodec, 1); - - while(temp) { - nativeindex++; - temp >>= 1; - } - - if(nativeindex) msg->video_formats->list->native = nativeindex-1; - msg->video_formats->list->native <<= 3; - - if(vNative == WFD_VIDEO_VESA_RESOLUTION) - msg->video_formats->list->native |= 1; - else if(vNative == WFD_VIDEO_HH_RESOLUTION) - msg->video_formats->list->native |= 2; - - msg->video_formats->list->preferred_display_mode_supported = 0; - msg->video_formats->list->H264_codec.profile = vProfile; - msg->video_formats->list->H264_codec.level = vLevel; - msg->video_formats->list->H264_codec.max_hres = vMaxWidth; - msg->video_formats->list->H264_codec.max_vres = vMaxHeight; - msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution; - msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution; - msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution; - msg->video_formats->list->H264_codec.misc_params.latency = vLatency; - msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size; - msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params; - msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control; - return WFD_OK; + guint nativeindex = 0; + guint64 temp = vNativeResolution; + + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + + if (!msg->video_formats) + msg->video_formats = g_new0(WFDVideoCodeclist, 1); + msg->video_formats->list = g_new0(WFDVideoCodec, 1); + + while (temp) { + nativeindex++; + temp >>= 1; + } + + if (nativeindex) msg->video_formats->list->native = nativeindex - 1; + msg->video_formats->list->native <<= 3; + + if (vNative == WFD_VIDEO_VESA_RESOLUTION) + msg->video_formats->list->native |= 1; + else if (vNative == WFD_VIDEO_HH_RESOLUTION) + msg->video_formats->list->native |= 2; + + msg->video_formats->list->preferred_display_mode_supported = 0; + msg->video_formats->list->H264_codec.profile = vProfile; + msg->video_formats->list->H264_codec.level = vLevel; + msg->video_formats->list->H264_codec.max_hres = vMaxWidth; + msg->video_formats->list->H264_codec.max_vres = vMaxHeight; + msg->video_formats->list->H264_codec.misc_params.CEA_Support = vCEAResolution; + msg->video_formats->list->H264_codec.misc_params.VESA_Support = vVESAResolution; + msg->video_formats->list->H264_codec.misc_params.HH_Support = vHHResolution; + msg->video_formats->list->H264_codec.misc_params.latency = vLatency; + msg->video_formats->list->H264_codec.misc_params.min_slice_size = min_slice_size; + msg->video_formats->list->H264_codec.misc_params.slice_enc_params = slice_enc_params; + msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support = frame_rate_control; + return WFD_OK; } WFDResult wfdconfig_get_supported_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec, - WFDVideoNativeResolution *vNative, guint64 *vNativeResolution, - guint64 *vCEAResolution, guint64 *vVESAResolution, guint64 *vHHResolution, - guint *vProfile, guint *vLevel, guint32 *vLatency, guint32 *vMaxHeight, - guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control) + WFDVideoNativeResolution *vNative, guint64 *vNativeResolution, + guint64 *vCEAResolution, guint64 *vVESAResolution, guint64 *vHHResolution, + guint *vProfile, guint *vLevel, guint32 *vLatency, guint32 *vMaxHeight, + guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control) { - guint nativeindex = 0; - - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - g_return_val_if_fail (msg->video_formats != NULL, WFD_EINVAL); - g_return_val_if_fail (msg->video_formats->list != NULL, WFD_EINVAL); - - *vCodec = WFD_VIDEO_H264; - *vNative = msg->video_formats->list->native & 0x7; - nativeindex = msg->video_formats->list->native >> 3; - *vNativeResolution = (guint64)1 << nativeindex; - *vProfile = msg->video_formats->list->H264_codec.profile; - *vLevel = msg->video_formats->list->H264_codec.level; - *vMaxWidth = msg->video_formats->list->H264_codec.max_hres; - *vMaxHeight = msg->video_formats->list->H264_codec.max_vres; - *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support; - *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support; - *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support; - *vLatency = msg->video_formats->list->H264_codec.misc_params.latency; - *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size; - *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params; - *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support; - return WFD_OK; + guint nativeindex = 0; + + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + g_return_val_if_fail(msg->video_formats != NULL, WFD_EINVAL); + g_return_val_if_fail(msg->video_formats->list != NULL, WFD_EINVAL); + + *vCodec = WFD_VIDEO_H264; + *vNative = msg->video_formats->list->native & 0x7; + nativeindex = msg->video_formats->list->native >> 3; + *vNativeResolution = (guint64)1 << nativeindex; + *vProfile = msg->video_formats->list->H264_codec.profile; + *vLevel = msg->video_formats->list->H264_codec.level; + *vMaxWidth = msg->video_formats->list->H264_codec.max_hres; + *vMaxHeight = msg->video_formats->list->H264_codec.max_vres; + *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support; + *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support; + *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support; + *vLatency = msg->video_formats->list->H264_codec.misc_params.latency; + *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size; + *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params; + *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support; + return WFD_OK; } WFDResult wfdconfig_get_prefered_video_format(WFDMessage *msg, WFDVideoCodecs *vCodec, - WFDVideoNativeResolution *vNative, guint64 *vNativeResolution, - WFDVideoCEAResolution *vCEAResolution, WFDVideoVESAResolution *vVESAResolution, - WFDVideoHHResolution *vHHResolution, WFDVideoH264Profile *vProfile, - WFDVideoH264Level *vLevel, guint32 *vLatency, guint32 *vMaxHeight, - guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control) + WFDVideoNativeResolution *vNative, guint64 *vNativeResolution, + WFDVideoCEAResolution *vCEAResolution, WFDVideoVESAResolution *vVESAResolution, + WFDVideoHHResolution *vHHResolution, WFDVideoH264Profile *vProfile, + WFDVideoH264Level *vLevel, guint32 *vLatency, guint32 *vMaxHeight, + guint32 *vMaxWidth, guint32 *min_slice_size, guint32 *slice_enc_params, guint *frame_rate_control) { - guint nativeindex = 0; - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - g_return_val_if_fail (msg->video_formats != NULL, WFD_EINVAL); - g_return_val_if_fail (msg->video_formats->list != NULL, WFD_EINVAL); - - *vCodec = WFD_VIDEO_H264; - *vNative = msg->video_formats->list->native & 0x7; - nativeindex = msg->video_formats->list->native >> 3; - *vNativeResolution = (guint64)1 << nativeindex; - *vProfile = msg->video_formats->list->H264_codec.profile; - *vLevel = msg->video_formats->list->H264_codec.level; - *vMaxWidth = msg->video_formats->list->H264_codec.max_hres; - *vMaxHeight = msg->video_formats->list->H264_codec.max_vres; - *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support; - *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support; - *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support; - *vLatency = msg->video_formats->list->H264_codec.misc_params.latency; - *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size; - *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params; - *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support; - return WFD_OK; + guint nativeindex = 0; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + g_return_val_if_fail(msg->video_formats != NULL, WFD_EINVAL); + g_return_val_if_fail(msg->video_formats->list != NULL, WFD_EINVAL); + + *vCodec = WFD_VIDEO_H264; + *vNative = msg->video_formats->list->native & 0x7; + nativeindex = msg->video_formats->list->native >> 3; + *vNativeResolution = (guint64)1 << nativeindex; + *vProfile = msg->video_formats->list->H264_codec.profile; + *vLevel = msg->video_formats->list->H264_codec.level; + *vMaxWidth = msg->video_formats->list->H264_codec.max_hres; + *vMaxHeight = msg->video_formats->list->H264_codec.max_vres; + *vCEAResolution = msg->video_formats->list->H264_codec.misc_params.CEA_Support; + *vVESAResolution = msg->video_formats->list->H264_codec.misc_params.VESA_Support; + *vHHResolution = msg->video_formats->list->H264_codec.misc_params.HH_Support; + *vLatency = msg->video_formats->list->H264_codec.misc_params.latency; + *min_slice_size = msg->video_formats->list->H264_codec.misc_params.min_slice_size; + *slice_enc_params = msg->video_formats->list->H264_codec.misc_params.slice_enc_params; + *frame_rate_control = msg->video_formats->list->H264_codec.misc_params.frame_rate_control_support; + return WFD_OK; } WFDResult wfdconfig_set_contentprotection_type(WFDMessage *msg, WFDHDCPProtection hdcpversion, guint32 TCPPort) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - - if(!msg->content_protection) msg->content_protection = g_new0 (WFDContentProtection, 1); - if(hdcpversion == WFD_HDCP_NONE) return WFD_OK; - msg->content_protection->hdcp2_spec = g_new0 (WFDHdcp2Spec, 1); - if(hdcpversion == WFD_HDCP_2_0) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup("HDCP2.0"); - else if(hdcpversion == WFD_HDCP_2_1) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup("HDCP2.1"); - char str[11]={0,}; - snprintf(str, 11, "port=%d", TCPPort); - msg->content_protection->hdcp2_spec->TCPPort = g_strdup(str); - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + + if (!msg->content_protection) msg->content_protection = g_new0(WFDContentProtection, 1); + if (hdcpversion == WFD_HDCP_NONE) return WFD_OK; + msg->content_protection->hdcp2_spec = g_new0(WFDHdcp2Spec, 1); + if (hdcpversion == WFD_HDCP_2_0) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup("HDCP2.0"); + else if (hdcpversion == WFD_HDCP_2_1) msg->content_protection->hdcp2_spec->hdcpversion = g_strdup("HDCP2.1"); + char str[11] = {0, }; + snprintf(str, 11, "port=%d", TCPPort); + msg->content_protection->hdcp2_spec->TCPPort = g_strdup(str); + return WFD_OK; } WFDResult wfdconfig_get_contentprotection_type(WFDMessage *msg, WFDHDCPProtection *hdcpversion, guint32 *TCPPort) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(msg->content_protection && msg->content_protection->hdcp2_spec) { - char *result = NULL; - char *ptr = NULL; - if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"none")) { - wfd_warning("HDCP none"); - *hdcpversion = WFD_HDCP_NONE; - *TCPPort = 0; - return WFD_OK; - } - if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"HDCP2.0")) *hdcpversion = WFD_HDCP_2_0; - else if(!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion,"HDCP2.1")) *hdcpversion = WFD_HDCP_2_1; - else { - wfd_warning("Unknown protection type"); - *hdcpversion = WFD_HDCP_NONE; - *TCPPort = 0; - return WFD_OK; - } - - result = strtok_r(msg->content_protection->hdcp2_spec->TCPPort, "=", &ptr); - while (result !=NULL) { - result = strtok_r(NULL, "=", &ptr); - *TCPPort = atoi (result); - break; - } - } else *hdcpversion = WFD_HDCP_NONE; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (msg->content_protection && msg->content_protection->hdcp2_spec) { + char *result = NULL; + char *ptr = NULL; + if (!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion, "none")) { + wfd_warning("HDCP none"); + *hdcpversion = WFD_HDCP_NONE; + *TCPPort = 0; + return WFD_OK; + } + if (!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion, "HDCP2.0")) *hdcpversion = WFD_HDCP_2_0; + else if (!g_strcmp0(msg->content_protection->hdcp2_spec->hdcpversion, "HDCP2.1")) *hdcpversion = WFD_HDCP_2_1; + else { + wfd_warning("Unknown protection type"); + *hdcpversion = WFD_HDCP_NONE; + *TCPPort = 0; + return WFD_OK; + } + + result = strtok_r(msg->content_protection->hdcp2_spec->TCPPort, "=", &ptr); + while (result != NULL) { + result = strtok_r(NULL, "=", &ptr); + *TCPPort = atoi(result); + break; + } + } else *hdcpversion = WFD_HDCP_NONE; + return WFD_OK; } WFDResult wfdconfig_set_display_EDID(WFDMessage *msg, gboolean edid_supported, guint32 edid_blockcount, gchar *edid_playload) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(!msg->display_edid) msg->display_edid = g_new0 (WFDDisplayEdid, 1); - msg->display_edid->edid_supported = edid_supported; - if(!edid_supported) return WFD_OK; - msg->display_edid->edid_block_count = edid_blockcount; - if(edid_blockcount) { - msg->display_edid->edid_payload = g_malloc(128 * edid_blockcount); - if(!msg->display_edid->edid_payload) - memcpy(msg->display_edid->edid_payload, edid_playload, 128 * edid_blockcount); - } else msg->display_edid->edid_payload = g_strdup("none"); - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (!msg->display_edid) msg->display_edid = g_new0(WFDDisplayEdid, 1); + msg->display_edid->edid_supported = edid_supported; + if (!edid_supported) return WFD_OK; + msg->display_edid->edid_block_count = edid_blockcount; + if (edid_blockcount) { + msg->display_edid->edid_payload = g_malloc(128 * edid_blockcount); + if (!msg->display_edid->edid_payload) + memcpy(msg->display_edid->edid_payload, edid_playload, 128 * edid_blockcount); + } else msg->display_edid->edid_payload = g_strdup("none"); + return WFD_OK; } WFDResult wfdconfig_get_display_EDID(WFDMessage *msg, gboolean *edid_supported, guint32 *edid_blockcount, gchar **edid_playload) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(msg->display_edid ) { - if(msg->display_edid->edid_supported) { - *edid_blockcount = msg->display_edid->edid_block_count; - if(msg->display_edid->edid_block_count) { - char * temp; - temp = g_malloc(EDID_BLOCK_SIZE * msg->display_edid->edid_block_count); - if(temp) { - memset(temp, 0, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count); - memcpy(temp, msg->display_edid->edid_payload, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count); - *edid_playload = temp; - *edid_supported = TRUE; - } - } else *edid_playload = g_strdup("none"); - } - } else *edid_supported = FALSE; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (msg->display_edid) { + if (msg->display_edid->edid_supported) { + *edid_blockcount = msg->display_edid->edid_block_count; + if (msg->display_edid->edid_block_count) { + char *temp; + temp = g_malloc(EDID_BLOCK_SIZE * msg->display_edid->edid_block_count); + if (temp) { + memset(temp, 0, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count); + memcpy(temp, msg->display_edid->edid_payload, EDID_BLOCK_SIZE * msg->display_edid->edid_block_count); + *edid_playload = temp; + *edid_supported = TRUE; + } + } else *edid_playload = g_strdup("none"); + } + } else *edid_supported = FALSE; + return WFD_OK; } WFDResult wfdconfig_set_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus status, gchar *sink_address) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(!msg->coupled_sink) msg->coupled_sink = g_new0 (WFDCoupledSink, 1); - if(status == WFD_SINK_UNKNOWN) return WFD_OK; - msg->coupled_sink->coupled_sink_cap = g_new0 (WFDCoupled_sink_cap, 1); - msg->coupled_sink->coupled_sink_cap->status = status; - msg->coupled_sink->coupled_sink_cap->sink_address = g_strdup(sink_address); - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (!msg->coupled_sink) msg->coupled_sink = g_new0(WFDCoupledSink, 1); + if (status == WFD_SINK_UNKNOWN) return WFD_OK; + msg->coupled_sink->coupled_sink_cap = g_new0(WFDCoupled_sink_cap, 1); + msg->coupled_sink->coupled_sink_cap->status = status; + msg->coupled_sink->coupled_sink_cap->sink_address = g_strdup(sink_address); + return WFD_OK; } WFDResult wfdconfig_get_coupled_sink(WFDMessage *msg, WFDCoupledSinkStatus *status, gchar **sink_address) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(msg->coupled_sink && msg->coupled_sink->coupled_sink_cap) { - *status = msg->coupled_sink->coupled_sink_cap->status; - *sink_address = g_strdup(msg->coupled_sink->coupled_sink_cap->sink_address); - } else *status = WFD_SINK_UNKNOWN; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (msg->coupled_sink && msg->coupled_sink->coupled_sink_cap) { + *status = msg->coupled_sink->coupled_sink_cap->status; + *sink_address = g_strdup(msg->coupled_sink->coupled_sink_cap->sink_address); + } else *status = WFD_SINK_UNKNOWN; + return WFD_OK; } WFDResult wfdconfig_set_trigger_type(WFDMessage *msg, WFDTrigger trigger) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - - if(!msg->trigger_method) - msg->trigger_method = g_new0 (WFDTriggerMethod, 1); - if(trigger == WFD_TRIGGER_SETUP) - msg->trigger_method->wfd_trigger_method = g_strdup("SETUP"); - else if(trigger == WFD_TRIGGER_PAUSE) - msg->trigger_method->wfd_trigger_method = g_strdup("PAUSE"); - else if(trigger == WFD_TRIGGER_TEARDOWN) - msg->trigger_method->wfd_trigger_method = g_strdup("TEARDOWN"); - else if(trigger == WFD_TRIGGER_PLAY) - msg->trigger_method->wfd_trigger_method = g_strdup("PLAY"); - else - return WFD_EINVAL; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + + if (!msg->trigger_method) + msg->trigger_method = g_new0(WFDTriggerMethod, 1); + if (trigger == WFD_TRIGGER_SETUP) + msg->trigger_method->wfd_trigger_method = g_strdup("SETUP"); + else if (trigger == WFD_TRIGGER_PAUSE) + msg->trigger_method->wfd_trigger_method = g_strdup("PAUSE"); + else if (trigger == WFD_TRIGGER_TEARDOWN) + msg->trigger_method->wfd_trigger_method = g_strdup("TEARDOWN"); + else if (trigger == WFD_TRIGGER_PLAY) + msg->trigger_method->wfd_trigger_method = g_strdup("PLAY"); + else + return WFD_EINVAL; + return WFD_OK; } WFDResult wfdconfig_get_trigger_type(WFDMessage *msg, WFDTrigger *trigger) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "SETUP")) - *trigger = WFD_TRIGGER_SETUP; - else if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "PAUSE")) - *trigger = WFD_TRIGGER_PAUSE; - else if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "TEARDOWN")) - *trigger = WFD_TRIGGER_TEARDOWN; - else if(!g_strcmp0(msg->trigger_method->wfd_trigger_method, "PLAY")) - *trigger = WFD_TRIGGER_PLAY; - else { - *trigger = WFD_TRIGGER_UNKNOWN; - return WFD_EINVAL; - } - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (!g_strcmp0(msg->trigger_method->wfd_trigger_method, "SETUP")) + *trigger = WFD_TRIGGER_SETUP; + else if (!g_strcmp0(msg->trigger_method->wfd_trigger_method, "PAUSE")) + *trigger = WFD_TRIGGER_PAUSE; + else if (!g_strcmp0(msg->trigger_method->wfd_trigger_method, "TEARDOWN")) + *trigger = WFD_TRIGGER_TEARDOWN; + else if (!g_strcmp0(msg->trigger_method->wfd_trigger_method, "PLAY")) + *trigger = WFD_TRIGGER_PLAY; + else { + *trigger = WFD_TRIGGER_UNKNOWN; + return WFD_EINVAL; + } + return WFD_OK; } WFDResult wfdconfig_set_presentation_url(WFDMessage *msg, gchar *wfd_url0, gchar *wfd_url1) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(!msg->presentation_url) msg->presentation_url = g_new0 (WFDPresentationUrl, 1); - if(wfd_url0) msg->presentation_url->wfd_url0 = g_strdup(wfd_url0); - if(wfd_url1) msg->presentation_url->wfd_url1 = g_strdup(wfd_url1); - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (!msg->presentation_url) msg->presentation_url = g_new0(WFDPresentationUrl, 1); + if (wfd_url0) msg->presentation_url->wfd_url0 = g_strdup(wfd_url0); + if (wfd_url1) msg->presentation_url->wfd_url1 = g_strdup(wfd_url1); + return WFD_OK; } WFDResult wfdconfig_get_presentation_url(WFDMessage *msg, gchar **wfd_url0, gchar **wfd_url1) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(msg->presentation_url) { - *wfd_url0 = g_strdup(msg->presentation_url->wfd_url0); - *wfd_url1 = g_strdup(msg->presentation_url->wfd_url1); - } - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (msg->presentation_url) { + *wfd_url0 = g_strdup(msg->presentation_url->wfd_url0); + *wfd_url1 = g_strdup(msg->presentation_url->wfd_url1); + } + return WFD_OK; } WFDResult wfdconfig_set_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode trans, WFDRTSPProfile profile, - WFDRTSPLowerTrans lowertrans, guint32 rtp_port0, guint32 rtp_port1) + WFDRTSPLowerTrans lowertrans, guint32 rtp_port0, guint32 rtp_port1) { - GString *lines; - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - - if(!msg->client_rtp_ports) - msg->client_rtp_ports = g_new0 (WFDClientRtpPorts, 1); - - if(trans != WFD_RTSP_TRANS_UNKNOWN) { - lines = g_string_new (""); - if(trans == WFD_RTSP_TRANS_RTP) g_string_append_printf (lines,"RTP"); - else if(trans == WFD_RTSP_TRANS_RDT) g_string_append_printf (lines,"RDT"); - - if(profile == WFD_RTSP_PROFILE_AVP) g_string_append_printf (lines,"/AVP"); - else if(profile == WFD_RTSP_PROFILE_SAVP) g_string_append_printf (lines,"/SAVP"); - - if(lowertrans == WFD_RTSP_LOWER_TRANS_UDP) g_string_append_printf (lines,"/UDP;unicast"); - else if(lowertrans == WFD_RTSP_LOWER_TRANS_UDP_MCAST) g_string_append_printf (lines,"/UDP;multicast"); - else if(lowertrans == WFD_RTSP_LOWER_TRANS_TCP) g_string_append_printf (lines,"/TCP;unicast"); - else if(lowertrans == WFD_RTSP_LOWER_TRANS_HTTP) g_string_append_printf (lines,"/HTTP"); - - msg->client_rtp_ports->profile = g_string_free (lines, FALSE); - msg->client_rtp_ports->rtp_port0 = rtp_port0; - msg->client_rtp_ports->rtp_port1 = rtp_port1; - msg->client_rtp_ports->mode = g_strdup("mode=play"); - } - return WFD_OK; + GString *lines; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + + if (!msg->client_rtp_ports) + msg->client_rtp_ports = g_new0(WFDClientRtpPorts, 1); + + if (trans != WFD_RTSP_TRANS_UNKNOWN) { + lines = g_string_new(""); + if (trans == WFD_RTSP_TRANS_RTP) g_string_append_printf(lines, "RTP"); + else if (trans == WFD_RTSP_TRANS_RDT) g_string_append_printf(lines, "RDT"); + + if (profile == WFD_RTSP_PROFILE_AVP) g_string_append_printf(lines, "/AVP"); + else if (profile == WFD_RTSP_PROFILE_SAVP) g_string_append_printf(lines, "/SAVP"); + + if (lowertrans == WFD_RTSP_LOWER_TRANS_UDP) g_string_append_printf(lines, "/UDP;unicast"); + else if (lowertrans == WFD_RTSP_LOWER_TRANS_UDP_MCAST) g_string_append_printf(lines, "/UDP;multicast"); + else if (lowertrans == WFD_RTSP_LOWER_TRANS_TCP) g_string_append_printf(lines, "/TCP;unicast"); + else if (lowertrans == WFD_RTSP_LOWER_TRANS_HTTP) g_string_append_printf(lines, "/HTTP"); + + msg->client_rtp_ports->profile = g_string_free(lines, FALSE); + msg->client_rtp_ports->rtp_port0 = rtp_port0; + msg->client_rtp_ports->rtp_port1 = rtp_port1; + msg->client_rtp_ports->mode = g_strdup("mode=play"); + } + return WFD_OK; } WFDResult wfdconfig_get_prefered_RTP_ports(WFDMessage *msg, WFDRTSPTransMode *trans, WFDRTSPProfile *profile, - WFDRTSPLowerTrans *lowertrans, guint32 *rtp_port0, guint32 *rtp_port1) + WFDRTSPLowerTrans *lowertrans, guint32 *rtp_port0, guint32 *rtp_port1) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - g_return_val_if_fail (msg->client_rtp_ports != NULL, WFD_EINVAL); - - if(g_strrstr(msg->client_rtp_ports->profile, "RTP")) *trans = WFD_RTSP_TRANS_RTP; - if(g_strrstr(msg->client_rtp_ports->profile, "RDT")) *trans = WFD_RTSP_TRANS_RDT; - if(g_strrstr(msg->client_rtp_ports->profile, "AVP")) *profile = WFD_RTSP_PROFILE_AVP; - if(g_strrstr(msg->client_rtp_ports->profile, "SAVP")) *profile = WFD_RTSP_PROFILE_SAVP; - if(g_strrstr(msg->client_rtp_ports->profile, "UDP;unicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP; - if(g_strrstr(msg->client_rtp_ports->profile, "UDP;multicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP_MCAST; - if(g_strrstr(msg->client_rtp_ports->profile, "TCP;unicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_TCP; - if(g_strrstr(msg->client_rtp_ports->profile, "HTTP")) *lowertrans = WFD_RTSP_LOWER_TRANS_HTTP; - - *rtp_port0 = msg->client_rtp_ports->rtp_port0; - *rtp_port1 = msg->client_rtp_ports->rtp_port1; - - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + g_return_val_if_fail(msg->client_rtp_ports != NULL, WFD_EINVAL); + + if (g_strrstr(msg->client_rtp_ports->profile, "RTP")) *trans = WFD_RTSP_TRANS_RTP; + if (g_strrstr(msg->client_rtp_ports->profile, "RDT")) *trans = WFD_RTSP_TRANS_RDT; + if (g_strrstr(msg->client_rtp_ports->profile, "AVP")) *profile = WFD_RTSP_PROFILE_AVP; + if (g_strrstr(msg->client_rtp_ports->profile, "SAVP")) *profile = WFD_RTSP_PROFILE_SAVP; + if (g_strrstr(msg->client_rtp_ports->profile, "UDP;unicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP; + if (g_strrstr(msg->client_rtp_ports->profile, "UDP;multicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_UDP_MCAST; + if (g_strrstr(msg->client_rtp_ports->profile, "TCP;unicast")) *lowertrans = WFD_RTSP_LOWER_TRANS_TCP; + if (g_strrstr(msg->client_rtp_ports->profile, "HTTP")) *lowertrans = WFD_RTSP_LOWER_TRANS_HTTP; + + *rtp_port0 = msg->client_rtp_ports->rtp_port0; + *rtp_port1 = msg->client_rtp_ports->rtp_port1; + + return WFD_OK; } WFDResult wfdconfig_set_audio_sink_type(WFDMessage *msg, WFDSinkType sinktype) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(!msg->route) msg->route = g_new0 (WFDRoute, 1); - if(sinktype == WFD_PRIMARY_SINK) msg->route->destination = g_strdup("primary"); - else if(sinktype == WFD_SECONDARY_SINK) msg->route->destination = g_strdup("secondary"); - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (!msg->route) msg->route = g_new0(WFDRoute, 1); + if (sinktype == WFD_PRIMARY_SINK) msg->route->destination = g_strdup("primary"); + else if (sinktype == WFD_SECONDARY_SINK) msg->route->destination = g_strdup("secondary"); + return WFD_OK; } WFDResult wfdconfig_get_audio_sink_type(WFDMessage *msg, WFDSinkType *sinktype) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(msg->route) { - if(!g_strcmp0(msg->route->destination,"primary")) *sinktype = WFD_PRIMARY_SINK; - else if(!g_strcmp0(msg->route->destination,"secondary")) *sinktype = WFD_SECONDARY_SINK; - } - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (msg->route) { + if (!g_strcmp0(msg->route->destination, "primary")) *sinktype = WFD_PRIMARY_SINK; + else if (!g_strcmp0(msg->route->destination, "secondary")) *sinktype = WFD_SECONDARY_SINK; + } + return WFD_OK; } WFDResult wfdconfig_set_I2C_port(WFDMessage *msg, gboolean i2csupport, guint32 i2cport) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(!msg->I2C) msg->I2C = g_new0 (WFDI2C, 1); - msg->I2C->I2CPresent = i2csupport; - msg->I2C->I2C_port = i2cport; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (!msg->I2C) msg->I2C = g_new0(WFDI2C, 1); + msg->I2C->I2CPresent = i2csupport; + msg->I2C->I2C_port = i2cport; + return WFD_OK; } WFDResult wfdconfig_get_I2C_port(WFDMessage *msg, gboolean *i2csupport, guint32 *i2cport) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(msg->I2C && msg->I2C->I2CPresent) { - *i2csupport = msg->I2C->I2CPresent; - *i2cport = msg->I2C->I2C_port; - } else *i2csupport = FALSE; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (msg->I2C && msg->I2C->I2CPresent) { + *i2csupport = msg->I2C->I2CPresent; + *i2cport = msg->I2C->I2C_port; + } else *i2csupport = FALSE; + return WFD_OK; } WFDResult wfdconfig_set_av_format_change_timing(WFDMessage *msg, guint64 PTS, guint64 DTS) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(!msg->av_format_change_timing) msg->av_format_change_timing = g_new0 (WFDAVFormatChangeTiming, 1); - msg->av_format_change_timing->PTS = PTS; - msg->av_format_change_timing->DTS = DTS; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (!msg->av_format_change_timing) msg->av_format_change_timing = g_new0(WFDAVFormatChangeTiming, 1); + msg->av_format_change_timing->PTS = PTS; + msg->av_format_change_timing->DTS = DTS; + return WFD_OK; } WFDResult wfdconfig_get_av_format_change_timing(WFDMessage *msg, guint64 *PTS, guint64 *DTS) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(msg->av_format_change_timing) { - *PTS = msg->av_format_change_timing->PTS; - *DTS = msg->av_format_change_timing->DTS; - } - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (msg->av_format_change_timing) { + *PTS = msg->av_format_change_timing->PTS; + *DTS = msg->av_format_change_timing->DTS; + } + return WFD_OK; } WFDResult wfdconfig_set_uibc_capability(WFDMessage *msg, guint32 input_category, guint32 inp_type, WFDHIDCTypePathPair *inp_pair, - guint32 inp_type_path_count, guint32 tcp_port) + guint32 inp_type_path_count, guint32 tcp_port) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(!msg->uibc_capability) msg->uibc_capability = g_new0 (WFDUibcCapability, 1); - msg->uibc_capability->uibcsupported = TRUE; - msg->uibc_capability->input_category_list.input_cat = input_category; - msg->uibc_capability->generic_cap_list.inp_type = inp_type; - msg->uibc_capability->hidc_cap_list.cap_count = inp_type_path_count; - if(msg->uibc_capability->hidc_cap_list.cap_count) { - detailed_cap *temp_cap; - guint i=0; - msg->uibc_capability->hidc_cap_list.next = g_new0 (detailed_cap, 1); - temp_cap = msg->uibc_capability->hidc_cap_list.next; - for(;ip.inp_type = inp_pair[i].inp_type; - temp_cap->p.inp_path = inp_pair[i].inp_path; - i++; - if(inext = g_new0 (detailed_cap, 1); - temp_cap = temp_cap->next; - } - } - } - msg->uibc_capability->tcp_port = tcp_port; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (!msg->uibc_capability) msg->uibc_capability = g_new0(WFDUibcCapability, 1); + msg->uibc_capability->uibcsupported = TRUE; + msg->uibc_capability->input_category_list.input_cat = input_category; + msg->uibc_capability->generic_cap_list.inp_type = inp_type; + msg->uibc_capability->hidc_cap_list.cap_count = inp_type_path_count; + if (msg->uibc_capability->hidc_cap_list.cap_count) { + detailed_cap *temp_cap; + guint i = 0; + msg->uibc_capability->hidc_cap_list.next = g_new0(detailed_cap, 1); + temp_cap = msg->uibc_capability->hidc_cap_list.next; + for (; i < inp_type_path_count;) { + temp_cap->p.inp_type = inp_pair[i].inp_type; + temp_cap->p.inp_path = inp_pair[i].inp_path; + i++; + if (i < inp_type_path_count) { + temp_cap->next = g_new0(detailed_cap, 1); + temp_cap = temp_cap->next; + } + } + } + msg->uibc_capability->tcp_port = tcp_port; + return WFD_OK; } WFDResult wfdconfig_get_uibc_capability(WFDMessage *msg, guint32 *input_category, guint32 *inp_type, WFDHIDCTypePathPair **inp_pair, - guint32 *inp_type_path_count, guint32 *tcp_port) + guint32 *inp_type_path_count, guint32 *tcp_port) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(msg->uibc_capability && msg->uibc_capability->uibcsupported) { - *input_category = msg->uibc_capability->input_category_list.input_cat; - *inp_type = msg->uibc_capability->generic_cap_list.inp_type; - *inp_type_path_count = msg->uibc_capability->hidc_cap_list.cap_count; - if(msg->uibc_capability->hidc_cap_list.cap_count) { - detailed_cap *temp_cap; - guint i = 0; - *inp_pair = g_new0 (WFDHIDCTypePathPair, msg->uibc_capability->hidc_cap_list.cap_count); - temp_cap = msg->uibc_capability->hidc_cap_list.next; - while(temp_cap) { - (*(inp_pair))[i].inp_type = temp_cap->p.inp_type; - (*(inp_pair))[i].inp_path = temp_cap->p.inp_path; - temp_cap = temp_cap->next; - i++; - } - } - *tcp_port = msg->uibc_capability->tcp_port; - } - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (msg->uibc_capability && msg->uibc_capability->uibcsupported) { + *input_category = msg->uibc_capability->input_category_list.input_cat; + *inp_type = msg->uibc_capability->generic_cap_list.inp_type; + *inp_type_path_count = msg->uibc_capability->hidc_cap_list.cap_count; + if (msg->uibc_capability->hidc_cap_list.cap_count) { + detailed_cap *temp_cap; + guint i = 0; + *inp_pair = g_new0(WFDHIDCTypePathPair, msg->uibc_capability->hidc_cap_list.cap_count); + temp_cap = msg->uibc_capability->hidc_cap_list.next; + while (temp_cap) { + (*(inp_pair))[i].inp_type = temp_cap->p.inp_type; + (*(inp_pair))[i].inp_path = temp_cap->p.inp_path; + temp_cap = temp_cap->next; + i++; + } + } + *tcp_port = msg->uibc_capability->tcp_port; + } + return WFD_OK; } WFDResult wfdconfig_set_uibc_status(WFDMessage *msg, gboolean uibc_enable) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(!msg->uibc_setting) msg->uibc_setting = g_new0 (WFDUibcSetting, 1); - msg->uibc_setting->uibc_setting = uibc_enable; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (!msg->uibc_setting) msg->uibc_setting = g_new0(WFDUibcSetting, 1); + msg->uibc_setting->uibc_setting = uibc_enable; + return WFD_OK; } WFDResult wfdconfig_get_uibc_status(WFDMessage *msg, gboolean *uibc_enable) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(msg->uibc_setting) *uibc_enable = msg->uibc_setting->uibc_setting; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (msg->uibc_setting) *uibc_enable = msg->uibc_setting->uibc_setting; + return WFD_OK; } #ifdef STANDBY_RESUME_CAPABILITY WFDResult wfdconfig_set_standby_resume_capability(WFDMessage *msg, gboolean supported) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(!msg->standby_resume_capability) msg->standby_resume_capability = g_new0 (WFDStandbyResumeCapability, 1); - msg->standby_resume_capability->standby_resume_cap = supported; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (!msg->standby_resume_capability) msg->standby_resume_capability = g_new0(WFDStandbyResumeCapability, 1); + msg->standby_resume_capability->standby_resume_cap = supported; + return WFD_OK; } WFDResult wfdconfig_get_standby_resume_capability(WFDMessage *msg, gboolean *supported) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(msg->standby_resume_capability) *supported = msg->standby_resume_capability->standby_resume_cap; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (msg->standby_resume_capability) *supported = msg->standby_resume_capability->standby_resume_cap; + return WFD_OK; } #endif WFDResult wfdconfig_set_standby(WFDMessage *msg, gboolean standby_enable) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(!msg->standby) msg->standby = g_new0 (WFDStandby, 1); - msg->standby->wfd_standby = standby_enable; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (!msg->standby) msg->standby = g_new0(WFDStandby, 1); + msg->standby->wfd_standby = standby_enable; + return WFD_OK; } WFDResult wfdconfig_get_standby(WFDMessage *msg, gboolean *standby_enable) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(msg->standby) *standby_enable = msg->standby->wfd_standby; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (msg->standby) *standby_enable = msg->standby->wfd_standby; + return WFD_OK; } WFDResult wfdconfig_set_connector_type(WFDMessage *msg, WFDConnector connector) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(!msg->connector_type) msg->connector_type = g_new0 (WFDConnectorType, 1); - msg->connector_type->connector_type = connector; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (!msg->connector_type) msg->connector_type = g_new0(WFDConnectorType, 1); + msg->connector_type->connector_type = connector; + return WFD_OK; } WFDResult wfdconfig_get_connector_type(WFDMessage *msg, WFDConnector *connector) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(msg->connector_type) *connector = msg->connector_type->connector_type; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (msg->connector_type) *connector = msg->connector_type->connector_type; + return WFD_OK; } WFDResult wfdconfig_set_idr_request(WFDMessage *msg) { - g_return_val_if_fail (msg != NULL, WFD_EINVAL); - if(!msg->idr_request) msg->idr_request = g_new0 (WFDIdrRequest, 1); - msg->idr_request->idr_request = TRUE; - return WFD_OK; + g_return_val_if_fail(msg != NULL, WFD_EINVAL); + if (!msg->idr_request) msg->idr_request = g_new0(WFDIdrRequest, 1); + msg->idr_request->idr_request = TRUE; + return WFD_OK; } -- 2.7.4 From 3232f58aad7e3b58a764c4c84298e850f8c051d3 Mon Sep 17 00:00:00 2001 From: Sangkyu Park Date: Tue, 14 Jul 2015 09:26:22 +0900 Subject: [PATCH 7/9] Fix a wfd message bug which has two white space between audio codecs Change-Id: I596679724d8e016c75a9a4a5a71cc4ee284b466d Signed-off-by: Sangkyu Park --- packaging/libmm-scmirroring-common.spec | 2 +- wfdconfig/wfdconfigmessage.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/libmm-scmirroring-common.spec b/packaging/libmm-scmirroring-common.spec index 66252cd..f93fb12 100755 --- a/packaging/libmm-scmirroring-common.spec +++ b/packaging/libmm-scmirroring-common.spec @@ -1,6 +1,6 @@ Name: libmm-scmirroring-common Summary: Multimedia Framework Wifi-Display Common Library -Version: 0.0.37 +Version: 0.0.38 Release: 0 Group: System/Libraries License: Apache License 2.0 diff --git a/wfdconfig/wfdconfigmessage.c b/wfdconfig/wfdconfigmessage.c index f6229f6..61b610f 100755 --- a/wfdconfig/wfdconfigmessage.c +++ b/wfdconfig/wfdconfigmessage.c @@ -252,7 +252,7 @@ wfdconfig_message_as_text(const WFDMessage *msg) g_string_append_printf(lines, " %08x", msg->audio_codecs->list[i].modes); g_string_append_printf(lines, " %02x", msg->audio_codecs->list[i].latency); if ((i + 1) < msg->audio_codecs->count) - g_string_append_printf(lines, ", "); + g_string_append_printf(lines, ","); } } g_string_append_printf(lines, "\r\n"); -- 2.7.4 From 7b72d3541542f36232f1cfbbb345d8068e522f16 Mon Sep 17 00:00:00 2001 From: Sangkyu Park Date: Tue, 14 Jul 2015 09:27:12 +0900 Subject: [PATCH 8/9] Fix memory leak of uninit function. Change-Id: Ie68f6a6decbe81a21d2a3557818f2ec608dce86c Signed-off-by: Sangkyu Park --- wfdconfig/wfdconfigmessage.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/wfdconfig/wfdconfigmessage.c b/wfdconfig/wfdconfigmessage.c index 61b610f..77cbd4a 100755 --- a/wfdconfig/wfdconfigmessage.c +++ b/wfdconfig/wfdconfigmessage.c @@ -128,10 +128,16 @@ wfdconfig_message_uninit(WFDMessage *msg) } if (msg->video_3d_formats) { + FREE_STRING(msg->video_3d_formats->list); FREE_STRING(msg->video_3d_formats); } if (msg->content_protection) { + if (msg->content_protection->hdcp2_spec) { + FREE_STRING(msg->content_protection->hdcp2_spec->hdcpversion); + FREE_STRING(msg->content_protection->hdcp2_spec->TCPPort); + FREE_STRING(msg->content_protection->hdcp2_spec); + } FREE_STRING(msg->content_protection); } @@ -142,6 +148,10 @@ wfdconfig_message_uninit(WFDMessage *msg) } if (msg->coupled_sink) { + if (msg->coupled_sink->coupled_sink_cap) { + FREE_STRING(msg->coupled_sink->coupled_sink_cap->sink_address); + FREE_STRING(msg->coupled_sink->coupled_sink_cap); + } FREE_STRING(msg->coupled_sink); } @@ -151,7 +161,9 @@ wfdconfig_message_uninit(WFDMessage *msg) } if (msg->presentation_url) { - FREE_STRING(msg->trigger_method); + FREE_STRING(msg->presentation_url->wfd_url0); + FREE_STRING(msg->presentation_url->wfd_url1); + FREE_STRING(msg->presentation_url); } if (msg->client_rtp_ports) { @@ -161,6 +173,7 @@ wfdconfig_message_uninit(WFDMessage *msg) } if (msg->route) { + FREE_STRING(msg->route->destination); FREE_STRING(msg->route); } @@ -177,6 +190,15 @@ wfdconfig_message_uninit(WFDMessage *msg) } if (msg->uibc_capability) { + if (msg->uibc_capability->hidc_cap_list.next) { + detailed_cap *list = msg->uibc_capability->hidc_cap_list.next; + detailed_cap *temp = NULL; + while (list) { + temp = list->next; + FREE_STRING(list); + list = temp; + } + } FREE_STRING(msg->uibc_capability); } -- 2.7.4 From 44ad71302e7ad044d1c7f2ba69105e8f3de526a6 Mon Sep 17 00:00:00 2001 From: Sangkyu Park Date: Thu, 16 Jul 2015 14:39:00 +0900 Subject: [PATCH 9/9] Fix to convert guint64 value to string. Change-Id: I90acf0cfbdd121808f4c739a93e51b9fdb04d0f7 Signed-off-by: Sangkyu Park --- packaging/libmm-scmirroring-common.spec | 2 +- wfdconfig/wfdconfigmessage.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packaging/libmm-scmirroring-common.spec b/packaging/libmm-scmirroring-common.spec index f93fb12..7866c0b 100755 --- a/packaging/libmm-scmirroring-common.spec +++ b/packaging/libmm-scmirroring-common.spec @@ -1,6 +1,6 @@ Name: libmm-scmirroring-common Summary: Multimedia Framework Wifi-Display Common Library -Version: 0.0.38 +Version: 0.0.39 Release: 0 Group: System/Libraries License: Apache License 2.0 diff --git a/wfdconfig/wfdconfigmessage.c b/wfdconfig/wfdconfigmessage.c index 77cbd4a..3f3d458 100755 --- a/wfdconfig/wfdconfigmessage.c +++ b/wfdconfig/wfdconfigmessage.c @@ -437,8 +437,8 @@ wfdconfig_message_as_text(const WFDMessage *msg) if (msg->av_format_change_timing) { g_string_append_printf(lines, "wfd_av_format_change_timing"); g_string_append_printf(lines, ":"); - g_string_append_printf(lines, " %10"G_GUINT64_FORMAT, msg->av_format_change_timing->PTS); - g_string_append_printf(lines, " %10"G_GUINT64_FORMAT, msg->av_format_change_timing->DTS); + g_string_append_printf(lines, " %010llx", msg->av_format_change_timing->PTS); + g_string_append_printf(lines, " %010llx", msg->av_format_change_timing->DTS); g_string_append_printf(lines, "\r\n"); } @@ -446,7 +446,7 @@ wfdconfig_message_as_text(const WFDMessage *msg) g_string_append_printf(lines, "wfd_preferred_display_mode"); g_string_append_printf(lines, ":"); if (msg->preferred_display_mode->displaymodesupported) { - g_string_append_printf(lines, " %06"G_GUINT64_FORMAT, msg->preferred_display_mode->p_clock); + g_string_append_printf(lines, " %06llx", msg->preferred_display_mode->p_clock); g_string_append_printf(lines, " %04x", msg->preferred_display_mode->H); g_string_append_printf(lines, " %04x", msg->preferred_display_mode->HB); g_string_append_printf(lines, " %04x", msg->preferred_display_mode->HSPOL_HSOFF); -- 2.7.4