Closed xinlingyun2015 closed 4 years ago
It turns out that the rtsp server need a heart beat, otherwise the server automatically disconnected the connection. So I add a heart beat of GET_PARAMETERS rtsp request, and the problem solved. After that, this locomote player works great! Thanks to the author again!
Glad you got it to work. I think that would be a nice feature to have in Locomote. Would you mind sharing your code?
Sure. It is a very simple, all in RTSPClient.as. Just add the following timer:
private var heartBeatTimer:Timer; heartBeatTimer = new Timer(10*1000); heartBeatTimer.addEventListener(TimerEvent.TIMER, heartBeatTick);
private function heartBeatTick(e:TimerEvent):void { try{ sendHeartBeatReq(); }catch (ex:Error) { trace(ex.message + ex.getStackTrace()); } } private function sendHeartBeatReq():void { var command:String = "GET_PARAMETER"; if (!this.supportCommand(command)) { command = "PLAY"; } var req:String = command + " " + getControlURL() + " RTSP/1.0\r\n" + "CSeq: " + (++cSeq) + "\r\n" + "User-Agent: " + userAgent + "\r\n" + "Session: " + session + "\r\n" + auth.authorizationHeader("GET_PARAMETER", authState, authOpts, urlParsed, digestNC++) + "\r\n"; Logger.log('RTSP OUT:', req); if (handle != null) { handle.writeUTFBytes(req); } }
Then, at the end of RTSTClient.start(), start the timer: heartBeatTimer.start();
That's all. Have a good day!
Hi, I am playing a rtsp stream within a local network, and it stopped playing for every 135s (or so), the bcTimerHandler function is called, why???