Beispiel #1
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();
        }
Beispiel #2
0
        void thread_audio_send()
        {
            int i;
            //int read_num;
            //T_U32 destip;
            // T_U8 temp[20];
            int data_len;

            //T_U16 *p_liner;
            //T_U8 *pbuf;
            //AudioDataHead *head;
            //int send_size=0;
            //int a=0,b=0;
            byte[] ip   = new byte[4];
            byte[] addr = new byte[6];

            Console.WriteLine("thread_audio_send...");
            //head = (AudioDataHead *)audio_manage.pack_buff;
            AudioPack  head;
            FileStream playFile = null;

            while (true)
            {
                lock (audio_manage.send_sem)
                {
                    Monitor.Wait(audio_manage.send_sem);
                }
                Console.WriteLine("thread_audio_send...");
                try
                {
                    if (playPath != null && playPath != "")
                    {
                        playFile = new FileStream(playPath, FileMode.Open);
                    }
                    else
                    {
                        playFile = null;
                    }
                }
                catch
                {
                    playFile = null;
                }
                if (playFile == null)
                {
                    continue;
                }
                Console.WriteLine("thread_audio_send file ok...");
                while (true)
                {
                    lock (audio_manage.send_lock)
                    {
                        if (audio_manage.send_flag == false)
                        {
                            //AK_Release_Semaphore(audio_manage.send_lock);
                            break;
                        }
                        //if(audio_manage.send_len >= 128)
                        {
                            //打包
                            //data_len = (audio_manage.send_len - (audio_manage.send_len % 128))/2;
                            data_len = (int)(playFile.Length - playFile.Position);
                            if (data_len > 256)
                            {
                                data_len = 256;
                            }


                            head = new AudioPack();
                            //memcpy(head->PublicHead,audio_manage.public_head, 10);  //公共包头
                            //memcpy(head->SourceAddr,audio_manage.source_addr, 6);//源地址
                            head.SourceAddr   = LocalCfg.Addr;
                            head.Type         = 0;
                            head.Fomat        = 0;
                            head.Frameno      = (UInt16)audio_manage.send_frame_no;
                            head.Framelen     = (UInt32)data_len;                               //帧数据长度
                            head.TotalPackage = 1;                                              //总包数
                            head.CurrPackage  = 1;                                              //当前包
                            head.Datalen      = (UInt16)data_len;                               //数据长度
                            head.PackLen      = (UInt16)data_len;
                            head.audioData    = new byte[data_len];
                            playFile.Read(head.audioData, 0, data_len);
                            if (data_len == 0)
                            {
                                playFile.Position = 0;
                            }
                            //转成alaw

                            /*
                             *          p_liner = (T_U16 *)(audio_manage.send_buff+audio_manage.send_rpos);
                             *          for(i=0; i<data_len; i++)
                             *          {
                             *              audio_manage.pack_buff[sizeof(AudioDataHead)+i] = linear2alaw(p_liner[i]);
                             *          }*/

                            audio_manage.send_rpos += data_len * 2;
                            audio_manage.send_len  -= data_len * 2;
                            audio_manage.send_frame_no++;
                            audio_manage.send_frame_total++;

                            /*send_size += data_len;            //统计发送速率
                             *      if(send_size >= 40000)
                             *      {
                             *              a = get_tick_count();
                             *              audio_manage.send_bps = (send_size*1000)/(a-b);
                             *              send_size = 0;
                             *              b = a;
                             *      }*/
                            //printf("audio frame%d: len = %ld\r\n",audio_manage.send_frame_no,head->Datalen = data_len);
                            //AK_Release_Semaphore(audio_manage.send_lock);
                            //发送
                            for (i = 0; i < Remoter.REMOTEMAX; i++)
                            {
                                if (Remoter.Remoter_get_audio_flag(i) == 1)
                                {
                                    Remoter.Remoter_get_ip(i, ip);
                                    Remoter.Remoter_get_addr(i, addr);
                                    head.DestAddr = addr;               //目的地址
                                    audio_manage.udp_trans.Send(head.GetByte(), head.GetLength(), new IPEndPoint(new IPAddress(ip), audio_manage.udp_port));
                                    // Console.WriteLine("thread_audio_send...");
                                }
                            }
                            Thread.Sleep(30);
                        }

                        /*
                         *       else
                         *       {
                         *          //AK_Release_Semaphore(audio_manage.send_lock);
                         *          Thread.Sleep(5);
                         *       }	*/
                    }
                }
                if (playFile != null)
                {
                    playFile.Close();
                }
            }
        }