Пример #1
0
        public override bool TryGetLogger(out Common.ILogging logger)
        {
            if (IsReady.Equals(false))
            {
                return(base.TryGetLogger(out logger));
            }

            try
            {
                //Set the logger
                logger = RtpClient.Logger;

                return(true);
            }
            catch
            {
                logger = null;

                return(false);
            }
            finally
            {
                //
            }
        }
Пример #2
0
        public override bool TrySetLogger(Common.ILogging logger)
        {
            if (false.Equals(IsReady))
            {
                return(false);
            }

            try
            {
                //Set the rtp logger and the rtsp logger
                RtspClient.Logger = logger;

                return(base.TrySetLogger(logger));
            }
            catch { return(false); }
        }
Пример #3
0
        //System.Drawing.Image m_lastDecodedFrame;
        //internal virtual void DecodeFrame(Rtp.RtpClient sender, Rtp.RtpFrame frame)
        //{
        //    if (RtpClient == null || RtpClient != sender) return;
        //    try
        //    {
        //        //Get the MediaDescription (by ssrc so dynamic payload types don't conflict
        //        Media.Sdp.MediaDescription mediaDescription = RtpClient.GetContextBySourceId(frame.SynchronizationSourceIdentifier).MediaDescription;
        //        if (mediaDescription.MediaType == Sdp.MediaType.audio)
        //        {
        //            //Could have generic byte[] handlers OnAudioData OnVideoData OnEtc
        //            //throw new NotImplementedException();
        //        }
        //        else if (mediaDescription.MediaType == Sdp.MediaType.video)
        //        {
        //            if (mediaDescription.MediaFormat == 26)
        //            {
        //                OnFrameDecoded(m_lastDecodedFrame = (new RFC2435Stream.RFC2435Frame(frame)).ToImage());
        //            }
        //            else if (mediaDescription.MediaFormat >= 96 && mediaDescription.MediaFormat < 128)
        //            {
        //                //Dynamic..
        //                //throw new NotImplementedException();
        //            }
        //            else
        //            {
        //                //0 - 95 || >= 128
        //                //throw new NotImplementedException();
        //            }
        //        }
        //    }
        //    catch
        //    {
        //        return;
        //    }
        //}

        public override bool TrySetLogger(Common.ILogging logger)
        {
            if (false == Ready)
            {
                return(false);
            }

            try
            {
                //Set the logger
                RtpClient.Logger = logger;

                return(true);
            }
            catch { return(false); }
        }
Пример #4
0
        //It is completely possible to allow another thread here, such a thread would be soley responsible for issuing the data to the handlers of the RtpClient's events and would provide better performance in some cases.
        //It's also possible to Multicast the source resulting in the network handling the aggregation (See Sink)

        #endregion

        #region Unused [Example of how an implementation would begin to propagate the realization that may have to actually do some type of work]

        //Asked by a user here how they would save a rtsp stream to disk....
        //RtpTools, MediaFileWriter, FFMPEG, Media Foundation................................................................
        //http://stackoverflow.com/questions/37285323/how-to-record-a-rtsp-stream-to-disk-using-net7mma

        //System.Drawing.Image m_lastDecodedFrame;
        //internal virtual void DecodeFrame(Rtp.RtpClient sender, Rtp.RtpFrame frame)
        //{
        //    if (RtpClient == null || RtpClient != sender) return;
        //    try
        //    {
        //        //Get the MediaDescription (by ssrc so dynamic payload types don't conflict
        //        Media.Sdp.MediaDescription mediaDescription = RtpClient.GetContextBySourceId(frame.SynchronizationSourceIdentifier).MediaDescription;
        //        if (mediaDescription.MediaType == Sdp.MediaType.audio)
        //        {
        //            //Could have generic byte[] handlers OnAudioData OnVideoData OnEtc
        //            //throw new NotImplementedException();
        //        }
        //        else if (mediaDescription.MediaType == Sdp.MediaType.video)
        //        {
        //            if (mediaDescription.MediaFormat == 26)
        //            {
        //                OnFrameDecoded(m_lastDecodedFrame = (new RFC2435Stream.RFC2435Frame(frame)).ToImage());
        //            }
        //            else if (mediaDescription.MediaFormat >= 96 && mediaDescription.MediaFormat < 128)
        //            {
        //                //Dynamic..
        //                //throw new NotImplementedException();
        //            }
        //            else
        //            {
        //                //0 - 95 || >= 128
        //                //throw new NotImplementedException();
        //            }
        //        }
        //    }
        //    catch
        //    {
        //        return;
        //    }
        //}

        #endregion

        #endregion

        #region ILoggingReference

        public override bool TrySetLogger(Common.ILogging logger)
        {
            if (IsReady.Equals(false))
            {
                return(false);
            }

            try
            {
                //Set the logger
                RtpClient.Logger = logger;

                return(true);
            }
            catch
            {
                return(false);
            }
            finally
            {
                //
            }
        }
Пример #5
0
        /// <summary>
        /// Calls <see cref="Disconnect"/> and disposes all contained <see cref="RtpClient.TransportContext"/>.
        /// Stops the raising of any events.
        /// Removes the Logger
        /// </summary>
        public override void Dispose()
        {
            if (IsDisposed) return;

            Disconnect();

            base.Dispose();

            if (false == ShouldDispose) return;

            //Dispose contexts
            foreach (TransportContext tc in TransportContexts) tc.Dispose();

            //Counters go away with the transportChannels
            TransportContexts.Clear();

            //Remove my handler (should be done when set to null anyway)
            RtpPacketSent -= new RtpPacketHandler(HandleOutgoingRtpPacket);
            RtcpPacketSent -= new RtcpPacketHandler(HandleOutgoingRtcpPacket);

            //Stop raising events
            RtpPacketSent = null;
            RtcpPacketSent = null;
            RtpPacketReceieved = null;
            RtcpPacketReceieved = null;
            InterleavedData = null;

            //Send abort signal
            Media.Common.Extensions.Thread.ThreadExtensions.TryAbort(ref m_WorkerThread);

            //Send abort signal to all threads contained.
            //Delegate AbortDelegate
            //Media.Common.IThreadReferenceExtensions.AbortAll(this);

            DisableFeedbackReports(this);

            //Empty packet buffers
            m_OutgoingRtpPackets.Clear();
            m_OutgoingRtcpPackets.Clear();

            //Remove the buffer
            m_Buffer.Dispose();
            m_Buffer = null;

            //Unset the logger
            Logger = null;
        }