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

Jean-Baptiste Kempf jb at videolan.org
Sun Jul 14 11:55:56 CEST 2019



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?

> +    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.

> +    // TODO: get real status and speed
> +    out_params["CurrentTransportStatus"] = "";
> +    out_params["CurrentSpeed"] = "";

Is that hard to get? (speed is rate in VLC)

> +        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.


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


More information about the vlc-devel mailing list