Example #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="request"></param>
        /// <param name="session"></param>
        internal void ProcessRtspPlay(RtspMessage request, ClientSession session, bool sendResponse = true)
        {
            RtpSource found = FindStreamByLocation(request.Location) as RtpSource;

            if (found == null)
            {
                ProcessLocationNotFoundRtspRequest(session, sendResponse);
                return;
            }

            if (false == AuthenticateRequest(request, found))
            {
                ProcessAuthorizationRequired(found, session, sendResponse);
                return;
            }
            else if (false == found.Ready)
            {
                //Stream is not yet ready
                ProcessInvalidRtspRequest(session, RtspStatusCode.PreconditionFailed, null, sendResponse);
                return;
            }

            //New method...
            TryCreateResponse:

            try
            {
                RtspMessage resp = session.ProcessPlay(request, found);

                //Send the response to the client
                ProcessSendRtspMessage(resp, session, sendResponse);

                if (resp.StatusCode == RtspStatusCode.OK)
                {
                    //Take the range into account given.
                    session.ProcessPacketBuffer(found);
                }

                resp = null;
            }
            catch(Exception ex)
            {
                if(Logger != null) Logger.LogException(ex);

                if (ex is InvalidOperationException) goto TryCreateResponse;

                throw;

            }
        }