X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fsapenc.c;h=37ce0e5eea01311c97942e65b807d99fec7fdfc1;hb=66adb7ce1bc1cc5e3f1c4b1cd9f20ac68086a486;hp=c216342a4ccee4c389c8e4520f73220b2981961e;hpb=5958df341de69d94b9958c10cc4aaca510b8cd24;p=ffmpeg diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c index c216342a4cc..37ce0e5eea0 100644 --- a/libavformat/sapenc.c +++ b/libavformat/sapenc.c @@ -24,6 +24,7 @@ #include "libavutil/random_seed.h" #include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" +#include "libavutil/time.h" #include "internal.h" #include "network.h" #include "os_support.h" @@ -104,8 +105,7 @@ static int sap_write_header(AVFormatContext *s) } if (!announce_addr[0]) { - struct addrinfo hints, *ai = NULL; - memset(&hints, 0, sizeof(hints)); + struct addrinfo hints = { 0 }, *ai = NULL; hints.ai_family = AF_UNSPEC; if (getaddrinfo(host, NULL, &hints, &ai)) { av_log(s, AV_LOG_ERROR, "Unable to resolve %s\n", host); @@ -146,19 +146,22 @@ static int sap_write_header(AVFormatContext *s) "?ttl=%d", ttl); if (!same_port) base_port += 2; - ret = ffurl_open(&fd, url, URL_WRONLY); + ret = ffurl_open(&fd, url, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL); if (ret) { ret = AVERROR(EIO); goto fail; } - s->streams[i]->priv_data = contexts[i] = - ff_rtp_chain_mux_open(s, s->streams[i], fd, 0); + ret = ff_rtp_chain_mux_open(&contexts[i], s, s->streams[i], fd, 0); + if (ret < 0) + goto fail; + s->streams[i]->priv_data = contexts[i]; av_strlcpy(contexts[i]->filename, url, sizeof(contexts[i]->filename)); } ff_url_join(url, sizeof(url), "udp", NULL, announce_addr, port, "?ttl=%d&connect=1", ttl); - ret = ffurl_open(&sap->ann_fd, url, URL_WRONLY); + ret = ffurl_open(&sap->ann_fd, url, AVIO_FLAG_WRITE, + &s->interrupt_callback, NULL); if (ret) { ret = AVERROR(EIO); goto fail; @@ -208,8 +211,8 @@ static int sap_write_header(AVFormatContext *s) av_strlcpy(&sap->ann[pos], "application/sdp", sap->ann_size - pos); pos += strlen(&sap->ann[pos]) + 1; - if (avf_sdp_create(contexts, s->nb_streams, &sap->ann[pos], - sap->ann_size - pos)) { + if (av_sdp_create(contexts, s->nb_streams, &sap->ann[pos], + sap->ann_size - pos)) { ret = AVERROR_INVALIDDATA; goto fail; } @@ -250,16 +253,13 @@ static int sap_write_packet(AVFormatContext *s, AVPacket *pkt) } AVOutputFormat ff_sap_muxer = { - "sap", - NULL_IF_CONFIG_SMALL("SAP output format"), - NULL, - NULL, - sizeof(struct SAPState), - CODEC_ID_AAC, - CODEC_ID_MPEG4, - sap_write_header, - sap_write_packet, - sap_write_close, - .flags = AVFMT_NOFILE | AVFMT_GLOBALHEADER, + .name = "sap", + .long_name = NULL_IF_CONFIG_SMALL("SAP output"), + .priv_data_size = sizeof(struct SAPState), + .audio_codec = CODEC_ID_AAC, + .video_codec = CODEC_ID_MPEG4, + .write_header = sap_write_header, + .write_packet = sap_write_packet, + .write_trailer = sap_write_close, + .flags = AVFMT_NOFILE | AVFMT_GLOBALHEADER, }; -