The decoder output frame was hard-coded to 960 samples, which is 20 ms
at 48 kHz. libopus refuses to decode a packet that does not fit the
given frame size, so every 40 ms and 60 ms packet (both ptimes accepted
by opus_init) failed with "buffer too small" and was dropped.
Size the buffer for 120 ms, the longest duration an Opus packet can
carry, at the decoder's clock rate.
Closes#2224
Change-Id: Ic2fcb32977ad0e262d42b74948103b0f68511d95
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 47cd1458a7)
(cherry picked from commit 8591ed023a)
When the negotiated fmtp has a bitrate range (br=A-B), the encoder's
lower bound check compared the bitrate against max_br instead of
min_br. Any bitrate below the upper bound was therefore forced down
to the minimum, e.g. br=9.6-24.4 with the default 16.4 kbit/s ended
up encoding at 9.6 kbit/s instead of staying at 16.4.
Compare against min_br so the bitrate is only raised when it is
actually below the lower bound.
Closes#2223
Change-Id: I8bfaff332476e351e0b7a6a375a9c55bb3fa772f
(cherry picked from commit 0402477b96)
(cherry picked from commit e9d9792bd9)
stats->ext_seq has been the SRTP receive index since srtp_index moved into
shm (08c7f5853d). The transcode sequencer overwrote it after every
emitted packet with its own roc<<16|seq, which lags the received packets
and, whenever the sequencer emits a late or replayed packet with a lower
sequence number, carries a roc that was incremented without a real
wrap-around. packet_index() then estimated the wrong index, and once the
sender's real roc reached 1 none of the fallback guesses matched, so every
packet of the stream failed authentication until the call ended.
packet_index() already maintains the index for every received packet, so
drop the write. Also make the sequencer's own roc increment only on a
forward wrap-around, never on a backwards step.
Closes#2221
Change-Id: Ia38bf8cbc63dd3435717927f1adfd81ac94ea347
(cherry picked from commit 956d7add09)
(cherry picked from commit dd5c0f7d87)
Has the benefit of not needing to write to the buffer
Change-Id: I5897d4fcd7a37e143bceb5569b9bfa1237593b3e
(cherry picked from commit bc08b05912)
(cherry picked from commit a73ce2f128)
Per RFC 4867 section 8.1, absent fmtp parameters imply defaults (bandwidth-efficient mode, no CRC,
no robust-sorting, no interleaving). Previously, codec matching was rejected when either side had no
``a=fmtp`` attribute for the AMR payload type, causing AMR to be dropped as a "stray answer codec".
This patch changes this behavior to instead "parse" fmtp even when absent so that the format struct
is populated with zero-initialized defaults and fmtp_parsed is set.
Closes#2141
Change-Id: I1371cb1fdb9354746a4019477845d777e619a2f6
(cherry picked from commit 702ccec969)
(cherry picked from commit 84d62960a3)
(cherry picked from commit b7eec52628)
ffmpeg's CNG expects a fixed frame size, or at least a maximum frame
size, as it allocates internal buffers on construction based on that
frame size. Calling the decoder with a larger frame size therefore leads
to an internal buffer overflow. Calling it with a smaller frame size is
fine.
Retain the simple one-shot CNG for the most common case (frame size
smaller than the max). For larger frames, call the CNG in a loop and
manually construct a return frame.
Change-Id: I0ebe0b7a9ad8a08bbabd0d8dea264b08cb44feee
(cherry picked from commit dfcb9a8322)
(cherry picked from commit f1fc3bb10c)
The frame size might not be set before avcodec_open2 is called. Move
setting it to below the call.
Fixes MP3 recording output.
Change-Id: Ie81528e64c2497f769d19a5c54228bf0f5cd138d
... from packetizer function instead of putting it into the AVPacket.
Remove AVPacket from callback function arguments.
Fix up PTS/duration adjustments where they were missing.
Closes#1963
Change-Id: Ib36b36bb6648b0579dd83155c7217317dda29cc3
RFC says that annex B is the default in the absence of the annexb=no
format string. Consider the alias "G729a" as annex A.
Closes#1951
Change-Id: I9a8483ee5520bf4688601123f1ebec4f1f480642
The GLib slice allocator has been obsoleted. Having a mixture of two
allocators can lead to hidden issues on systems that use different
implementations. Take the leap and replace everything with g_new/g_free.
Change-Id: I025c8383ef47b2c2472573360407fd6a6ca339b3
Teach rtpengine to distinguish between G.729 with and without annex B,
which are incompatible to each other.
Change-Id: I09b66a097007ba3283546880f06f81b4f89e126d
In many transcoding scenarios resampling is not actually required. We
can shortcut the operation by just returning the original frame, instead
of a cloned and newly allocated one. We just need to distinguish between
the cases to determine whether the frame returned by resample_frame()
needs to be freed.
Change-Id: I3f36a46bd3b967f140c8353119fdb24ad8363c15
In some cases, in particular when multiple input codecs are transcoding
to the same output codec (e.g. audio + DTMF -> audio), it's possible
that one of the input decoders produces frames in a format different
from the one expected by the encoder. Add an encoder-side resampler to
compensate for that.
Change-Id: I74d55edf47ac2fa65f950e68f4a5975f1ab947bb
ffmpeg 7.1+ has deprecated direct usage of ->sample_fmts in favour of a
call to avcodec_get_supported_config(). Update accordingly.
Change-Id: I0fbecbbcf52c38976f3387e34d816d11e1d09480
Fix the math in the sequencer code to determine ROC and extended
sequence number. This has become significant as the sequence numbers are
written into shared memory space.
Change-Id: I9e519a29a3822d02f7c389920ee0909b48828525
Use provided macros for initrialise str objects everywhere instead of
manually setting .s and .len. This allows for flexibility to extend str
objects.
Change-Id: I5ebca0bc82b348301c2c8e94b974c7acbf249b82
Obsolete str_init(), rename STR_INIT() to just STR(), and replace all
instances of str_init() with STR().
no-op
Change-Id: I981529063ad2ea26089add467f7a84b638dbf423