[FFmpeg-devel,V1,1/5] lavf/hls: Update av_log() log message

Submitted by Jun Zhao on June 4, 2019, 5:38 a.m.

Details

Message ID 1559626724-16376-1-git-send-email-mypopydev@gmail.com
State New
Headers show

Commit Message

Jun Zhao June 4, 2019, 5:38 a.m.
From: Jun Zhao <barryjzhao@tencent.com>

Pass correct pointer to av_log() and update some error/warning message,
it's will help the debugging

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavformat/hls.c |   22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

Comments

Steven Liu June 4, 2019, 6:13 a.m.
> 在 2019年6月4日,下午1:38,Jun Zhao <mypopydev@gmail.com> 写道:
> 
> From: Jun Zhao <barryjzhao@tencent.com>
> 
> Pass correct pointer to av_log() and update some error/warning message,
> it's will help the debugging
> 
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
> libavformat/hls.c |   22 ++++++++++++++--------
> 1 files changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 19ea88e..1b45fe2 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -476,17 +476,23 @@ static struct rendition *new_rendition(HLSContext *c, struct rendition_info *inf
>          * AVC SEI RBSP anyway */
>         return NULL;
> 
> -    if (type == AVMEDIA_TYPE_UNKNOWN)
> +    if (type == AVMEDIA_TYPE_UNKNOWN) {
> +        av_log(c, AV_LOG_WARNING, "Can't support the type: %s\n", info->type);
>         return NULL;
> +    }
> 
>     /* URI is mandatory for subtitles as per spec */
> -    if (type == AVMEDIA_TYPE_SUBTITLE && !info->uri[0])
> +    if (type == AVMEDIA_TYPE_SUBTITLE && !info->uri[0]) {
> +        av_log(c, AV_LOG_ERROR, "The URI tag is REQUIRED for subtitle.\n");
>         return NULL;
> +    }
> 
>     /* TODO: handle subtitles (each segment has to parsed separately) */
>     if (c->ctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL)
> -        if (type == AVMEDIA_TYPE_SUBTITLE)
> +        if (type == AVMEDIA_TYPE_SUBTITLE) {
> +            av_log(c, AV_LOG_WARNING, "Can't support the subtitle(uri: %s)\n", info->uri);
>             return NULL;
> +        }
> 
>     rend = av_mallocz(sizeof(struct rendition));
>     if (!rend)
> @@ -1202,12 +1208,12 @@ static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg,
>             if (open_url(pls->parent, &pb, seg->key, c->avio_opts, opts, NULL) == 0) {
>                 ret = avio_read(pb, pls->key, sizeof(pls->key));
>                 if (ret != sizeof(pls->key)) {
> -                    av_log(NULL, AV_LOG_ERROR, "Unable to read key file %s\n",
> +                    av_log(pls->parent, AV_LOG_ERROR, "Unable to read key file %s\n",
>                            seg->key);
>                 }
>                 ff_format_io_close(pls->parent, &pb);
>             } else {
> -                av_log(NULL, AV_LOG_ERROR, "Unable to open key file %s\n",
> +                av_log(pls->parent, AV_LOG_ERROR, "Unable to open key file %s\n",
>                        seg->key);
>             }
>             av_strlcpy(pls->key_url, seg->key, sizeof(pls->key_url));
> @@ -1419,7 +1425,7 @@ reload:
>             reload_interval = v->target_duration / 2;
>         }
>         if (v->cur_seq_no < v->start_seq_no) {
> -            av_log(NULL, AV_LOG_WARNING,
> +            av_log(v->parent, AV_LOG_WARNING,
>                    "skipping %d segments ahead, expired from playlists\n",
>                    v->start_seq_no - v->cur_seq_no);
>             v->cur_seq_no = v->start_seq_no;
> @@ -1800,7 +1806,7 @@ static int hls_read_header(AVFormatContext *s)
>         goto fail;
> 
>     if (c->n_variants == 0) {
> -        av_log(NULL, AV_LOG_WARNING, "Empty playlist\n");
> +        av_log(s, AV_LOG_WARNING, "Empty playlist\n");
>         ret = AVERROR_EOF;
>         goto fail;
>     }
> @@ -1815,7 +1821,7 @@ static int hls_read_header(AVFormatContext *s)
>     }
> 
>     if (c->variants[0]->playlists[0]->n_segments == 0) {
> -        av_log(NULL, AV_LOG_WARNING, "Empty playlist\n");
> +        av_log(s, AV_LOG_WARNING, "Empty segment\n");
>         ret = AVERROR_EOF;
>         goto fail;
>     }
> -- 
> 1.7.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”.

LGTM

Thanks

Steven

Patch hide | download patch | download mbox

diff --git a/libavformat/hls.c b/libavformat/hls.c
index 19ea88e..1b45fe2 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -476,17 +476,23 @@  static struct rendition *new_rendition(HLSContext *c, struct rendition_info *inf
          * AVC SEI RBSP anyway */
         return NULL;
 
-    if (type == AVMEDIA_TYPE_UNKNOWN)
+    if (type == AVMEDIA_TYPE_UNKNOWN) {
+        av_log(c, AV_LOG_WARNING, "Can't support the type: %s\n", info->type);
         return NULL;
+    }
 
     /* URI is mandatory for subtitles as per spec */
-    if (type == AVMEDIA_TYPE_SUBTITLE && !info->uri[0])
+    if (type == AVMEDIA_TYPE_SUBTITLE && !info->uri[0]) {
+        av_log(c, AV_LOG_ERROR, "The URI tag is REQUIRED for subtitle.\n");
         return NULL;
+    }
 
     /* TODO: handle subtitles (each segment has to parsed separately) */
     if (c->ctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL)
-        if (type == AVMEDIA_TYPE_SUBTITLE)
+        if (type == AVMEDIA_TYPE_SUBTITLE) {
+            av_log(c, AV_LOG_WARNING, "Can't support the subtitle(uri: %s)\n", info->uri);
             return NULL;
+        }
 
     rend = av_mallocz(sizeof(struct rendition));
     if (!rend)
@@ -1202,12 +1208,12 @@  static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg,
             if (open_url(pls->parent, &pb, seg->key, c->avio_opts, opts, NULL) == 0) {
                 ret = avio_read(pb, pls->key, sizeof(pls->key));
                 if (ret != sizeof(pls->key)) {
-                    av_log(NULL, AV_LOG_ERROR, "Unable to read key file %s\n",
+                    av_log(pls->parent, AV_LOG_ERROR, "Unable to read key file %s\n",
                            seg->key);
                 }
                 ff_format_io_close(pls->parent, &pb);
             } else {
-                av_log(NULL, AV_LOG_ERROR, "Unable to open key file %s\n",
+                av_log(pls->parent, AV_LOG_ERROR, "Unable to open key file %s\n",
                        seg->key);
             }
             av_strlcpy(pls->key_url, seg->key, sizeof(pls->key_url));
@@ -1419,7 +1425,7 @@  reload:
             reload_interval = v->target_duration / 2;
         }
         if (v->cur_seq_no < v->start_seq_no) {
-            av_log(NULL, AV_LOG_WARNING,
+            av_log(v->parent, AV_LOG_WARNING,
                    "skipping %d segments ahead, expired from playlists\n",
                    v->start_seq_no - v->cur_seq_no);
             v->cur_seq_no = v->start_seq_no;
@@ -1800,7 +1806,7 @@  static int hls_read_header(AVFormatContext *s)
         goto fail;
 
     if (c->n_variants == 0) {
-        av_log(NULL, AV_LOG_WARNING, "Empty playlist\n");
+        av_log(s, AV_LOG_WARNING, "Empty playlist\n");
         ret = AVERROR_EOF;
         goto fail;
     }
@@ -1815,7 +1821,7 @@  static int hls_read_header(AVFormatContext *s)
     }
 
     if (c->variants[0]->playlists[0]->n_segments == 0) {
-        av_log(NULL, AV_LOG_WARNING, "Empty playlist\n");
+        av_log(s, AV_LOG_WARNING, "Empty segment\n");
         ret = AVERROR_EOF;
         goto fail;
     }