#include "libavutil/parseutils.h"
#include "libavutil/random_seed.h"
#include "libavutil/avstring.h"
+#include "libavutil/dict.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/time.h"
#include "internal.h"
int ann_size;
URLContext *ann_fd;
int64_t last_time;
+
+ const URLProtocol **protocols;
};
static int sap_write_close(AVFormatContext *s)
ffurl_write(sap->ann_fd, sap->ann, sap->ann_size);
}
+ av_freep(&sap->protocols);
+
av_freep(&sap->ann);
if (sap->ann_fd)
ffurl_close(sap->ann_fd);
struct sockaddr_storage localaddr;
socklen_t addrlen = sizeof(localaddr);
int udp_fd;
+ AVDictionaryEntry* title = av_dict_get(s->metadata, "title", NULL, 0);
if (!ff_network_init())
return AVERROR(EIO);
freeaddrinfo(ai);
}
+ sap->protocols = ffurl_get_protocols(s->protocol_whitelist,
+ s->protocol_blacklist);
+ if (!sap->protocols) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+
contexts = av_mallocz(sizeof(AVFormatContext*) * s->nb_streams);
if (!contexts) {
ret = AVERROR(ENOMEM);
"?ttl=%d", ttl);
if (!same_port)
base_port += 2;
- ret = ffurl_open(&fd, url, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL);
+ ret = ffurl_open(&fd, url, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL,
+ sap->protocols, NULL);
if (ret) {
ret = AVERROR(EIO);
goto fail;
}
- ret = ff_rtp_chain_mux_open(&contexts[i], s, s->streams[i], fd, 0);
+ ret = ff_rtp_chain_mux_open(&contexts[i], s, s->streams[i], fd, 0, i);
if (ret < 0)
goto fail;
s->streams[i]->priv_data = contexts[i];
+ s->streams[i]->time_base = contexts[i]->streams[0]->time_base;
av_strlcpy(contexts[i]->filename, url, sizeof(contexts[i]->filename));
}
+ if (s->nb_streams > 0 && title)
+ av_dict_set(&contexts[0]->metadata, "title", title->value, 0);
+
ff_url_join(url, sizeof(url), "udp", NULL, announce_addr, port,
"?ttl=%d&connect=1", ttl);
ret = ffurl_open(&sap->ann_fd, url, AVIO_FLAG_WRITE,
- &s->interrupt_callback, NULL);
+ &s->interrupt_callback, NULL, sap->protocols, NULL);
if (ret) {
ret = AVERROR(EIO);
goto fail;
{
AVFormatContext *rtpctx;
struct SAPState *sap = s->priv_data;
- int64_t now = av_gettime();
+ int64_t now = av_gettime_relative();
if (!sap->last_time || now - sap->last_time > 5000000) {
int ret = ffurl_write(sap->ann_fd, sap->ann, sap->ann_size);
AVOutputFormat ff_sap_muxer = {
.name = "sap",
- .long_name = NULL_IF_CONFIG_SMALL("SAP output format"),
+ .long_name = NULL_IF_CONFIG_SMALL("SAP output"),
.priv_data_size = sizeof(struct SAPState),
- .audio_codec = CODEC_ID_AAC,
- .video_codec = CODEC_ID_MPEG4,
+ .audio_codec = AV_CODEC_ID_AAC,
+ .video_codec = AV_CODEC_ID_MPEG4,
.write_header = sap_write_header,
.write_packet = sap_write_packet,
.write_trailer = sap_write_close,