forked from ultravideo/uvgRTP
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfiguration.cc
45 lines (35 loc) · 1.74 KB
/
configuration.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <uvgrtp/lib.hh>
#define PAYLOAD_MAXLEN 4096
int main(void)
{
/* See sending.cc for more details */
uvgrtp::context ctx;
/* See sending.cc for more details */
uvgrtp::session *sess = ctx.create_session("127.0.0.1");
/* Some of the functionality of uvgRTP can be enabled/disabled using RCE_* flags.
*
* For example, here the created MediaStream object has RTCP enabled,
* does not utilize system call clustering to reduce the possibility of packet dropping
* and prepends a 4-byte HEVC start code (0x00000001) before each NAL unit */
unsigned flags =
RCE_RTCP | /* enable RTCP */
RCE_NO_SYSTEM_CALL_CLUSTERING | /* disable system call clustering */
RCE_H26X_PREPEND_SC; /* prepend a start code before each NAL unit */
uvgrtp::media_stream *hevc = sess->create_stream(8888, 8889, RTP_FORMAT_H265, flags);
/* uvgRTP context can also be configured using RCC_* flags
* These flags do not enable/disable functionality but alter default behaviour of uvgRTP
*
* For example, here UDP send/recv buffers are increased to 40MB
* and frame delay is set 150 milliseconds to allow frames to arrive a little late */
hevc->configure_ctx(RCC_UDP_RCV_BUF_SIZE, 40 * 1000 * 1000);
hevc->configure_ctx(RCC_UDP_SND_BUF_SIZE, 40 * 1000 * 1000);
hevc->configure_ctx(RCC_PKT_MAX_DELAY, 150);
for (;;) {
auto buffer = std::unique_ptr<uint8_t[]>(new uint8_t[PAYLOAD_MAXLEN]);
if (hevc->push_frame(std::move(buffer), PAYLOAD_MAXLEN, RTP_NO_FLAGS) != RTP_OK)
fprintf(stderr, "Failed to send RTP frame!");
}
/* Session must be destroyed manually */
ctx.destroy_session(sess);
return 0;
}