summaryrefslogtreecommitdiff
path: root/libavformat/sapenc.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2016-02-19 18:02:45 +0100
committerAnton Khirnov <anton@khirnov.net>2016-02-22 11:45:31 +0100
commit8c0ceafb0f25da077ff23e394667119f031574fd (patch)
treec495ca2679de2d9c0bc436652cfb5764cee47905 /libavformat/sapenc.c
parentcae448cfbf31d492cba782bc64fc4eed556ed83d (diff)
downloadffmpeg-8c0ceafb0f25da077ff23e394667119f031574fd.tar.gz
urlprotocol: receive a list of protocols from the caller
This way, the decisions about which protocols are available for use in any given situations can be delegated to the caller.
Diffstat (limited to 'libavformat/sapenc.c')
-rw-r--r--libavformat/sapenc.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libavformat/sapenc.c b/libavformat/sapenc.c
index 89f7f99ecc..54eb0bec38 100644
--- a/libavformat/sapenc.c
+++ b/libavformat/sapenc.c
@@ -37,6 +37,8 @@ struct SAPState {
int ann_size;
URLContext *ann_fd;
int64_t last_time;
+
+ const URLProtocol **protocols;
};
static int sap_write_close(AVFormatContext *s)
@@ -59,6 +61,8 @@ 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);
@@ -134,6 +138,12 @@ static int sap_write_header(AVFormatContext *s)
freeaddrinfo(ai);
}
+ sap->protocols = ffurl_get_protocols(NULL, NULL);
+ if (!sap->protocols) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
+
contexts = av_mallocz(sizeof(AVFormatContext*) * s->nb_streams);
if (!contexts) {
ret = AVERROR(ENOMEM);
@@ -148,7 +158,8 @@ static int sap_write_header(AVFormatContext *s)
"?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);
if (ret) {
ret = AVERROR(EIO);
goto fail;
@@ -167,7 +178,7 @@ static int sap_write_header(AVFormatContext *s)
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);
if (ret) {
ret = AVERROR(EIO);
goto fail;