[PATCH v6 05/37] raop: Parse server capabilities on discovery

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2016-01-31 at 22:16 -0600, Hajime Fujita wrote:
> From: Martin Blanchard <tinram at gmx.fr>
> 
> During the discovery phase, raop servers send theirs capabilities
> (supported encryption, audio codec...). These should be passed to the
> raop sink via module's arguments.
> ---
>  src/modules/raop/module-raop-discover.c | 100
> ++++++++++++++++++++++++++++----
>  1 file changed, 90 insertions(+), 10 deletions(-)
> 
> diff --git a/src/modules/raop/module-raop-discover.c
> b/src/modules/raop/module-raop-discover.c
> index 1ced777..f174da3 100644
> --- a/src/modules/raop/module-raop-discover.c
> +++ b/src/modules/raop/module-raop-discover.c
> @@ -138,7 +138,10 @@ static void resolver_cb(
>          void *userdata) {
>      struct userdata *u = userdata;
>      struct tunnel *tnl;
> -    char *device = NULL, *nicename, *dname, *vname, *args;
> +    char *nicename, *dname, *vname, *args;
> +    char *tp = NULL, *et = NULL, *cn = NULL;
> +    char *ch = NULL, *ss = NULL, *sr = NULL;
> +    char *t = NULL;
>      char at[AVAHI_ADDRESS_STR_MAX];
>      AvahiStringList *l;
>      pa_module *m;
> @@ -166,8 +169,54 @@ static void resolver_cb(
>          pa_assert_se(avahi_string_list_get_pair(l, &key, &value,
> NULL) == 0);
>  
>          pa_log_debug("Found key: '%s' with value: '%s'", key,
> value);
> -        if (pa_streq(key, "device")) {
> -            device = value;

Is there a reason the device is dropped here. Ideally this should be a
separate commit, but for now, if we have a reason we can put in the
commit message, that'd be fine too.

-- Arun

> +
> +        if (pa_streq(key, "tp")) {
> +            /* Transport protocol:
> +             *  - TCP = only TCP,
> +             *  - UDP = only UDP,
> +             *  - TCP,UDP = both supported (UDP should be prefered)
> */
> +             if (pa_str_in_list(value, ",", "UDP"))
> +                 tp = strdup("UDP");
> +            else if (pa_str_in_list(value, ",", "TCP"))
> +                tp = strdup("TCP");
> +            else
> +                tp = strdup(value);
> +        } else if (pa_streq(key, "et")) {
> +            /* Supported encryption types:
> +             *  - 0 = none,
> +             *  - 1 = RSA,
> +             *  - 2 = FairPlay,
> +             *  - 3 = MFiSAP,
> +             *  - 4 = FairPlay SAPv2.5. */
> +             if (pa_str_in_list(value, ",", "1"))
> +                 et = strdup("RSA");
> +             else
> +                 et = strdup("none");
> +        } else if (pa_streq(key, "cn")) {
> +            /* Suported audio codecs:
> +             *  - 0 = PCM,
> +             *  - 1 = ALAC,
> +             *  - 2 = AAC,
> +             *  - 3 = AAC ELD. */
> +            cn = strdup("PCM");
> +        } else if (pa_streq(key, "md")) {
> +            /* Supported metadata types:
> +             *  - 0 = text,
> +             *  - 1 = artwork,
> +             *  - 2 = progress. */
> +        } else if (pa_streq(key, "pw")) {
> +            /* Requires password ? (true/false) */
> +        } else if (pa_streq(key, "ch")) {
> +            /* Number of channels */
> +            ch = value;
> +            value = NULL;
> +        } else if (pa_streq(key, "ss")) {
> +            /* Sample size */
> +            ss = value;
> +            value = NULL;
> +        } else if (pa_streq(key, "sr")) {
> +            /* Sample rate */
> +            sr = value;
>              value = NULL;
>          }
>  
> @@ -175,19 +224,13 @@ static void resolver_cb(
>          avahi_free(value);
>      }
>  
> -    if (device)
> -        dname = pa_sprintf_malloc("raop.%s.%s", host_name, device);
> -    else
> -        dname = pa_sprintf_malloc("raop.%s", host_name);
> -
> +    dname = pa_sprintf_malloc("raop_output.%s", host_name);
>      if (!(vname = pa_namereg_make_valid_name(dname))) {
>          pa_log("Cannot construct valid device name from '%s'.",
> dname);
> -        avahi_free(device);
>          pa_xfree(dname);
>          goto finish;
>      }
>  
> -    avahi_free(device);
>      pa_xfree(dname);
>  
>      if (nicename) {
> @@ -205,6 +248,43 @@ static void resolver_cb(
>                                   vname);
>      }
>  
> +    if (tp != NULL) {
> +        t = args;
> +        args = pa_sprintf_malloc("%s protocol=%s", args, tp);
> +        avahi_free(tp);
> +        pa_xfree(t);
> +    }
> +    if (et != NULL) {
> +        t = args;
> +        args = pa_sprintf_malloc("%s encryption=%s", args, et);
> +        pa_xfree(et);
> +        pa_xfree(t);
> +    }
> +    if (cn != NULL) {
> +        t = args;
> +        args = pa_sprintf_malloc("%s codec=%s", args, cn);
> +        pa_xfree(cn);
> +        pa_xfree(t);
> +    }
> +    if (ch != NULL) {
> +        t = args;
> +        args = pa_sprintf_malloc("%s channels=%s", args, ch);
> +        avahi_free(ch);
> +        pa_xfree(t);
> +    }
> +    if (ss != NULL) {
> +        t = args;
> +        args = pa_sprintf_malloc("%s format=%s", args, ss);
> +        avahi_free(ss);
> +        pa_xfree(t);
> +    }
> +    if (sr != NULL) {
> +        t = args;
> +        args = pa_sprintf_malloc("%s rate=%s", args, sr);
> +        avahi_free(sr);
> +        pa_xfree(t);
> +    }
> +
>      pa_log_debug("Loading module-raop-sink with arguments '%s'",
> args);
>  
>      if ((m = pa_module_load(u->core, "module-raop-sink", args))) {


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux