Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtsp无重连机制 #62

Closed
haoshaolin opened this issue Aug 11, 2014 · 6 comments
Closed

rtsp无重连机制 #62

haoshaolin opened this issue Aug 11, 2014 · 6 comments

Comments

@haoshaolin
Copy link

请教个问题:ffmpeg中,rtsp的实现是不是没有重连机制。比如网络断开过会在恢复,是不是无法正常恢复播放?

@bbcallen
Copy link
Contributor

我不知道有没有现成的重连机制。

@chodison
Copy link
Contributor

chodison commented Feb 2, 2015

这个需要你在IJK的播放逻辑里添加的,关闭再重新播放。

@CrazyPeter
Copy link

我也遇到了相关问题,log显示播放状态改变,在之前有丢包信息,而且是和audio有关。
估计是因为rtsp丢包,调起了链接状态的异常,本地关闭相关的接口,造成无法直接继续播放。

解决方法是在状态回调那里添加重新播放的功能。因为我的播放器只做直播所以只是粗暴的让它重新播放,没有加其他判断。

ps:测试过只添加play,但是还是无法重新开启,所以在开始前要停止原来的播放。

相关代码如下。

- (void)loadStateDidChange:(NSNotification*)notification{
 IJKMPMovieLoadState loadState = _player.loadState;
    if ((loadState & IJKMPMovieLoadStatePlaythroughOK) != 0) {
        NSLog(@"loadStateDidChange: IJKMPMovieLoadStatePlaythroughOK: %d\n", (int)loadState);
    } else if ((loadState & IJKMPMovieLoadStateStalled) != 0) {
        NSLog(@"loadStateDidChange: IJKMPMovieLoadStateStalled: %d\n", (int)loadState);
        [self.player stop];
        [self.player play];
        [self.mediaControl refreshMediaControl];
    } else {
        NSLog(@"loadStateDidChange: ???: %d\n", (int)loadState);
    }
}

@mistak
Copy link

mistak commented Dec 29, 2015

你重新播放成功了吗?是怎么做到的?@CrazyPeter

@CrazyPeter
Copy link

@mistak
如果我提到的方法不行,可以使用一个简单粗暴的方法,直接stop,然后nil掉对象再重新创建,相当于重连。ps:由于项目紧张,没有时间测试具体问题。

@mistak
Copy link

mistak commented Dec 30, 2015

好吧,我也是这样做的。。。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants