[FFmpeg-devel] avformat/dashdec: add ProgramInformation parser

Submitted by Steven Liu on April 15, 2019, 6:26 a.m.

Details

Message ID 20190415062604.23419-1-lq@chinaffmpeg.org
State New
Headers show

Commit Message

Steven Liu April 15, 2019, 6:26 a.m.
Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/dashdec.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

Comments

Carl Eugen Hoyos April 15, 2019, 10:59 a.m.
2019-04-15 8:26 GMT+02:00, Steven Liu <lq@chinaffmpeg.org>:
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/dashdec.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
>
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index eed149cd1a..b6394403b9 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -1161,6 +1161,36 @@ static int
> parse_manifest_adaptationset(AVFormatContext *s, const char *url,
>      return 0;
>  }
>
> +static int parse_programinformation(AVFormatContext *s, xmlNodePtr node)
> +{
> +    xmlNodePtr programinfo_node = NULL;
> +    xmlChar *val = NULL;

> +    DASHContext *c = s->priv_data;

Unused variable.

> +
> +    programinfo_node = xmlFirstElementChild(node);
> +    while (programinfo_node) {

> +        if (!av_strcasecmp((const char *)programinfo_node->name,

Unneeded cast.

> (const char *)"Title")) {

Unneeded cast.

Carl Eugen
Steven Liu April 15, 2019, 11:18 a.m.
Carl Eugen Hoyos <ceffmpeg@gmail.com> 于2019年4月15日周一 下午6:59写道:
>
> 2019-04-15 8:26 GMT+02:00, Steven Liu <lq@chinaffmpeg.org>:
> > Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> > ---
> >  libavformat/dashdec.c | 32 ++++++++++++++++++++++++++++++++
> >  1 file changed, 32 insertions(+)
> >
> > diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> > index eed149cd1a..b6394403b9 100644
> > --- a/libavformat/dashdec.c
> > +++ b/libavformat/dashdec.c
> > @@ -1161,6 +1161,36 @@ static int
> > parse_manifest_adaptationset(AVFormatContext *s, const char *url,
> >      return 0;
> >  }
> >
> > +static int parse_programinformation(AVFormatContext *s, xmlNodePtr node)
> > +{
> > +    xmlNodePtr programinfo_node = NULL;
> > +    xmlChar *val = NULL;
>
> > +    DASHContext *c = s->priv_data;
>
> Unused variable.
>
> > +
> > +    programinfo_node = xmlFirstElementChild(node);
> > +    while (programinfo_node) {
>
> > +        if (!av_strcasecmp((const char *)programinfo_node->name,
>
> Unneeded cast.
>
> > (const char *)"Title")) {
>
> Unneeded cast.
>

Ok, will update new version.

Thanks Carl

Patch hide | download patch | download mbox

diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
index eed149cd1a..b6394403b9 100644
--- a/libavformat/dashdec.c
+++ b/libavformat/dashdec.c
@@ -1161,6 +1161,36 @@  static int parse_manifest_adaptationset(AVFormatContext *s, const char *url,
     return 0;
 }
 
+static int parse_programinformation(AVFormatContext *s, xmlNodePtr node)
+{
+    xmlNodePtr programinfo_node = NULL;
+    xmlChar *val = NULL;
+    DASHContext *c = s->priv_data;
+
+    programinfo_node = xmlFirstElementChild(node);
+    while (programinfo_node) {
+        if (!av_strcasecmp((const char *)programinfo_node->name, (const char *)"Title")) {
+            val = xmlNodeGetContent(programinfo_node);
+            if (val && strlen(val) < 1024) {
+                av_dict_set(&s->metadata, "Title", val, 0);
+            }
+        } else if (!av_strcasecmp((const char *)programinfo_node->name, (const char *)"Source")) {
+            val = xmlNodeGetContent(programinfo_node);
+            if (val && strlen(val) < 1024) {
+                av_dict_set(&s->metadata, "Source", val, 0);
+            }
+        } else if (!av_strcasecmp((const char *)programinfo_node->name, (const char *)"Copyright")) {
+            val = xmlNodeGetContent(programinfo_node);
+            if (val && strlen(val) < 1024) {
+                av_dict_set(&s->metadata, "Copyright", val, 0);
+            }
+        }
+        programinfo_node = xmlNextElementSibling(programinfo_node);
+        xmlFree(val);
+    }
+    return 0;
+}
+
 static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in)
 {
     DASHContext *c = s->priv_data;
@@ -1310,6 +1340,8 @@  static int parse_manifest(AVFormatContext *s, const char *url, AVIOContext *in)
                     if (c->period_start > 0)
                         c->media_presentation_duration = c->period_duration;
                 }
+            } else if (!av_strcasecmp(node->name, (const char *)"ProgramInformation")) {
+                parse_programinformation(s, node);
             }
             node = xmlNextElementSibling(node);
         }