* [FFmpeg-devel] [PATCH 1/4] avformat/aviobuf: Move code specific to URLContexts to avio.c
@ 2024-03-02 19:50 Andreas Rheinhardt
2024-03-02 19:51 ` [FFmpeg-devel] [PATCH 2/4] avformat/avio: Avoid function pointer casts Andreas Rheinhardt
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Andreas Rheinhardt @ 2024-03-02 19:50 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This separates the URL-layer adjacent parts of the code
from the parts that are also usable with custom IO.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavformat/avio.c | 191 +++++++++++++++++++++++++++++++++++++++++-
libavformat/aviobuf.c | 186 ----------------------------------------
libavformat/url.h | 2 -
3 files changed, 189 insertions(+), 190 deletions(-)
diff --git a/libavformat/avio.c b/libavformat/avio.c
index b793a7546c..794ebd4bd8 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -24,6 +24,7 @@
#include "libavutil/opt.h"
#include "libavutil/time.h"
#include "libavutil/avassert.h"
+#include "avio_internal.h"
#include "os_support.h"
#include "internal.h"
#if CONFIG_NETWORK
@@ -31,6 +32,8 @@
#endif
#include "url.h"
+#define IO_BUFFER_SIZE 32768
+
/** @name Logging context. */
/*@{*/
static const char *urlcontext_to_name(void *ptr)
@@ -60,7 +63,7 @@ static const AVOption options[] = {
{ NULL }
};
-const AVClass ffurl_context_class = {
+static const AVClass url_context_class = {
.class_name = "URLContext",
.item_name = urlcontext_to_name,
.option = options,
@@ -70,6 +73,47 @@ const AVClass ffurl_context_class = {
};
/*@}*/
+static void *avio_child_next(void *obj, void *prev)
+{
+ AVIOContext *s = obj;
+ return prev ? NULL : s->opaque;
+}
+
+static const AVClass *child_class_iterate(void **iter)
+{
+ const AVClass *c = *iter ? NULL : &url_context_class;
+ *iter = (void*)(uintptr_t)c;
+ return c;
+}
+
+#define AVIOOFFSET(x) offsetof(AVIOContext,x)
+#define E AV_OPT_FLAG_ENCODING_PARAM
+#define D AV_OPT_FLAG_DECODING_PARAM
+static const AVOption avio_options[] = {
+ {"protocol_whitelist", "List of protocols that are allowed to be used", AVIOOFFSET(protocol_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D },
+ { NULL },
+};
+
+const AVClass ff_avio_class = {
+ .class_name = "AVIOContext",
+ .item_name = av_default_item_name,
+ .version = LIBAVUTIL_VERSION_INT,
+ .option = avio_options,
+ .child_next = avio_child_next,
+ .child_class_iterate = child_class_iterate,
+};
+
+URLContext *ffio_geturlcontext(AVIOContext *s)
+{
+ if (!s)
+ return NULL;
+
+ if (s->opaque && s->read_packet == ffurl_read2)
+ return s->opaque;
+ else
+ return NULL;
+}
+
static int url_alloc_for_protocol(URLContext **puc, const URLProtocol *up,
const char *filename, int flags,
const AVIOInterruptCB *int_cb)
@@ -96,7 +140,7 @@ static int url_alloc_for_protocol(URLContext **puc, const URLProtocol *up,
err = AVERROR(ENOMEM);
goto fail;
}
- uc->av_class = &ffurl_context_class;
+ uc->av_class = &url_context_class;
uc->filename = (char *)&uc[1];
strcpy(uc->filename, filename);
uc->prot = up;
@@ -225,6 +269,17 @@ int ffurl_accept(URLContext *s, URLContext **c)
return AVERROR(EBADF);
}
+int avio_accept(AVIOContext *s, AVIOContext **c)
+{
+ int ret;
+ URLContext *sc = s->opaque;
+ URLContext *cc = NULL;
+ ret = ffurl_accept(sc, &cc);
+ if (ret < 0)
+ return ret;
+ return ffio_fdopen(c, cc);
+}
+
int ffurl_handshake(URLContext *c)
{
int ret;
@@ -237,6 +292,12 @@ int ffurl_handshake(URLContext *c)
return 0;
}
+int avio_handshake(AVIOContext *c)
+{
+ URLContext *cc = c->opaque;
+ return ffurl_handshake(cc);
+}
+
#define URL_SCHEME_CHARS \
"abcdefghijklmnopqrstuvwxyz" \
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
@@ -347,6 +408,92 @@ fail:
return ret;
}
+int ffio_fdopen(AVIOContext **s, URLContext *h)
+{
+ uint8_t *buffer = NULL;
+ int buffer_size, max_packet_size;
+
+ max_packet_size = h->max_packet_size;
+ if (max_packet_size) {
+ buffer_size = max_packet_size; /* no need to bufferize more than one packet */
+ } else {
+ buffer_size = IO_BUFFER_SIZE;
+ }
+ if (!(h->flags & AVIO_FLAG_WRITE) && h->is_streamed) {
+ if (buffer_size > INT_MAX/2)
+ return AVERROR(EINVAL);
+ buffer_size *= 2;
+ }
+ buffer = av_malloc(buffer_size);
+ if (!buffer)
+ return AVERROR(ENOMEM);
+
+ *s = avio_alloc_context(buffer, buffer_size, h->flags & AVIO_FLAG_WRITE, h,
+ ffurl_read2, ffurl_write2, ffurl_seek2);
+ if (!*s) {
+ av_freep(&buffer);
+ return AVERROR(ENOMEM);
+ }
+ (*s)->protocol_whitelist = av_strdup(h->protocol_whitelist);
+ if (!(*s)->protocol_whitelist && h->protocol_whitelist) {
+ avio_closep(s);
+ return AVERROR(ENOMEM);
+ }
+ (*s)->protocol_blacklist = av_strdup(h->protocol_blacklist);
+ if (!(*s)->protocol_blacklist && h->protocol_blacklist) {
+ avio_closep(s);
+ return AVERROR(ENOMEM);
+ }
+ (*s)->direct = h->flags & AVIO_FLAG_DIRECT;
+
+ (*s)->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL;
+ (*s)->max_packet_size = max_packet_size;
+ (*s)->min_packet_size = h->min_packet_size;
+ if(h->prot) {
+ (*s)->read_pause = (int (*)(void *, int))h->prot->url_read_pause;
+ (*s)->read_seek =
+ (int64_t (*)(void *, int, int64_t, int))h->prot->url_read_seek;
+
+ if (h->prot->url_read_seek)
+ (*s)->seekable |= AVIO_SEEKABLE_TIME;
+ }
+ ((FFIOContext*)(*s))->short_seek_get = ffurl_get_short_seek;
+ (*s)->av_class = &ff_avio_class;
+ return 0;
+}
+
+int ffio_open_whitelist(AVIOContext **s, const char *filename, int flags,
+ const AVIOInterruptCB *int_cb, AVDictionary **options,
+ const char *whitelist, const char *blacklist)
+{
+ URLContext *h;
+ int err;
+
+ *s = NULL;
+
+ err = ffurl_open_whitelist(&h, filename, flags, int_cb, options, whitelist, blacklist, NULL);
+ if (err < 0)
+ return err;
+ err = ffio_fdopen(s, h);
+ if (err < 0) {
+ ffurl_close(h);
+ return err;
+ }
+ return 0;
+}
+
+int avio_open2(AVIOContext **s, const char *filename, int flags,
+ const AVIOInterruptCB *int_cb, AVDictionary **options)
+{
+ return ffio_open_whitelist(s, filename, flags, int_cb, options, NULL, NULL);
+}
+
+int avio_open(AVIOContext **s, const char *filename, int flags)
+{
+ return avio_open2(s, filename, flags, NULL, NULL);
+}
+
+
static inline int retry_transfer_wrapper(URLContext *h, uint8_t *buf,
const uint8_t *cbuf,
int size, int size_min,
@@ -464,6 +611,46 @@ int ffurl_close(URLContext *h)
return ffurl_closep(&h);
}
+int avio_close(AVIOContext *s)
+{
+ FFIOContext *const ctx = ffiocontext(s);
+ URLContext *h;
+ int ret, error;
+
+ if (!s)
+ return 0;
+
+ avio_flush(s);
+ h = s->opaque;
+ s->opaque = NULL;
+
+ av_freep(&s->buffer);
+ if (s->write_flag)
+ av_log(s, AV_LOG_VERBOSE,
+ "Statistics: %"PRId64" bytes written, %d seeks, %d writeouts\n",
+ ctx->bytes_written, ctx->seek_count, ctx->writeout_count);
+ else
+ av_log(s, AV_LOG_VERBOSE, "Statistics: %"PRId64" bytes read, %d seeks\n",
+ ctx->bytes_read, ctx->seek_count);
+ av_opt_free(s);
+
+ error = s->error;
+ avio_context_free(&s);
+
+ ret = ffurl_close(h);
+ if (ret < 0)
+ return ret;
+
+ return error;
+}
+
+int avio_closep(AVIOContext **s)
+{
+ int ret = avio_close(*s);
+ *s = NULL;
+ return ret;
+}
+
const char *avio_find_protocol_name(const char *url)
{
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index d80b8527bb..8dfed22622 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -22,7 +22,6 @@
#include "libavutil/bprint.h"
#include "libavutil/crc.h"
#include "libavutil/dict.h"
-#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
@@ -31,7 +30,6 @@
#include "avio.h"
#include "avio_internal.h"
#include "internal.h"
-#include "url.h"
#include <stdarg.h>
#define IO_BUFFER_SIZE 32768
@@ -43,36 +41,6 @@
*/
#define SHORT_SEEK_THRESHOLD 32768
-static void *ff_avio_child_next(void *obj, void *prev)
-{
- AVIOContext *s = obj;
- return prev ? NULL : s->opaque;
-}
-
-static const AVClass *child_class_iterate(void **iter)
-{
- const AVClass *c = *iter ? NULL : &ffurl_context_class;
- *iter = (void*)(uintptr_t)c;
- return c;
-}
-
-#define OFFSET(x) offsetof(AVIOContext,x)
-#define E AV_OPT_FLAG_ENCODING_PARAM
-#define D AV_OPT_FLAG_DECODING_PARAM
-static const AVOption ff_avio_options[] = {
- {"protocol_whitelist", "List of protocols that are allowed to be used", OFFSET(protocol_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D },
- { NULL },
-};
-
-const AVClass ff_avio_class = {
- .class_name = "AVIOContext",
- .item_name = av_default_item_name,
- .version = LIBAVUTIL_VERSION_INT,
- .option = ff_avio_options,
- .child_next = ff_avio_child_next,
- .child_class_iterate = child_class_iterate,
-};
-
static void fill_buffer(AVIOContext *s);
static int url_resetbuf(AVIOContext *s, int flags);
/** @warning must be called before any I/O */
@@ -1035,71 +1003,6 @@ void ffio_write_lines(AVIOContext *s, const unsigned char *buf, int size,
}
}
-int ffio_fdopen(AVIOContext **s, URLContext *h)
-{
- uint8_t *buffer = NULL;
- int buffer_size, max_packet_size;
-
- max_packet_size = h->max_packet_size;
- if (max_packet_size) {
- buffer_size = max_packet_size; /* no need to bufferize more than one packet */
- } else {
- buffer_size = IO_BUFFER_SIZE;
- }
- if (!(h->flags & AVIO_FLAG_WRITE) && h->is_streamed) {
- if (buffer_size > INT_MAX/2)
- return AVERROR(EINVAL);
- buffer_size *= 2;
- }
- buffer = av_malloc(buffer_size);
- if (!buffer)
- return AVERROR(ENOMEM);
-
- *s = avio_alloc_context(buffer, buffer_size, h->flags & AVIO_FLAG_WRITE, h,
- ffurl_read2, ffurl_write2, ffurl_seek2);
- if (!*s) {
- av_freep(&buffer);
- return AVERROR(ENOMEM);
- }
- (*s)->protocol_whitelist = av_strdup(h->protocol_whitelist);
- if (!(*s)->protocol_whitelist && h->protocol_whitelist) {
- avio_closep(s);
- return AVERROR(ENOMEM);
- }
- (*s)->protocol_blacklist = av_strdup(h->protocol_blacklist);
- if (!(*s)->protocol_blacklist && h->protocol_blacklist) {
- avio_closep(s);
- return AVERROR(ENOMEM);
- }
- (*s)->direct = h->flags & AVIO_FLAG_DIRECT;
-
- (*s)->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL;
- (*s)->max_packet_size = max_packet_size;
- (*s)->min_packet_size = h->min_packet_size;
- if(h->prot) {
- (*s)->read_pause = (int (*)(void *, int))h->prot->url_read_pause;
- (*s)->read_seek =
- (int64_t (*)(void *, int, int64_t, int))h->prot->url_read_seek;
-
- if (h->prot->url_read_seek)
- (*s)->seekable |= AVIO_SEEKABLE_TIME;
- }
- ((FFIOContext*)(*s))->short_seek_get = ffurl_get_short_seek;
- (*s)->av_class = &ff_avio_class;
- return 0;
-}
-
-URLContext* ffio_geturlcontext(AVIOContext *s)
-{
- if (!s)
- return NULL;
-
- if (s->opaque && s->read_packet == ffurl_read2)
- return s->opaque;
- else
- return NULL;
-}
-
int ffio_copy_url_options(AVIOContext* pb, AVDictionary** avio_opts)
{
const char *opts[] = {
@@ -1300,78 +1203,6 @@ int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char **bufp, int buf_si
return 0;
}
-int avio_open(AVIOContext **s, const char *filename, int flags)
-{
- return avio_open2(s, filename, flags, NULL, NULL);
-}
-
-int ffio_open_whitelist(AVIOContext **s, const char *filename, int flags,
- const AVIOInterruptCB *int_cb, AVDictionary **options,
- const char *whitelist, const char *blacklist
- )
-{
- URLContext *h;
- int err;
-
- *s = NULL;
-
- err = ffurl_open_whitelist(&h, filename, flags, int_cb, options, whitelist, blacklist, NULL);
- if (err < 0)
- return err;
- err = ffio_fdopen(s, h);
- if (err < 0) {
- ffurl_close(h);
- return err;
- }
- return 0;
-}
-
-int avio_open2(AVIOContext **s, const char *filename, int flags,
- const AVIOInterruptCB *int_cb, AVDictionary **options)
-{
- return ffio_open_whitelist(s, filename, flags, int_cb, options, NULL, NULL);
-}
-
-int avio_close(AVIOContext *s)
-{
- FFIOContext *const ctx = ffiocontext(s);
- URLContext *h;
- int ret, error;
-
- if (!s)
- return 0;
-
- avio_flush(s);
- h = s->opaque;
- s->opaque = NULL;
-
- av_freep(&s->buffer);
- if (s->write_flag)
- av_log(s, AV_LOG_VERBOSE,
- "Statistics: %"PRId64" bytes written, %d seeks, %d writeouts\n",
- ctx->bytes_written, ctx->seek_count, ctx->writeout_count);
- else
- av_log(s, AV_LOG_VERBOSE, "Statistics: %"PRId64" bytes read, %d seeks\n",
- ctx->bytes_read, ctx->seek_count);
- av_opt_free(s);
-
- error = s->error;
- avio_context_free(&s);
-
- ret = ffurl_close(h);
- if (ret < 0)
- return ret;
-
- return error;
-}
-
-int avio_closep(AVIOContext **s)
-{
- int ret = avio_close(*s);
- *s = NULL;
- return ret;
-}
-
int avio_vprintf(AVIOContext *s, const char *fmt, va_list ap)
{
AVBPrint bp;
@@ -1450,23 +1281,6 @@ int avio_read_to_bprint(AVIOContext *h, AVBPrint *pb, size_t max_size)
return 0;
}
-int avio_accept(AVIOContext *s, AVIOContext **c)
-{
- int ret;
- URLContext *sc = s->opaque;
- URLContext *cc = NULL;
- ret = ffurl_accept(sc, &cc);
- if (ret < 0)
- return ret;
- return ffio_fdopen(c, cc);
-}
-
-int avio_handshake(AVIOContext *c)
-{
- URLContext *cc = c->opaque;
- return ffurl_handshake(cc);
-}
-
/* output in a dynamic buffer */
typedef struct DynBuffer {
diff --git a/libavformat/url.h b/libavformat/url.h
index 59d9f1b870..4f3bfb6d57 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -32,8 +32,6 @@
#define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */
#define URL_PROTOCOL_FLAG_NETWORK 2 /*< The protocol uses network */
-extern const AVClass ffurl_context_class;
-
typedef struct URLContext {
const AVClass *av_class; /**< information for av_log(). Set by url_open(). */
const struct URLProtocol *prot;
--
2.40.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 5+ messages in thread
* [FFmpeg-devel] [PATCH 2/4] avformat/avio: Avoid function pointer casts
2024-03-02 19:50 [FFmpeg-devel] [PATCH 1/4] avformat/aviobuf: Move code specific to URLContexts to avio.c Andreas Rheinhardt
@ 2024-03-02 19:51 ` Andreas Rheinhardt
2024-03-02 19:51 ` [FFmpeg-devel] [PATCH 3/4] avformat/avio: Avoid indirection in ffio_fdopen() Andreas Rheinhardt
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Andreas Rheinhardt @ 2024-03-02 19:51 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
It is undefined behaviour to use a different type for a call
than the actual type of the function.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavformat/avio.c | 5 ++---
libavformat/librtmp.c | 6 ++++--
libavformat/mmsh.c | 3 ++-
libavformat/rtmpproto.c | 6 ++++--
libavformat/url.h | 4 ++--
5 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 794ebd4bd8..1622a03d7f 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -450,9 +450,8 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
(*s)->max_packet_size = max_packet_size;
(*s)->min_packet_size = h->min_packet_size;
if(h->prot) {
- (*s)->read_pause = (int (*)(void *, int))h->prot->url_read_pause;
- (*s)->read_seek =
- (int64_t (*)(void *, int, int64_t, int))h->prot->url_read_seek;
+ (*s)->read_pause = h->prot->url_read_pause;
+ (*s)->read_seek = h->prot->url_read_seek;
if (h->prot->url_read_seek)
(*s)->seekable |= AVIO_SEEKABLE_TIME;
diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c
index 5fa788fac8..bdd82ce15f 100644
--- a/libavformat/librtmp.c
+++ b/libavformat/librtmp.c
@@ -220,8 +220,9 @@ static int rtmp_read(URLContext *s, uint8_t *buf, int size)
return ret;
}
-static int rtmp_read_pause(URLContext *s, int pause)
+static int rtmp_read_pause(void *opaque, int pause)
{
+ URLContext *s = opaque;
LibRTMPContext *ctx = s->priv_data;
RTMP *r = &ctx->rtmp;
@@ -230,9 +231,10 @@ static int rtmp_read_pause(URLContext *s, int pause)
return 0;
}
-static int64_t rtmp_read_seek(URLContext *s, int stream_index,
+static int64_t rtmp_read_seek(void *opaque, int stream_index,
int64_t timestamp, int flags)
{
+ URLContext *s = opaque;
LibRTMPContext *ctx = s->priv_data;
RTMP *r = &ctx->rtmp;
diff --git a/libavformat/mmsh.c b/libavformat/mmsh.c
index 672f4b3788..60113d61d2 100644
--- a/libavformat/mmsh.c
+++ b/libavformat/mmsh.c
@@ -371,9 +371,10 @@ static int mmsh_read(URLContext *h, uint8_t *buf, int size)
return res;
}
-static int64_t mmsh_read_seek(URLContext *h, int stream_index,
+static int64_t mmsh_read_seek(void *opaque, int stream_index,
int64_t timestamp, int flags)
{
+ URLContext *h = opaque;
MMSHContext *mmsh_old = h->priv_data;
MMSHContext *mmsh = av_mallocz(sizeof(*mmsh));
int ret;
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 817c27b7ef..4b01b67d28 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -2952,9 +2952,10 @@ static int rtmp_read(URLContext *s, uint8_t *buf, int size)
return orig_size;
}
-static int64_t rtmp_seek(URLContext *s, int stream_index, int64_t timestamp,
+static int64_t rtmp_seek(void *opaque, int stream_index, int64_t timestamp,
int flags)
{
+ URLContext *s = opaque;
RTMPContext *rt = s->priv_data;
int ret;
av_log(s, AV_LOG_DEBUG,
@@ -2972,8 +2973,9 @@ static int64_t rtmp_seek(URLContext *s, int stream_index, int64_t timestamp,
return timestamp;
}
-static int rtmp_pause(URLContext *s, int pause)
+static int rtmp_pause(void *opaque, int pause)
{
+ URLContext *s = opaque;
RTMPContext *rt = s->priv_data;
int ret;
av_log(s, AV_LOG_DEBUG, "Pause at timestamp %d\n",
diff --git a/libavformat/url.h b/libavformat/url.h
index 4f3bfb6d57..f62afedb78 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -76,8 +76,8 @@ typedef struct URLProtocol {
int (*url_write)(URLContext *h, const unsigned char *buf, int size);
int64_t (*url_seek)( URLContext *h, int64_t pos, int whence);
int (*url_close)(URLContext *h);
- int (*url_read_pause)(URLContext *h, int pause);
- int64_t (*url_read_seek)(URLContext *h, int stream_index,
+ int (*url_read_pause)(void *urlcontext, int pause);
+ int64_t (*url_read_seek)(void *urlcontext, int stream_index,
int64_t timestamp, int flags);
int (*url_get_file_handle)(URLContext *h);
int (*url_get_multi_file_handle)(URLContext *h, int **handles,
--
2.40.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 5+ messages in thread
* [FFmpeg-devel] [PATCH 3/4] avformat/avio: Avoid indirection in ffio_fdopen()
2024-03-02 19:50 [FFmpeg-devel] [PATCH 1/4] avformat/aviobuf: Move code specific to URLContexts to avio.c Andreas Rheinhardt
2024-03-02 19:51 ` [FFmpeg-devel] [PATCH 2/4] avformat/avio: Avoid function pointer casts Andreas Rheinhardt
@ 2024-03-02 19:51 ` Andreas Rheinhardt
2024-03-02 19:51 ` [FFmpeg-devel] [PATCH 4/4] avformat/avio: Avoid av_strdup(NULL) Andreas Rheinhardt
2024-03-04 16:12 ` [FFmpeg-devel] [PATCH 1/4] avformat/aviobuf: Move code specific to URLContexts to avio.c Andreas Rheinhardt
3 siblings, 0 replies; 5+ messages in thread
From: Andreas Rheinhardt @ 2024-03-02 19:51 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavformat/avio.c | 40 +++++++++++++++++++++-------------------
1 file changed, 21 insertions(+), 19 deletions(-)
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 1622a03d7f..f3d10fac39 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -408,8 +408,9 @@ fail:
return ret;
}
-int ffio_fdopen(AVIOContext **s, URLContext *h)
+int ffio_fdopen(AVIOContext **sp, URLContext *h)
{
+ AVIOContext *s;
uint8_t *buffer = NULL;
int buffer_size, max_packet_size;
@@ -428,36 +429,37 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
if (!buffer)
return AVERROR(ENOMEM);
- *s = avio_alloc_context(buffer, buffer_size, h->flags & AVIO_FLAG_WRITE, h,
- ffurl_read2, ffurl_write2, ffurl_seek2);
- if (!*s) {
+ *sp = avio_alloc_context(buffer, buffer_size, h->flags & AVIO_FLAG_WRITE, h,
+ ffurl_read2, ffurl_write2, ffurl_seek2);
+ if (!*sp) {
av_freep(&buffer);
return AVERROR(ENOMEM);
}
- (*s)->protocol_whitelist = av_strdup(h->protocol_whitelist);
- if (!(*s)->protocol_whitelist && h->protocol_whitelist) {
- avio_closep(s);
+ s = *sp;
+ s->protocol_whitelist = av_strdup(h->protocol_whitelist);
+ if (!s->protocol_whitelist && h->protocol_whitelist) {
+ avio_closep(sp);
return AVERROR(ENOMEM);
}
- (*s)->protocol_blacklist = av_strdup(h->protocol_blacklist);
- if (!(*s)->protocol_blacklist && h->protocol_blacklist) {
- avio_closep(s);
+ s->protocol_blacklist = av_strdup(h->protocol_blacklist);
+ if (!s->protocol_blacklist && h->protocol_blacklist) {
+ avio_closep(sp);
return AVERROR(ENOMEM);
}
- (*s)->direct = h->flags & AVIO_FLAG_DIRECT;
+ s->direct = h->flags & AVIO_FLAG_DIRECT;
- (*s)->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL;
- (*s)->max_packet_size = max_packet_size;
- (*s)->min_packet_size = h->min_packet_size;
+ s->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL;
+ s->max_packet_size = max_packet_size;
+ s->min_packet_size = h->min_packet_size;
if(h->prot) {
- (*s)->read_pause = h->prot->url_read_pause;
- (*s)->read_seek = h->prot->url_read_seek;
+ s->read_pause = h->prot->url_read_pause;
+ s->read_seek = h->prot->url_read_seek;
if (h->prot->url_read_seek)
- (*s)->seekable |= AVIO_SEEKABLE_TIME;
+ s->seekable |= AVIO_SEEKABLE_TIME;
}
- ((FFIOContext*)(*s))->short_seek_get = ffurl_get_short_seek;
- (*s)->av_class = &ff_avio_class;
+ ((FFIOContext*)s)->short_seek_get = ffurl_get_short_seek;
+ s->av_class = &ff_avio_class;
return 0;
}
--
2.40.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 5+ messages in thread
* [FFmpeg-devel] [PATCH 4/4] avformat/avio: Avoid av_strdup(NULL)
2024-03-02 19:50 [FFmpeg-devel] [PATCH 1/4] avformat/aviobuf: Move code specific to URLContexts to avio.c Andreas Rheinhardt
2024-03-02 19:51 ` [FFmpeg-devel] [PATCH 2/4] avformat/avio: Avoid function pointer casts Andreas Rheinhardt
2024-03-02 19:51 ` [FFmpeg-devel] [PATCH 3/4] avformat/avio: Avoid indirection in ffio_fdopen() Andreas Rheinhardt
@ 2024-03-02 19:51 ` Andreas Rheinhardt
2024-03-04 16:12 ` [FFmpeg-devel] [PATCH 1/4] avformat/aviobuf: Move code specific to URLContexts to avio.c Andreas Rheinhardt
3 siblings, 0 replies; 5+ messages in thread
From: Andreas Rheinhardt @ 2024-03-02 19:51 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavformat/avio.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/libavformat/avio.c b/libavformat/avio.c
index f3d10fac39..5186c2b464 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -436,15 +436,19 @@ int ffio_fdopen(AVIOContext **sp, URLContext *h)
return AVERROR(ENOMEM);
}
s = *sp;
- s->protocol_whitelist = av_strdup(h->protocol_whitelist);
- if (!s->protocol_whitelist && h->protocol_whitelist) {
- avio_closep(sp);
- return AVERROR(ENOMEM);
+ if (h->protocol_whitelist) {
+ s->protocol_whitelist = av_strdup(h->protocol_whitelist);
+ if (!s->protocol_whitelist) {
+ avio_closep(sp);
+ return AVERROR(ENOMEM);
+ }
}
- s->protocol_blacklist = av_strdup(h->protocol_blacklist);
- if (!s->protocol_blacklist && h->protocol_blacklist) {
- avio_closep(sp);
- return AVERROR(ENOMEM);
+ if (h->protocol_blacklist) {
+ s->protocol_blacklist = av_strdup(h->protocol_blacklist);
+ if (!s->protocol_blacklist) {
+ avio_closep(sp);
+ return AVERROR(ENOMEM);
+ }
}
s->direct = h->flags & AVIO_FLAG_DIRECT;
--
2.40.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/4] avformat/aviobuf: Move code specific to URLContexts to avio.c
2024-03-02 19:50 [FFmpeg-devel] [PATCH 1/4] avformat/aviobuf: Move code specific to URLContexts to avio.c Andreas Rheinhardt
` (2 preceding siblings ...)
2024-03-02 19:51 ` [FFmpeg-devel] [PATCH 4/4] avformat/avio: Avoid av_strdup(NULL) Andreas Rheinhardt
@ 2024-03-04 16:12 ` Andreas Rheinhardt
3 siblings, 0 replies; 5+ messages in thread
From: Andreas Rheinhardt @ 2024-03-04 16:12 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> This separates the URL-layer adjacent parts of the code
> from the parts that are also usable with custom IO.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavformat/avio.c | 191 +++++++++++++++++++++++++++++++++++++++++-
> libavformat/aviobuf.c | 186 ----------------------------------------
> libavformat/url.h | 2 -
> 3 files changed, 189 insertions(+), 190 deletions(-)
>
> diff --git a/libavformat/avio.c b/libavformat/avio.c
> index b793a7546c..794ebd4bd8 100644
> --- a/libavformat/avio.c
> +++ b/libavformat/avio.c
> @@ -24,6 +24,7 @@
> #include "libavutil/opt.h"
> #include "libavutil/time.h"
> #include "libavutil/avassert.h"
> +#include "avio_internal.h"
> #include "os_support.h"
> #include "internal.h"
> #if CONFIG_NETWORK
> @@ -31,6 +32,8 @@
> #endif
> #include "url.h"
>
> +#define IO_BUFFER_SIZE 32768
> +
> /** @name Logging context. */
> /*@{*/
> static const char *urlcontext_to_name(void *ptr)
> @@ -60,7 +63,7 @@ static const AVOption options[] = {
> { NULL }
> };
>
> -const AVClass ffurl_context_class = {
> +static const AVClass url_context_class = {
> .class_name = "URLContext",
> .item_name = urlcontext_to_name,
> .option = options,
> @@ -70,6 +73,47 @@ const AVClass ffurl_context_class = {
> };
> /*@}*/
>
> +static void *avio_child_next(void *obj, void *prev)
> +{
> + AVIOContext *s = obj;
> + return prev ? NULL : s->opaque;
> +}
> +
> +static const AVClass *child_class_iterate(void **iter)
> +{
> + const AVClass *c = *iter ? NULL : &url_context_class;
> + *iter = (void*)(uintptr_t)c;
> + return c;
> +}
> +
> +#define AVIOOFFSET(x) offsetof(AVIOContext,x)
> +#define E AV_OPT_FLAG_ENCODING_PARAM
> +#define D AV_OPT_FLAG_DECODING_PARAM
> +static const AVOption avio_options[] = {
> + {"protocol_whitelist", "List of protocols that are allowed to be used", AVIOOFFSET(protocol_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D },
> + { NULL },
> +};
> +
> +const AVClass ff_avio_class = {
> + .class_name = "AVIOContext",
> + .item_name = av_default_item_name,
> + .version = LIBAVUTIL_VERSION_INT,
> + .option = avio_options,
> + .child_next = avio_child_next,
> + .child_class_iterate = child_class_iterate,
> +};
> +
> +URLContext *ffio_geturlcontext(AVIOContext *s)
> +{
> + if (!s)
> + return NULL;
> +
> + if (s->opaque && s->read_packet == ffurl_read2)
> + return s->opaque;
> + else
> + return NULL;
> +}
> +
> static int url_alloc_for_protocol(URLContext **puc, const URLProtocol *up,
> const char *filename, int flags,
> const AVIOInterruptCB *int_cb)
> @@ -96,7 +140,7 @@ static int url_alloc_for_protocol(URLContext **puc, const URLProtocol *up,
> err = AVERROR(ENOMEM);
> goto fail;
> }
> - uc->av_class = &ffurl_context_class;
> + uc->av_class = &url_context_class;
> uc->filename = (char *)&uc[1];
> strcpy(uc->filename, filename);
> uc->prot = up;
> @@ -225,6 +269,17 @@ int ffurl_accept(URLContext *s, URLContext **c)
> return AVERROR(EBADF);
> }
>
> +int avio_accept(AVIOContext *s, AVIOContext **c)
> +{
> + int ret;
> + URLContext *sc = s->opaque;
> + URLContext *cc = NULL;
> + ret = ffurl_accept(sc, &cc);
> + if (ret < 0)
> + return ret;
> + return ffio_fdopen(c, cc);
> +}
> +
> int ffurl_handshake(URLContext *c)
> {
> int ret;
> @@ -237,6 +292,12 @@ int ffurl_handshake(URLContext *c)
> return 0;
> }
>
> +int avio_handshake(AVIOContext *c)
> +{
> + URLContext *cc = c->opaque;
> + return ffurl_handshake(cc);
> +}
> +
> #define URL_SCHEME_CHARS \
> "abcdefghijklmnopqrstuvwxyz" \
> "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
> @@ -347,6 +408,92 @@ fail:
> return ret;
> }
>
> +int ffio_fdopen(AVIOContext **s, URLContext *h)
> +{
> + uint8_t *buffer = NULL;
> + int buffer_size, max_packet_size;
> +
> + max_packet_size = h->max_packet_size;
> + if (max_packet_size) {
> + buffer_size = max_packet_size; /* no need to bufferize more than one packet */
> + } else {
> + buffer_size = IO_BUFFER_SIZE;
> + }
> + if (!(h->flags & AVIO_FLAG_WRITE) && h->is_streamed) {
> + if (buffer_size > INT_MAX/2)
> + return AVERROR(EINVAL);
> + buffer_size *= 2;
> + }
> + buffer = av_malloc(buffer_size);
> + if (!buffer)
> + return AVERROR(ENOMEM);
> +
> + *s = avio_alloc_context(buffer, buffer_size, h->flags & AVIO_FLAG_WRITE, h,
> + ffurl_read2, ffurl_write2, ffurl_seek2);
> + if (!*s) {
> + av_freep(&buffer);
> + return AVERROR(ENOMEM);
> + }
> + (*s)->protocol_whitelist = av_strdup(h->protocol_whitelist);
> + if (!(*s)->protocol_whitelist && h->protocol_whitelist) {
> + avio_closep(s);
> + return AVERROR(ENOMEM);
> + }
> + (*s)->protocol_blacklist = av_strdup(h->protocol_blacklist);
> + if (!(*s)->protocol_blacklist && h->protocol_blacklist) {
> + avio_closep(s);
> + return AVERROR(ENOMEM);
> + }
> + (*s)->direct = h->flags & AVIO_FLAG_DIRECT;
> +
> + (*s)->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL;
> + (*s)->max_packet_size = max_packet_size;
> + (*s)->min_packet_size = h->min_packet_size;
> + if(h->prot) {
> + (*s)->read_pause = (int (*)(void *, int))h->prot->url_read_pause;
> + (*s)->read_seek =
> + (int64_t (*)(void *, int, int64_t, int))h->prot->url_read_seek;
> +
> + if (h->prot->url_read_seek)
> + (*s)->seekable |= AVIO_SEEKABLE_TIME;
> + }
> + ((FFIOContext*)(*s))->short_seek_get = ffurl_get_short_seek;
> + (*s)->av_class = &ff_avio_class;
> + return 0;
> +}
> +
> +int ffio_open_whitelist(AVIOContext **s, const char *filename, int flags,
> + const AVIOInterruptCB *int_cb, AVDictionary **options,
> + const char *whitelist, const char *blacklist)
> +{
> + URLContext *h;
> + int err;
> +
> + *s = NULL;
> +
> + err = ffurl_open_whitelist(&h, filename, flags, int_cb, options, whitelist, blacklist, NULL);
> + if (err < 0)
> + return err;
> + err = ffio_fdopen(s, h);
> + if (err < 0) {
> + ffurl_close(h);
> + return err;
> + }
> + return 0;
> +}
> +
> +int avio_open2(AVIOContext **s, const char *filename, int flags,
> + const AVIOInterruptCB *int_cb, AVDictionary **options)
> +{
> + return ffio_open_whitelist(s, filename, flags, int_cb, options, NULL, NULL);
> +}
> +
> +int avio_open(AVIOContext **s, const char *filename, int flags)
> +{
> + return avio_open2(s, filename, flags, NULL, NULL);
> +}
> +
> +
> static inline int retry_transfer_wrapper(URLContext *h, uint8_t *buf,
> const uint8_t *cbuf,
> int size, int size_min,
> @@ -464,6 +611,46 @@ int ffurl_close(URLContext *h)
> return ffurl_closep(&h);
> }
>
> +int avio_close(AVIOContext *s)
> +{
> + FFIOContext *const ctx = ffiocontext(s);
> + URLContext *h;
> + int ret, error;
> +
> + if (!s)
> + return 0;
> +
> + avio_flush(s);
> + h = s->opaque;
> + s->opaque = NULL;
> +
> + av_freep(&s->buffer);
> + if (s->write_flag)
> + av_log(s, AV_LOG_VERBOSE,
> + "Statistics: %"PRId64" bytes written, %d seeks, %d writeouts\n",
> + ctx->bytes_written, ctx->seek_count, ctx->writeout_count);
> + else
> + av_log(s, AV_LOG_VERBOSE, "Statistics: %"PRId64" bytes read, %d seeks\n",
> + ctx->bytes_read, ctx->seek_count);
> + av_opt_free(s);
> +
> + error = s->error;
> + avio_context_free(&s);
> +
> + ret = ffurl_close(h);
> + if (ret < 0)
> + return ret;
> +
> + return error;
> +}
> +
> +int avio_closep(AVIOContext **s)
> +{
> + int ret = avio_close(*s);
> + *s = NULL;
> + return ret;
> +}
> +
>
> const char *avio_find_protocol_name(const char *url)
> {
> diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
> index d80b8527bb..8dfed22622 100644
> --- a/libavformat/aviobuf.c
> +++ b/libavformat/aviobuf.c
> @@ -22,7 +22,6 @@
> #include "libavutil/bprint.h"
> #include "libavutil/crc.h"
> #include "libavutil/dict.h"
> -#include "libavutil/internal.h"
> #include "libavutil/intreadwrite.h"
> #include "libavutil/log.h"
> #include "libavutil/opt.h"
> @@ -31,7 +30,6 @@
> #include "avio.h"
> #include "avio_internal.h"
> #include "internal.h"
> -#include "url.h"
> #include <stdarg.h>
>
> #define IO_BUFFER_SIZE 32768
> @@ -43,36 +41,6 @@
> */
> #define SHORT_SEEK_THRESHOLD 32768
>
> -static void *ff_avio_child_next(void *obj, void *prev)
> -{
> - AVIOContext *s = obj;
> - return prev ? NULL : s->opaque;
> -}
> -
> -static const AVClass *child_class_iterate(void **iter)
> -{
> - const AVClass *c = *iter ? NULL : &ffurl_context_class;
> - *iter = (void*)(uintptr_t)c;
> - return c;
> -}
> -
> -#define OFFSET(x) offsetof(AVIOContext,x)
> -#define E AV_OPT_FLAG_ENCODING_PARAM
> -#define D AV_OPT_FLAG_DECODING_PARAM
> -static const AVOption ff_avio_options[] = {
> - {"protocol_whitelist", "List of protocols that are allowed to be used", OFFSET(protocol_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, D },
> - { NULL },
> -};
> -
> -const AVClass ff_avio_class = {
> - .class_name = "AVIOContext",
> - .item_name = av_default_item_name,
> - .version = LIBAVUTIL_VERSION_INT,
> - .option = ff_avio_options,
> - .child_next = ff_avio_child_next,
> - .child_class_iterate = child_class_iterate,
> -};
> -
> static void fill_buffer(AVIOContext *s);
> static int url_resetbuf(AVIOContext *s, int flags);
> /** @warning must be called before any I/O */
> @@ -1035,71 +1003,6 @@ void ffio_write_lines(AVIOContext *s, const unsigned char *buf, int size,
> }
> }
>
> -int ffio_fdopen(AVIOContext **s, URLContext *h)
> -{
> - uint8_t *buffer = NULL;
> - int buffer_size, max_packet_size;
> -
> - max_packet_size = h->max_packet_size;
> - if (max_packet_size) {
> - buffer_size = max_packet_size; /* no need to bufferize more than one packet */
> - } else {
> - buffer_size = IO_BUFFER_SIZE;
> - }
> - if (!(h->flags & AVIO_FLAG_WRITE) && h->is_streamed) {
> - if (buffer_size > INT_MAX/2)
> - return AVERROR(EINVAL);
> - buffer_size *= 2;
> - }
> - buffer = av_malloc(buffer_size);
> - if (!buffer)
> - return AVERROR(ENOMEM);
> -
> - *s = avio_alloc_context(buffer, buffer_size, h->flags & AVIO_FLAG_WRITE, h,
> - ffurl_read2, ffurl_write2, ffurl_seek2);
> - if (!*s) {
> - av_freep(&buffer);
> - return AVERROR(ENOMEM);
> - }
> - (*s)->protocol_whitelist = av_strdup(h->protocol_whitelist);
> - if (!(*s)->protocol_whitelist && h->protocol_whitelist) {
> - avio_closep(s);
> - return AVERROR(ENOMEM);
> - }
> - (*s)->protocol_blacklist = av_strdup(h->protocol_blacklist);
> - if (!(*s)->protocol_blacklist && h->protocol_blacklist) {
> - avio_closep(s);
> - return AVERROR(ENOMEM);
> - }
> - (*s)->direct = h->flags & AVIO_FLAG_DIRECT;
> -
> - (*s)->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL;
> - (*s)->max_packet_size = max_packet_size;
> - (*s)->min_packet_size = h->min_packet_size;
> - if(h->prot) {
> - (*s)->read_pause = (int (*)(void *, int))h->prot->url_read_pause;
> - (*s)->read_seek =
> - (int64_t (*)(void *, int, int64_t, int))h->prot->url_read_seek;
> -
> - if (h->prot->url_read_seek)
> - (*s)->seekable |= AVIO_SEEKABLE_TIME;
> - }
> - ((FFIOContext*)(*s))->short_seek_get = ffurl_get_short_seek;
> - (*s)->av_class = &ff_avio_class;
> - return 0;
> -}
> -
> -URLContext* ffio_geturlcontext(AVIOContext *s)
> -{
> - if (!s)
> - return NULL;
> -
> - if (s->opaque && s->read_packet == ffurl_read2)
> - return s->opaque;
> - else
> - return NULL;
> -}
> -
> int ffio_copy_url_options(AVIOContext* pb, AVDictionary** avio_opts)
> {
> const char *opts[] = {
> @@ -1300,78 +1203,6 @@ int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char **bufp, int buf_si
> return 0;
> }
>
> -int avio_open(AVIOContext **s, const char *filename, int flags)
> -{
> - return avio_open2(s, filename, flags, NULL, NULL);
> -}
> -
> -int ffio_open_whitelist(AVIOContext **s, const char *filename, int flags,
> - const AVIOInterruptCB *int_cb, AVDictionary **options,
> - const char *whitelist, const char *blacklist
> - )
> -{
> - URLContext *h;
> - int err;
> -
> - *s = NULL;
> -
> - err = ffurl_open_whitelist(&h, filename, flags, int_cb, options, whitelist, blacklist, NULL);
> - if (err < 0)
> - return err;
> - err = ffio_fdopen(s, h);
> - if (err < 0) {
> - ffurl_close(h);
> - return err;
> - }
> - return 0;
> -}
> -
> -int avio_open2(AVIOContext **s, const char *filename, int flags,
> - const AVIOInterruptCB *int_cb, AVDictionary **options)
> -{
> - return ffio_open_whitelist(s, filename, flags, int_cb, options, NULL, NULL);
> -}
> -
> -int avio_close(AVIOContext *s)
> -{
> - FFIOContext *const ctx = ffiocontext(s);
> - URLContext *h;
> - int ret, error;
> -
> - if (!s)
> - return 0;
> -
> - avio_flush(s);
> - h = s->opaque;
> - s->opaque = NULL;
> -
> - av_freep(&s->buffer);
> - if (s->write_flag)
> - av_log(s, AV_LOG_VERBOSE,
> - "Statistics: %"PRId64" bytes written, %d seeks, %d writeouts\n",
> - ctx->bytes_written, ctx->seek_count, ctx->writeout_count);
> - else
> - av_log(s, AV_LOG_VERBOSE, "Statistics: %"PRId64" bytes read, %d seeks\n",
> - ctx->bytes_read, ctx->seek_count);
> - av_opt_free(s);
> -
> - error = s->error;
> - avio_context_free(&s);
> -
> - ret = ffurl_close(h);
> - if (ret < 0)
> - return ret;
> -
> - return error;
> -}
> -
> -int avio_closep(AVIOContext **s)
> -{
> - int ret = avio_close(*s);
> - *s = NULL;
> - return ret;
> -}
> -
> int avio_vprintf(AVIOContext *s, const char *fmt, va_list ap)
> {
> AVBPrint bp;
> @@ -1450,23 +1281,6 @@ int avio_read_to_bprint(AVIOContext *h, AVBPrint *pb, size_t max_size)
> return 0;
> }
>
> -int avio_accept(AVIOContext *s, AVIOContext **c)
> -{
> - int ret;
> - URLContext *sc = s->opaque;
> - URLContext *cc = NULL;
> - ret = ffurl_accept(sc, &cc);
> - if (ret < 0)
> - return ret;
> - return ffio_fdopen(c, cc);
> -}
> -
> -int avio_handshake(AVIOContext *c)
> -{
> - URLContext *cc = c->opaque;
> - return ffurl_handshake(cc);
> -}
> -
> /* output in a dynamic buffer */
>
> typedef struct DynBuffer {
> diff --git a/libavformat/url.h b/libavformat/url.h
> index 59d9f1b870..4f3bfb6d57 100644
> --- a/libavformat/url.h
> +++ b/libavformat/url.h
> @@ -32,8 +32,6 @@
> #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */
> #define URL_PROTOCOL_FLAG_NETWORK 2 /*< The protocol uses network */
>
> -extern const AVClass ffurl_context_class;
> -
> typedef struct URLContext {
> const AVClass *av_class; /**< information for av_log(). Set by url_open(). */
> const struct URLProtocol *prot;
Will apply this patchset tomorrow unless there are objections.
- Andreas
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-03-04 16:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-02 19:50 [FFmpeg-devel] [PATCH 1/4] avformat/aviobuf: Move code specific to URLContexts to avio.c Andreas Rheinhardt
2024-03-02 19:51 ` [FFmpeg-devel] [PATCH 2/4] avformat/avio: Avoid function pointer casts Andreas Rheinhardt
2024-03-02 19:51 ` [FFmpeg-devel] [PATCH 3/4] avformat/avio: Avoid indirection in ffio_fdopen() Andreas Rheinhardt
2024-03-02 19:51 ` [FFmpeg-devel] [PATCH 4/4] avformat/avio: Avoid av_strdup(NULL) Andreas Rheinhardt
2024-03-04 16:12 ` [FFmpeg-devel] [PATCH 1/4] avformat/aviobuf: Move code specific to URLContexts to avio.c Andreas Rheinhardt
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git