Commit Graph

110 Commits

Author SHA1 Message Date
Martin Pulec
cdef66a141 Revert "audio TX: use the packet API"
This reverts commit 8da83d3e92.
2023-10-16 16:19:56 +02:00
Martin Pulec
f0e7333d88 transmit: use constant for hdr lens
+ move the computation to a function
2023-09-20 09:53:30 +02:00
Martin Pulec
2c8dd6743e transmit: moved stat reporting after send loop
it simplifies the code and facilites eventual refactor
2023-09-20 09:24:47 +02:00
Martin Pulec
4a745780e2 lavc video: header_inserter - support HEVC
\+ ignore leading AUD NALU if present (add own 4B start code instead) -
it could have produced problems when AUD+SPS+PPS is prepended to regular
frame that is not an IDR frame
2023-08-25 11:54:33 +02:00
Martin Pulec
d17c5ea24c removed platform_time.c + references
get_time_in_ns() should be used instead time_since_epoch_in_ms(). Having
both may be misleading and may lead to errors when interchanged.
2023-08-08 15:32:29 +02:00
Martin Pulec
3639d00dbf replaced not thread-safe *rand48 functions
Use rand_s() in Windows and random() in POSIX systems.
2023-08-02 10:07:19 +02:00
Martin Pulec
8da83d3e92 audio TX: use the packet API
It needs to be enabled explicitly, anyways - at least Opus won't work
with former UG versions. For 40 ms frame, it produces 2 packets. When
merged into one packet, the decoder is unable to decompress.
2023-08-01 12:01:05 +02:00
Martin Pulec
bf35242e78 audio transmit: new sending API
Added API allowing sending multiple compressed packets (eg. by Opus)
with the same timestamp.
2023-08-01 10:26:15 +02:00
Martin Pulec
a81b19d231 format_audio_header: do not use audio_frame2
rewrite for further changes
2023-08-01 10:26:15 +02:00
Martin Pulec
6c07a3e43f audio_tx_send: send indiviual channel with a func
Send channels sequentially with a new function to simplify the code.

Also removed the the cumbersome multiplier packet interleaving - not
sure if it worked as expected (having sliding n-packet interleave window
for n-multiplied stream).

Now we simply send all packets of the frame as without multiplication
and then repeated with M-bit set to the latest packet. It is much easier
and it is  supposed to work approximately the same or even better.
2023-08-01 10:26:15 +02:00
Martin Pulec
452a59e317 audio_tx_send: removed rate-limiting
Currently not used and so it needlessly complicates the code. If later
needed, it can be re-added and possibly in a better way.
2023-08-01 10:26:15 +02:00
Martin Pulec
2f1bfa9340 do not use source TS as RTP TS by default
Do not use source TS as (a base for) RTP TS by default anymore. Since this
was essential for synchronized DeckLink playback, require `--incompatible`
to enable this.

The reason to disable for now is because it breaks compressed
audio. Eg. for Opus, one receives 2 packets for 40 ms input. Currently
only the first gets source TS, second is undefined, thus getting the
default, loosely related TS, that may however create TS discontinuity
(especially with the time, when PC and DeckLink time diverges).

There is no good solution for the above yet, sending both packet with
the same TS and m-bit on second isn't sufficient now, because it gets
joined in receiver buffer and eg. Opus is not self delimiting so it will
need changes on receiver side to pass RTP packets to Opus decoder as
Opus packets.

refer to GH-326
2023-07-26 16:59:50 +02:00
Martin Pulec
d8ccc3b729 video rxtx: removed remains of multi-link sending
This is not used and removing it simplifies the code.
2023-07-19 16:31:00 +02:00
Martin Pulec
17f50eede2 RTP: send synchronized A/V TS where possible
Send same RTP timestamps for audio/video frames captured at the same
time.

RTP specification allows this (although doesn't require - according to
the spec, the RTP timestamps should colaesce with RTCP NTP
correspondence). We slightly modify that in a way that we use for both
audio and video 90 kHz clock resolution, so if the start point is the
same (random), the RTP timestamps will be exactly the same for related
data.

Implemented for vidcap DeckLink and testcard.
2023-07-18 11:09:07 +02:00
Martin Pulec
48219758ea use Opus, not OPUS
For audio codecs, we respect its native capitalization of letters, eg.
AAC, speex. So do it also for Opus. This should not affect existing
applications since the Opus name is parsed case-insensitively.

Only exception is SDP (rtpmap) where is usually used lower-case (at
least in rfc7587).
2023-04-26 09:53:10 +02:00
Martin Piatka
5161d2b33d transmit: use platform_time for control port stat report 2022-11-23 14:37:23 +01:00
Martin Piatka
c4a26b49b1 transmit: include ssrc in bandwidth report 2022-11-23 13:22:26 +01:00
Martin Piatka
5f6540fabf transmit: report tx bandwidth on control port 2022-11-23 13:22:25 +01:00
Martin Pulec
b5cc0e9a1b removed some rang.hpp references 2022-11-21 14:17:01 +01:00
Martin Pulec
8369e3923d encrypt added GCM and set it default
Since the CRC fix has already broken compatibility with older versions,
we can switch by default, anyways.

+ do not request CFB but keep CBC for future compat (seems to be more
  widely supported across implementations)
2022-11-10 09:45:33 +01:00
Martin Pulec
5ca097c4eb encrypt: fixed RAND_bytes call
currntly it returns 1 on success so not only 0 is success
2022-11-02 13:54:50 +01:00
Martin Pulec
293e71c96b fixed missing condition in previous commit
fixes GH-254
2022-09-19 09:20:40 +02:00
Martin Pulec
257c3c3100 transmit: rewritten packet splitting
Start lines of uncompressed video only on packet start otherwise in
adverse combination of source and display pixfmts, signal may be broken,
eg. packet start in the middle of dst pixfmt block. Steps to reproduce:

    uv -t testcard:size=14x2:codec=Y216 -d gl -m 180!  # GL uses v210

In first packet - first 56 B of first line was decoded, than 40 B of the
second line (10 pixels). But 10 pixels from second line was consumed
while v210 block size is 6 pixels, therefore the next packet started in
midst of second v210 block on second line.
2022-09-16 16:01:11 +02:00
Martin Pulec
229e9015a0 transmit.cpp: small rewrite 2022-09-16 16:01:11 +02:00
Martin Pulec
801a66d9b8 transmit.cpp: prevent infinite loop
When packat size is too low (< 180 IPv6 or 160 IPv4 - 96 B + headers),
looping in an infinite loop occured.

Steps to reproduce:

    uv -t testcard -m 150!
2022-09-16 16:01:11 +02:00
Martin Pulec
0b8cc39f9c removed perf tool
It was almost never used since added.
2022-08-17 17:24:34 +02:00
Martin Pulec
04c2d245d0 fixed Win compile warnings (from CI) 2022-08-11 10:42:45 +02:00
Martin Pulec
f103a9e53f tx_init: remove one indention level 2022-07-20 11:07:40 +02:00
Martin Pulec
cbc548d384 Added+use dynamic rate limiter
Added a rate limiter that occasionally allows excessive frames.

It permits using 1.5x frame time for frame 2x bigger that moving
average if 4 normal frames (using .75x frame time) were emitted
inbetween.

This mode is now default (for video, audio doesn't use rate limiter).
2022-07-20 11:05:40 +02:00
Martin Pulec
f42cafcedf get_packet_rate: needless use of long long 2022-07-19 09:51:14 +02:00
Martin Pulec
5be9d658e4 transmit.cpp: compute packet rate in separate func 2022-07-19 09:51:11 +02:00
Martin Pulec
1a31999f1a utils/misc: split to misc and macros.h
Some macros are quite common so it is perhaps more wise to use a
separate header.

Also moved ref_count_init_once and ref_count_terminate last to misc.h.
2022-06-06 11:06:06 +02:00
Martin Pulec
a354d2ab56 replaced some occurences of get_bpp with int version 2022-05-24 14:09:03 +02:00
Martin Pulec
8eccc3bcdd fixed uncompressed packet splitting
Fixes problem described (and partially fixed) by commit 13b44851.

The idea is to use least common multiple of all pixel format alignments
(in pixels) and split only on this boundry (in source pixfmt byte
length) because we don't know destination pixfmt alignment requirement.
2022-05-23 15:59:37 +02:00
Martin Pulec
1327c0619f transmit H.264: use rtpenc_h264_get_next_nal
Also removed remaining H.264 codestream parsing/splitting code - it was
a bit over-engineered.
2022-05-04 10:20:57 +02:00
Martin Pulec
d1f3206077 RTP: work also with time in NS 2022-03-18 08:52:32 +01:00
Martin Pulec
8b793e9772 rtpenc_h264: use RTPENC_STATE_DECLARE 2022-03-11 10:48:49 +01:00
Martin Pulec
57fcc088cb transmit: moved packet size computation to separate func 2022-03-11 10:48:42 +01:00
Martin Pulec
6d5cbde4fa transmit video multipliers: simplified pattern
Simply send multiplied packets sequentially, like for mult:3:

0 0 0 1 1 1 2 2 2 ....

This simplifies the code while the old one was already defunct (at least
the access to packet sizes' list was wrong since recent rewrite).
2022-03-11 10:19:50 +01:00
Martin Pulec
eb9b00b6e9 rtpenc_h264 rewritten
- store the buffer+size with _init
- return also pointer to data and EOF flag from _parse
- use longs instead of unsigned for buffer lengths
2022-03-11 10:19:50 +01:00
Martin Pulec
df16e3f17a transmit: compute pixel format alignment only once 2022-03-11 10:19:50 +01:00
Martin Pulec
806d456db5 transmit: moved gcd/lcm to utils/math.h 2022-03-11 10:19:49 +01:00
Martin Pulec
3b1eff5cc3 transmit: rewrite get_data_len
- renamed to get_video_pkt_len()
- use alignment var that is common denominator for both pixel formats
  and FEC symbols
2022-03-11 10:19:49 +01:00
Martin Pulec
600b5c92fa transmit: use array for mult_pos
+ declare some vars when initialized (audio_tx_send())
2022-03-11 10:19:19 +01:00
Martin Pulec
a778460fba Compute packet sizes only once 2022-03-11 10:02:02 +01:00
Martin Pulec
5b62e4e884 rtpenc_h264: allocate on stack 2022-03-04 16:28:58 +01:00
Martin Pulec
8bded29c1c rtpenc_h264: hide API 2022-03-04 16:28:58 +01:00
Martin Pulec
e712578f43 Added audio RS encoding 2021-11-30 17:09:29 +01:00
Martin Pulec
0c4c8627e7 Transmit: moved FEC symbol size check to sep. func 2021-11-30 17:09:26 +01:00
Martin Pulec
1b3b27eb7c Updated copyright dates for modified files 2021-11-08 15:43:14 +01:00