What's the use of libsrtp?
This article mainly shows you "what is the use of libsrtp", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what is the use of libsrtp" this article?
Description
Libsrtp is mainly used to encrypt rtp/rtcp; you can also encrypt any text. Note that the bytes of the previous rtp_ protocol are not encrypted; it is no different from AES encryption.
Source code compilation
Cd / home/fengyuzaitu
Wget https://github.com/cisco/libsrtp/archive/master.zip.
Unzip master.zip
Cd libsrtp-master
. / configure
Make
Make runtest
Make install
Refer to the documentation in the source code: libsrtp.pdf
1.7 Example Code
The example is very practical, but there is no error checking. Suppose that * * c has been correctly assigned in the sent data stream, and get_rtp_packet and send_srtp_packet () can be used.
Get_rtp_packet saves the RTP package to the cache, returns the specific length, and the last one sends out the data in the cache. Srtp_protect is responsible for data encryption.
Srtp_t session
Srtp_policy_t policy
Uint8_t key [30]
/ / initialize libSRTP
Srtp_init ()
/ / set policy to describe a policy for an SRTP stream
Crypto_policy_set_rtp_default & policy.rtp)
Crypto_policy_set_rtcp_default & policy.rtcp)
Policy.***c = * * c
Policy.key = key
Policy.next = NULL
/ / set key to random value
Crypto_get_random (key, 30)
/ / allocate and initialize the SRTP session
Srtp_create (& session, policy)
/ / main loop: get rtp packets, send srtp packets
While (1) {
Char rtp_buffer [2048]
Unsigned len
Len = get_rtp_packet (rtp_buffer)
Srtp_protect (session, rtp_buffer, & len)
Send_srtp_packet (rtp_buffer, len)
}
The above is all the content of this article "what's the use of libsrtp?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!