Skip to content

Commit

Permalink
ci: Fix never-ending example srtp_zrtp and add it to CI-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tampsa committed Jan 30, 2023
1 parent 0166a3c commit 42116d7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ examples_with_crypto:
- ./sending_generic
- ./srtp_user
- ./zrtp_multistream
- ./srtp_zrtp

artifacts:
paths:
Expand Down
17 changes: 16 additions & 1 deletion examples/srtp_zrtp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include <cstring>
#include <iostream>

constexpr int AMOUNT_OF_TEST_PACKETS = 30;
constexpr auto END_WAIT = std::chrono::seconds(5);

void thread_func(void)
{
/* See sending.cc for more details */
Expand Down Expand Up @@ -48,11 +51,23 @@ int main(void)
char *message = (char *)"Hello, world!";
size_t msg_len = strlen(message);

for (;;) {
for (int i = 0; i < AMOUNT_OF_TEST_PACKETS; ++i) {
uint8_t* message_data = new uint8_t[msg_len];
memcpy(message_data, message, msg_len);

send->push_frame((uint8_t *)message_data, msg_len, RTP_NO_FLAGS);
std::this_thread::sleep_for(std::chrono::milliseconds(500));
}

std::cout << "All packets sent, waiting " << END_WAIT.count()
<< " seconds before exiting." << std::endl;
// destroy the session after waiting for END_WAIT seconds
std::this_thread::sleep_for(END_WAIT);
sess->destroy_stream(send);
if (sess) {
ctx.destroy_session(sess);
}

return EXIT_SUCCESS;

}

0 comments on commit 42116d7

Please sign in to comment.