Fix RTCP example code
This commit is contained in:
parent
7fae21db8c
commit
6636a5fe61
|
@ -1,39 +1,31 @@
|
|||
# uvgRTP example codes
|
||||
|
||||
This directory contains a collection of simple examples that demonstrate how to use uvgRTP
|
||||
This directory contains a collection of simple and thoroughly commented examples that demonstrate how to use uvgRTP
|
||||
|
||||
## Available examples
|
||||
|
||||
We provide several simple and thoroughly commented examples on how to use uvgRTP.
|
||||
## Basic RTP functionality
|
||||
|
||||
[How to create a simple RTP sender](sending.cc)
|
||||
|
||||
[How to use fragmented input with uvgRTP \(HEVC slices\)](sending_fragmented.cc)
|
||||
[How to create a simple RTP receiver (hooking)](receiving_hook.cc)
|
||||
|
||||
NOTE: The hook should **not** be used for media processing. It should be used as interface between application and library where the frame handout happens.
|
||||
|
||||
[How to create a simple RTP receiver (polling)](receiving_poll.cc)
|
||||
|
||||
## Advanced RTP functionality
|
||||
|
||||
[How to fragment generic media types](sending_generic.cc)
|
||||
|
||||
[How to configure uvgRTP to send high-quality video](configuration.cc)
|
||||
|
||||
[How to create a simple RTP receiver (hooking)](receiving_hook.cc)
|
||||
## RTCP
|
||||
|
||||
NOTE: The hook should **not** be used for media processing. It should be rather used as interface between application and library where the frame handout happens.
|
||||
[How to use RTCP instance (polling)](rtcp_poll.cc)
|
||||
|
||||
[How to create a simple RTP receiver (polling)](receiving_poll.cc)
|
||||
[How to use RTCP instance (hooking)](rtcp_hook.cc)
|
||||
|
||||
[How to create an RTCP instance (polling)](rtcp_poll.cc)
|
||||
|
||||
[How to create an RTCP instance (hoooking)](rtcp_hook.cc)
|
||||
## Security
|
||||
|
||||
[How to use SRTP with ZRTP](srtp_zrtp.cc)
|
||||
|
||||
[How to use SRTP with user-managed keys](srtp_user.cc)
|
||||
|
||||
### Memory ownership/deallocation
|
||||
|
||||
If you have not enabled the system call dispatcher, you don't need to worry about these
|
||||
|
||||
[Method 1, unique_ptr](deallocation_1.cc)
|
||||
|
||||
[Method 2, copying](deallocation_2.cc)
|
||||
|
||||
[Method 3, deallocation hook](deallocation_3.cc)
|
||||
|
|
|
@ -1,24 +1,13 @@
|
|||
#include <uvgrtp/lib.hh>
|
||||
#include <cstring>
|
||||
|
||||
/* uvgRTP calls this hook when it receives an RTCP Sender Report
|
||||
* In this example, this doesn't get called because there's only one sender
|
||||
*
|
||||
* NOTE: If application uses hook, it must also free the frame when it's done with i
|
||||
* Frame must deallocated using uvg_rtp::frame::dealloc_frame() function */
|
||||
void sender_hook(uvg_rtp::frame::rtcp_sender_frame *frame)
|
||||
{
|
||||
fprintf(stderr, "Got RTCP Sender Report\n");
|
||||
|
||||
(void)uvg_rtp::frame::dealloc_frame(frame);
|
||||
}
|
||||
/* uvgRTP calls this hook when it receives an RTCP Receiver Report
|
||||
*
|
||||
* NOTE: If application uses hook, it must also free the frame when it's done with i
|
||||
* Frame must deallocated using uvg_rtp::frame::dealloc_frame() function */
|
||||
void receiver_hook(uvg_rtp::frame::rtcp_receiver_frame *frame)
|
||||
{
|
||||
fprintf(stderr, "got RTCP Receiver Report\n");
|
||||
LOG_INFO("Received an RTCP Receiver Report");
|
||||
|
||||
(void)uvg_rtp::frame::dealloc_frame(frame);
|
||||
}
|
||||
|
@ -30,23 +19,18 @@ int main(void)
|
|||
|
||||
uvg_rtp::session *sess = ctx.create_session("127.0.0.1");
|
||||
|
||||
uvg_rtp::media_stream *s1 = sess->create_stream(7777, 8888, RTP_FORMAT_GENERIC, RTP_NO_FLAGS);
|
||||
uvg_rtp::media_stream *s2 = sess->create_stream(8888, 7777, RTP_FORMAT_GENERIC, RTP_NO_FLAGS);
|
||||
/* For s1, RTCP runner is using port 7778 and for s2 port 8889 */
|
||||
uvg_rtp::media_stream *s1 = sess->create_stream(7777, 8888, RTP_FORMAT_GENERIC, RCE_RTCP);
|
||||
uvg_rtp::media_stream *s2 = sess->create_stream(8888, 7777, RTP_FORMAT_GENERIC, RCE_RTCP);
|
||||
|
||||
s1->create_rtcp(7778, 8889);
|
||||
s2->create_rtcp(8889, 7778);
|
||||
|
||||
/* Send Sender Reports 127.0.0.1:8889 and receive RTCP Reports to 5566
|
||||
* Add hook for the Receiver Report */
|
||||
/* (void)writer->create_rtcp("127.0.0.1", 8889, 5566); */
|
||||
/* In this example code, s1 acts as the sender and because it is the only sender,
|
||||
* it does not send any RTCP frames but only receives RTCP Receiver reports from s2.
|
||||
*
|
||||
* Because s1 only sends and s2 only receives, we only need to install receive hook for s1
|
||||
*
|
||||
* By default, all media_stream that have RTCP enabled start as receivers and only if/when they
|
||||
* call push_frame() are they converted into senders. */
|
||||
(void)s1->get_rtcp()->install_receiver_hook(receiver_hook);
|
||||
(void)s1->get_rtcp()->install_sender_hook(sender_hook);
|
||||
|
||||
/* Send Receiver Reports 127.0.0.1:5566 and receive RTCP Reports to 8889
|
||||
* and add hook for the Sender Report */
|
||||
/* (void)reader->create_rtcp("127.0.0.1", 5566, 8889); */
|
||||
(void)s2->get_rtcp()->install_sender_hook(sender_hook);
|
||||
(void)s2->get_rtcp()->install_receiver_hook(receiver_hook);
|
||||
|
||||
/* Send dummy data so there's some RTCP data to send */
|
||||
uint8_t buffer[50] = { 0 };
|
||||
|
|
|
@ -35,9 +35,6 @@ int main(void)
|
|||
uvg_rtp::media_stream *s1 = sess->create_stream(7777, 8888, RTP_FORMAT_GENERIC, RTP_NO_FLAGS);
|
||||
uvg_rtp::media_stream *s2 = sess->create_stream(8888, 7777, RTP_FORMAT_GENERIC, RTP_NO_FLAGS);
|
||||
|
||||
s1->create_rtcp(7778, 8889);
|
||||
s2->create_rtcp(8889, 7778);
|
||||
|
||||
/* Create separate thread for polling the RTCP packets. In this example,
|
||||
* we only create thread for RTCP Receiver Reports (so for RTP Sender).
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue