Пример #1
0
        public int app_udp_init(int port)
        {
            multi_udp.port          = port;
            multi_udp.recv_deal_fun = null;
            //初始化发送缓冲区
            multi_udp.send_buff = new MULTI_UDP_BUFF[UDP_SEND_BUFF_COUNT];

            for (int i = 0; i < UDP_SEND_BUFF_COUNT; i++)
            {
                multi_udp.send_buff[i] = new MULTI_UDP_BUFF();
            }
            VsProtocol.Get_MulticastIP(VsProtocol.MulticastIPType.INDOOR_MULICASTIP, LocalCfg.Addr, 0, LocalCfg.IP_Mulicast);
            //创建UDP,绑定指定端口
            try
            {
                IPEndPoint ipEp = new IPEndPoint(new IPAddress(LocalCfg.IP), multi_udp.port);
                multi_udp.udp_trans = new UdpClient(ipEp);
                multi_udp.udp_trans.JoinMulticastGroup(new IPAddress(LocalCfg.IP_Mulicast), new IPAddress(LocalCfg.IP));
            }
            catch (Exception e)
            {
                Console.WriteLine("new UdpClient fail :" + e.ToString());
            }

            //创建发送和接收线程
            multi_udp.recv_task = new Thread(thread_multi_udp_recv);
            multi_udp.recv_task.Start();
            multi_udp.send_task = new Thread(thread_multi_udp_send);
            multi_udp.send_task.Start();
            //初始化定时器
            multi_udp.vTimer = new Timer(udp_pack_time_update);
            multi_udp.vTimer.Change(0, 10);

            return(0);
        }
Пример #2
0
        public CallTabPage()
        {
            InitializeComponent();

            AppTimer.app_timer_init();
            Remoter.Remoter_init();
            LocalCfg.Addr = new byte[] { (byte)VsProtocol.DevType.DEV_INDOORPHONE, 1, 1, 8, 8, 1 };
            VsProtocol.Change_IDToIP(LocalCfg.Addr, LocalCfg.IP);
            talkback = new Talkback();
            talkback.talk_back_init();
            talkback.udpDeal.app_udp_init(8300);
            talkback.udpDeal.set_multi_udp_recv_fun(UdpApp.udp_deal);
            talkback.videoDeal.video_manage.video_recv_callback = videoCallback;
            UdpApp.UdpAppInit(talkback);
            label1.Text      = new IPAddress(LocalCfg.IP).ToString();
            Output.outObject = richTextBox1;
            InitSetting();
        }