From 8a1cb9883f0a62e0fe568039872019250464f58d Mon Sep 17 00:00:00 2001 From: skyjet18 <57456827+skyjet18@users.noreply.github.com> Date: Tue, 24 Jan 2023 20:57:12 +0100 Subject: [PATCH] =?UTF-8?q?reduce=C2=A0http=C2=A0timeout=C2=A0to=C2=A04s?= =?UTF-8?q?=C2=A0and=C2=A0make=C2=A0it=C2=A0configurable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/4a56ebd0b390c5548e6b84973b73ed9f0af37753 Author: skyjet18 <57456827+skyjet18@users.noreply.github.com> Date: 2023-01-24 (Tue, 24 Jan 2023) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libeplayer3/container/container_ffmpeg.c | 5 ++++- libeplayer3/external/ffmpeg/mathops.h | 6 +----- libeplayer3/include/playback.h | 3 +++ libeplayer3/main/exteplayer.c | 11 +++++++---- libeplayer3/playback/playback.c | 6 +++++- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/libeplayer3/container/container_ffmpeg.c b/libeplayer3/container/container_ffmpeg.c index b450125..221a41b 100644 --- a/libeplayer3/container/container_ffmpeg.c +++ b/libeplayer3/container/container_ffmpeg.c @@ -1804,7 +1804,10 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uin else if (0 == strncmp(filename, "http://", 7) || 0 == strncmp(filename, "https://", 8)) { - av_dict_set(&avio_opts, "timeout", "20000000", 0); //20sec + char num[16]; + + sprintf(num, "%u000", context->playback->httpTimeout); + av_dict_set(&avio_opts, "timeout", num, 0); // default is 4s av_dict_set(&avio_opts, "reconnect", "1", 0); if (context->playback->isTSLiveMode) // special mode for live TS stream with skip packet { diff --git a/libeplayer3/external/ffmpeg/mathops.h b/libeplayer3/external/ffmpeg/mathops.h index b8c7ff7..d558e34 100644 --- a/libeplayer3/external/ffmpeg/mathops.h +++ b/libeplayer3/external/ffmpeg/mathops.h @@ -37,11 +37,7 @@ static inline av_const int sign_extend(int val, unsigned bits) { unsigned shift = 8 * sizeof(int) - bits; - union - { - unsigned u; - int s; - } v = { (unsigned) val << shift }; + union { unsigned u; int s; } v = { (unsigned) val << shift }; return v.s >> shift; } #endif diff --git a/libeplayer3/include/playback.h b/libeplayer3/include/playback.h index 1781651..f5673a5 100644 --- a/libeplayer3/include/playback.h +++ b/libeplayer3/include/playback.h @@ -66,6 +66,9 @@ typedef struct PlaybackHandler_s uint8_t noprobe; /* hack: only minimal probing in av_find_stream_info */ uint8_t isLoopMode; uint8_t isTSLiveMode; + uint32_t httpTimeout; // in ms + + void *stamp; } PlaybackHandler_t; #endif diff --git a/libeplayer3/main/exteplayer.c b/libeplayer3/main/exteplayer.c index 196c769..7067cfd 100644 --- a/libeplayer3/main/exteplayer.c +++ b/libeplayer3/main/exteplayer.c @@ -518,10 +518,7 @@ static int ParseParams(int argc, char *argv[], PlayFiles_t *playbackFiles, int * { int ret = 0; int c; - //int digit_optind = 0; - //int aopt = 0, bopt = 0; - //char *copt = 0, *dopt = 0; - while ((c = getopt(argc, argv, "we3dlsrimva:n:x:u:c:h:o:p:P:t:9:0:1:4:f:b:F:S:O:")) != -1) + while ((c = getopt(argc, argv, "G:W:H:A:V:U:we3dlsrimva:n:x:u:c:h:o:p:P:t:9:0:1:4:f:b:F:S:O:T:")) != -1) { switch (c) { @@ -656,6 +653,11 @@ static int ParseParams(int argc, char *argv[], PlayFiles_t *playbackFiles, int * map_inter_file_path(playbackFiles->szFirstMoovAtomFile); } break; + case 'T': + PlaybackHandler.httpTimeout = (uint32_t) strtoul(optarg, NULL, 10); + printf("Setting http timeout to %u ms\n", PlaybackHandler.httpTimeout); + break; + default: printf("?? getopt returned character code 0%o ??\n", c); ret = -1; @@ -700,6 +702,7 @@ int main(int argc, char *argv[]) char argvBuff[256]; memset(argvBuff, '\0', sizeof(argvBuff)); int commandRetVal = -1; + /* inform client that we can handle additional commands */ fprintf(stderr, "{\"EPLAYER3_EXTENDED\":{\"version\":%d}}\n", 55); diff --git a/libeplayer3/playback/playback.c b/libeplayer3/playback/playback.c index b4ee075..9e0b075 100644 --- a/libeplayer3/playback/playback.c +++ b/libeplayer3/playback/playback.c @@ -478,6 +478,7 @@ static int32_t PlaybackTerminate(Context_t *context) } ret = context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL); + if (context && context->playback) { context->playback->isPaused = 0; @@ -487,6 +488,7 @@ static int32_t PlaybackTerminate(Context_t *context) context->playback->SlowMotion = 0; context->playback->Speed = 0; } + if (context && context->output) context->output->Command(context, OUTPUT_STOP, NULL); } @@ -1014,5 +1016,7 @@ PlaybackHandler_t PlaybackHandler = 0, //size 0, //noprobe 0, //isLoopMode - 0 //isTSLiveMode + 0, //isTSLiveMode + 4000, //httpTimeout + NULL //stamp };