[FFmpeg-cvslog] avio: add (ff)url_get_multi_file_handle() for getting more than one fd
Jordi Ortiz
git at videolan.org
Sat Aug 18 15:26:28 CEST 2012
ffmpeg | branch: master | Jordi Ortiz <nenjordi at gmail.com> | Fri Aug 17 18:38:59 2012 +0200| [d6b9da1178a8e84d1bf999337c058440826d3f54] | committer: Martin Storsjö
avio: add (ff)url_get_multi_file_handle() for getting more than one fd
Signed-off-by: Martin Storsjö <martin at martin.st>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d6b9da1178a8e84d1bf999337c058440826d3f54
---
libavformat/avio.c | 15 +++++++++++++++
libavformat/rtpproto.c | 30 ++++++++++++++++++++++--------
libavformat/url.h | 9 +++++++++
3 files changed, 46 insertions(+), 8 deletions(-)
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 5acaf30..45ee866 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -344,6 +344,21 @@ int ffurl_get_file_handle(URLContext *h)
return h->prot->url_get_file_handle(h);
}
+int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles)
+{
+ if (!h->prot->url_get_multi_file_handle) {
+ if (!h->prot->url_get_file_handle)
+ return AVERROR(ENOSYS);
+ *handles = av_malloc(sizeof(*handles));
+ if (!*handles)
+ return AVERROR(ENOMEM);
+ *numhandles = 1;
+ *handles[0] = h->prot->url_get_file_handle(h);
+ return 0;
+ }
+ return h->prot->url_get_multi_file_handle(h, handles, numhandles);
+}
+
int ffurl_shutdown(URLContext *h, int flags)
{
if (!h->prot->url_shutdown)
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index e70b89e..fc1ae06 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -320,13 +320,27 @@ int ff_rtp_get_rtcp_file_handle(URLContext *h) {
return s->rtcp_fd;
}
+static int rtp_get_multi_file_handle(URLContext *h, int **handles,
+ int *numhandles)
+{
+ RTPContext *s = h->priv_data;
+ int *hs = *handles = av_malloc(sizeof(**handles) * 2);
+ if (!hs)
+ return AVERROR(ENOMEM);
+ hs[0] = s->rtp_fd;
+ hs[1] = s->rtcp_fd;
+ *numhandles = 2;
+ return 0;
+}
+
URLProtocol ff_rtp_protocol = {
- .name = "rtp",
- .url_open = rtp_open,
- .url_read = rtp_read,
- .url_write = rtp_write,
- .url_close = rtp_close,
- .url_get_file_handle = rtp_get_file_handle,
- .priv_data_size = sizeof(RTPContext),
- .flags = URL_PROTOCOL_FLAG_NETWORK,
+ .name = "rtp",
+ .url_open = rtp_open,
+ .url_read = rtp_read,
+ .url_write = rtp_write,
+ .url_close = rtp_close,
+ .url_get_file_handle = rtp_get_file_handle,
+ .url_get_multi_file_handle = rtp_get_multi_file_handle,
+ .priv_data_size = sizeof(RTPContext),
+ .flags = URL_PROTOCOL_FLAG_NETWORK,
};
diff --git a/libavformat/url.h b/libavformat/url.h
index 0f0de78..195a8ff 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -81,6 +81,8 @@ typedef struct URLProtocol {
int64_t (*url_read_seek)(URLContext *h, 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,
+ int *numhandles);
int (*url_shutdown)(URLContext *h, int flags);
int priv_data_size;
const AVClass *priv_data_class;
@@ -202,6 +204,13 @@ int64_t ffurl_size(URLContext *h);
int ffurl_get_file_handle(URLContext *h);
/**
+ * Return the file descriptors associated with this URL.
+ *
+ * @return 0 on success or <0 on error.
+ */
+int ffurl_get_multi_file_handle(URLContext *h, int **handles, int *numhandles);
+
+/**
* Signal the URLContext that we are done reading or writing the stream.
*
* @param h pointer to the resource
More information about the ffmpeg-cvslog
mailing list