Ejemplo n.º 1
0
 public override void Write(byte[] buffer, int offset, int count)
 {
     try
     {
         lock (outStream)
         {
             mMediaTask.Write(buffer, offset, count);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Ejemplo n.º 2
0
        public void VideoInputFrameArrived(IDeckLinkVideoInputFrame videoFrame, IDeckLinkAudioInputPacket audioPacket)
        {
            if (videoFrame == null && audioPacket == null)
            {
                return;
            }
            try
            {
                if (!_Streaming)
                {
                    return;
                }
                if (!_VideoLock.Wait(TimeSpan.Zero))
                {
                    return;
                }
                try
                {
                    Interlocked.Increment(ref _FrameCount);
                    Run(() => frameCount.Text = _FrameCount.ToString());

                    if (videoFrame != null)
                    {
                        var rowBytes = videoFrame.GetRowBytes();
                        var height   = videoFrame.GetHeight();

                        IntPtr framePointer;
                        videoFrame.GetBytes(out framePointer);

                        var frame = new byte[rowBytes * height];
                        Marshal.Copy(framePointer, frame, 0, frame.Length);

                        if (writeRaw.Checked)
                        {
                            _VideoWriter.Write(frame);
                        }

                        if (writeEncoded.Checked)
                        {
                            _EncodeTask.Write(frame, 0, frame.Length);
                        }
                    }

                    if (audioPacket != null)
                    {
                        IntPtr audioPointer;
                        audioPacket.GetBytes(out audioPointer);

                        var frameCount = audioPacket.GetSampleFrameCount();

                        var audio = new byte[frameCount * _AudioChannels * (_AudioSampleDepth / 8)];
                        Marshal.Copy(audioPointer, audio, 0, audio.Length);

                        if (writeRaw.Checked)
                        {
                            _AudioWriter.Write(audio);
                        }
                    }
                }
                finally
                {
                    _VideoLock.Release();
                }
            }
            finally
            {
                if (videoFrame != null)
                {
                    Marshal.ReleaseComObject(videoFrame);
                }
                if (audioPacket != null)
                {
                    Marshal.ReleaseComObject(audioPacket);
                }
            }
        }
Ejemplo n.º 3
0
        public static void Write(this ConvertLiveMediaTask task, Bitmap frame)
        {
            var buffer = frame.GetBytes();

            task.Write(buffer, 0, buffer.Length);
        }