Commit Graph

1831 Commits

Author SHA1 Message Date
Aaro Altonen 9ec560613f Remove the transaction from queue only after it's deinitialized 2019-10-25 09:07:55 +03:00
Aaro Altonen 0f0a052e54 Create Runner class
Several classes have common active_ and runner_ variables and
stop/start/active routines (such as reader and dispatch).

Create one common class for these to make the interface cleaner
2019-10-24 08:36:54 +03:00
Aaro Altonen bde19e3f7f Create RTCP function for getting session participants' SSRCs 2019-10-24 08:15:46 +03:00
Aaro Altonen c0e1f69081 Separate hooked and polling RTP frame receiving examples 2019-10-24 08:15:20 +03:00
Aaro Altonen 8f2ae2063c Create RTCP hooking and polling examples 2019-10-24 08:05:55 +03:00
Aaro Altonen 1c33e6a0a2 Create RTCP getter
Used to install hooking functions for RTCP packets
2019-10-24 07:49:17 +03:00
Aaro Altonen 931fb74521 Deinitialize transactions that don't get committed to SCD's queue 2019-10-22 12:27:43 +03:00
Aaro Altonen 4385361fdc Create examples for memory deallocation/ownership stuff 2019-10-22 07:22:02 +03:00
Aaro Altonen bcf7c82e48 Add support for deallocation hook
This is the third way of dealing with memory ownership/deallocation.

Application "lends" the memory for kvzRTP's use and when SCD has finished
processing the transaction associated with this memory, it will call the
deallocation hook provided by the application to release the memory.

This makes, for example, custom allocators possible where wrapping the
memory inside a unique_ptr is not suitable and creating copies is also
not acceptable.
2019-10-11 11:23:38 +03:00
Aaro Altonen 1695691d2b Add support for RTP_COPY flag
This was actually very simple thing to do because we can take
advantage of the unique_ptr support added earlier
2019-10-11 10:26:35 +03:00
Aaro Altonen 434a07156c Add unique_ptr support for RTP writer API and all media formats 2019-10-11 09:16:39 +03:00
Aaro Altonen 45d2a4ec26 Add unique_ptr support for frame queue
Now both unique_ptrs and raw pointers can be used
2019-10-11 09:06:35 +03:00
Aaro Altonen eec4ceb41a Add specification on how to deal with memory ownership/deallocation problem 2019-10-10 08:41:09 +03:00
Aaro Altonen e6adf2ad21 Update README 2019-10-10 07:54:35 +03:00
Aaro Altonen d1a6d18adf Create System Call Dispatcher
This is a separate thread running in the background responsible for
executing system calls (mainly sending UDP packets).

This commit divides the sending into frontend and backend:
  - Frontend packetizes the media into "transactions" which are then
    pushed to backend's task queue
  - Backend executes these transactions FIFO-style and pushes executed
    transactions back to frame queue for reuse

Frontend is the part of sending that executes in application's context
and backend (system call) happens in a background thread.

Ideally frontend and backend would be run on separate physical cores.

This change made sending significantly faster (from 650 MB/s to 720 MB/s)
and cut down the delay experienced by application from 315us to 45us
for large HEVC chunks (177 kB)
2019-10-09 10:38:41 +03:00
Aaro Altonen f23e116e04 Start using send_vecio() from socket.cc for frame queue 2019-10-08 08:56:24 +03:00
Aaro Altonen fe14697793 Make the frame queue transaction-based
Using system call dispatcher complicates the frame queue design because
we can no longer store f.ex. NAL and FU headers to caller's stack (as
SCD doesn't have access to that stack).

We must create transaction object that contains all necessary
information related to one media frames (all Vectored I/O buffers,
RTP headers and outgoing address).

This model works both with and without SCD and is much cleaner than the
previous implementation. It also makes a more clear distinction between
the frontend and backend of sending operationg by creating
a clear producer/consumer model.

One problem that has arisen is memory deallocation and ownership in
general: when SCD is used, it owns the memory given to kvzRTP by
push_frame() BUT it doens't know what kind of memory it is so it doesn't
know how to deallocate it. Some kind of deallocation scheme must be
implemented because right now the library leaks a lot of memory.
2019-10-08 08:20:29 +03:00
Aaro Altonen c140498971 Give RTP payload format to Connection
The payload format must be known when creating the Connection object
because Connection owns the frame queue and frame queue needs the format
in order to allocate correct media-specific headers for transactions
2019-10-08 08:13:49 +03:00
Aaro Altonen d9065aa564 Create send_vecio() function
This is a generic way of sending multiple packets with one system call.

It takes a pointer to vecio_buf (mmsghdr on Linux, TRANSMIT_PACKETS_ELEMENT
on Windows) and vecio_buf length and calls either sendmmsg(2) or TransmitPackets()
2019-10-02 11:41:06 +03:00
Aaro Altonen 9d6f58db59 Make fragment buffer size configurable 2019-09-30 09:53:09 +03:00
Aaro Altonen dec078f7b7 Add hook functions for RTCP packets 2019-09-30 09:34:46 +03:00
Aaro Altonen 9eca881371 Add code for resolving fragment relocations 2019-09-30 09:01:59 +03:00
Aaro Altonen 1cf8ec8d40 Make probation zone size configurable 2019-09-30 08:58:01 +03:00
Aaro Altonen a7b39c7d97 Update README 2019-09-30 08:57:45 +03:00
Aaro Altonen 8b38a9eef4 Make payload size and number of fragments/syscall configurable 2019-09-27 08:15:17 +03:00
Aaro Altonen 669733def9 Separate benchmarks to sending and receiving 2019-09-25 10:43:26 +03:00
Aaro Altonen be3c7fd5e4 Rewrite HEVC fragment receiver to use one common frame structure
Now both active and inactive frames reside in the same structure
making the code much cleaner.

Windows support for the receiver started
2019-09-25 10:28:58 +03:00
Aaro Altonen 0a7a5b455d Fix double free in frame.cc
Only probation OR payload should be freed but not both
2019-09-24 09:17:20 +03:00
Aaro Altonen 6d7c243184 Set the marker bit of last fragment to 1 2019-09-24 09:15:13 +03:00
Aaro Altonen 2b58b25f08 Add support for HEVC slices
The API didn't change much, if user wishes to use HEVC slices
(and thus preserve the state between push_frame() calls), he must
call the push_frame() with RTP_SLICE and RTP_MORE flags, like this:

push_frame(conn, data, 123, RTP_SLICE | RTP_MORE);
push_frame(conn, data, 456, RTP_SLICE | RTP_MORE);
push_frame(conn, data, 789, RTP_SLICE | RTP_MORE);
push_frame(conn, data, 100, RTP_SLICE);

RTP_MORE preserves the state between push_frame() calls and when the
last slice is given to kvzRTP, the RTP_MORE flags must be removed.
This flushes the frame queue and deinitializes it.
2019-09-24 09:15:06 +03:00
Aaro Altonen bdded6ef7b Fix optimistic HEVC receiver
Some of the more complex relocations still don't work, invalid and
duplicate packets wreck havoc and frame reallocation is missing but
it's already able to receiver stream with very large packets gracefully.
2019-09-13 12:59:41 +03:00
Aaro Altonen ebc914e95b Separate optimistic and regular HEVC receivers to different files
Separate them to different files and make it configurable which to use.
By default the normal receiver is used and if use gives __RTP_USE_OPTIMISTIC_RECEIVER__
then the optimistic receiver is started.
2019-09-13 08:52:01 +03:00
Aaro Altonen a7ec35bd87 Update gitignore 2019-09-12 08:06:02 +03:00
Aaro Altonen 2b34d2f6b0 Remove the msghdr struct from frame queue
mmsghdr struct already contains msg_hdr struct so this header
duplication is unnecessary
2019-09-12 07:59:30 +03:00
Aaro Altonen c4de5397fb Disable RTP probation zone by default
It makes more sense to disable it by default, especially when it's not
platform-independent and has negative side effects (larger memory footprint)
2019-09-11 11:58:12 +03:00
Aaro Altonen 3577b87379 Create optimistic HEVC fragment receiver
Small frames work, larger frames are sometimes dropped. This is supposed
to reduce the amount of copying but the performance will degrade as
network load increases
2019-09-11 11:33:41 +03:00
Aaro Altonen 78401d6fa8 Add probation zone for RTP frames
Probation zone lives below the actual payload and can be used as a
temporary storage for fragments that cannot be relocated.

It's part of the larger memory block so the fragments that are copied
to probation zone are spatially very close to their actual place in
the array making relocation faster
2019-09-11 11:18:09 +03:00
Aaro Altonen 07c0dd1bcc Replace the overwritten byte before exitint from __get_hevc_start() 2019-09-11 11:16:01 +03:00
Aaro Altonen 098287098c Create formats folder for all different media types
This makes the folder structure much cleaner and media-specific
files are more clearly separated from RTP/RTCP etc. files
2019-09-11 11:14:24 +03:00
Aaro Altonen f642569ae5 Fix frame queue flush bug in rtp_hevc.cc
More flag made it possible to give more data to the frame queue
(and thus return from __push_hevc_frame()).

This is not actually possible because the fragment headers are stored
on the stack. That is why postponing the frame queue flush is not a good idea.
2019-09-11 10:16:12 +03:00
Aaro Altonen 0a8c70e17b Update gitignore 2019-09-11 10:10:09 +03:00
Aaro Altonen a07803b16f Improve HEVC start code searching
This improvement gives a 100 MB/s boost to our send performance in
ideal conditions
2019-09-11 10:06:52 +03:00
Aaro Altonen 5a85b1463b Fix Live555 send benchmark 2019-09-08 14:51:23 +03:00
Aaro Altonen 3016ce4c92 Don't overwrite previous results 2019-09-08 14:50:35 +03:00
Aaro Altonen 454ba45c29 Implement fragmentation for JRTPLIB, oRTP and ccRTP 2019-09-07 16:01:24 +03:00
Aaro Altonen fb54d469b9 Increase the payload size to maximum
Now the max payload is 1441 + overhead totalling 1500 bytes (MTU)
2019-09-06 12:47:26 +03:00
Aaro Altonen 7242be636c Create test script 2019-09-06 10:41:57 +03:00
Aaro Altonen de2211ce40 Update benchmarking README 2019-09-06 10:11:47 +03:00
Aaro Altonen 0166171b18 Fix oRTP send benchmarking code 2019-09-06 09:54:36 +03:00
Aaro Altonen 8c6d7dcaed Fix FFmpeg send benchmark 2019-09-04 07:24:31 +03:00