Ejemplo n.º 1
0
 internal void AddFrame(RtspClientSharp.RawFrames.RawFrame frame)
 {
     if (frame is RtspClientSharp.RawFrames.Video.RawH264Frame h264Frame)
     {
         var safeFrame = CopyFrame(h264Frame);
         if (safeFrame != null)
         {
             queue.Add(safeFrame);
         }
     }
 }
Ejemplo n.º 2
0
 private void RtspFrameRecieved(object sender, RtspClientSharp.RawFrames.RawFrame frame)
 {
     if (frame.Type == RtspClientSharp.RawFrames.FrameType.Video)
     {
         ContractsRawVideo.RawVideoFrame rawFrame = ToContractsRawVideoFrame(frame);
         if (rawFrame != null)
         {
             OnVideoFrameReceived(rawFrame);
         }
     }
 }
Ejemplo n.º 3
0
 private ContractsRawVideo.RawVideoFrame ToContractsRawVideoFrame(RtspClientSharp.RawFrames.RawFrame frame)
 {
     if (frame is RtspRawVideo.RawH264IFrame f1)
     {
         return(new ContractsRawVideo.RawH264IFrame(f1.Timestamp, f1.FrameSegment, f1.SpsPpsSegment));
     }
     if (frame is RtspRawVideo.RawH264PFrame f2)
     {
         return(new ContractsRawVideo.RawH264PFrame(f2.Timestamp, f2.FrameSegment));
     }
     return(null);
 }
Ejemplo n.º 4
0
        private void RtspClient_FrameReceived(object sender, RtspClientSharp.RawFrames.RawFrame e)
        {
            if (rtspCancel.Token.IsCancellationRequested)
            {
                return;
            }
            //Console.WriteLine("Got Frame " + e.ToString());

            switch (e)
            {
            case RawH264IFrame h264IFrame:
            {
                if (callbacks.buffers.Count == 0)
                {
                    return;
                }
                var index  = callbacks.buffers.Pop();
                var buffer = codec.GetInputBuffer(index);
                buffer.Clear();
                buffer.Put(h264IFrame.SpsPpsSegment.Array);
                codec.QueueInputBuffer(index, 0, h264IFrame.SpsPpsSegment.Count, 0, MediaCodecBufferFlags.CodecConfig);

                if (callbacks.buffers.Count == 0)
                {
                    return;
                }
                index  = callbacks.buffers.Pop();
                buffer = codec.GetInputBuffer(index);
                buffer.Clear();
                buffer.Put(h264IFrame.FrameSegment.Array);
                codec.QueueInputBuffer(index, 0, h264IFrame.FrameSegment.Count, 0, MediaCodecBufferFlags.None);

                iframestart = false;
                break;
            }

            case RawH264PFrame h264PFrame:
            {
                if (iframestart)
                {
                    return;
                }
                if (callbacks.buffers.Count == 0)
                {
                    return;
                }
                var index  = callbacks.buffers.Pop();
                var buffer = codec.GetInputBuffer(index);
                buffer.Clear();
                buffer.Put(h264PFrame.FrameSegment.Array);
                codec.QueueInputBuffer(index, 0, h264PFrame.FrameSegment.Count, 0, 0);
                break;
            }

            case RawJpegFrame jpegFrame:
            case RawAACFrame aacFrame:
            case RawG711AFrame g711AFrame:
            case RawG711UFrame g711UFrame:
            case RawPCMFrame pcmFrame:
            case RawG726Frame g726Frame:
                break;
            }
        }