[FFmpeg-devel] [PATCH] avformat/rtmpproto: send proper status for response to play command

Marton Balint cus at passwd.hu
Wed Apr 20 21:00:24 EEST 2022



On Thu, 14 Apr 2022, Marton Balint wrote:

> This fixes referencing the uninitialized filename variable.
>
> Fixes ticket #9711.

Will apply tomorrow.

Regards,
Marton

>
> Signed-off-by: Marton Balint <cus at passwd.hu>
> ---
> libavformat/rtmpproto.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
> index f97e3c3b8e..f0ef223f05 100644
> --- a/libavformat/rtmpproto.c
> +++ b/libavformat/rtmpproto.c
> @@ -1857,11 +1857,10 @@ static int write_begin(URLContext *s)
> }
>
> static int write_status(URLContext *s, RTMPPacket *pkt,
> -                        const char *status, const char *filename)
> +                        const char *status, const char *description, const char *details)
> {
>     RTMPContext *rt = s->priv_data;
>     RTMPPacket spkt = { 0 };
> -    char statusmsg[128];
>     uint8_t *pp;
>     int ret;
>
> @@ -1884,11 +1883,11 @@ static int write_status(URLContext *s, RTMPPacket *pkt,
>     ff_amf_write_field_name(&pp, "code");
>     ff_amf_write_string(&pp, status);
>     ff_amf_write_field_name(&pp, "description");
> -    snprintf(statusmsg, sizeof(statusmsg),
> -             "%s is now published", filename);
> -    ff_amf_write_string(&pp, statusmsg);
> -    ff_amf_write_field_name(&pp, "details");
> -    ff_amf_write_string(&pp, filename);
> +    ff_amf_write_string(&pp, description);
> +    if (details) {
> +        ff_amf_write_field_name(&pp, "details");
> +        ff_amf_write_string(&pp, details);
> +    }
>     ff_amf_write_object_end(&pp);
>
>     spkt.size = pp - spkt.data;
> @@ -1964,20 +1963,22 @@ static int send_invoke_response(URLContext *s, RTMPPacket *pkt)
>         pp = spkt.data;
>         ff_amf_write_string(&pp, "onFCPublish");
>     } else if (!strcmp(command, "publish")) {
> +        char statusmsg[128];
> +        snprintf(statusmsg, sizeof(statusmsg), "%s is now published", filename);
>         ret = write_begin(s);
>         if (ret < 0)
>             return ret;
>
>         // Send onStatus(NetStream.Publish.Start)
>         return write_status(s, pkt, "NetStream.Publish.Start",
> -                           filename);
> +                            statusmsg, filename);
>     } else if (!strcmp(command, "play")) {
>         ret = write_begin(s);
>         if (ret < 0)
>             return ret;
>         rt->state = STATE_SENDING;
>         return write_status(s, pkt, "NetStream.Play.Start",
> -                            filename);
> +                            "playing stream", NULL);
>     } else {
>         if ((ret = ff_rtmp_packet_create(&spkt, RTMP_SYSTEM_CHANNEL,
>                                          RTMP_PT_INVOKE, 0,
> -- 
> 2.31.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-devel mailing list