2020-04-27 11:07:24 +00:00
# uvgRTP example codes
2019-06-03 08:45:11 +00:00
2021-05-18 13:40:52 +00:00
This directory contains a collection of simple and thoroughly commented examples that demonstrate how to use uvgRTP.
2020-04-16 10:24:08 +00:00
2020-10-06 03:45:04 +00:00
Below is a very simple example usage of uvgRTP:
```
#include <uvgrtp/lib.hh>
/* g++ main.cc -luvgrtp -lpthread & & ./a.out */
int main(void)
{
2021-04-23 05:55:15 +00:00
uvgrtp::context ctx;
uvgrtp::session *sess = ctx.create_session("127.0.0.1");
2020-10-06 03:45:04 +00:00
2021-04-23 05:55:15 +00:00
uvgrtp::media_stream *strm = sess->create_stream(8888, 8888, RTP_FORMAT_GENERIC, RTP_NO_FLAGS);
2020-10-06 03:45:04 +00:00
char *message = (char * )"Hello, world!";
2021-05-30 04:52:40 +00:00
size_t msg_len = strlen(message) + 1;
2020-10-06 03:45:04 +00:00
for (;;) {
strm->push_frame((uint8_t *)message, msg_len, RTP_NO_FLAGS);
auto frame = strm->pull_frame();
fprintf(stderr, "Message: '%s'\n", frame->payload);
2021-04-23 05:55:15 +00:00
uvgrtp::frame::dealloc_frame(frame);
2020-10-06 03:45:04 +00:00
}
}
```
2020-08-11 08:47:33 +00:00
## Basic RTP functionality
2019-05-15 06:46:48 +00:00
2020-04-06 09:02:57 +00:00
[How to create a simple RTP sender ](sending.cc )
[How to create a simple RTP receiver (hooking) ](receiving_hook.cc )
2021-04-23 05:55:15 +00:00
NOTE: The hook should **not** be used for media processing. It should be used as interface between application and library where the frame hand-off happens.
2020-04-06 09:02:57 +00:00
[How to create a simple RTP receiver (polling) ](receiving_poll.cc )
2020-08-11 08:47:33 +00:00
## Advanced RTP functionality
2020-04-06 09:02:57 +00:00
2021-02-12 13:08:21 +00:00
[How to configure uvgRTP context ](configuration.cc )
2020-04-06 09:02:57 +00:00
2021-02-12 13:08:21 +00:00
[How to fragment generic media types ](sending_generic.cc )
2020-05-28 06:50:26 +00:00
2020-10-06 03:45:04 +00:00
[How to enable UDP hole punching ](binding.cc )
2020-05-28 06:50:26 +00:00
2020-10-06 03:45:04 +00:00
[How to use custom timestamps correctly ](custom_timestamps.cc )
## RTCP
2020-04-06 09:02:57 +00:00
2020-08-11 08:47:33 +00:00
[How to use RTCP instance (hooking) ](rtcp_hook.cc )
2020-04-06 09:02:57 +00:00
2020-08-11 08:47:33 +00:00
## Security
2020-04-06 09:02:57 +00:00
2020-08-11 08:47:33 +00:00
[How to use SRTP with ZRTP ](srtp_zrtp.cc )
2020-04-06 09:02:57 +00:00
2020-10-06 03:45:04 +00:00
[How to use multi-stream SRTP with ZRTP ](zrtp_multistream.cc )
2020-08-11 08:47:33 +00:00
[How to use SRTP with user-managed keys ](srtp_user.cc )