Exemplo n.º 1
0
        public void StopPush()
        {
            var result = Environment.Is64BitProcess ?
                         Interop64.StopPush(_pusherHandle) :
                         Interop32.StopPush(_pusherHandle);

            if (result != 0)
            {
                throw new PusherException(result);
            }
        }
Exemplo n.º 2
0
        internal VideoFrame(IntPtr frameHandle)
        {
            _frameHandle = frameHandle;
            Index        = Environment.Is64BitProcess ?
                           Interop64.GetFrameIndex(_frameHandle) :
                           Interop32.GetFrameIndex(_frameHandle);

            Size = Environment.Is64BitProcess ?
                   Interop64.GetFrameSize(_frameHandle) :
                   Interop32.GetFrameSize(_frameHandle);
        }
Exemplo n.º 3
0
        public VideoPacket(IntPtr packetHandle)
        {
            _packetHandle = packetHandle;
            Index         = Environment.Is64BitProcess ?
                            Interop64.GetPacketIndex(_packetHandle) :
                            Interop32.GetPacketIndex(_packetHandle);

            Size = Environment.Is64BitProcess ?
                   Interop64.GetPacketSize(_packetHandle) :
                   Interop32.GetPacketSize(_packetHandle);
        }
Exemplo n.º 4
0
        public void Flush()
        {
            var result = Environment.Is64BitProcess ?
                         Interop64.FlushEncoder(_encoderHandle) :
                         Interop32.FlushEncoder(_encoderHandle);

            if (result != 0)
            {
                throw new PusherException(result);
            }
        }
Exemplo n.º 5
0
        public void PushPacket(VideoPacket packet)
        {
            var result = Environment.Is64BitProcess ?
                         Interop64.PushPacket(_pusherHandle, packet.Handle) :
                         Interop32.PushPacket(_pusherHandle, packet.Handle);

            if (result != 0)
            {
                throw new PusherException(result);
            }
        }
Exemplo n.º 6
0
        public void StartPush(string url, int width, int height, int frameRate)
        {
            var result = Environment.Is64BitProcess ?
                         Interop64.StartPush(_pusherHandle, url, width, height, frameRate) :
                         Interop32.StartPush(_pusherHandle, url, width, height, frameRate);

            if (result != 0)
            {
                throw new PusherException(result);
            }
        }
Exemplo n.º 7
0
        public Pusher()
        {
            var result = Environment.Is64BitProcess ?
                         Interop64.CreatePusher(out _pusherHandle) :
                         Interop32.CreatePusher(out _pusherHandle);

            if (result != 0)
            {
                throw new PusherException(result);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Only support BGRA data.
        /// </summary>
        /// <param name="imageData"></param>
        /// <returns></returns>
        public void AddImage(byte[] imageData)
        {
            var result = Environment.Is64BitProcess ?
                         Interop64.AddImage(_encoderHandle, imageData, imageData.Length):
                         Interop32.AddImage(_encoderHandle, imageData, imageData.Length);

            if (result != 0)
            {
                throw new PusherException(result);
            }
        }
Exemplo n.º 9
0
        public Encoder(int width, int height, int frameRate)
        {
            _myFrameEncodedCallback = MyFrameEncodedCallback;
            var result = Environment.Is64BitProcess ?
                         Interop64.CreateEncoder(out _encoderHandle, width, height, frameRate, _myFrameEncodedCallback) :
                         Interop32.CreateEncoder(out _encoderHandle, width, height, frameRate, _myFrameEncodedCallback);

            if (result != 0)
            {
                throw new PusherException(result);
            }
        }
Exemplo n.º 10
0
 private void DoDispose()
 {
     if (!_disposed)
     {
         var result = Environment.Is64BitProcess ?
                      Interop64.DestroyPacket(_packetHandle) :
                      Interop32.DestroyPacket(_packetHandle);
         if (result != 0)
         {
             throw new PusherException(result);
         }
         _disposed = true;
     }
 }
Exemplo n.º 11
0
 private void DoDispose()
 {
     if (!_disposed)
     {
         if (Environment.Is64BitProcess)
         {
             Interop64.DestroyFrame(_frameHandle);
         }
         else
         {
             Interop32.DestroyFrame(_frameHandle);
         }
         _disposed = true;
     }
 }
Exemplo n.º 12
0
        public Encoder(int width, int height, int frameRate, int bitRate)
        {
            _myFrameEncodedCallback = MyFrameEncodedCallback;
            var result = Environment.Is64BitProcess ?
                         Interop64.CreateEncoder(out _encoderHandle, width, height, frameRate, bitRate, _myFrameEncodedCallback) :
                         Interop32.CreateEncoder(out _encoderHandle, width, height, frameRate, bitRate, _myFrameEncodedCallback);

            if (result != 0)
            {
                throw new PusherException(result);
            }
            _layerImage    = new Bitmap(width, height);
            _layerGraphics = Graphics.FromImage(_layerImage);
            _layerRect     = new Rectangle(0, 0, width, height);
            _layerDataSzie = width * height * 4;
        }
Exemplo n.º 13
0
 private void DoDispose()
 {
     if (!_disposed)
     {
         _myFrameEncodedCallback = null;
         if (Environment.Is64BitProcess)
         {
             Interop64.DestroyEncoder(_encoderHandle);
         }
         else
         {
             Interop32.DestroyEncoder(_encoderHandle);
         }
         _disposed = true;
     }
 }
Exemplo n.º 14
0
        /// <summary>
        /// Only support BGRA data.
        /// </summary>
        /// <param name="image"></param>
        /// <returns></returns>
        public void AddImage(Bitmap image)
        {
            var processImage = _layerImage;

            if (image.Width == _layerImage.Width && image.Height == _layerImage.Height)
            {
                processImage = image;
            }
            else
            {
                _layerGraphics.DrawImage(image, _layerRect);
            }
            var bmpData = processImage.LockBits(_layerRect, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
            var result  = Environment.Is64BitProcess ?
                          Interop64.AddImage(_encoderHandle, bmpData.Scan0, _layerDataSzie) :
                          Interop32.AddImage(_encoderHandle, bmpData.Scan0, _layerDataSzie);

            if (result != 0)
            {
                throw new PusherException(result);
            }
            processImage.UnlockBits(bmpData);
        }