Go implementation of RTP stack--GORTP introduction

Source: Internet
Author: User

Https://github.com/whtang/GoRTP

GORTP implements some important functions that modify the head and contents of the RTP packet. Most, however, handle only the payload and timestamp of the RTP packet.

RTP Data grouping

The packet module implements a buffering mechanism that allows for missed calls, which reduces the dynamic allocation request for memory. Although not necessary, it is recommended that freepacket () be used to return packets to the packet queue, which reduces dynamic memory allocation and excessive garbage collection. This may be advantageous for applications that send audio and video for long periods of time.

Transmission module

The GORTP is implemented using a stack-transfer module. Use UDP,TCP or other network protocols at the bottom. The transmission module must implement TRANSPORTRECV and/or transportwrite if it wants to be a recipient of a predetermined sender.

The transport module on the upper layer filters the received data and produces a specific output, such as the ice transfer to handle all ice-related data and will not send the ice data packets to the session module because the session module only expects to accept RTP data. The session module discards all non-RTP and non-RTCP groupings.

The client program should build the transport stack according to its own needs. The application uses a high-level transport module to initialize the RTP reply, and typically an application uses only one transport module. The following code shows how it works.

var localport = 5220var Local, _ = net. RESOLVEIPADDR ("IP", "127.0.0.1") var remoteport = 5222var Remote, _ = net. RESOLVEIPADDR ("IP", "127.0.0.1") ...//create a UDP transport with a local address and use it for the RTP session//RTP session with the transport layer to receive and send the RTP packet tplocal to the remote, _: = RTP. NEWTRANSPORTUDP (Local, LocalPort)//TRANSPORTUDP implements the Transportwrite and TRANSPORTRECV interface, so// Use it as a read-write module for session rslocal = RTP. NewSession (tplocal, tplocal)

  

You may have noticed that the code does not use a standard go UDP address, but a separate IP and port number. This approach makes it easier to implement multiple TCP and UDP transmissions. The network transmission module has its own address format, RTP requires two ports, one is used to transfer data another to manage the connection. The RFC3550 requires an even number port to send data, and the next odd number port of the even number is used to manage the connection. So the transport module only needs the port number of the data connection.

An application may stack multiple transport modules. To do this, first create the transport module and then let them connect as follows.

12345678 transportNet, _ := rtp.NewTransportUDP(local, localPort)transportAboveNet, _ := rtp.NewTransportWhatEver(....)// Register AboveNet as upper layer transporttransportNet.SetCallUpper(transportAboveNet)// Register transportNet as lower layertransportAboveNet.SetToLower(transportNet)

Todo

Go implementation of RTP stack--GORTP introduction

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.