[PATCH 2/4] Implement ffserver generic metadata setting in the stream.
Stefano Sabatini
stefano.sabatini-lala
Sun Apr 11 20:20:23 CEST 2010
Also disable the use of the deprecated fields of AVFormatContext title,
author, copyright, comment and album at the next libavformat major
bump.
---
ffserver.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/ffserver.c b/ffserver.c
index 0807e73..926eec3 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -213,10 +213,13 @@ typedef struct FFStream {
int feed_streams[MAX_STREAMS]; /* index of streams in the feed */
char feed_filename[1024]; /* file name of the feed storage, or
input file name for a stream */
+#if LIBAVFORMAT_VERSION_MAJOR < 53
char author[512];
char title[512];
char copyright[512];
char comment[512];
+#endif
+ AVMetadata *metadata;
pid_t pid; /* Of ffmpeg process */
time_t pid_start; /* Of ffmpeg process */
char **child_argv;
@@ -2227,15 +2230,20 @@ static int http_prepare_data(HTTPContext *c)
{
int i, len, ret;
AVFormatContext *ctx;
+ AVMetadataTag *tag = NULL;
av_freep(&c->pb_buffer);
switch(c->state) {
case HTTPSTATE_SEND_DATA_HEADER:
memset(&c->fmt_ctx, 0, sizeof(c->fmt_ctx));
+#if LIBAVFORMAT_VERSION_MAJOR < 53
av_metadata_set(&c->fmt_ctx.metadata, "author" ,c->stream->author);
av_metadata_set(&c->fmt_ctx.metadata, "comment" ,c->stream->comment);
av_metadata_set(&c->fmt_ctx.metadata, "copyright",c->stream->copyright);
av_metadata_set(&c->fmt_ctx.metadata, "title" ,c->stream->title);
+#endif
+ while ((tag = av_metadata_get(c->stream->metadata, "", tag, AV_METADATA_IGNORE_SUFFIX)))
+ av_metadata_set2(&c->fmt_ctx.metadata, tag->key, tag->value, 0);
for(i=0;i<c->stream->nb_streams;i++) {
AVStream *st;
@@ -4245,6 +4253,7 @@ static int parse_ffconfig(const char *filename)
} else {
ERROR("FaviconURL only permitted for status streams\n");
}
+#if LIBAVFORMAT_VERSION_MAJOR < 53
} else if (!strcasecmp(cmd, "Author")) {
if (stream)
get_arg(stream->author, sizeof(stream->author), &p);
@@ -4257,6 +4266,20 @@ static int parse_ffconfig(const char *filename)
} else if (!strcasecmp(cmd, "Title")) {
if (stream)
get_arg(stream->title, sizeof(stream->title), &p);
+#endif
+ } else if (!strcasecmp(cmd, "Metadata")) {
+ if (stream) {
+ char *mid;
+ get_arg(arg, sizeof(arg), &p);
+ if (!(mid = strchr(arg, '=')))
+ ERROR("Missing '=' in value for Metadata: %s\n", arg);
+ else {
+ *mid++= 0;
+ if (av_metadata_set2(&stream->metadata, arg, mid, 0) < 0) {
+ ERROR("Impossible to set metadata '%s' -> '%s'", arg, mid);
+ }
+ }
+ }
} else if (!strcasecmp(cmd, "Preroll")) {
get_arg(arg, sizeof(arg), &p);
if (stream)
--
1.7.0
--LQksG6bCIzRHxTLp--
More information about the ffmpeg-devel
mailing list