'ffmpeg's api falls into infinite loop or doesn't respond in android JNI

ffmpeg is integrated to Android JNI to play RTSP links

It is able to play this RTSP link rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4

On the contrary it is unable to play this RTSP link rtsp://210.99.70.120:1935/live/cctv013.stream

When it happen, avformat_find_stream_info() api doesn't respond or seems to fall in infinite loop.

Here are lines of code in the top of the function.

Is it abnormal behavior for specific RTSP link?

extern "C"
JNIEXPORT jboolean JNICALL
Java_com_nubicam_tools_rtsptest_NDKAdapter_play(JNIEnv *env, jclass instance, jstring url_, jobject surface)
{
    const char *path = env->GetStringUTFChars(url_, 0);

    av_register_all();
    avformat_network_init();

    AVFormatContext *ic = NULL;

    int re = avformat_open_input(&ic,path,0,0);

    if (re != 0){
        LOGW("avformat_open_input failed!:%s",av_err2str(re));
        return -1;
    }

    re = avformat_find_stream_info(ic,0);  // When it happen, avformat_find_stream_info() api doesn't respond or seems to fall in infinite loop.
    if (re != 0){
        LOGW("avformat_find_stream_info failed :%s",av_err2str(re));
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source