Skip to content

Commit

Permalink
examples: Update examples to use new create_session API
Browse files Browse the repository at this point in the history
  • Loading branch information
tampsa committed Jan 30, 2024
1 parent 1005d9d commit 57c5fb1
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
6 changes: 4 additions & 2 deletions examples/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,16 @@ int main(void)
std::cout << "Starting uvgRTP binding example" << std::endl;

uvgrtp::context rtp_ctx;
uvgrtp::session *sending_session = rtp_ctx.create_session(LOCAL_INTERFACE, REMOTE_ADDRESS);
std::pair<std::string, std::string> addresses_sender(LOCAL_INTERFACE, REMOTE_ADDRESS);
uvgrtp::session *sending_session = rtp_ctx.create_session(addresses_sender);
uvgrtp::media_stream *send = sending_session->create_stream(LOCAL_PORT, REMOTE_PORT,
RTP_FORMAT_H265, RCE_NO_FLAGS);

/* RCE flags or RTP Context Enable flags are given when creating the Media Stream.
Notice the RCE_HOLEPUNCH_KEEPALIVE flag which keeps the NAT/firewall open */
int flags = RCE_HOLEPUNCH_KEEPALIVE;
uvgrtp::session *receiving_session = rtp_ctx.create_session(REMOTE_ADDRESS, LOCAL_INTERFACE);
std::pair<std::string, std::string> addresses_receiver(REMOTE_ADDRESS, LOCAL_INTERFACE);
uvgrtp::session *receiving_session = rtp_ctx.create_session(addresses_receiver);
uvgrtp::media_stream *recv = receiving_session->create_stream(REMOTE_PORT, LOCAL_PORT,
RTP_FORMAT_H265, flags);

Expand Down
6 changes: 4 additions & 2 deletions examples/configuration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ int main(void)
RCE_RECEIVE_ONLY; /* interpret address/port as binding interface */

uvgrtp::context ctx;
uvgrtp::session *local_session = ctx.create_session(REMOTE_ADDRESS, LOCAL_ADDRESS);
std::pair<std::string, std::string> addresses_sender(LOCAL_ADDRESS, REMOTE_ADDRESS);
uvgrtp::session *local_session = ctx.create_session(addresses_sender);
uvgrtp::media_stream *send = local_session->create_stream(REMOTE_PORT, LOCAL_PORT, RTP_FORMAT_H265, send_flags);

uvgrtp::session *remote_session = ctx.create_session(LOCAL_ADDRESS, REMOTE_ADDRESS);
std::pair<std::string, std::string> addresses_receiver(REMOTE_ADDRESS, LOCAL_ADDRESS);
uvgrtp::session *remote_session = ctx.create_session(addresses_receiver);
uvgrtp::media_stream *receive = remote_session->create_stream(LOCAL_PORT, REMOTE_PORT, RTP_FORMAT_H265, receive_flags);

if (receive)
Expand Down
3 changes: 2 additions & 1 deletion examples/sync_receiver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ int main(void)

std::cout << "Initializing receivers" << std::endl;
uvgrtp::context receiver_ctx;
uvgrtp::session* receiver_session = receiver_ctx.create_session(SENDER_ADDRESS, RECEIVER_ADDRESS);
std::pair<std::string, std::string> addresses_receiver(RECEIVER_ADDRESS, SENDER_ADDRESS);
uvgrtp::session* receiver_session = receiver_ctx.create_session(addresses_receiver);

// start the audio and video receivers in different threads
std::thread a_receiver(receive_function, receiver_session, rce_dh_flags, print_mutex,
Expand Down
3 changes: 2 additions & 1 deletion examples/sync_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ int main(void)

std::cout << "Initializing senders" << std::endl;
uvgrtp::context sender_ctx;
uvgrtp::session* sender_session = sender_ctx.create_session(RECEIVER_ADDRESS, SENDER_ADDRESS);
std::pair<std::string, std::string> addresses_sender(SENDER_ADDRESS, RECEIVER_ADDRESS);
uvgrtp::session* sender_session = sender_ctx.create_session(addresses_sender);

// start the audio and video in their own threads
std::thread a_sender(sender_function, sender_session, rce_dh_flags, print_mutex,
Expand Down
3 changes: 2 additions & 1 deletion examples/v3c_receiver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ int main(void)

/* Initialize uvgRTP context and session*/
uvgrtp::context ctx;
uvgrtp::session* sess = ctx.create_session(LOCAL_IP, LOCAL_IP);
std::pair<std::string, std::string> addresses_receiver(LOCAL_IP, LOCAL_IP);
uvgrtp::session* sess = ctx.create_session(addresses_receiver);
int flags = 0;

// Create the uvgRTP media streams with the correct RTP format
Expand Down
3 changes: 2 additions & 1 deletion examples/v3c_sender.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ int main(void)

/* Create the necessary uvgRTP media streams */
uvgrtp::context ctx;
uvgrtp::session* sess = ctx.create_session(LOCAL_IP, LOCAL_IP);
std::pair<std::string, std::string> addresses_sender(LOCAL_IP, LOCAL_IP);
uvgrtp::session* sess = ctx.create_session(addresses_sender);

int flags = 0;
v3c_streams streams = init_v3c_streams(sess, 8892, 8890, flags, false);
Expand Down
6 changes: 4 additions & 2 deletions examples/zrtp_multistream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ int main(void)
}

std::cout << "Initializing receivers" << std::endl;
uvgrtp::session *receiver_session = receiver_ctx.create_session(SENDER_ADDRESS, RECEIVER_ADDRESS);
std::pair<std::string, std::string> addresses_receiver(RECEIVER_ADDRESS, SENDER_ADDRESS);
uvgrtp::session *receiver_session = receiver_ctx.create_session(addresses_receiver);

std::shared_ptr<std::mutex> print_mutex = std::shared_ptr<std::mutex> (new std::mutex);

Expand All @@ -86,7 +87,8 @@ int main(void)

std::cout << "Initializing senders" << std::endl;
uvgrtp::context sender_ctx;
uvgrtp::session *sender_session = sender_ctx.create_session(RECEIVER_ADDRESS, SENDER_ADDRESS);
std::pair<std::string, std::string> addresses_sender(SENDER_ADDRESS, RECEIVER_ADDRESS);
uvgrtp::session *sender_session = sender_ctx.create_session(addresses_sender);

// start the senders in their own threads
std::thread a_sender(sender_function, sender_session, rce_dh_flags, print_mutex,
Expand Down

0 comments on commit 57c5fb1

Please sign in to comment.