Exemple #1
0
        public override ARESULT Start()
        {
            try {
                encoder = new RTMPEncoder();
                encoder.Initialize(width, height, frameRate);
                encoder.Start(uri);
            }
            catch (Exception e) {
                Tracker.LogE(e);
                return(ARESULT.E_FAIL);
            }

            EventEmitter.Instance.Subscribe(eventName, onReceiveImage);
            return(base.Start());
        }
        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);
            }
        }