Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What's the use of libsrtp?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report