reduce http timeout to 4s and make it configurable

This commit is contained in:
skyjet18
2023-01-24 20:57:12 +01:00
committed by Thilo Graf
parent 66363cc76b
commit e4d1d85a6e
5 changed files with 20 additions and 11 deletions

View File

@@ -1804,7 +1804,10 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uin
else if (0 == strncmp(filename, "http://", 7) || else if (0 == strncmp(filename, "http://", 7) ||
0 == strncmp(filename, "https://", 8)) 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); av_dict_set(&avio_opts, "reconnect", "1", 0);
if (context->playback->isTSLiveMode) // special mode for live TS stream with skip packet if (context->playback->isTSLiveMode) // special mode for live TS stream with skip packet
{ {

View File

@@ -37,11 +37,7 @@
static inline av_const int sign_extend(int val, unsigned bits) static inline av_const int sign_extend(int val, unsigned bits)
{ {
unsigned shift = 8 * sizeof(int) - bits; unsigned shift = 8 * sizeof(int) - bits;
union union { unsigned u; int s; } v = { (unsigned) val << shift };
{
unsigned u;
int s;
} v = { (unsigned) val << shift };
return v.s >> shift; return v.s >> shift;
} }
#endif #endif

View File

@@ -66,6 +66,9 @@ typedef struct PlaybackHandler_s
uint8_t noprobe; /* hack: only minimal probing in av_find_stream_info */ uint8_t noprobe; /* hack: only minimal probing in av_find_stream_info */
uint8_t isLoopMode; uint8_t isLoopMode;
uint8_t isTSLiveMode; uint8_t isTSLiveMode;
uint32_t httpTimeout; // in ms
void *stamp;
} PlaybackHandler_t; } PlaybackHandler_t;
#endif #endif

View File

@@ -518,10 +518,7 @@ static int ParseParams(int argc, char *argv[], PlayFiles_t *playbackFiles, int *
{ {
int ret = 0; int ret = 0;
int c; int c;
//int digit_optind = 0; 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)
//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)
{ {
switch (c) switch (c)
{ {
@@ -656,6 +653,11 @@ static int ParseParams(int argc, char *argv[], PlayFiles_t *playbackFiles, int *
map_inter_file_path(playbackFiles->szFirstMoovAtomFile); map_inter_file_path(playbackFiles->szFirstMoovAtomFile);
} }
break; break;
case 'T':
PlaybackHandler.httpTimeout = (uint32_t) strtoul(optarg, NULL, 10);
printf("Setting http timeout to %u ms\n", PlaybackHandler.httpTimeout);
break;
default: default:
printf("?? getopt returned character code 0%o ??\n", c); printf("?? getopt returned character code 0%o ??\n", c);
ret = -1; ret = -1;
@@ -700,6 +702,7 @@ int main(int argc, char *argv[])
char argvBuff[256]; char argvBuff[256];
memset(argvBuff, '\0', sizeof(argvBuff)); memset(argvBuff, '\0', sizeof(argvBuff));
int commandRetVal = -1; int commandRetVal = -1;
/* inform client that we can handle additional commands */ /* inform client that we can handle additional commands */
fprintf(stderr, "{\"EPLAYER3_EXTENDED\":{\"version\":%d}}\n", 55); fprintf(stderr, "{\"EPLAYER3_EXTENDED\":{\"version\":%d}}\n", 55);

View File

@@ -478,6 +478,7 @@ static int32_t PlaybackTerminate(Context_t *context)
} }
ret = context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL); ret = context->container->selectedContainer->Command(context, CONTAINER_STOP, NULL);
if (context && context->playback) if (context && context->playback)
{ {
context->playback->isPaused = 0; context->playback->isPaused = 0;
@@ -487,6 +488,7 @@ static int32_t PlaybackTerminate(Context_t *context)
context->playback->SlowMotion = 0; context->playback->SlowMotion = 0;
context->playback->Speed = 0; context->playback->Speed = 0;
} }
if (context && context->output) if (context && context->output)
context->output->Command(context, OUTPUT_STOP, NULL); context->output->Command(context, OUTPUT_STOP, NULL);
} }
@@ -1014,5 +1016,7 @@ PlaybackHandler_t PlaybackHandler =
0, //size 0, //size
0, //noprobe 0, //noprobe
0, //isLoopMode 0, //isLoopMode
0 //isTSLiveMode 0, //isTSLiveMode
4000, //httpTimeout
NULL //stamp
}; };