examples: Reduce run times and prints of examples

This is mainly to reduce strain on CI system
This commit is contained in:
Joni Räsänen 2021-07-27 16:51:14 +03:00
parent 100a34daf3
commit c759251bbc
8 changed files with 24 additions and 12 deletions

View File

@ -9,6 +9,7 @@ jobs:
build:
docker:
- image: cimg/base:2021.04
resource_class: small
steps:
- checkout
- run:
@ -22,7 +23,7 @@ jobs:
command: 'cmake -H. -Bbuild'
- run:
name: Build the uvgRTP library
command: 'cmake --build build -j'
command: 'cmake --build build'
- run:
name: Build binding example
command: 'g++ -D__RTP_NO_CRYPTO__ docs/examples/binding.cc -Iinclude/ build/libuvgrtp.a -lpthread -o example_binding'
@ -79,7 +80,7 @@ jobs:
command: 'cmake -H. -Bbuild_c'
- run:
name: Build the uvgRTP library with Crypto++ enabled
command: 'cmake --build build_c -j'
command: 'cmake --build build_c'
- run:
name: Build user managed SRTP key example
command: 'g++ docs/examples/srtp_user.cc -Iinclude/ build_c/libuvgrtp.a -lpthread -lcryptopp -o example_srtp'

View File

@ -93,7 +93,9 @@ int main(void)
{
auto buffer = std::unique_ptr<uint8_t[]>(new uint8_t[PAYLOAD_LEN]);
std::cout << "Sending frame " << i + 1 << '/' << SEND_TEST_PACKETS << std::endl;
if ((i+1)%10 == 0 || i == 0) // print every 10 frames and first
std::cout << "Sending frame " << i + 1 << '/' << SEND_TEST_PACKETS << std::endl;
if (send->push_frame(std::move(buffer), PAYLOAD_LEN, RTP_NO_FLAGS) != RTP_OK)
{
std::cerr << "Failed to send RTP frame!" << std::endl;

View File

@ -26,7 +26,7 @@ constexpr char REMOTE_ADDRESS[] = "127.0.0.1";
constexpr uint16_t REMOTE_PORT = 8888;
// This example runs for 5 seconds
constexpr auto RECEIVE_TIME_S = std::chrono::seconds(5);
constexpr auto RECEIVE_TIME_S = std::chrono::seconds(3);
void rtp_receive_hook(void *arg, uvgrtp::frame::rtp_frame *frame);
void cleanup(uvgrtp::context& ctx, uvgrtp::session *sess, uvgrtp::media_stream *receiver);

View File

@ -26,7 +26,7 @@ constexpr char REMOTE_ADDRESS[] = "127.0.0.1";
constexpr uint16_t REMOTE_PORT = 8888;
// How long this example will run
constexpr auto RECEIVE_TIME_MS = std::chrono::milliseconds(10000);
constexpr auto RECEIVE_TIME_MS = std::chrono::milliseconds(3000);
constexpr int RECEIVER_WAIT_TIME_MS = 100;
void process_frame(uvgrtp::frame::rtp_frame *frame);

View File

@ -19,7 +19,8 @@ constexpr uint16_t REMOTE_PORT = 8890;
constexpr uint16_t PAYLOAD_LEN = 256;
constexpr uint16_t FRAME_RATE = 30;
constexpr int SEND_TEST_PACKETS = FRAME_RATE*60; // one minute
constexpr uint32_t EXAMPLE_RUN_TIME_S = 30;
constexpr int SEND_TEST_PACKETS = FRAME_RATE*EXAMPLE_RUN_TIME_S;
constexpr int PACKET_INTERVAL_MS = 1000/FRAME_RATE;
/* uvgRTP calls this hook when it receives an RTCP Report
@ -85,8 +86,11 @@ int main(void)
for (unsigned int i = 0; i < SEND_TEST_PACKETS; ++i)
{
std::cout << "Sending RTP frame " << (i + 1) << "/" << SEND_TEST_PACKETS
<< " Total data sent: " << (i + 1)*PAYLOAD_LEN << std::endl;
if ((i+1)%10 == 0 || i == 0) // print every 10 frames and first
{
std::cout << "Sending RTP frame " << (i + 1) << "/" << SEND_TEST_PACKETS
<< " Total data sent: " << (i + 1)*PAYLOAD_LEN << std::endl;
}
local_stream->push_frame((uint8_t *)buffer, PAYLOAD_LEN, RTP_NO_FLAGS);

View File

@ -53,7 +53,9 @@ int main(void)
for (int i = 0; i < AMOUNT_OF_TEST_PACKETS; ++i)
{
std::unique_ptr<uint8_t[]> dummy_frame = std::unique_ptr<uint8_t[]>(new uint8_t[PAYLOAD_LEN]);
std::cout << "Sending frame " << i + 1 << '/' << AMOUNT_OF_TEST_PACKETS << std::endl;
if ((i+1)%10 == 0 || i == 0) // print every 10 frames and first
std::cout << "Sending frame " << i + 1 << '/' << AMOUNT_OF_TEST_PACKETS << std::endl;
if (hevc->push_frame(std::move(dummy_frame), PAYLOAD_LEN, RTP_NO_FLAGS) != RTP_OK)
{

View File

@ -26,7 +26,7 @@ constexpr int SALT_SIZE = 112;
constexpr int SALT_SIZE_BYTES = SALT_SIZE/8;
// demonstration parameters
constexpr auto EXAMPLE_DURATION = std::chrono::seconds(10);
constexpr auto EXAMPLE_DURATION = std::chrono::seconds(5);
constexpr int FRAME_RATE = 30; // fps
constexpr int SEND_TEST_PACKETS = (EXAMPLE_DURATION.count() - 1)*FRAME_RATE;
constexpr int PACKET_INTERVAL_MS = 1000/FRAME_RATE;
@ -91,7 +91,8 @@ int main(void)
auto start = std::chrono::steady_clock::now();
for (unsigned int i = 0; i < SEND_TEST_PACKETS; ++i)
{
std::cout << "Sending frame " << i + 1 << '/' << SEND_TEST_PACKETS << std::endl;
if ((i+1)%10 == 0 || i == 0) // print every 10 frames and first
std::cout << "Sending frame # " << i + 1 << '/' << SEND_TEST_PACKETS << std::endl;
if (send->push_frame((uint8_t *)message, msg_len, RTP_NO_FLAGS) != RTP_OK)
{

View File

@ -30,7 +30,7 @@ constexpr uint16_t RECEIVER_AUDIO_PORT = 7778;
constexpr int VIDEO_PAYLOAD_SIZE = 4000;
constexpr int AUDIO_PAYLOAD_SIZE = 100;
constexpr auto EXAMPLE_RUN_TIME_S = std::chrono::seconds(10);
constexpr auto EXAMPLE_RUN_TIME_S = std::chrono::seconds(5);
constexpr auto RECEIVER_WAIT_TIME_MS = std::chrono::milliseconds(50);
constexpr auto AUDIO_FRAME_INTERVAL_MS = std::chrono::milliseconds(20);
@ -177,9 +177,11 @@ void sender_function(uvgrtp::session* sender_session, int flags, std::shared_ptr
for (int i = 0; std::chrono::steady_clock::now() < (start + EXAMPLE_RUN_TIME_S); ++i)
{
/*
print_mutex->lock();
std::cout << "Sending frame" << std::endl;
print_mutex->unlock();
*/
std::unique_ptr<uint8_t[]> dummy_audio_frame = std::unique_ptr<uint8_t[]>(new uint8_t[payload_size]);