Наследование: BaseConnectivity, IDisposable
Пример #1
0
        public InboundConnectivity GetInboundConnectivity(string sdpStreamName, uint bandwidthHint, byte rtcpDetectionInterval)
        {
            CloseInboundConnectivity();
            var streamName = ((string)CustomParameters["localStreamName"]) ?? sdpStreamName;

            InboundConnectivity = new InboundConnectivity(this, streamName,
                                                          bandwidthHint, TimeSpan.FromSeconds(rtcpDetectionInterval));
            return(InboundConnectivity);
        }
Пример #2
0
 private void CloseInboundConnectivity()
 {
     InboundConnectivity?.Dispose();
     InboundConnectivity = null;
 }
Пример #3
0
 public InboundConnectivity GetInboundConnectivity(string sdpStreamName, uint bandwidthHint, byte rtcpDetectionInterval)
 {
     CloseInboundConnectivity();
     var streamName = ((string)CustomParameters["localStreamName"]) ?? sdpStreamName;
     InboundConnectivity = new InboundConnectivity(this, streamName,
             bandwidthHint,TimeSpan.FromSeconds(rtcpDetectionInterval) );
     return InboundConnectivity;
 }
Пример #4
0
        public override bool SignalInputData(InputStream inputStream, IPEndPoint address)
        {
            if (address != _lastAddress)
            {
                _lastAddress = address;
                _validLastAddress = true;
            }
            var bufferLength = inputStream.AvaliableByteCounts;
            var pos = inputStream.Position;
            //1. Parse the SR
            if (bufferLength < 16) return true;
            inputStream.Reader.ReadByte();
            var PT = inputStream.Reader.ReadByte();
            var len = inputStream.Reader.ReadUInt16();
            len = (ushort) ((len + 1) * 4);
            if (len > bufferLength)
            {
                inputStream.IgnoreAll();
                return true;
            }
            switch (PT)
            {
                case 200:
                    if (len < 28)
                    {
                        Logger.WARN("Invalid RTCP packet length: {0}", len);
                        inputStream.IgnoreAll();
                        return true;
                    }
                    inputStream.Reader.ReadUInt32();
                    var ntpSec = inputStream.Reader.ReadUInt32()- 2208988800U;
                    var ntpFrac = inputStream.Reader.ReadUInt32();
                    ulong ntpMicroseconds = (ulong)((ntpFrac / (double)(0x100000000L))*1000000.0);
                    ntpMicroseconds += ((ulong)ntpSec) * 1000000;
                    var rtpTimestamp = inputStream.Reader.ReadUInt32();
                    _pConnectivity.ReportSR(ntpMicroseconds, rtpTimestamp, _isAudio);
                    break;
                default:
                    inputStream.IgnoreAll();
                    return true;
            }
            inputStream.Position = pos + 10;
            _lsr = inputStream.Reader.ReadUInt32();
            inputStream.IgnoreAll();
            //2. Send the RR
            if (_pConnectivity == null)
            {
                Logger.FATAL("no connectivity");
                return false;
            }
            if (!_pConnectivity.SendRR(_isAudio))
            {
                Logger.FATAL("Unable to send RR");
                _pConnectivity.EnqueueForDelete();
                _pConnectivity = null;
                return false;
            }

            return true;
        }
Пример #5
0
 public void SetInbboundConnectivity(InboundConnectivity pConnectivity, bool isAudio)
 {
     _pConnectivity = pConnectivity;
     _isAudio = isAudio;
 }
Пример #6
0
 private void CloseInboundConnectivity()
 {
     InboundConnectivity?.Dispose();
     InboundConnectivity = null;
 }
Пример #7
0
        public override bool SignalInputData(InputStream inputStream, IPEndPoint address)
        {
            if (address != _lastAddress)
            {
                _lastAddress      = address;
                _validLastAddress = true;
            }
            var bufferLength = inputStream.AvaliableByteCounts;
            var pos          = inputStream.Position;

            //1. Parse the SR
            if (bufferLength < 16)
            {
                return(true);
            }
            inputStream.Reader.ReadByte();
            var PT  = inputStream.Reader.ReadByte();
            var len = inputStream.Reader.ReadUInt16();

            len = (ushort)((len + 1) * 4);
            if (len > bufferLength)
            {
                inputStream.IgnoreAll();
                return(true);
            }
            switch (PT)
            {
            case 200:
                if (len < 28)
                {
                    Logger.WARN("Invalid RTCP packet length: {0}", len);
                    inputStream.IgnoreAll();
                    return(true);
                }
                inputStream.Reader.ReadUInt32();
                var   ntpSec          = inputStream.Reader.ReadUInt32() - 2208988800U;
                var   ntpFrac         = inputStream.Reader.ReadUInt32();
                ulong ntpMicroseconds = (ulong)((ntpFrac / (double)(0x100000000L)) * 1000000.0);
                ntpMicroseconds += ((ulong)ntpSec) * 1000000;
                var rtpTimestamp = inputStream.Reader.ReadUInt32();
                _pConnectivity.ReportSR(ntpMicroseconds, rtpTimestamp, _isAudio);
                break;

            default:
                inputStream.IgnoreAll();
                return(true);
            }
            inputStream.Position = pos + 10;
            _lsr = inputStream.Reader.ReadUInt32();
            inputStream.IgnoreAll();
            //2. Send the RR
            if (_pConnectivity == null)
            {
                Logger.FATAL("no connectivity");
                return(false);
            }
            if (!_pConnectivity.SendRR(_isAudio))
            {
                Logger.FATAL("Unable to send RR");
                _pConnectivity.EnqueueForDelete();
                _pConnectivity = null;
                return(false);
            }

            return(true);
        }
Пример #8
0
 public void SetInbboundConnectivity(InboundConnectivity pConnectivity, bool isAudio)
 {
     _pConnectivity = pConnectivity;
     _isAudio       = isAudio;
 }