RTP协议介绍:http://www.360doc.com/content/11/1009/15/496343_154624612.shtml

本文中使用了 StreamCoders 的 RTP.net组件,此组件中有些和c++ 混合编程部分,我已将此组件转成全部c#代码

收听端代码

        RTPSession session;
        RTPReceiver receiver;
        RTPParticipant participant;

        WinSound.Player m_Player;
        public Form1()
        {
            InitializeComponent();
            m_Player = new WinSound.Player();
            List<String> names = WinSound.WinSound.GetPlaybackNames();
            m_Player.Open(names[0], 44100, 16, 2, 8);
        }

        private void btnListen_Click(object sender, EventArgs e)
        {
            IPAddress ipaddr;
            ushort usPort;

            if (!(IPAddress.TryParse(txtIp.Text, out ipaddr) && ushort.TryParse(txtPort.Text, out usPort)))
            {
                MessageBox.Show("IP地址或端口填写错误!");
                return;
            }
            session = new RTPSession();
            receiver = new RTPReceiver();
            IPEndPoint rtpEp = new IPEndPoint(ipaddr, usPort);

            participant = new RTPParticipant(rtpEp);
            session.NewRTPPacket = NewRTPPacket;
            session.NewRTCPPacket = NewRTCPPacket;
            receiver.AddParticipant(participant);
            session.AddReceiver(receiver);
        }

        bool NewRTPPacket(RTPPacket packet)
        {
            if (packet.DataPointer != null)
            {
                //Nach Linear umwandeln
                Byte[] linearBytes = WinSound.Utils.MuLawToLinear(packet.DataPointer, 16, 2);
                //Abspielen
                m_Player.PlayData(linearBytes, false);
            }
            return true;

        }

Rtp 协议实现网络广播台网络收音机

 

全部源码可有偿提供

相关文章:

  • 2022-02-08
  • 2022-02-08
  • 2021-08-15
  • 2022-12-23
  • 2022-02-13
  • 2021-09-17
  • 2021-07-30
  • 2021-12-15
猜你喜欢
  • 2021-11-13
  • 2021-10-31
  • 2021-12-14
  • 2021-07-24
  • 2021-10-18
  • 2022-02-08
  • 2021-11-14
相关资源
相似解决方案