public void Close() { if (!Closed) { try { if (_rtpStream != null) { _rtpStream.RemoveSession(SessionId); _rtpStream = null; } } catch (Exception ex) { _logger.Error(ex); } finally { if (_logger.IsDebugEnabled) { _logger.Debug("Removing session {0}", SessionId); } _connection.Server.RemoveSession(SessionId); Closed = true; } if (_logger.IsDebugEnabled) { _logger.Debug("Session {0} is closed", SessionId); } } }
public async Task <bool> Play(RTSPRequestParser parser) { string stream = parser.Media; ServerMediaSession session = _connection.Server.lookupServerMediaSession(stream); if (session == null) { _connection.HandleNotFound(parser); return(false); } // Look up information for the specified subsession (track): ServerMediaSubsession subsession; subsession = session.LookupSubSession(stream); ushort rtpSeqNum = 0; uint rtpTimestamp = 0; _rtpStream = subsession.GetStreamInstance(); rtpSeqNum = _rtpStream.CurrentSeqNo(); rtpTimestamp = _rtpStream.CurrentTimeStamp(); // presetNextTimestamp(); Playing = true; await _rtpStream.AddDestination(this, _destinations); if (_destinations.isTCP) { _connection.RegisterFilter(_rtpStream); } StringBuilder sb = new StringBuilder(); sb.Append("RTSP/1.0 200 OK\r\n"); sb.AppendFormat("Server: {0}\r\n", RTSPServer.ServerVersion); sb.AppendFormat("Cseq: {0}\r\n", parser.Headers["CSEQ"]); sb.AppendFormat("Session: {0}\r\n", parser.Headers["SESSION"]); sb.Append("Last-Modified: Tue, 30 Aug 2016 01:33:17 GMT\r\n"); sb.Append("Cache-Control: must-revalidate\r\n"); sb.Append("Date: Sat, 22 Dec 2018 16:18:03 GMT\r\n"); sb.Append("Expires: Sun, 23 Dec 2018 12:01:28 GMT\r\n"); sb.Append("Range: npt=0.000-\r\n"). AppendFormat("RTP-Info: url=rtsp://{0}:{1}/{2}/track1;seq={3};rtptime={4}\r\n\r\n", SocketExtensions.GetLocalIPV4Address(), _connection.Server.Port, subsession.Name, rtpSeqNum, rtpTimestamp); string reply = sb.ToString(); _connection.SendResponse(reply); return(true); }
internal void RegisterFilter(RTPStream rtpStream) { _rtcpFilter = rtpStream; }
public H264VideoCaptureMediaSubsession() : base(true) { _stream = new RTPUnicastStream(Name, "track1", _rtpGroupsock, _rtcpGroupsock); }
public H264MulticastVideoCaptureSubsession() : base(true) { _stream = new RTPMulticastStream(Name, "track1", _rtpGroupsock, _rtcpGroupsock, MulticastAdress, ServerRTPPort, ServerRTCPPort); }
public H264VideoRTPFramer(RTPStream client, byte rtpPayloadFormat) : base(client, rtpPayloadFormat, 90000, "H264") { }