Commit Graph

31834 Commits

Author SHA1 Message Date
George Joseph 7071e9d64c media_index.c: Refactored so it doesn't cache the index
Testing revealed that the cache added no benefit but that it could
consume excessive memory.

Two new index related functions were created:
ast_sounds_get_index_for_file() and ast_media_index_update_for_file()
which restrict index updating to specific sound files.

The original ast_sounds_get_index() and ast_media_index_update()
calls are still available but since they no longer cache the results
internally, developers should re-use an index they may already have
instead of calling ast_sounds_get_index() repeatedly.  If information
for only a single file is needed, ast_sounds_get_index_for_file()
should be called instead of ast_sounds_get_index().

The media_index directory scan code was elimininated in favor of
using the existing ast_file_read_dirs() function.

Since there's no more cache, ast_sounds_index_init now only
registers the sounds cli commands instead of generating the
initial index and subscribing to stasis format register/unregister
messages.

"sounds" is no longer a valid target for the "module reload"
command.

Both the sounds cli commands and the sounds ari resources were
refactored to only call ast_sounds_get_index() once per invocation
and to use ast_sounds_get_index_for_file() when a specific sound
file is requested.

Change-Id: I1cef327ba1b0648d85d218b70ce469ad07f4aa8d
2019-01-28 12:26:58 -07:00
George Joseph 6118b65a5a Merge "codecs.conf.sample: update codec opus docs" 2019-01-28 07:46:51 -06:00
George Joseph 42d63b69b0 Merge "format_g726: add support for seeking" 2019-01-28 07:46:17 -06:00
George Joseph 423a51ca11 Merge "res_http_websocket: ensure control frames do not interfere with data" 2019-01-28 07:22:01 -06:00
Kevin Harwell 0bcaadc037 codecs.conf.sample: update codec opus docs
The option value "sdp" for some of the settings was removed a while back,
however the sample conf was not updated.

This patch removes any wording with regards to the old "sdp" option value,
and adjusts the defaults to what they are now.

ASTERISK-28263

Change-Id: I41bfa44e9f69446bcc5c8fd92e3675c676fdc445
2019-01-25 14:32:02 -06:00
eyalhasson aede739778 format_g726: add support for seeking
Added support for the seek function in format_g726
so playback can start from anywhere.
Before the fix, playback of g726 files
always started from the beginning.

ASTERISK-28246

Change-Id: I626235bc4642df1479050d3d06828412603a9b40
2019-01-24 08:30:57 -06:00
Joshua C. Colp 83fa4510fc Merge "build : Fix cross-compilation errors" 2019-01-24 08:23:53 -06:00
Joshua C. Colp 1797cd2071 Merge "app_voicemail: Add Mailbox Aliases" 2019-01-24 05:56:34 -06:00
Joshua C. Colp 5e3d7ffdca Merge "res_pjsip_registrar: mitigate blocked threads on reliable transport shutdown" 2019-01-24 05:52:57 -06:00
Joshua C. Colp fc8db07208 Merge "Test_cel: Fails when DONT_OPTIMIZE is off" 2019-01-23 11:26:34 -06:00
Friendly Automation 389b2ab39b Merge "manager_channels: Fix throwing of HangupHandler manager events" 2019-01-23 09:46:00 -06:00
Jeremy Lainé 69e9fd63e1 res_http_websocket: ensure control frames do not interfere with data
Control frames (PING / PONG / CLOSE) can be received in the middle of a
fragmented message. In order to ensure they do not interfere with the
reassembly buffer, we exit early and do not return the payload to the
caller.

ASTERISK-28257 #close

Change-Id: Ia5367144fe08ac6141bba3309517a48ec7f013bc
2019-01-23 09:02:38 -06:00
Jean Aunis d9fae4a824 build : Fix cross-compilation errors
Bundled pjproject and jansson must be configured with the host and build
parameters provided to the configure script.
Autotools do not permit to check for the existence of local header files, so
the control of hrirs.h must not be done when cross-compiling.

ASTERISK-28250

Change-Id: If0a76e52a87d4ab82b7d4c72d27d8759ca931880
2019-01-23 15:19:26 +01:00
Joshua C. Colp 884aaa5f72 Merge "stasis / manager / ari: Better filter messages." 2019-01-22 18:58:48 -06:00
Joshua C. Colp 3655d304af Merge "bridge_softmix: Use MSID:LABEL metadata as the cloned stream's appendix" 2019-01-22 18:55:42 -06:00
Joshua C. Colp 4e41be0a59 Merge "pjsip_transport_management: Shutdown transport immediately on disconnect" 2019-01-22 18:55:21 -06:00
Joshua C. Colp ca5ca2e861 Merge "res_http_websocket: respond to CLOSE opcode" 2019-01-22 18:15:16 -06:00
Gerald Schnabel f9ca0afb39 manager_channels: Fix throwing of HangupHandler manager events
The type value extracted from stasis message data in channel_hangup_handler_cb
isn't compared against the valid values "run", "pop" and "push". Thus the
manager events HangupHandlerPush, HangupHandlerPop and HangupHandlerRun are
never thrown.

This regression was introduced by ASTERISK_21462.

ASTERISK-28252

Change-Id: I9956e35e18da1873113644df1ddc3c7cd37bf524
2019-01-22 17:30:07 -06:00
Chris-Savinovich 1c8378bbc9 Test_cel: Fails when DONT_OPTIMIZE is off
A bug in GCC causes TEST_CEL to return failure under the following
conditions:
1. TEST_FRAMEWORK on
2. DONT_OPTIMIZE off
3. Fedora and Ubuntu
4. GCC 8.2.1
5. Test name: test_cel_dial_pickup
6. There must exist a certain combination of multithreading.
The bug affects arithmetic calculations when the optimization level
is bigger than O1 and the -fpartial-inline flag is on. Provided these
conditions, function ast_str_to_lower() fails to convert to lower case
due to said function being of type force_inline.  The solution is to
remove the "force_inline" type declaration from function ast_str_to_lower()

Change-Id: Ied32e0071f12ed9d5f3b4cdd878b2532a1c769d7
2019-01-22 15:53:01 -06:00
George Joseph c6980e32ae app_voicemail: Add Mailbox Aliases
You can now define an "aliases" context in voicemail.conf
whose entries point to actual mailboxes.  These can be used anywhere
the mailbox is specified.

Example:
[general]
aliasescontext = myaliases

[default]
1234 = yadayada

[myaliases]
4321@devices = 1234@default

Now you can use 4321@devices to refer to the 1234@default mailbox.

This can be useful to provide channel drivers with constant
mailbox specifications such as <extension>@devices leaving
app_voicemail to control exactly which mailbox the alias points to.
Now, only voicemail has to be reloaded to make changes instead of
individual channel drivers which are usually more expensive to
reload.

Change-Id: I395b9205c91523a334fe971be0d1de4522067b04
2019-01-22 13:32:04 -06:00
Kevin Harwell b82d2856b4 res_pjsip_registrar: mitigate blocked threads on reliable transport shutdown
When a reliable transport is shutdown it's possible for the pjsip registrar
resource shutdown handler to get called multiple times. If this happens and one
of the threads is taking "too long" (slow database call for instance) then the
others get blocked waiting to delete.

Since it only takes one to delete the contact then the other threads should be
able to continue on if one of the threads is currently "deleting". This patch
makes it so now when a thread enters the shutdown handler it checks to see if a
thread is currently already "deleting". If so, then the thread does not attempt
to get the lock, and instead continues on thus avoiding the blockage.

ASTERISK-28213 #close

Change-Id: I7563ca596312b1dff4f3ab41483e89fe2862328a
2019-01-22 13:16:42 -06:00
George Joseph deffb8a6e0 pjproject_bundled: Add patch for double free issue in timer heap
Fixed #2172: Avoid double reference counter decrements in
timer in the scenario of race condition between
pj_timer_heap_cancel() and pj_timer_heap_poll().

Change-Id: If000e9438c83ac5084b678eb811e902c035bd2d8
2019-01-22 09:04:43 -06:00
Xiemin Chen a526676836 bridge_softmix: Use MSID:LABEL metadata as the cloned stream's appendix
To avoid the stream name collide if there're more than one video track
in one client. If client has multi video tracks, the name of ast_stream
which represents each video track may be the same. Use the MSID:LABEL
here because it's identifiable.

ASTERISK-28196 #close
Reported-by: xiemchen

Change-Id: Ib62b2886e8d3a30e481d94616b0ceaeab68a870b
2019-01-22 09:01:34 -06:00
Joshua C. Colp 6f5bc854ab Merge "channel.c: Fix segfault with Monitor(wav,file,i)" 2019-01-21 13:18:20 -06:00
Jeremy Lainé 0b8867f7d6 res_http_websocket: respond to CLOSE opcode
This ensures that Asterisk responds properly to frames received from a
client with opcode 8 (CLOSE) by echoing back the status code in its own
CLOSE frame.

Handling of the CLOSE opcode is moved up with the rest of the opcodes so
that unmasking gets applied. The payload is no longer returned to the
caller, but neither ARI nor the chan_sip nor pjsip made use of the
payload, which is a good thing since it was masked.

ASTERISK-28231 #close

Change-Id: Icb1b60205fc77ee970ddc91d1f545671781344cf
2019-01-21 13:06:56 -06:00
Sean Bright 20f672539e pjsip_transport_management: Shutdown transport immediately on disconnect
The transport management code that checks for idle connections keeps a
reference to PJSIP's transport for IDLE_TIMEOUT milliseconds (32000 by
default). Because of this, if the transport is closed before this
timeout, the idle checking code will keep the transport from actually
being shutdown until the timeout expires.

Rather than passing the AO2 object to the scheduler task, we just pass
its key and look it up when it is time to potentially close the idle
connection. The other transport management code handles cleaning up
everything else for us.

Additionally, because we use the address of the transport when
generating its name, we concatenate an incrementing ID to the end of the
name to guarantee uniqueness.

Related to ASTERISK~28231

Change-Id: I02ee9f4073b6abca9169d30c47aa69b5e8ae9afb
2019-01-21 07:57:12 -06:00
Valentin Vidic 17f76d27cc channel.c: Fix segfault with Monitor(wav,file,i)
If the Monitor is started with the i option the read_stream will be
NULL. One code path in channel.c checks if write_stream is set but than
uses read_stream instead causing a segfault.

ASTERISK-28249

Change-Id: I1bae9126537be54895c7fea2d08dd9488d8cc525
2019-01-20 19:49:11 +01:00
Joshua C. Colp 1323730f6c stasis / manager / ari: Better filter messages.
Previously both AMI and ARI used a default route on
their stasis message router to handle some of the
messages for publishing out their respective
connection. This caused messages to be given to
their subscription that could not be formatted
into AMI or JSON.

This change adds an API call to the stasis message
router which allows a default route to be set as well
as formatters that the default route is expecting.
This allows both AMI and ARI to specify that their
default route only wants messages of their given
formatter. By doing so stasis can more intelligently
filter at publishing time so that they do not receive
messages which will not be turned into AMI or JSON.

ASTERISK-28244

Change-Id: I65272819a53ce99f869181d1d370da559a7d1703
2019-01-17 14:51:47 -04:00
Sean Bright 58b55f2a30 sched: Make sched_settime() return void because it cannot fail
Change-Id: I66b8b2b2778f186919d73ae9bf592104b8fb1cd5
2019-01-17 10:02:35 -06:00
Sean Bright 2b8602e8cf res_pjsip_transport_websocket: Don't assert on 0 length payloads
When --enable-dev-mode is used, pjsip_tpmgr_receive_packet() will assert
if passed a payload length of 0, so treat empty frames as if we didn't
receive them.

Change-Id: I9c5fdccd89cc8d2f3ed7e3ee405ef0fc78178f48
2019-01-14 09:35:55 -06:00
Joshua C. Colp b19210214f Merge "res_pjsip: add option to enable ContactStatus event when contact is updated" 2019-01-14 08:38:14 -06:00
Joshua C. Colp c2e02645b4 Merge "stasis/endpoint: Fix memory leak of channel_ids in ast_endpoint structure." 2019-01-14 08:26:32 -06:00
Joshua C. Colp a3f1f82272 Merge "res_pjsip_sdp_rtp: Only enable abs-send-time when WebRTC is enabled." 2019-01-14 08:03:27 -06:00
Joshua C. Colp 2bbcc76f79 Merge "RTP: reset DTMF last seqno/timestamp on RTP renegotiation" 2019-01-14 08:03:03 -06:00
Joshua C. Colp b4523ef334 Merge "app_voicemail: Fix Channel variable VM_MESSAGEFILE for "urgent" voicemail" 2019-01-14 06:19:45 -06:00
mohitdhiman d60ee2eeae stasis/endpoint: Fix memory leak of channel_ids in ast_endpoint structure.
During Bridging of two channels if masquerade operation is performed on a
channel (clone channel) which was created with endpoint details
(ast_channel_alloc_with_endpoint()) and the original channel which is created
without endpoint details (ast_channel_alloc()) then both the channels must
exchange their endpoint details or else after masquerade when clone channel
is being destroyed the endpoint cleanup callbacks will be destroyed too and
after call completion unique_id of original channel will still be there in
ast_endpoint structure's channel_ids container.

ASTERISK-28197

Change-Id: I97ce73da390af20fd082fb09d722a6fe9cb2f39d
2019-01-14 17:07:35 +05:30
Alexei Gradinari f0546d1d87 res_pjsip: add option to enable ContactStatus event when contact is updated
The commit I2f97ebfa79969a36a97bb7b9afd5b6268cf1a07d removed sending out
the ContactStatus AMI event when a contact is updated.
Thist change broke things which rely on old behavior.

This patch adds a new PJSIP global configuration option
'send_contact_status_on_update_registration' to be able to preserve old
ContactStatus behavior.
By default new behavior, i.e. the ContactStatus event will not be sent when a
device refreshes its registration.

Change-Id: I706adf7584e7077eb6bde6d9799ca408bc82ce46
2019-01-11 10:52:18 -05:00
Joshua Colp 18e206381a res_pjsip_sdp_rtp: Only enable abs-send-time when WebRTC is enabled.
For video streams it was possible for the abs-send-time information
to be placed into RTP streams even if not negotiated. Depending on
the endpoint in use this could cause video to not flow.

We now only enable abs-send-time for negotiation if WebRTC is enabled.

ASTERISK-28230

Change-Id: I0eb682302f8da3a4ea3c42e839208d55f825ed0c
2019-01-07 10:35:18 -05:00
Diederik de Groot 7bd30905fd RAII: Change order or variables in clang version
This prevents use-after-scope issues when unwinding the stack,
which happens in reverse order. The varname variable needs to
remain alive for the destruction to be able to access it.
Issue was found using clang + address-sanitizer.

ASTERISK-28232 #close

Change-Id: I00811c34ae910836a5fb6d22304528aef92624db
2019-01-05 18:39:47 +01:00
Alexei Gradinari f662a26ea0 RTP: reset DTMF last seqno/timestamp on RTP renegotiation
The remote side may start a new stream when renegotiating RTP.
Need to reset the DTMF last sequence number and the timestamp
of the last END packet on RTP renegotiation.

If the new time stamp is lower then the timestamp of the last DTMF END packet
the asterisk drops all DTMF frames as out of order.

This bug was caught using Cisco ip-phone SPA5XX and codec g722.
On SIP session update the SPA50X resets stream and a new timestamp is twice
smaller then the previous.

ASTERISK-28162 #close

Change-Id: Ic72b4497e74d801b27a635559c1cf29c16c95254
2019-01-04 10:58:39 -05:00
Joshua C. Colp 28dbb06e8c Merge "ast_coredumper: Refactor the pid determination process" 2019-01-04 08:27:04 -06:00
Friendly Automation 95dd00af3d Merge "stasis: Fix ABI between DEVMODE and non-DEVMODE." 2019-01-03 17:39:22 -06:00
Friendly Automation 9a92d814ea Merge "stasic.c: Fix printf format type mismatches with arguments." 2019-01-03 05:38:16 -06:00
Bryan Boatright 2c48b5d9bf app_voicemail: Fix Channel variable VM_MESSAGEFILE for "urgent" voicemail
If a voicemail is marked "urgent" then the VM_MESSAGEFILE channel variable is
not updated correctly since urgent messages are in a different directory. The
fix is to update the channel variable when the path to the urgent message is
created.

ASTERISK-28225

Change-Id: I8efbace06e6122ea0793f7bdb073d4378e8274ca
2019-01-02 13:16:58 -05:00
Joshua Colp b7b080a0aa app_queue: Fix crash when using 'b' option on non-ringall queue.
When using the 'b' option to Queue with a queue that was not configured
for ring all a crash would occur as the wrong pointer would be used.

ASTERISK-28218

Change-Id: If1390f64e321047dff24fd2410c95dde74904980
2019-01-02 12:35:27 -05:00
Richard Mudgett 7c08ff51d7 stasic.c: Fix printf format type mismatches with arguments.
An int64_t is not likely the same size as a long.

* Changed the int64_t values in the statistics structs to longs so casting
is not necessary when generating the formatted CLI output.  The offending
members did not need to be int64_t anyway as they were only set by an int
type variable which was already truncating bits.

* Reordered the statistics structs to reduce potential padding bytes.

Change-Id: Ic090a070e9dc4ca650ebdb9c01ed50a581289962
2019-01-02 12:11:07 -05:00
George Joseph 192d9dd9c5 Merge "backtrace.c: Fix casting pointer to/from integral type." 2019-01-02 09:51:36 -06:00
Corey Farrell 110934706f
stasis: Fix ABI between DEVMODE and non-DEVMODE.
Eliminate differences with DEVMODE prototypes for public functions.

ASTERISK-28212 #close

Change-Id: I872c04842ab6b61e9dd6d37e4166bc619aa20626
2018-12-26 13:36:13 -05:00
George Joseph 4c084c6b1b Revert "stasis_cache: Stop caching stasis subscription change messages"
This reverts commit 5ec6d2c33e.

This commit caused issues with polling when combined with
the revert commit "Revert "app_voicemail: Remove need to subscribe to stasis"

ASTERISK-28222
Reported by: abelbeck

Change-Id: I1e83a433e4202574181bc128dce876ef24936a52
2018-12-26 10:29:35 -06:00
George Joseph 809e836265 ast_coredumper: Refactor the pid determination process
In order to get a dump of the running process, we need to find the
pid of the main asterisk process.  This can be tricky if there are
also instances of "asterisk -r" running or if an alternate location
for asterisk.conf was specified on the command line with the -C
option that also specified an alternation location for the pid file.

So now...

1. We find the asterisk executable with "which" or the --asterisk-bin
   command line option.
2. If there's only 1 process with an executable path that matches,
   we use that pid.  If not...
3. We try "<asterisk-bin> -rx 'core show settings'" and parse the
   output to find the pidfile, then read that for the pid.  If that
   didn't work...
4. We get a list of all the pids matching <asterisk-bin> and look
   in /proc/<pid>/cmdline for a -C argument and retry the "core show
   settings" using the same -C option.  We can't parse the output
   of "ps" to get the -C path because it may contain spaces.  The
   contents of /proc/<pid>/cmdline are delimited by NULLs.  For BSDs
   we may have to mount /proc first. :(

ASTERISK-28221
Reported by: Andrew Nagy

Change-Id: I8aa1f3f912f949df2b5348908803c636bde1d57c
2018-12-24 14:17:38 -05:00