[vlc-devel] [PATCH v2 5/5] upnp: Add UPnP/DLNA MediaRenderer control plugin

Johan Gunnarsson johan.gunnarsson at gmail.com
Tue Jul 16 10:32:28 CEST 2019


Den sön 14 juli 2019 kl 11:55 skrev Jean-Baptiste Kempf <jb at videolan.org>:
>
>
>
> On Sat, Jul 13, 2019, at 11:38, Johan Gunnarsson wrote:
> > +/**
> > + * Convert ticks (in microseconds) to a string in the form H:MM:SS.
> > Can't use
> > + * secstotimestr since it will omit hours if time is less than 1 hour.
> > + */
> > +static std::string
> > +time_to_string( vlc_tick_t ticks )
> > +{
> > +    unsigned int time_in_seconds = (unsigned int)
> > SEC_FROM_VLC_TICK(ticks);
> > +    unsigned int s = time_in_seconds % 60;
> > +    time_in_seconds -= s;
> > +    unsigned int m = (time_in_seconds / 60) % 60;
> > +    time_in_seconds -= 60 * m;
> > +    unsigned int h = time_in_seconds / (60 * 60);
> > +    char str[16] = {};
> > +    if( snprintf( str, sizeof( str ) - 1, "%u:%02u:%02u", h, m, s ) <
> > 0 )
> > +        return std::string( "0:00:00" );
> > +    return std::string( str );
> > +}
>
> Can't you use vlc_strftime for this?

Not sure I can. With format %H:%M:%S I can only support up media that
is up to 24 hours long. Media that is, for example, 25 hours long
should be printed as 25:00:00. Don't think I can do that with stftime.
See section 2.2.14 in
http://upnp.org/specs/av/UPnP-av-AVTransport-v1-Service.pdf for
description of the output.

>
> > +    vlc_player_t *player = vlc_playlist_GetPlayer(
> > p_intf->p_sys->playlist );
>
> I would prefer a local (inline) function for the player getter to this module, in case we decide to use a different player, and that will be easier in the future if you do this.

My code is a bit inconsistent. I have player in intf_sys_t already. I
suggest I use player in intf_sys_t instead. Then there will only be
one spot where I do vlc_intf_GetMainPlaylist + vlc_playlist_GetPlayer.

>
> > +    // TODO: get real status and speed
> > +    out_params["CurrentTransportStatus"] = "";
> > +    out_params["CurrentSpeed"] = "";
>
> Is that hard to get? (speed is rate in VLC)

OK, I will fix this.

>
> > +        if( !strptime(in_params["Target"].c_str(), "%H:%M:%S", &tm) )
> > +            return true;
>
> strptime is not everywhere. We have a check in the configure for that.

OK, I will see if I can use sscanf or something.

>
>
> --
> Jean-Baptiste Kempf -  President
> +33 672 704 734


More information about the vlc-devel mailing list