Update examples directory

This commit is contained in:
Aaro Altonen 2020-05-28 09:50:26 +03:00
parent a7649218c7
commit 77621dc803
7 changed files with 10 additions and 35 deletions

View File

@ -1,20 +1,6 @@
# uvgRTP example codes
## Instructions for Windows
1) Run prepare.bat in this directory to prepare testing environment for uvgRTP
* The script creates lib/ and include/ directories to project root directory
2) Build uvgRTP using QtCreator
3) When uvgRTP has been built, copy the libuvgrtp.a from the Qt build directory to lib/ created by the script
4) Open the example.pro and build & run it
* Make sure the Qt build directory for example.pro is located in the same directory as lib/ and include/ (projects root directory) or tweak the include/lib paths accordingly
## Instructions for Linux
```
sudo make --directory=.. all install
g++ sending.cc -luvgrtp -lpthread && ./a.out
```
This directory contains a collection of simple examples that demonstrate how to use uvgRTP
## Available examples
@ -38,6 +24,10 @@ NOTE: The hook should **not** be used for media processing. It should be rather
[How to create an RTCP instance (hoooking)](rtcp_hook.cc)
[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

View File

@ -18,9 +18,8 @@ int main(void)
while (true) {
std::unique_ptr<uint8_t[]> buffer = std::unique_ptr<uint8_t[]>(new uint8_t[PAYLOAD_MAXLEN]);
rtp_error_t ret = hevc->push_frame(std::move(buffer), PAYLOAD_MAXLEN, RTP_NO_FLAGS);
if (ret != RTP_OK)
fprintf(stderr, "failed to push hevc frame: %d\n", ret);
if (hevc->push_frame(std::move(buffer), PAYLOAD_MAXLEN, RTP_NO_FLAGS) != RTP_OK)
fprintf(stderr, "failed to push hevc frame\n");
std::this_thread::sleep_for(std::chrono::milliseconds(800));
}

View File

@ -23,9 +23,8 @@ int main(void)
* We can no longer use buffer and must reallocate new memory chunk on the next iteration.
*
* The memory is deallocated automatically when system call dispatcher has finished processing the transaction */
if (hevc->push_frame(std::move(buffer), PAYLOAD_MAXLEN, RTP_NO_FLAGS) != RTP_OK) {
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 */

View File

@ -1,8 +0,0 @@
TEMPLATE = app
CONFIG += console c++11
CONFIG -= app_bundle
CONFIG -= qt
SOURCES += sending.cc
INCLUDEPATH = $$PWD/../include
LIBS += -L$$PWD/../lib -luvgrtp -lws2_32 -lpthread

View File

@ -1,4 +0,0 @@
mkdir ..\lib ..\include ..\include\uvgrtp ..\include\uvgrtp\formats
copy ..\src\*.hh ..\include\uvgrtp
copy ..\src\formats\*.hh ..\include\uvgrtp\formats
copy ..\src\formats\*.hh ..\include\uvgrtp\formats

View File

@ -34,7 +34,7 @@ int main(void)
while ((frame = hevc->pull_frame()) != nullptr) {
/* When we receive a frame, the ownership of the frame belongs to us and
* when we're done with it, we need to deallocate the frame */
uvg_rtp::frame::dealloc_frame(frame);
(void)uvg_rtp::frame::dealloc_frame(frame);
}
ctx.destroy_session(sess);

View File

@ -34,9 +34,8 @@ int main(void)
/* Sending data is as simple as calling push_frame().
*
* push_frame() will fragment the input buffer into payloads of 1500 bytes and send them to remote */
if (hevc->push_frame(buffer, PAYLOAD_MAXLEN, RTP_NO_FLAGS) != RTP_OK) {
if (hevc->push_frame(buffer, PAYLOAD_MAXLEN, RTP_NO_FLAGS) != RTP_OK)
fprintf(stderr, "Failed to send RTP frame!");
}
}
/* Session must be destroyed manually */