コード例 #1
0
ファイル: Targets.cs プロジェクト: memedude56/rt
        public void SDLCallback(Span <byte> buffer)
        {
            while (buffer.Length != 0 && !tok.IsCancellationRequested)
            {
                if (currentOffset != -1)
                {
                    int toCopy = Math.Min(currentBlock.Length - currentOffset, buffer.Length);
                    currentBlock.Buffer.AsSpan().Slice(currentOffset, toCopy).CopyTo(buffer);

                    buffer         = buffer.Slice(toCopy);
                    currentOffset += toCopy;
                }

                if (currentOffset >= currentBlock.Length)
                {
                    currentOffset = -1;
                    currentBlock.Free();
                }

                if (currentOffset == -1 && buffer.Length != 0)
                {
                    try
                    {
                        currentBlock  = samples.Take(tok);
                        currentOffset = 0;
                    }
                    catch (OperationCanceledException)
                    {
                        return;
                    }
                }
            }
        }
コード例 #2
0
ファイル: Streams.cs プロジェクト: noobkun/SysDVR
        override public void SendData(PoolBuffer block, ulong ts)
        {
            Span <byte> data = block;
            var         nal  = FindNalOffset(data);

            while (nal != null)
            {
                InvokeEvent(nal, ts / 1000);
                nal = FindNalOffset(nal);
            }
            block.Free();
        }
コード例 #3
0
ファイル: LoggingTarget.cs プロジェクト: noobkun/SysDVR
        public void SendData(PoolBuffer data, UInt64 ts)
        {
            Console.WriteLine($"{filename} - ts: {ts}");
            bin.Write(0xAAAAAAAA);
            bin.Write(sw.ElapsedMilliseconds);
            bin.Write(ts);
            bin.Write(data.Length);
            bin.Write(data.Span);
            sw.Restart();

            data.Free();
        }
コード例 #4
0
        public PoolBuffer PreloadObject(T resource, int count)
        {
            if (this._trackActiveComponent)
            {
                this._activeInstances = new List <T> (Mathf.Max(count, 0));
            }

            if (count < 0)
            {
                count = DEFAULT_INSTANCE_COUNT;
            }

            PoolBuffer buffer = new PoolBuffer(this, resource, count);

            return(buffer);
        }
コード例 #5
0
        public unsafe void SendData(PoolBuffer data, ulong ts)
        {
            byte[] buffer = data.Buffer;
            int    size   = data.Length;

            if (firstTs == -1)
                firstTs = (long)ts;

            fixed(byte *nal_data = buffer)
            {
                AVPacket pkt;

                av_init_packet(&pkt);

                pkt.data = nal_data;
                pkt.size = size;
                pkt.pts  = pkt.dts = (long)(((long)ts - firstTs) / 1E+6 * timebase_den);

                int res = 0;

send_again:
                lock (ctx.CodecLock)
                    res = avcodec_send_packet(ctx.CodecCtx, &pkt);

                if (res == AVERROR(EAGAIN))
                {
                    if (!tok.IsCancellationRequested)
                    {
                        // This never seems to happen
                        goto send_again;
                    }
                }
                else if (res != 0)
                {
                    Console.WriteLine($"avcodec_send_packet {res}");
                }
            }

            data.Free();
        }
コード例 #6
0
ファイル: Streams.cs プロジェクト: noobkun/SysDVR
 public override void SendData(PoolBuffer block, ulong ts)
 {
     InvokeEvent(block, ts / 1000);
     block.Free();
 }
コード例 #7
0
ファイル: Streams.cs プロジェクト: noobkun/SysDVR
 public abstract void SendData(PoolBuffer block, ulong ts);
コード例 #8
0
ファイル: Targets.cs プロジェクト: memedude56/rt
 public unsafe void SendData(PoolBuffer block, UInt64 ts)
 {
     samples.Add(block, tok);
 }
コード例 #9
0
 public Pool(T resource, int count, bool trackActiveComponents = true)
 {
     this._trackActiveComponent = trackActiveComponents;
     this._buffer = PreloadObject(resource, count);
 }
コード例 #10
0
 public void SendData(PoolBuffer block, ulong ts)
 {
     SendData(block.Buffer, block.Length, ts);
     block.Free();
 }