Пример #1
0
        /// <summary>
        /// 初始化音视频通信组件
        /// </summary>
        /// <param name="Model">视频显示大小模式</param>
        public void iniAV(VideoSizeModel Model)
        {
            if (!IsIni)
                IsIni = true;//标识已经初始化
            else
                return; //如果已经初始化,则退出

            if (WebCam == null)
            {
                DsDevice[] capDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice);
                if (capDevices.Length>0)
                {
                    codeinfo = GetEncoderInfo("image/jpeg");
                    ep = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (long)64);
                    coderpam = new EncoderParameters(1);
                    coderpam.Param[0] = ep;

                    try
                    {
                        WebCam = new HuaSDKSolution.DirectShow.Capture(0, 0, 320, 240);
                        WebCam.Start();
                    }
                    catch (Exception ex)
                    {
                        WebCam.Dispose();
                        WebCam = null;
                        MsgBox.Show("CSS&IM", ex.Message + " 当前系统摄像头正在使用!");
                    }

                }
            }

            if (AE == null)
            {
                AE = new AudioEncoder();//创建G711音频编解码器
            }

            if (AC == null)
            {
                AC = new AudioCapturer(this.trackBar1, this.trackBar2);//创建新的音频捕捉组件
                AC.AudioDataCapturered += new AudioCapturer.AudioDataCaptureredEventHandler(AC_AudioDataCapturered);
            }

            if (AR == null)
            {
                try
                {
                    AR = new CSS.IM.Library.AV.Controls.AudioRender();//创建G711音频回放组件
                }
                catch (Exception)
                {
                    AR = null;
                }

            }

            sendding = true;
            sendthread = new Thread(this.Sending);
            sendthread.Start();
        }
Пример #2
0
        /// <summary>
        /// 初始化音视频通信组件
        /// </summary>
        /// <param name="Model">视频显示大小模式</param>
        public void iniAV(VideoSizeModel Model)
        {
            if (!IsIni)
                IsIni = true;//标识已经初始化
            else
                return; //如果已经初始化,则退出

            if (VC == null)
            {
                VC = new VideoCapturer(this.cLocal);//创建新的视频捕捉组件
                VC.VideoCapturerBefore += new VideoCapturer.VideoCapturerBeforeEventHandler(VC_VideoCapturerBefore);
                VC.VideoDataCapturered += new VideoCapturer.VideoDataCaptureredEventHandler(VC_VideoDataCapturered);
                VC.StartVideoCapture(Model);//开始捕捉视频
            }

            if (AE == null)
            {
                AE = new AudioEncoder();//创建G711音频编解码器
            }

            if (AC == null)
            {
                AC = new AudioCapturer(this.trackBarOut, this.trackBarIn);//创建新的音频捕捉组件
                AC.AudioDataCapturered += new AudioCapturer.AudioDataCaptureredEventHandler(AC_AudioDataCapturered);
            }

            if (AR == null)
            {
                AR = new AudioRender();//创建G711音频回放组件
            }
        }
Пример #3
0
        /// <summary>
        /// 关闭 
        /// </summary>
        public void AVClose()
        {
            try
            {
                callSoundPlayer.Stop();

            }
            catch (Exception)
            {

            }
            finally
            {
                sendding = false;
            }

            try
            {
                aVcommunicationEx1.closeCommunication();
            }
            catch (Exception)
            {

            }

            try
            {
                aVcommunicationEx1.sockUDP1.CloseSock();
            }
            catch (Exception)
            {

            }

            if (WebCam!=null)
            {
                WebCam.Dispose();
            }
            if (AC!=null)
            {
                AC = null;
            }
            if (AR!=null)
            {
                AR = null;
            }
            if (AE!=null)
            {
                AE = null;
            }

            try
            {
                this.Close();
            }
            catch (Exception)
            {

            }

            try
            {
                this.Dispose();
            }
            catch (Exception)
            {

            }
        }
Пример #4
0
        /// <summary>
        /// 关闭 
        /// </summary>
        public void Close()
        {
            try
            {
                aVcommunicationEx1.closeCommunication();
            }
            catch (Exception)
            {

            }

            try
            {
                aVcommunicationEx1.sockUDP1.CloseSock();
            }
            catch (Exception)
            {

            }

            if (this.VC != null)
            {
                if (VC != null)
                {
                    VC.Close();
                    VC = null;
                }
            }

            if (VR!=null)
            {
                VR = null;
            }

            if (VE!=null)
            {
                VE.Close();
                VE = null;
            }
            if (VD!=null)
            {
                VD.Close();
                VD = null;
            }
            if (AC!=null)
            {
                AC = null;
            }
            if (AR!=null)
            {
                AR = null;
            }
            if (AE!=null)
            {
                AE = null;
            }
        }