Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v6 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file
@ 2023-01-07  0:15 Basel Sayeh
  2023-01-07  0:23 ` [FFmpeg-devel] [PATCH v6 2/2] libavformat/dashenc: Enable HTTP persistent connections for dashenc_delete_file Basel Sayeh
  2023-01-13  6:03 ` [FFmpeg-devel] [PATCH v6 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file Steven Liu
  0 siblings, 2 replies; 3+ messages in thread
From: Basel Sayeh @ 2023-01-07  0:15 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Basel Sayeh

V6:
 - Removed the const for filename in "hls_delete_file" to
   fix compilation warnings

 - Removed the unnecessary calls to ff_format_io_close
   this patch introduced in hls_delete_file and in
   dashenc_delete_file

V1-V5:
 hls_delete_file and dashenc_delete_file functions open a
 new HTTP connection regardless of the http_persistent value,
 So change their behaviour to keep http connections open
 if http_persistent is set


Signed-off-by: Basel Sayeh <basel.sayeh@hotmail.com>
---
 libavformat/hlsenc.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a86fc8907f..39df9becc7 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -252,6 +252,7 @@ typedef struct HLSContext {
     int http_persistent;
     AVIOContext *m3u8_out;
     AVIOContext *sub_m3u8_out;
+    AVIOContext *http_delete;
     int64_t timeout;
     int ignore_io_errors;
     char *headers;
@@ -565,19 +566,22 @@ static void reflush_dynbuf(VariantStream *vs, int *range_length)
 #endif
 
 static int hls_delete_file(HLSContext *hls, AVFormatContext *avf,
-                           const char *path, const char *proto)
+                           char *path, const char *proto)
 {
     if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
         AVDictionary *opt = NULL;
-        AVIOContext  *out = NULL;
         int ret;
+
         set_http_options(avf, &opt, hls);
         av_dict_set(&opt, "method", "DELETE", 0);
-        ret = avf->io_open(avf, &out, path, AVIO_FLAG_WRITE, &opt);
+
+        ret = hlsenc_io_open(avf, &hls->http_delete, path, &opt);
         av_dict_free(&opt);
         if (ret < 0)
             return hls->ignore_io_errors ? 1 : ret;
-        ff_format_io_close(avf, &out);
+
+        //Nothing to write
+        hlsenc_io_close(avf, &hls->http_delete, path);
     } else if (unlink(path) < 0) {
         av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
                path, strerror(errno));
@@ -662,7 +666,7 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
         }
 
         proto = avio_find_protocol_name(s->url);
-        if (ret = hls_delete_file(hls, vs->avf, path.str, proto))
+        if (ret = hls_delete_file(hls, s, path.str, proto))
             goto fail;
 
         if ((segment->sub_filename[0] != '\0')) {
@@ -679,7 +683,7 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
                 goto fail;
             }
 
-            if (ret = hls_delete_file(hls, vs->vtt_avf, path.str, proto))
+            if (ret = hls_delete_file(hls, s, path.str, proto))
                 goto fail;
         }
         av_bprint_clear(&path);
@@ -2707,6 +2711,7 @@ static void hls_deinit(AVFormatContext *s)
 
     ff_format_io_close(s, &hls->m3u8_out);
     ff_format_io_close(s, &hls->sub_m3u8_out);
+    ff_format_io_close(s, &hls->http_delete);
     av_freep(&hls->key_basename);
     av_freep(&hls->var_streams);
     av_freep(&hls->cc_streams);
-- 
2.30.2

_______________________________________________
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] 3+ messages in thread

* [FFmpeg-devel] [PATCH v6 2/2] libavformat/dashenc: Enable HTTP persistent connections for dashenc_delete_file
  2023-01-07  0:15 [FFmpeg-devel] [PATCH v6 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file Basel Sayeh
@ 2023-01-07  0:23 ` Basel Sayeh
  2023-01-13  6:03 ` [FFmpeg-devel] [PATCH v6 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file Steven Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Basel Sayeh @ 2023-01-07  0:23 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Basel Sayeh

Signed-off-by: Basel Sayeh <basel.sayeh@hotmail.com>
---
 libavformat/dashenc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 9c1bcad9e3..8e725a0d3f 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -179,6 +179,7 @@ typedef struct DASHContext {
     int master_playlist_created;
     AVIOContext *mpd_out;
     AVIOContext *m3u8_out;
+    AVIOContext *http_delete;
     int streaming;
     int64_t timeout;
     int index_correction;
@@ -642,6 +643,7 @@ static void dash_free(AVFormatContext *s)
 
     ff_format_io_close(s, &c->mpd_out);
     ff_format_io_close(s, &c->m3u8_out);
+    ff_format_io_close(s, &c->http_delete);
 }
 
 static void output_segment_list(OutputStream *os, AVIOContext *out, AVFormatContext *s,
@@ -1855,18 +1857,18 @@ static void dashenc_delete_file(AVFormatContext *s, char *filename) {
     int http_base_proto = ff_is_http_proto(filename);
 
     if (http_base_proto) {
-        AVIOContext *out = NULL;
         AVDictionary *http_opts = NULL;
 
         set_http_options(&http_opts, c);
         av_dict_set(&http_opts, "method", "DELETE", 0);
 
-        if (dashenc_io_open(s, &out, filename, &http_opts) < 0) {
+        if (dashenc_io_open(s, &c->http_delete, filename, &http_opts) < 0) {
             av_log(s, AV_LOG_ERROR, "failed to delete %s\n", filename);
         }
-
         av_dict_free(&http_opts);
-        ff_format_io_close(s, &out);
+
+        //Nothing to write
+        dashenc_io_close(s, &c->http_delete, filename);
     } else {
         int res = ffurl_delete(filename);
         if (res < 0) {
-- 
2.30.2

_______________________________________________
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] 3+ messages in thread

* Re: [FFmpeg-devel] [PATCH v6 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file
  2023-01-07  0:15 [FFmpeg-devel] [PATCH v6 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file Basel Sayeh
  2023-01-07  0:23 ` [FFmpeg-devel] [PATCH v6 2/2] libavformat/dashenc: Enable HTTP persistent connections for dashenc_delete_file Basel Sayeh
@ 2023-01-13  6:03 ` Steven Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Steven Liu @ 2023-01-13  6:03 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Basel Sayeh

Basel Sayeh <basel.sayeh@hotmail.com> 于2023年1月7日周六 08:22写道:
>
> V6:
>  - Removed the const for filename in "hls_delete_file" to
>    fix compilation warnings
>
>  - Removed the unnecessary calls to ff_format_io_close
>    this patch introduced in hls_delete_file and in
>    dashenc_delete_file
>
> V1-V5:
>  hls_delete_file and dashenc_delete_file functions open a
>  new HTTP connection regardless of the http_persistent value,
>  So change their behaviour to keep http connections open
>  if http_persistent is set
>
>
> Signed-off-by: Basel Sayeh <basel.sayeh@hotmail.com>
> ---
>  libavformat/hlsenc.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index a86fc8907f..39df9becc7 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -252,6 +252,7 @@ typedef struct HLSContext {
>      int http_persistent;
>      AVIOContext *m3u8_out;
>      AVIOContext *sub_m3u8_out;
> +    AVIOContext *http_delete;
>      int64_t timeout;
>      int ignore_io_errors;
>      char *headers;
> @@ -565,19 +566,22 @@ static void reflush_dynbuf(VariantStream *vs, int *range_length)
>  #endif
>
>  static int hls_delete_file(HLSContext *hls, AVFormatContext *avf,
> -                           const char *path, const char *proto)
> +                           char *path, const char *proto)
>  {
>      if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
>          AVDictionary *opt = NULL;
> -        AVIOContext  *out = NULL;
>          int ret;
> +
>          set_http_options(avf, &opt, hls);
>          av_dict_set(&opt, "method", "DELETE", 0);
> -        ret = avf->io_open(avf, &out, path, AVIO_FLAG_WRITE, &opt);
> +
> +        ret = hlsenc_io_open(avf, &hls->http_delete, path, &opt);
>          av_dict_free(&opt);
>          if (ret < 0)
>              return hls->ignore_io_errors ? 1 : ret;
> -        ff_format_io_close(avf, &out);
> +
> +        //Nothing to write
> +        hlsenc_io_close(avf, &hls->http_delete, path);
>      } else if (unlink(path) < 0) {
>          av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
>                 path, strerror(errno));
> @@ -662,7 +666,7 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
>          }
>
>          proto = avio_find_protocol_name(s->url);
> -        if (ret = hls_delete_file(hls, vs->avf, path.str, proto))
> +        if (ret = hls_delete_file(hls, s, path.str, proto))
>              goto fail;
>
>          if ((segment->sub_filename[0] != '\0')) {
> @@ -679,7 +683,7 @@ static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
>                  goto fail;
>              }
>
> -            if (ret = hls_delete_file(hls, vs->vtt_avf, path.str, proto))
> +            if (ret = hls_delete_file(hls, s, path.str, proto))
>                  goto fail;
>          }
>          av_bprint_clear(&path);
> @@ -2707,6 +2711,7 @@ static void hls_deinit(AVFormatContext *s)
>
>      ff_format_io_close(s, &hls->m3u8_out);
>      ff_format_io_close(s, &hls->sub_m3u8_out);
> +    ff_format_io_close(s, &hls->http_delete);
>      av_freep(&hls->key_basename);
>      av_freep(&hls->var_streams);
>      av_freep(&hls->cc_streams);
> --
> 2.30.2
>
> _______________________________________________
> 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".


Patchset pushed


Thanks
Steven
_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2023-01-13  6:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-07  0:15 [FFmpeg-devel] [PATCH v6 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file Basel Sayeh
2023-01-07  0:23 ` [FFmpeg-devel] [PATCH v6 2/2] libavformat/dashenc: Enable HTTP persistent connections for dashenc_delete_file Basel Sayeh
2023-01-13  6:03 ` [FFmpeg-devel] [PATCH v6 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file Steven Liu

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