Re: Building a Media Renderer



On 26 January 2016 at 00:34, Nick Deubert <ndeubert gmail com> wrote:
On Mon, Jan 25, 2016 at 6:58 AM, Jussi Kukkonen
<jussi kukkonen intel com> wrote:
> On 21 January 2016 at 22:23, Nick Deubert <ndeubert gmail com> wrote:
>>
>> Hey Everyone,
>>
>> I've been lingering on irc, but figured I would post here to get a
>> broader audience. I am working on implementing a media renderer using
>> GUPNP. I started by looking at the example code and followed the
>> "Writing a UPnP Service" tutorial. I used the AVTransport3.xml
>> RenderingControl3.xml and ConnectionManager3.xml files from upnp.org
>> for my SCPDs and ran them through gupnp-binding-tool to create the
>> action_get/set and signal_connect functions, though I don't see these
>> equivalent functions in the example code so I wasn't sure if this was
>> necessary?
>
> In a couple of places GUPnP has multiple ways to do something -- this is one
> of them and the docs don't really make it clear how you're supposed to pick
> one. The main options are:
> 1. Write all the signal connection stuff by hand, e.g.:
>     g_signal_connect (service, "action-invoked::GetProtocolInfo", cb, data);
> 2. Use gupnp_service_signals_autoconnect() and hope you got every function
> name correct
> 3. Use the gupnp-binding-tool to generate a service-specific API and use
> e.g.
>     cm_get_protocol_info_action_connect (service, cb, data)
>
> All have pros and cons but TL;DR is that if you use #2, there's no need for
> the gupnp-binding-tool generated files of #3.

Ah, I see... if I were do #3, would I simply just call all of the
_action_set and _action_connect functions on startup in place of the
autoconnect call?

This example assumes "cm" as the prefix given to gupnp-binding-tool: You'd use the _connect() calls in your initialization, e.g.

    cm_get_protocol_info_action_connect (service, get_protocol_info_cb, data);

Then the handler function uses _get() and _set() calls to get function arguments and set return variables The example function only has return variables:

    static void
    get_protocol_info_cb (GUPnPService *service,
                   GUPnPServiceAction *action,
                   gpointer user_data)
    {
        cm_get_protocol_info_action_set (action, "source", "sink");
        gupnp_service_action_return (action);
    }

This is about the same amount of lines of code as doing it completely manually (as you can see the wrapper does not do much) but you do get correctly typed function signatures (in the example the char* arguments for cm_get_protocol_info_action_set()) and also the magic strings for variable and function names are hidden in the wrapper. I've found this useful with editor autocomplete.

 - Jussi


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