You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In processSOS of RTSPPusher we make a call to write_header() function which internally calls avformat_write_header with outContext. If the RTSP server is not available then the function does not return anything blocking the process. There are comments added below the avformat_write_header pointing to this issue.
To Reproduce
Steps to reproduce the behavior: Run RTSP Pusher tests without the rtsp server and observe behaviour in procesSOS function.
Solution:
Add an interrupt callback to outContext with timeout logic before calling avformat_write_header(). Please find the associated code below. We need to add test cases for this scenario in rtsppusher_tests.
typedef struct
{
AVFormatContext* formatContext;
int timeout_ms;
uint64_t start_time_ms;
} InterruptCallbackData;
static int rtspInterruptCallback(void *ctx)
{
LOG_TRACE<<"Callback triggered";
InterruptCallbackData* callbackData = reinterpret_cast<InterruptCallbackData*>(ctx);
std::chrono::time_point<std::chrono::system_clock> t = std::chrono::system_clock::now();
auto dur = std::chrono::duration_cast<std::chrono::milliseconds>(t.time_since_epoch());
uint64_t current_time = dur.count();
if ((current_time - callbackData->start_time_ms) > callbackData->timeout_ms)
{
LOG_INFO<<"Timeout reached in callback, returning error";
return -1;
}
return 0;
}
//Interrupt callback
InterruptCallbackData callbackData;
callbackData.formatContext = outContext;
callbackData.timeout_ms = rtspTimeout; //This value is passed as props for rtspPusher module
std::chrono::time_point<std::chrono::system_clock> t = std::chrono::system_clock::now();
auto dur = std::chrono::duration_cast<std::chrono::milliseconds>(t.time_since_epoch());
uint64_t now = dur.count();
callbackData.start_time_ms = now;
outContext->interrupt_callback.callback = rtspInterruptCallback;
outContext->interrupt_callback.opaque = &callbackData;
outContext->flags = outContext->flags | AVFMT_FLAG_NONBLOCK;
ret = avformat_write_header(outContext, &options);
The text was updated successfully, but these errors were encountered:
Describe the bug
In processSOS of RTSPPusher we make a call to write_header() function which internally calls avformat_write_header with outContext. If the RTSP server is not available then the function does not return anything blocking the process. There are comments added below the avformat_write_header pointing to this issue.
To Reproduce
Steps to reproduce the behavior: Run RTSP Pusher tests without the rtsp server and observe behaviour in procesSOS function.
Solution:
Add an interrupt callback to outContext with timeout logic before calling avformat_write_header(). Please find the associated code below. We need to add test cases for this scenario in rtsppusher_tests.
The text was updated successfully, but these errors were encountered: