Re: [FFmpeg-devel] Update for my hls and dash patches?

2023-01-06 Thread Basel Sayeh


On 1/5/23 09:26, Steven Liu wrote:

Basel Sayeh  于2023年1月5日周四 09:19写道:



Hello,


Any update or comment on these patch sets?


Enable HTTP persistent connections for hls_delete_file &
dashenc_delete_file:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=8033

https://patchwork.ffmpeg.org/project/ffmpeg/patch/db9p191mb14827461396938910246ace9fe...@db9p191mb1482.eurp191.prod.outlook.com/

You should check the first patch of this series.

Do you mean i should take a look at the warnings?

Yes, just fix the warning should be ok.


Just sent a V6 that should have no new compilation warnings,

https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=8163




Use http_read_header in http_shutdown to react to response errors:
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=8058

Is it will use block mode of socket?

Yes, it will wait for a server reply (if not sent), and react to some http 
errors, like 404
I am aware that it may slow the encoding/sending down, but is there any better 
way that it can be done?

Yes, you aware that, so that if a problem. I have no better way to do
that. :( Maybe other developer can give us some better way?


I hope developers can give their input on this


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v6 2/2] libavformat/dashenc: Enable HTTP persistent connections for dashenc_delete_file

2023-01-06 Thread Basel Sayeh
Signed-off-by: Basel Sayeh 
---
 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, >mpd_out);
 ff_format_io_close(s, >m3u8_out);
+ff_format_io_close(s, >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(_opts, c);
 av_dict_set(_opts, "method", "DELETE", 0);
 
-if (dashenc_io_open(s, , filename, _opts) < 0) {
+if (dashenc_io_open(s, >http_delete, filename, _opts) < 0) {
 av_log(s, AV_LOG_ERROR, "failed to delete %s\n", filename);
 }
-
 av_dict_free(_opts);
-ff_format_io_close(s, );
+
+//Nothing to write
+dashenc_io_close(s, >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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v6 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file

2023-01-06 Thread 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 
---
 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, , hls);
 av_dict_set(, "method", "DELETE", 0);
-ret = avf->io_open(avf, , path, AVIO_FLAG_WRITE, );
+
+ret = hlsenc_io_open(avf, >http_delete, path, );
 av_dict_free();
 if (ret < 0)
 return hls->ignore_io_errors ? 1 : ret;
-ff_format_io_close(avf, );
+
+//Nothing to write
+hlsenc_io_close(avf, >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();
@@ -2707,6 +2711,7 @@ static void hls_deinit(AVFormatContext *s)
 
 ff_format_io_close(s, >m3u8_out);
 ff_format_io_close(s, >sub_m3u8_out);
+ff_format_io_close(s, >http_delete);
 av_freep(>key_basename);
 av_freep(>var_streams);
 av_freep(>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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] Update for my hls and dash patches?

2023-01-04 Thread Basel Sayeh


> >
> > Hello,
> >
> >
> > Any update or comment on these patch sets?
> >
> >
> > Enable HTTP persistent connections for hls_delete_file &
> > dashenc_delete_file:
> > https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=8033

> https://patchwork.ffmpeg.org/project/ffmpeg/patch/db9p191mb14827461396938910246ace9fe...@db9p191mb1482.eurp191.prod.outlook.com/
>
> You should check the first patch of this series.

Do you mean i should take a look at the warnings?

> >
> >
> > Use http_read_header in http_shutdown to react to response errors:
> > https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=8058
> Is it will use block mode of socket?

Yes, it will wait for a server reply (if not sent), and react to some http 
errors, like 404
I am aware that it may slow the encoding/sending down, but is there any better 
way that it can be done?

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] Update for my hls and dash patches?

2023-01-03 Thread Basel Sayeh

Hello,


Any update or comment on these patch sets?


Enable HTTP persistent connections for hls_delete_file & 
dashenc_delete_file: 
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=8033



Use http_read_header in http_shutdown to react to response errors: 
https://patchwork.ffmpeg.org/project/ffmpeg/list/?series=8058



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 2/2] libavformat/hlsenc: Return in hls_write_packet if error after retrying with a new http session

2022-12-10 Thread Basel Sayeh
Signed-off-by: Basel Sayeh 
---
 libavformat/hlsenc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a86fc8907f..57149985da 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2591,6 +2591,9 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 av_dict_free();
 av_freep(>temp_buffer);
 av_freep();
+
+if (ret < 0)
+return hls->ignore_io_errors ? 0 : ret;
 }
 
 if (use_temp_file)
-- 
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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 1/2] libavformat/http: Use http_read_header in http_shutdown to react to response errors

2022-12-10 Thread Basel Sayeh
Use http_read_header to parse and print/react to errors in http_shutdown if
 the http server responds with an error (404/500/...)

Signed-off-by: Basel Sayeh 
---
 libavformat/http.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 7bce821535..123a7c77f2 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -1853,15 +1853,13 @@ static int http_shutdown(URLContext *h, int flags)
 ((flags & AVIO_FLAG_READ) && s->chunked_post && s->listen)) {
 ret = ffurl_write(s->hd, footer, sizeof(footer) - 1);
 ret = ret > 0 ? 0 : ret;
-/* flush the receive buffer when it is write only mode */
+
+/* Read and parse http headers when it is write only mode to react to 
response errors */
 if (!(flags & AVIO_FLAG_READ)) {
-char buf[1024];
 int read_ret;
-s->hd->flags |= AVIO_FLAG_NONBLOCK;
-read_ret = ffurl_read(s->hd, buf, sizeof(buf));
-s->hd->flags &= ~AVIO_FLAG_NONBLOCK;
+read_ret = http_read_header(h);
 if (read_ret < 0 && read_ret != AVERROR(EAGAIN)) {
-av_log(h, AV_LOG_ERROR, "URL read error: %s\n", 
av_err2str(read_ret));
+av_log(h, AV_LOG_ERROR, "HTTP error: %s\n", 
av_err2str(read_ret));
 ret = read_ret;
 }
 }
-- 
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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] A question about http connections

2022-12-06 Thread Basel Sayeh
Hello

I'm thinking of implementing code to check the server response for the hls/dash 
encoders (incase the output was a URL).

Is it ok to implement it inside hlsenc_io_close/dashenc_io_close, and using 
blocking ffurl_read?

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v5 2/2] libavformat/dashenc: Enable HTTP persistent connections for dashenc_delete_file

2022-12-06 Thread Basel Sayeh
Signed-off-by: Basel Sayeh 
---
 libavformat/dashenc.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 9c1bcad9e3..ba0eb913a1 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, >mpd_out);
 ff_format_io_close(s, >m3u8_out);
+ff_format_io_close(s, >http_delete);
 }
 
 static void output_segment_list(OutputStream *os, AVIOContext *out, 
AVFormatContext *s,
@@ -1855,18 +1857,22 @@ 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(_opts, c);
 av_dict_set(_opts, "method", "DELETE", 0);
 
-if (dashenc_io_open(s, , filename, _opts) < 0) {
+if (dashenc_io_open(s, >http_delete, filename, _opts) < 0) {
 av_log(s, AV_LOG_ERROR, "failed to delete %s\n", filename);
+} else {
+//Nothing to write
+avio_flush(c->http_delete);
+dashenc_io_close(s, >http_delete, filename);
 }
-
 av_dict_free(_opts);
-ff_format_io_close(s, );
+
+if (!c->http_persistent)
+ff_format_io_close(s, >http_delete);
 } 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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v5 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file

2022-12-06 Thread Basel Sayeh
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 
---
 libavformat/hlsenc.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a86fc8907f..9781ed1ceb 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;
@@ -569,15 +570,21 @@ static int hls_delete_file(HLSContext *hls, 
AVFormatContext *avf,
 {
 if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
 AVDictionary *opt = NULL;
-AVIOContext  *out = NULL;
 int ret;
+
 set_http_options(avf, , hls);
 av_dict_set(, "method", "DELETE", 0);
-ret = avf->io_open(avf, , path, AVIO_FLAG_WRITE, );
+ret = hlsenc_io_open(avf, >http_delete, path, );
 av_dict_free();
 if (ret < 0)
 return hls->ignore_io_errors ? 1 : ret;
-ff_format_io_close(avf, );
+
+//Nothing to write
+avio_flush(hls->http_delete);
+hlsenc_io_close(avf, >http_delete, path);
+
+if (!hls->http_persistent)
+ff_format_io_close(avf, >http_delete);
 } else if (unlink(path) < 0) {
 av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
path, strerror(errno));
@@ -662,7 +669,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 +686,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();
@@ -2707,6 +2714,7 @@ static void hls_deinit(AVFormatContext *s)
 
 ff_format_io_close(s, >m3u8_out);
 ff_format_io_close(s, >sub_m3u8_out);
+ff_format_io_close(s, >http_delete);
 av_freep(>key_basename);
 av_freep(>var_streams);
 av_freep(>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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v4 1/2] libavformat/hlsenc: Enable HTTP persistent connections for for hls_delete_file

2022-12-06 Thread Basel Sayeh
mistakes keep on happening, please use v5


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v4 2/2] libavformat/dashenc: Enable HTTP persistent connections for for dashenc_delete_file

2022-12-06 Thread Basel Sayeh
Signed-off-by: Basel Sayeh 
---
 libavformat/dashenc.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 9c1bcad9e3..ba0eb913a1 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, >mpd_out);
 ff_format_io_close(s, >m3u8_out);
+ff_format_io_close(s, >http_delete);
 }
 
 static void output_segment_list(OutputStream *os, AVIOContext *out, 
AVFormatContext *s,
@@ -1855,18 +1857,22 @@ 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(_opts, c);
 av_dict_set(_opts, "method", "DELETE", 0);
 
-if (dashenc_io_open(s, , filename, _opts) < 0) {
+if (dashenc_io_open(s, >http_delete, filename, _opts) < 0) {
 av_log(s, AV_LOG_ERROR, "failed to delete %s\n", filename);
+} else {
+//Nothing to write
+avio_flush(c->http_delete);
+dashenc_io_close(s, >http_delete, filename);
 }
-
 av_dict_free(_opts);
-ff_format_io_close(s, );
+
+if (!c->http_persistent)
+ff_format_io_close(s, >http_delete);
 } 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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v4 1/2] libavformat/hlsenc: Enable HTTP persistent connections for for hls_delete_file

2022-12-06 Thread Basel Sayeh
V4
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 
---
 libavformat/hlsenc.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a86fc8907f..9781ed1ceb 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;
@@ -569,15 +570,21 @@ static int hls_delete_file(HLSContext *hls, 
AVFormatContext *avf,
 {
 if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
 AVDictionary *opt = NULL;
-AVIOContext  *out = NULL;
 int ret;
+
 set_http_options(avf, , hls);
 av_dict_set(, "method", "DELETE", 0);
-ret = avf->io_open(avf, , path, AVIO_FLAG_WRITE, );
+ret = hlsenc_io_open(avf, >http_delete, path, );
 av_dict_free();
 if (ret < 0)
 return hls->ignore_io_errors ? 1 : ret;
-ff_format_io_close(avf, );
+
+//Nothing to write
+avio_flush(hls->http_delete);
+hlsenc_io_close(avf, >http_delete, path);
+
+if (!hls->http_persistent)
+ff_format_io_close(avf, >http_delete);
 } else if (unlink(path) < 0) {
 av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
path, strerror(errno));
@@ -662,7 +669,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 +686,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();
@@ -2707,6 +2714,7 @@ static void hls_deinit(AVFormatContext *s)
 
 ff_format_io_close(s, >m3u8_out);
 ff_format_io_close(s, >sub_m3u8_out);
+ff_format_io_close(s, >http_delete);
 av_freep(>key_basename);
 av_freep(>var_streams);
 av_freep(>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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v3 1/2] libavformat/hlsenc: Enable HTTP persistent connections

2022-12-06 Thread Basel Sayeh
another mistake, Please see v4

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v3 2/2] libavformat/dashenc: Enable HTTP persistent connections for dashenc_delete_file

2022-12-05 Thread Basel Sayeh
Signed-off-by: Basel Sayeh 
---
 libavformat/dashenc.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 9c1bcad9e3..ba0eb913a1 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, >mpd_out);
 ff_format_io_close(s, >m3u8_out);
+ff_format_io_close(s, >http_delete);
 }
 
 static void output_segment_list(OutputStream *os, AVIOContext *out, 
AVFormatContext *s,
@@ -1855,18 +1857,22 @@ 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(_opts, c);
 av_dict_set(_opts, "method", "DELETE", 0);
 
-if (dashenc_io_open(s, , filename, _opts) < 0) {
+if (dashenc_io_open(s, >http_delete, filename, _opts) < 0) {
 av_log(s, AV_LOG_ERROR, "failed to delete %s\n", filename);
+} else {
+//Nothing to write
+avio_flush(c->http_delete);
+dashenc_io_close(s, >http_delete, filename);
 }
-
 av_dict_free(_opts);
-ff_format_io_close(s, );
+
+if (!c->http_persistent)
+ff_format_io_close(s, >http_delete);
 } 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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v3 1/2] libavformat/hlsenc: Enable HTTP persistent connections

2022-12-05 Thread Basel Sayeh
V3

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

Signed-off-by: Basel Sayeh 
---
 libavformat/hlsenc.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a86fc8907f..9781ed1ceb 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;
@@ -569,15 +570,21 @@ static int hls_delete_file(HLSContext *hls, 
AVFormatContext *avf,
 {
 if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
 AVDictionary *opt = NULL;
-AVIOContext  *out = NULL;
 int ret;
+
 set_http_options(avf, , hls);
 av_dict_set(, "method", "DELETE", 0);
-ret = avf->io_open(avf, , path, AVIO_FLAG_WRITE, );
+ret = hlsenc_io_open(avf, >http_delete, path, );
 av_dict_free();
 if (ret < 0)
 return hls->ignore_io_errors ? 1 : ret;
-ff_format_io_close(avf, );
+
+//Nothing to write
+avio_flush(hls->http_delete);
+hlsenc_io_close(avf, >http_delete, path);
+
+if (!hls->http_persistent)
+ff_format_io_close(avf, >http_delete);
 } else if (unlink(path) < 0) {
 av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
path, strerror(errno));
@@ -662,7 +669,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 +686,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();
@@ -2707,6 +2714,7 @@ static void hls_deinit(AVFormatContext *s)
 
 ff_format_io_close(s, >m3u8_out);
 ff_format_io_close(s, >sub_m3u8_out);
+ff_format_io_close(s, >http_delete);
 av_freep(>key_basename);
 av_freep(>var_streams);
 av_freep(>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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v2 2/2] libavformat/dashenc: Enable HTTP persistent connections for dashenc_delete_file

2022-12-05 Thread Basel Sayeh
oops, another small mistake, please see v3



From: Basel Sayeh 
Sent: Monday, December 5, 2022 2:22 PM
To: ffmpeg-devel@ffmpeg.org 
Cc: Basel Sayeh 
Subject: [PATCH v2 2/2] libavformat/dashenc: Enable HTTP persistent connections 
for dashenc_delete_file

Signed-off-by: Basel Sayeh 
---
 libavformat/dashenc.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 9c1bcad9e3..2521568ea5 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, >mpd_out);
 ff_format_io_close(s, >m3u8_out);
+ff_format_io_close(s, >http_delete);
 }

 static void output_segment_list(OutputStream *os, AVIOContext *out, 
AVFormatContext *s,
@@ -1855,18 +1857,22 @@ 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(_opts, c);
 av_dict_set(_opts, "method", "DELETE", 0);

-if (dashenc_io_open(s, , filename, _opts) < 0) {
+if (dashenc_io_open(s, >http_delete, filename, _opts) < 0) {
 av_log(s, AV_LOG_ERROR, "failed to delete %s\n", filename);
+} else {
+//Nothing to write
+avio_flush(c->http_delete);
+dashenc_io_close(s, >http_delete, filename);
 }
-
 av_dict_free(_opts);
-ff_format_io_close(s, );
+
+if (!c->http_persistent)
+ff_format_io_close(s, );
 } 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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH v2 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file

2022-12-05 Thread Basel Sayeh
oops, another small mistake, please see v3

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v2 2/2] libavformat/dashenc: Enable HTTP persistent connections for dashenc_delete_file

2022-12-05 Thread Basel Sayeh
Signed-off-by: Basel Sayeh 
---
 libavformat/dashenc.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 9c1bcad9e3..2521568ea5 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, >mpd_out);
 ff_format_io_close(s, >m3u8_out);
+ff_format_io_close(s, >http_delete);
 }
 
 static void output_segment_list(OutputStream *os, AVIOContext *out, 
AVFormatContext *s,
@@ -1855,18 +1857,22 @@ 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(_opts, c);
 av_dict_set(_opts, "method", "DELETE", 0);
 
-if (dashenc_io_open(s, , filename, _opts) < 0) {
+if (dashenc_io_open(s, >http_delete, filename, _opts) < 0) {
 av_log(s, AV_LOG_ERROR, "failed to delete %s\n", filename);
+} else {
+//Nothing to write
+avio_flush(c->http_delete);
+dashenc_io_close(s, >http_delete, filename);
 }
-
 av_dict_free(_opts);
-ff_format_io_close(s, );
+
+if (!c->http_persistent)
+ff_format_io_close(s, );
 } 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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH v2 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file

2022-12-05 Thread Basel Sayeh
hls_delete_file and dashenc_delete_file functions open a
 new HTTP connection regardless of the http_persistent value,
 So change the behaviour to keep http connections open
 if http_persistent is set

Signed-off-by: Basel Sayeh 
---
 libavformat/hlsenc.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a86fc8907f..a23c17eea2 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;
@@ -569,15 +570,21 @@ static int hls_delete_file(HLSContext *hls, 
AVFormatContext *avf,
 {
 if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
 AVDictionary *opt = NULL;
-AVIOContext  *out = NULL;
 int ret;
+
 set_http_options(avf, , hls);
 av_dict_set(, "method", "DELETE", 0);
-ret = avf->io_open(avf, , path, AVIO_FLAG_WRITE, );
+ret = hlsenc_io_open(avf, >http_delete, path, );
 av_dict_free();
 if (ret < 0)
 return hls->ignore_io_errors ? 1 : ret;
-ff_format_io_close(avf, );
+
+//Nothing to write
+avio_flush(hls->http_delete);
+hlsenc_io_close(avf, >http_delete, path);
+
+if (!hls->http_persistent)
+ff_format_io_close(avf, );
 } else if (unlink(path) < 0) {
 av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
path, strerror(errno));
@@ -662,7 +669,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 +686,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();
@@ -2707,6 +2714,7 @@ static void hls_deinit(AVFormatContext *s)
 
 ff_format_io_close(s, >m3u8_out);
 ff_format_io_close(s, >sub_m3u8_out);
+ff_format_io_close(s, >http_delete);
 av_freep(>key_basename);
 av_freep(>var_streams);
 av_freep(>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-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 1/2] libavformat/hlsenc: Enable HTTP, persistent connections for hls_delete_file

2022-12-05 Thread Basel Sayeh



On 12/5/22 05:29, Steven Liu wrote:


Hi Basel,

Could you send a new version patchset name lead by "v2" ?

git format -patch -v 2



Will do

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


Re: [FFmpeg-devel] [PATCH 1/2] libavformat/hlsenc: Enable HTTP, persistent connections for hls_delete_file

2022-11-28 Thread Basel Sayeh
Please ignore this version and use the other one, as it was sent using 
the wrong email client and the patch is missed up.


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 2/2] libavformat/dashenc: Enable HTTP persistent connections for dashenc_delete_file

2022-11-28 Thread Basel Sayeh
Signed-off-by: Basel Sayeh 
---
 libavformat/dashenc.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 9c1bcad9e3..ba0eb913a1 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, >mpd_out);
 ff_format_io_close(s, >m3u8_out);
+ff_format_io_close(s, >http_delete);
 }
 
 static void output_segment_list(OutputStream *os, AVIOContext *out, 
AVFormatContext *s,
@@ -1855,18 +1857,22 @@ 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(_opts, c);
 av_dict_set(_opts, "method", "DELETE", 0);
 
-if (dashenc_io_open(s, , filename, _opts) < 0) {
+if (dashenc_io_open(s, >http_delete, filename, _opts) < 0) {
 av_log(s, AV_LOG_ERROR, "failed to delete %s\n", filename);
+} else {
+//Nothing to write
+avio_flush(c->http_delete);
+dashenc_io_close(s, >http_delete, filename);
 }
-
 av_dict_free(_opts);
-ff_format_io_close(s, );
+
+if (!c->http_persistent)
+ff_format_io_close(s, >http_delete);
 } 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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file

2022-11-28 Thread Basel Sayeh
Signed-off-by: Basel Sayeh 
---
 libavformat/hlsenc.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a86fc8907f..e4749aad87 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;
@@ -569,15 +570,20 @@ static int hls_delete_file(HLSContext *hls, 
AVFormatContext *avf,
 {
 if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
 AVDictionary *opt = NULL;
-AVIOContext  *out = NULL;
 int ret;
+
 set_http_options(avf, , hls);
 av_dict_set(, "method", "DELETE", 0);
-ret = avf->io_open(avf, , path, AVIO_FLAG_WRITE, );
+ret = hlsenc_io_open(avf, >http_delete, path, );
 av_dict_free();
 if (ret < 0)
 return hls->ignore_io_errors ? 1 : ret;
-ff_format_io_close(avf, );
+
+//Nothing to write
+avio_flush(hls->http_delete);
+hlsenc_io_close(avf, >http_delete, path);
+if (!hls->http_persistent)
+ff_format_io_close(avf, >http_delete);
 } else if (unlink(path) < 0) {
 av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
path, strerror(errno));
@@ -662,7 +668,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 +685,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();
@@ -2707,6 +2713,7 @@ static void hls_deinit(AVFormatContext *s)
 
 ff_format_io_close(s, >m3u8_out);
 ff_format_io_close(s, >sub_m3u8_out);
+ff_format_io_close(s, >http_delete);
 av_freep(>key_basename);
 av_freep(>var_streams);
 av_freep(>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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 1/2] libavformat/hlsenc: Enable HTTP persistent connections for hls_delete_file

2022-11-28 Thread Basel Sayeh

Signed-off-by: Basel Sayeh 
---
 libavformat/hlsenc.c | 17 -
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a86fc8907f..e4749aad87 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;
@@ -569,15 +570,20 @@ static int hls_delete_file(HLSContext *hls, 
AVFormatContext *avf,

 {
 if (hls->method || (proto && !av_strcasecmp(proto, "http"))) {
 AVDictionary *opt = NULL;
-AVIOContext  *out = NULL;
 int ret;
+
 set_http_options(avf, , hls);
 av_dict_set(, "method", "DELETE", 0);
-ret = avf->io_open(avf, , path, AVIO_FLAG_WRITE, );
+ret = hlsenc_io_open(avf, >http_delete, path, );
 av_dict_free();
 if (ret < 0)
 return hls->ignore_io_errors ? 1 : ret;
-ff_format_io_close(avf, );
+
+//Nothing to write
+avio_flush(hls->http_delete);
+hlsenc_io_close(avf, >http_delete, path);
+if (!hls->http_persistent)
+ff_format_io_close(avf, >http_delete);
 } else if (unlink(path) < 0) {
 av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
path, strerror(errno));
@@ -662,7 +668,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 +685,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();
@@ -2707,6 +2713,7 @@ static void hls_deinit(AVFormatContext *s)
  ff_format_io_close(s, >m3u8_out);
 ff_format_io_close(s, >sub_m3u8_out);
+ff_format_io_close(s, >http_delete);
 av_freep(>key_basename);
 av_freep(>var_streams);
 av_freep(>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-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-devel] [PATCH 2/2] libavformat/dashenc: Enable HTTP persistent connections for dashenc_delete_file

2022-11-28 Thread Basel Sayeh

Signed-off-by: Basel Sayeh 
---
 libavformat/dashenc.c | 14 ++
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 9c1bcad9e3..ba0eb913a1 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, >mpd_out);
 ff_format_io_close(s, >m3u8_out);
+ff_format_io_close(s, >http_delete);
 }
  static void output_segment_list(OutputStream *os, AVIOContext *out, 
AVFormatContext *s,
@@ -1855,18 +1857,22 @@ 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(_opts, c);
 av_dict_set(_opts, "method", "DELETE", 0);
 -if (dashenc_io_open(s, , filename, _opts) < 0) {
+if (dashenc_io_open(s, >http_delete, filename, _opts) < 
0) {

 av_log(s, AV_LOG_ERROR, "failed to delete %s\n", filename);
+} else {
+//Nothing to write
+avio_flush(c->http_delete);
+dashenc_io_close(s, >http_delete, filename);
 }
-
 av_dict_free(_opts);
-ff_format_io_close(s, );
+
+if (!c->http_persistent)
+ff_format_io_close(s, >http_delete);
 } 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-requ...@ffmpeg.org with subject "unsubscribe".