Exemplo n.º 1
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.VideoCaptureredEventHandler(VC_VideoCapturerBefore);
                VC.VideoDataCapturered += new VideoCapturer.VideoCaptureredEventHandler(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音频回放组件
            }
        }
Exemplo n.º 2
0
        //private void aVcommunication1_AVConnected(object sender, IMLibrary.Class.NetCommunicationClass netCommuctionClass)
        //{
        //    if (this.AVConnected != null)
        //        this.AVConnected(sender, netCommuctionClass);
        //}

        /// <summary>
        /// 收到对方音频数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //private void aVcommunication1_AudioData(object sender, AVcommunication.AVEventArgs e)
        //{
        //    if (this.AE != null && this.AR != null)
        //    {
        //        this.AR.play(this.AE.Decode(e.Data));//将收到的音频数据解码后播放
        //    }
        //}

        /// <summary>
        /// 收到对方的视频数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //private void aVcommunication1_VideoData(object sender, AVcommunication.AVEventArgs e)
        //{
        //    if (this.VD != null && this.VR != null)
        //    {
        //        this.VR.DrawVideo(this.VD.Decode(e.Data));//将收到的视频数据解码后回显
        //    }
        //}

        /// <summary>
        /// 收到对方视频格式事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //private void aVcommunication1_GetBITMAPINFOHEADER(object sender, AVcommunication.AVEventArgs e)
        //{
        //    if (VD == null)
        //        VD = new VideoEncoder(e.BITMAPINFOHEADER, false);//创建视频解码器

        //    if (VR == null)
        //        VR = new VideoRender(this.cRemote);//创建视频回显组件

        //    VR.BITMAPINFOHEADER = e.BITMAPINFOHEADER;
        //}
        #endregion

        #region 关闭
        /// <summary>
        /// 关闭
        /// </summary>
        public void Close()
        {
            if (this.VC != null)
            {
                if (VC != null)
                {
                    VC.Close();
                    VC = null;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 初始化音视频通信组件
        /// </summary>
        /// <param name="Model">视频显示大小模式</param>
        public void iniAV(VideoSizeModel Model, System.Net.IPEndPoint ServerEP)
        {
            if (!IsIni)
            {
                IsIni = true;//标识已经初始化
            }
            else
            {
                return;                //如果已经初始化,则退出
            }
            VideoSize.SetModel(Model); //设置视频编码尺寸

            if (cam == null)
            {
                iniVideoCapturer();
            }

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

            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音频回放组件
            }

            if (frameTransmit == null)
            {
                frameTransmit = new FrameTransmit(ServerEP);
                frameTransmit.GetIPEndPoint     += new FrameTransmit.GetIPEndPointEventHandler(frameTransmit_GetIPEndPoint);
                frameTransmit.RecAudioData      += new FrameTransmit.RecDataEventHandler(frameTransmit_RecAudioData);
                frameTransmit.RecVideoData      += new FrameTransmit.RecDataEventHandler(frameTransmit_RecVideoData);
                frameTransmit.TransmitConnected += new FrameTransmit.TransmitEventHandler(frameTransmit_TransmitConnected);
                frameTransmit.Start();
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 关闭
 /// </summary>
 public void Close()
 {
     if (frameTransmit != null)
     {
         frameTransmit.Dispose();
         frameTransmit = null;
     }
     if (VC != null)
     {
         VC.Close();
         VC = null;
     }
     if (VE != null)
     {
         VE.Close();
         VE = null;
     }
     if (VD != null)
     {
         VD.Close();
         VD = null;
     }
     if (VR != null)
     {
         VR = null;
     }
     if (AC != null)
     {
         AC.Close();
         AC = null;
     }
     if (AE != null)
     {
         AE.Close(); AE = null;
     }
     if (AR != null)
     {
         AR.Close(); AE = null;
     }
     if (cam != null)
     {
         cam.Stop(); cam.Dispose();
         cam = null;
         timer1.Stop();
     }
     //cLocal.Dispose(); cLocal = null;
     //cRemote.Dispose(); cRemote = null;
     //trackBarIn.Dispose(); trackBarIn = null;
     //trackBarOut.Dispose(); trackBarOut = null;
 }
Exemplo n.º 5
0
        //private void aVcommunication1_AVConnected(object sender, IMLibrary.Class.NetCommunicationClass netCommuctionClass)
        //{
        //    if (this.AVConnected != null)
        //        this.AVConnected(sender, netCommuctionClass);
        //}
        
        /// <summary>
        /// 收到对方音频数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //private void aVcommunication1_AudioData(object sender, AVcommunication.AVEventArgs e)
        //{
        //    if (this.AE != null && this.AR != null)
        //    {
        //        this.AR.play(this.AE.Decode(e.Data));//将收到的音频数据解码后播放
        //    }
        //}

        /// <summary>
        /// 收到对方的视频数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //private void aVcommunication1_VideoData(object sender, AVcommunication.AVEventArgs e)
        //{
        //    if (this.VD != null && this.VR != null)
        //    {
        //        this.VR.DrawVideo(this.VD.Decode(e.Data));//将收到的视频数据解码后回显
        //    }
        //}

        /// <summary>
        /// 收到对方视频格式事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //private void aVcommunication1_GetBITMAPINFOHEADER(object sender, AVcommunication.AVEventArgs e)
        //{
        //    if (VD == null)
        //        VD = new VideoEncoder(e.BITMAPINFOHEADER, false);//创建视频解码器

        //    if (VR == null)
        //        VR = new VideoRender(this.cRemote);//创建视频回显组件

        //    VR.BITMAPINFOHEADER = e.BITMAPINFOHEADER;
        //}
        #endregion

        #region 关闭 
        /// <summary>
        /// 关闭 
        /// </summary>
        public void Close()
        {
            if (this.VC != null)
            {
                if (VC != null)
                {
                    VC.Close();
                    VC = null;
                }
            }
        }
Exemplo n.º 6
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.VideoCaptureredEventHandler(VC_VideoCapturerBefore);
                VC.VideoDataCapturered += new VideoCapturer.VideoCaptureredEventHandler(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音频回放组件
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// 关闭 
 /// </summary>
 public void Close()
 {
     if (frameTransmit != null)
     {
         frameTransmit.Dispose();
         frameTransmit = null;
     }
     if (VC != null)
     {
         VC.Close();
         VC = null;
     }
     if (VE != null)
     {
         VE.Close();
         VE = null;
     }
     if (VD != null)
     {
         VD.Close();
         VD = null;
     }
     if (VR != null)
     {
         VR = null;
     }
     if (AC != null)
     {
         AC.Close();
         AC = null;
     }
     if (AE != null)
     {
         AE.Close(); AE = null;
     }
     if (AR != null)
     {
         AR.Close(); AE = null;
     }
     if (cam != null)
     {
         cam.Stop(); cam.Dispose();
         cam = null;
         timer1.Stop();
     }
     //cLocal.Dispose(); cLocal = null;
     //cRemote.Dispose(); cRemote = null;
     //trackBarIn.Dispose(); trackBarIn = null;
     //trackBarOut.Dispose(); trackBarOut = null;
 }