Exemple #1
0
        protected override void Run()
        {
            PinnedBuffer <byte> image = null;
            int size = width * height;

            while (!IsTerminated())
            {
                // 克隆数据
                var temp = this.image;
                if (temp == null)
                {
                    Thread.Sleep(duration);
                    continue;
                }

                try {
                    // 编码
                    image = Arrays.Clone(temp, image, sizeof(byte));
                    encoder.Encode(image.ptr, image.ptr + size, image.ptr + size + size / 4);
                }
                catch (Exception e) {
                    Tracker.LogE(e);
                }

                Thread.Sleep(duration);
            }
        }
        public void Run(BaseWorker worker)
        {
            try {
                encoder.Stop();
                encoder.Start($"rtmp://{Global.gCloudRtmpIP}:{Global.gCloudRtmpPort}/live/{streamId}");
            }
            catch (Exception e) {
                Tracker.LogE(e);
                OnFault();
                return;
            }

            while (!worker.IsTerminated())
            {
                try {
                    IntPtr addr = imageGCHandle.AddrOfPinnedObject();
                    encoder.Encode(addr, addr + imageSize, addr + imageSize + imageSize / 4);
                }
                catch (Exception e) {
                    Tracker.LogE(e);
                    encoder.Stop();
                    OnFault();
                    return;
                }

                Thread.Sleep(1000 / cell.mCell.mIRCameraVideoFrameRate);
            }

            try {
                encoder.Encode(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
                encoder.Stop();
                Stop();
            }
            catch (Exception e) {
                Tracker.LogE(e);
            }
        }
Exemple #3
0
        protected override void Run()
        {
            PinnedBuffer <byte> image = null;
            int size = width * height;

            while (!IsTerminated())
            {
                // 克隆数据
                image = Arrays.Clone(this.image.buffer, image);

                try {
                    // 编码
                    encoder.Encode(image.ptr, image.ptr + size, image.ptr + size + size / 4);
                }
                catch (Exception e) {
                    Tracker.LogE(e);
                }

                Thread.Sleep(duration);
            }
        }