Example #1
0
        public void OnPacketReceived(RtpPayload payload, int time)
        {
            var allBytes = payload.Data
                           .Select(AlawEncoder.Alaw2Linear)
                           .Select(BitConverter.GetBytes)
                           .SelectMany(a => a.ToArray())
                           .ToArray();

            this.playbackDevice.PlaySample(allBytes);
        }
Example #2
0
        private void TryConvert(RtpPayload payload, Action <RtpPayload> next)
        {
            // TODO: get from configuration
            if (payload.PayloadType != 8)
            {
                next(payload);
                return;
            }

            var data = payload.Data.AsPairs().Select(a => new[] { a[0], a[1] }).Select(a => AlawEncoder.LinearToAlaw(a.AsShort())).ToArray();

            next(new RtpPayload(data, payload.SequenceNumber, payload.Identifier, payload.Timestamp, payload.IsFirst, payload.PayloadType));
        }
Example #3
0
        public RtpPayload GetData(long timestamp)
        {
            Interlocked.Increment(ref this.packetsSent);
            var endOfEvent = Interlocked.Read(ref this.numberOfPackets) == 1;

            // volume = 10 = 0x0a or 0x8a
            var data =
                new[] { (byte)this.digit, (byte)(endOfEvent ? 0x8a : 0x0a) }.Concat(
                BitConverter.GetBytes((short)(this.packetsSent * 160)).Reverse()).ToArray();

            var payload = new RtpPayload(data, this.sequenceNumber, this.identifier, timestamp, false, 0x65);

            Interlocked.Add(ref this.numberOfPackets, -1);

            return(payload);
        }