Make sure a codec is not only known to us, but that it can actually be
used, in places where it makes sense. This is partially redundant
because ensure_codec_def_type already takes care of this, but a codec
definition may come from a different source, so it doesn't help to
double check.
Change-Id: I91af84afc2477840f1400674b2538ad8fb7746ee
A matching payload type number in an answer might not be enough to
establish compatible codecs. Also check the format parameters. Reject
and ignore answer codecs that are not compatible.
Change-Id: I12a1287216886926ec4b3c704029c923f815b429
`packet_sequencer_init()` initializes
`packet_sequencer_t` sequence to -1 always.
So make sure to set `uint16_t` later not to
an underflowing value, which can potentially
set the `uint16_t` object type to some insanely
big value.
Fixes:
/daemon/codec.c: 1893 in __handler_func_sequencer()
1887 if (!seq) {
1888 seq = g_slice_alloc0(sizeof(*seq));
1889 packet_sequencer_init(seq, (GDestroyNotify) __transcode_packet_free);
1890 g_hash_table_insert(ssrc_in_p->sequencers, mp->media_out, seq);
1891 }
1892
>>> CID 1616503: Integer handling issues (INTEGER_OVERFLOW)
>>> Expression "seq_ori", where "seq->seq" is known to be equal to -1, overflows the type of "seq_ori", which is type "uint16_t".
1893 uint16_t seq_ori = seq->seq;
1894 int seq_ret = packet_sequencer_insert(seq, &packet->p);
1895 if (seq_ret < 0) {
1896 // dupe
1897 int func_ret = 0;
1898 if (packet->dup_func)
** CID 1616502: (LOCK_EVASION)
/daemon/media_player.c: 487 in media_player_read_decoded_packet()
/daemon/media_player.c: 479 in media_player_read_decoded_packet()
Change-Id: Ifbd68021f17866aa9b7482b1bd42e2acf1c25dfa
Make the macro return the appropriate pointer type, and make sure the
free function takes an argument of the same type. This also eliminates
some boilerplate type-casting code.
Change-Id: I3094271fa2c53ec93b9ff9f837d461cf422e0f12
The `answer` processing empties out the list of codecs and leaves only
those that were accepted in the answer. Side effect of this is that if
another answer with a different list of codecs comes through, them the
codec-accept function is missing the original list of offered codecs and
can yield an incorrect result.
Fix this by storing a copy of the offered codecs at the end of the
`offer` processing, and then restore this list at the beginning of each
`answer` message.
Change-Id: I3c714e80689f3c5689637cc7d1eb2f203c292a15
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
Remove all codecs that cannot be transcoded to when the audio player is in
use.
Add safety to make_transcoder to return failure in case an unsupported
codec is requested for transcoding.
Convert leftover passthrough handlers to SSRC passthrough if there are
any (shouldn't be).
closes#1858
Change-Id: I1822e48723622d550624c7355a1acfbf8ca38eb8
Obsolete str_init(), rename STR_INIT() to just STR(), and replace all
instances of str_init() with STR().
no-op
Change-Id: I981529063ad2ea26089add467f7a84b638dbf423
For typed hash tables, enforce the correct type in the arguments to the
hashing and equality functions.
Adapt existing affected callback functions and change their arguments
from void* to the respective types.
Add reverse casts to GHashFunc and GEqualFunc in instances where these
functions are used in non-typed hash tables (that should be converted at
a later point).
Add convenience macro to create typed wrapper functions for hash tables
that use "direct" hashing (i.e. the pointer value).
Add wrappers for existing GLib functions that have generic arguments so
that they can be used in typed hash tables.
Change-Id: I43bb32969208f4aae49584d95c0df8353df6e2a0
There isn't any immediate benefit to this, but it prepares the code for
use of shared memory for statistics.
Use the opportunity to switch accesses to these to relaxed memory order.
Change-Id: I585fef7579202179fbbcbc1b843d3bbe440a723b
Switch all memory buffers used for RTP I/O from generic stack or heap
allocated memory to the bufferpool implementation. Use a per-thread
bufferpool to minimise lock contention.
This commit is just a one-for-one swap and doesn't use the bufferpool's
reference counting semantics yet.
Change-Id: I9cba4ec97bd0afcd374bf6c0be2b608a46e73e57
using str_init_dup_str doesn't leave enough room for appending encryption
related pieces to the end of the packet when used for, eg, dtmf
injection
closes#1819
Change-Id: Iefae0e04b38f4a3eaaac32ed1ba70c7e3ee8e979
this function is used to determine if a pause is needed on a new
injected DTMF's start ts to ensure a gap between the events. However,
if an inject request comes in after the end of the previous event
but before it would have been offset due to pause, no pause is added
This change returns the ts value from dtmf_state if the queue is
empty as that will always be the ts of the last DTMF transmitted
Change-Id: I4f3cf5115d1a8e26c0ca1bc9570c46e29391e0d0
Make sure we increase the output RTP sequence
number for each generated packet in the case
of packets that need to be duplicated or sent
repeatedly (DTMF end event)
Change-Id: Ia16ffefc0791d01575248ac5d8025eb30ccaec67
when DTMF is being transmitted using codec_output_rtp, the scheduled
time to send the packet is calculated using the timestamp difference
from the last transmitted applied on top of the realtime time the
last packet was sent. However, the timestamp is only updated on the
first event packet so a delay needs to be passed in to codec_output_rtp
to ensure the subsequent packets are scheduled based on the event
duration of the event packets
Change-Id: I5a2f6cf67b5f570f6099d201592d9a6fc01d60a5
Use a dedicated enum return code for functions that are used in code
paths that can lead to 3 different outcomes (ok/error/consume) instead
of a plain int. Extend this tristate return code to also include
__rtp_decode().
Change-Id: I22e1b0bf72216613188cb88315edb1f8feb18d07
In the file implementations follow the rules:
1. Firstly goes the correlated header file, then one empty row.
2. Secondly go system headers, so in angle-brackets, then one empty row.
3. Thirdly, go custom header files, so in double quotes,
then one empty row.
4. If there is "xt_RTPENGINE.h", it's mentioned next, but separately,
then one empty row.
5. If there are pre-processor definitions, they are added.
6. And eventually at least one empty row before the code.
In some situations it's allowed to step aside from the rules,
when inclusions are dependent on each other, so on the sequence,
and also possibly on some inline objects definitions, but if possible
to follow the rules, it's being done.
Change-Id: Ie512a970e230fe202398656d1942e8874bb14cd9