2012-07-23 21:15:26 +00:00
|
|
|
/*
|
|
|
|
* Asterisk -- An open source telephony toolkit.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012, Matt Jordan
|
|
|
|
*
|
|
|
|
* Matt Jordan <mjordan@digium.com>
|
|
|
|
*
|
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \file
|
|
|
|
* \brief Abstract Jitterbuffer Tests
|
|
|
|
*
|
|
|
|
* \author \verbatim Matt Jordan <mjordan@digium.com> \endverbatim
|
|
|
|
*
|
|
|
|
* Tests the abstract jitter buffer API. This tests both adaptive and fixed
|
|
|
|
* jitter buffers. Functions defined in abstract_jb that are not part of the
|
|
|
|
* abstract jitter buffer API are not tested by this unit test.
|
|
|
|
*
|
|
|
|
* \ingroup tests
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*** MODULEINFO
|
|
|
|
<depend>TEST_FRAMEWORK</depend>
|
|
|
|
<support_level>core</support_level>
|
|
|
|
***/
|
|
|
|
|
|
|
|
#include "asterisk.h"
|
|
|
|
|
|
|
|
#include "asterisk/utils.h"
|
|
|
|
#include "asterisk/module.h"
|
|
|
|
#include "asterisk/test.h"
|
|
|
|
#include "asterisk/abstract_jb.h"
|
|
|
|
#include "asterisk/frame.h"
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
#include "asterisk/format_cache.h"
|
2012-07-23 21:15:26 +00:00
|
|
|
|
|
|
|
#define DEFAULT_FRAME_MS 160
|
|
|
|
#define DEFAULT_CONFIG_FLAGS 0
|
|
|
|
#define DEFAULT_CONFIG_SIZE (DEFAULT_FRAME_MS) * 10
|
|
|
|
#define DEFAULT_CONFIG_RESYNC_THRESHOLD (DEFAULT_FRAME_MS) * 2
|
|
|
|
#define DEFAULT_CONFIG_TARGET_EXTRA -1
|
|
|
|
|
2013-08-16 17:33:21 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Destructor for a jitter buffer
|
|
|
|
*
|
2012-07-23 21:15:26 +00:00
|
|
|
* \param jb The jitter buffer to destroy
|
2013-08-16 17:33:21 +00:00
|
|
|
*
|
2012-07-23 21:15:26 +00:00
|
|
|
* \note This will destroy all frames still in the jitter buffer
|
|
|
|
*/
|
|
|
|
static void dispose_jitterbuffer(struct ast_jb *jb)
|
|
|
|
{
|
|
|
|
if (!jb || !jb->impl || !jb->jbobj) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
jb->impl->empty_and_reset(jb->jbobj);
|
|
|
|
|
|
|
|
jb->impl->destroy(jb->jbobj);
|
|
|
|
jb->impl = NULL;
|
|
|
|
jb->jbobj = NULL;
|
|
|
|
}
|
|
|
|
|
2013-08-16 17:33:21 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Create a test frame
|
|
|
|
*
|
2012-07-23 21:15:26 +00:00
|
|
|
* \param timestamp the time in ms of the frame
|
|
|
|
* \param seqno the frame's sequence number
|
2013-08-16 17:33:21 +00:00
|
|
|
*
|
2012-07-23 21:15:26 +00:00
|
|
|
* \returns a malloc'd frame
|
|
|
|
*/
|
|
|
|
static struct ast_frame *create_test_frame(long timestamp,
|
|
|
|
int seqno)
|
|
|
|
{
|
|
|
|
struct ast_frame f = {0};
|
|
|
|
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
f.subclass.format = ast_format_slin;
|
2012-07-23 21:15:26 +00:00
|
|
|
f.frametype = AST_FRAME_VOICE;
|
|
|
|
f.src = "TEST";
|
|
|
|
f.ts = timestamp;
|
|
|
|
f.len = DEFAULT_FRAME_MS;
|
|
|
|
f.seqno = seqno;
|
|
|
|
|
|
|
|
return ast_frisolate(&f);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! \internal
|
|
|
|
* \brief Test two numeric (long int) values.
|
|
|
|
*/
|
|
|
|
#define LONG_INT_TEST(actual, expected) do { \
|
|
|
|
if ((actual) != (expected)) { \
|
|
|
|
ast_test_status_update(test, #actual ": expected [%ld]; actual [%ld]\n", (long int)(expected), (long int)(actual)); \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} } while (0)
|
|
|
|
|
|
|
|
/*! \internal
|
|
|
|
* \brief Test two numeric (int) values.
|
|
|
|
*/
|
|
|
|
#define INT_TEST(actual, expected) do { \
|
|
|
|
if ((actual) != (expected)) { \
|
|
|
|
ast_test_status_update(test, #actual ": expected [%d]; actual [%d]\n", (expected), (actual)); \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} } while (0)
|
|
|
|
|
2014-07-22 14:22:00 +00:00
|
|
|
/*! \internal
|
|
|
|
* \brief Test two numeric (unsigned int) values.
|
|
|
|
*/
|
|
|
|
#define UINT_TEST(actual, expected) do { \
|
|
|
|
if ((actual) != (expected)) { \
|
|
|
|
ast_test_status_update(test, #actual ": expected [%u]; actual [%u]\n", (expected), (actual)); \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} } while (0)
|
|
|
|
|
2012-07-23 21:15:26 +00:00
|
|
|
/*! \internal
|
|
|
|
* \brief Test two string values
|
|
|
|
*/
|
|
|
|
#define STRING_TEST(actual, expected) do { \
|
|
|
|
if (strcmp((actual), (expected))) { \
|
|
|
|
ast_test_status_update(test, #actual ": expected [%s]; actual [%s]\n", (expected), (actual)); \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} } while (0)
|
|
|
|
|
|
|
|
/*! \internal
|
|
|
|
* \brief Verify that two frames have the same properties
|
|
|
|
*/
|
|
|
|
#define VERIFY_FRAME(actual, expected) do { \
|
2014-07-22 14:22:00 +00:00
|
|
|
UINT_TEST((actual)->frametype, (expected)->frametype); \
|
2012-07-23 21:15:26 +00:00
|
|
|
INT_TEST((actual)->seqno, (expected)->seqno); \
|
|
|
|
LONG_INT_TEST((actual)->ts, (expected)->ts); \
|
|
|
|
LONG_INT_TEST((actual)->len, (expected)->len); \
|
|
|
|
STRING_TEST((actual)->src, (expected)->src); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/*! \internal
|
|
|
|
* \brief Get the implementation for a jitter buffer
|
|
|
|
*/
|
|
|
|
#define OBTAIN_JITTERBUFFER_IMPL(impl, ast_jb_type, literal_name) do { \
|
|
|
|
(impl) = ast_jb_get_impl((ast_jb_type)); \
|
|
|
|
if (!(impl)) { \
|
|
|
|
ast_test_status_update(test, "Error: no %s jitterbuffer defined\n", (literal_name)); \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
if (strcmp((impl)->name, (literal_name))) { \
|
|
|
|
ast_test_status_update(test, "Error: requested %s jitterbuffer and received %s\n", (literal_name), (impl)->name); \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} } while (0)
|
|
|
|
|
|
|
|
/*! \internal
|
|
|
|
* \brief Make a jitter buffer configuration object with default values
|
|
|
|
*/
|
|
|
|
#define MAKE_DEFAULT_CONFIG(conf, impl) do { \
|
|
|
|
(conf)->flags = DEFAULT_CONFIG_FLAGS; \
|
|
|
|
strcpy((conf)->impl, (impl)->name); \
|
|
|
|
(conf)->max_size = DEFAULT_CONFIG_SIZE; \
|
|
|
|
(conf)->resync_threshold = DEFAULT_CONFIG_RESYNC_THRESHOLD; \
|
|
|
|
(conf)->target_extra = DEFAULT_CONFIG_TARGET_EXTRA; \
|
|
|
|
} while (0)
|
|
|
|
|
2013-08-16 17:33:21 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief A container object for the jitter buffers, used for all tests
|
|
|
|
*/
|
2012-07-23 21:15:26 +00:00
|
|
|
static struct ast_jb default_jb = {
|
|
|
|
.impl = NULL,
|
|
|
|
.jbobj = NULL
|
|
|
|
};
|
|
|
|
|
2013-08-16 17:33:21 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Construct a test name
|
|
|
|
*/
|
2012-07-23 21:15:26 +00:00
|
|
|
#define TEST_NAME(type_name, specifier) type_name ## _ ## specifier
|
|
|
|
|
|
|
|
#define TEST_NAME2(test_name) #test_name
|
|
|
|
#define STRINGIFY_TESTNAME(test_name) TEST_NAME2(test_name)
|
|
|
|
|
2013-08-16 17:33:21 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Test nominal construction of a jitter buffer
|
|
|
|
*
|
2012-07-23 21:15:26 +00:00
|
|
|
* \param type_name The enum type of the jitter buffer to create
|
|
|
|
* \param literal_type_name The literal name of the type - "fixed" or "adaptive"
|
|
|
|
*/
|
|
|
|
#define test_create_nominal(type_name, literal_type_name) AST_TEST_DEFINE(TEST_NAME(type_name, create)) {\
|
|
|
|
RAII_VAR(struct ast_jb *, jb, &default_jb, dispose_jitterbuffer); \
|
|
|
|
const struct ast_jb_impl *impl; \
|
|
|
|
struct ast_jb_conf conf; \
|
|
|
|
\
|
|
|
|
switch (cmd) { \
|
|
|
|
case TEST_INIT: \
|
|
|
|
info->name = STRINGIFY_TESTNAME(TEST_NAME(type_name, create)); \
|
|
|
|
info->category = "/main/abstract_jb/"; \
|
|
|
|
info->summary = "Test nominal creation of a " literal_type_name " jitterbuffer"; \
|
|
|
|
info->description = \
|
|
|
|
"Tests nominal creation of a " literal_type_name " jitterbuffer using the " \
|
|
|
|
" jitterbuffer API."; \
|
|
|
|
return AST_TEST_NOT_RUN; \
|
|
|
|
case TEST_EXECUTE: \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
ast_test_status_update(test, "Executing " STRINGIFY_TESTNAME(TEST_NAME(type_name, create))"...\n"); \
|
|
|
|
OBTAIN_JITTERBUFFER_IMPL(impl, (type_name), (literal_type_name)); \
|
|
|
|
MAKE_DEFAULT_CONFIG(&conf, impl); \
|
|
|
|
\
|
|
|
|
jb->jbobj = impl->create(&conf); \
|
|
|
|
jb->impl = impl; \
|
|
|
|
if (!jb->jbobj) { \
|
|
|
|
ast_test_status_update(test, "Error: Failed to adaptive jitterbuffer\n"); \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
return AST_TEST_PASS; \
|
|
|
|
}
|
|
|
|
|
2013-08-16 17:33:21 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Test putting the initial frame into a jitter buffer
|
|
|
|
*
|
2012-07-23 21:15:26 +00:00
|
|
|
* \param type_name The enum type of the jitter buffer to create
|
|
|
|
* \param literal_type_name The literal name of the type - "fixed" or "adaptive"
|
|
|
|
*/
|
|
|
|
#define test_put_first(type_name, literal_type_name) AST_TEST_DEFINE(TEST_NAME(type_name, put_first)) {\
|
|
|
|
RAII_VAR(struct ast_jb *, jb, &default_jb, dispose_jitterbuffer); \
|
|
|
|
const struct ast_jb_impl *impl; \
|
|
|
|
struct ast_jb_conf conf; \
|
2013-04-08 13:27:45 +00:00
|
|
|
RAII_VAR(struct ast_frame *, expected_frame, NULL, ast_frame_dtor); \
|
|
|
|
RAII_VAR(struct ast_frame *, actual_frame, NULL, ast_frame_dtor); \
|
2012-07-23 21:15:26 +00:00
|
|
|
int res; \
|
|
|
|
\
|
|
|
|
switch (cmd) { \
|
|
|
|
case TEST_INIT: \
|
|
|
|
info->name = STRINGIFY_TESTNAME(TEST_NAME(type_name, put_first)); \
|
|
|
|
info->category = "/main/abstract_jb/"; \
|
|
|
|
info->summary = "Test putting a frame into a " literal_type_name " jitterbuffer"; \
|
|
|
|
info->description = \
|
|
|
|
"This tests putting a single frame into a " literal_type_name " jitterbuffer " \
|
|
|
|
"when the jitterbuffer is empty and verifying that it is indeed " \
|
2021-10-31 01:04:37 +00:00
|
|
|
"the first frame on the jitterbuffer"; \
|
2012-07-23 21:15:26 +00:00
|
|
|
return AST_TEST_NOT_RUN; \
|
|
|
|
case TEST_EXECUTE: \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
ast_test_status_update(test, "Executing " STRINGIFY_TESTNAME(TEST_NAME(type_name, create))"...\n"); \
|
|
|
|
OBTAIN_JITTERBUFFER_IMPL(impl, (type_name), (literal_type_name)); \
|
|
|
|
MAKE_DEFAULT_CONFIG(&conf, impl); \
|
|
|
|
jb->jbobj = impl->create(&conf); \
|
|
|
|
jb->impl = impl; \
|
|
|
|
if (!jb->jbobj) { \
|
|
|
|
ast_test_status_update(test, "Error: Failed to adaptive jitterbuffer\n"); \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
expected_frame = create_test_frame(1000, 0); \
|
|
|
|
res = jb->impl->put_first(jb->jbobj, \
|
|
|
|
expected_frame, \
|
|
|
|
1100); \
|
|
|
|
if (res != AST_JB_IMPL_OK) { \
|
|
|
|
ast_test_status_update(test, "Error: Got %d back from put_first (expected %d)\n", \
|
|
|
|
res, AST_JB_IMPL_OK); \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
res = jb->impl->remove(jb->jbobj, &actual_frame); \
|
|
|
|
if (!actual_frame || res != AST_JB_IMPL_OK) { \
|
|
|
|
ast_test_status_update(test, "Error: failed to retrieve first frame\n"); \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
expected_frame = create_test_frame(1000, 0); \
|
|
|
|
VERIFY_FRAME(actual_frame, expected_frame); \
|
|
|
|
return AST_TEST_PASS; \
|
|
|
|
}
|
|
|
|
|
2013-08-16 17:33:21 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Test putting a voice frames into a jitter buffer
|
|
|
|
*
|
2012-07-23 21:15:26 +00:00
|
|
|
* \param type_name The enum type of the jitter buffer to create
|
|
|
|
* \param literal_type_name The literal name of the type - "fixed" or "adaptive"
|
|
|
|
*/
|
|
|
|
#define test_put(type_name, literal_type_name) AST_TEST_DEFINE(TEST_NAME(type_name, put)) {\
|
|
|
|
RAII_VAR(struct ast_jb *, jb, &default_jb, dispose_jitterbuffer); \
|
|
|
|
const struct ast_jb_impl *impl; \
|
|
|
|
struct ast_jb_conf conf; \
|
2021-09-08 19:29:56 +00:00
|
|
|
struct ast_frame *expected_frame = NULL; \
|
|
|
|
struct ast_frame *actual_frame = NULL; \
|
2012-07-23 21:15:26 +00:00
|
|
|
int res; \
|
|
|
|
long next; \
|
|
|
|
int i; \
|
|
|
|
\
|
|
|
|
switch (cmd) { \
|
|
|
|
case TEST_INIT: \
|
|
|
|
info->name = STRINGIFY_TESTNAME(TEST_NAME(type_name, put)); \
|
|
|
|
info->category = "/main/abstract_jb/"; \
|
|
|
|
info->summary = "Test putting frames onto a " literal_type_name " jitterbuffer"; \
|
|
|
|
info->description = \
|
|
|
|
"This tests putting multiple frames into a " literal_type_name " jitterbuffer"; \
|
|
|
|
return AST_TEST_NOT_RUN; \
|
|
|
|
case TEST_EXECUTE: \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
ast_test_status_update(test, "Executing "STRINGIFY_TESTNAME(TEST_NAME(type_name, put))"...\n"); \
|
|
|
|
OBTAIN_JITTERBUFFER_IMPL(impl, (type_name), (literal_type_name)); \
|
|
|
|
MAKE_DEFAULT_CONFIG(&conf, impl); \
|
|
|
|
jb->jbobj = impl->create(&conf); \
|
|
|
|
jb->impl = impl; \
|
|
|
|
\
|
|
|
|
expected_frame = create_test_frame(1000, 0); \
|
2021-09-08 19:29:56 +00:00
|
|
|
res = jb->impl->put_first(jb->jbobj, \
|
|
|
|
expected_frame, \
|
|
|
|
1100); \
|
|
|
|
if (res != AST_JB_IMPL_OK) { \
|
|
|
|
ast_test_status_update(test, "Error: On first frame, got %d back from put_first (expected %d)\n", \
|
|
|
|
res, AST_JB_IMPL_OK); \
|
|
|
|
ast_frame_dtor(expected_frame); \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
2012-07-23 21:15:26 +00:00
|
|
|
for (i = 1; i < 10; i++) { \
|
|
|
|
expected_frame = create_test_frame(1000 + i * DEFAULT_FRAME_MS, 0); \
|
|
|
|
res = jb->impl->put(jb->jbobj, \
|
|
|
|
expected_frame, \
|
|
|
|
1100 + i * DEFAULT_FRAME_MS); \
|
|
|
|
if (res != AST_JB_IMPL_OK) { \
|
|
|
|
ast_test_status_update(test, "Error: On frame %d, got %d back from put (expected %d)\n", \
|
|
|
|
i, res, AST_JB_IMPL_OK); \
|
2021-09-08 19:29:56 +00:00
|
|
|
ast_frame_dtor(expected_frame); \
|
2012-07-23 21:15:26 +00:00
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
for (i = 0; i < 10; i++) { \
|
|
|
|
expected_frame = create_test_frame(1000 + i * DEFAULT_FRAME_MS, 0); \
|
|
|
|
next = jb->impl->next(jb->jbobj); \
|
|
|
|
res = jb->impl->get(jb->jbobj, &actual_frame, next, DEFAULT_FRAME_MS); \
|
|
|
|
if (res != AST_JB_IMPL_OK) { \
|
|
|
|
ast_test_status_update(test, "Error: failed to retrieve frame %i at time %ld\n", \
|
|
|
|
i, next); \
|
2021-09-08 19:29:56 +00:00
|
|
|
ast_frame_dtor(expected_frame); \
|
2012-07-23 21:15:26 +00:00
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
VERIFY_FRAME(actual_frame, expected_frame); \
|
2021-09-08 19:29:56 +00:00
|
|
|
ast_frame_dtor(expected_frame); \
|
|
|
|
ast_frame_dtor(actual_frame); \
|
2012-07-23 21:15:26 +00:00
|
|
|
} \
|
|
|
|
return AST_TEST_PASS; \
|
|
|
|
}
|
|
|
|
|
2013-08-16 17:33:21 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Test overflowing the limits of a jitter buffer
|
|
|
|
*
|
2012-07-23 21:15:26 +00:00
|
|
|
* \param type_name The enum type of the jitter buffer to create
|
|
|
|
* \param literal_type_name The literal name of the type - "fixed" or "adaptive"
|
|
|
|
* \param overflow_limit The number of frames at which we expect the buffer to overflow
|
|
|
|
*/
|
|
|
|
#define test_put_overflow(type_name, literal_type_name, overflow_limit) AST_TEST_DEFINE(TEST_NAME(type_name, put_overflow)) {\
|
|
|
|
RAII_VAR(struct ast_jb *, jb, &default_jb, dispose_jitterbuffer); \
|
|
|
|
const struct ast_jb_impl *impl; \
|
|
|
|
struct ast_jb_conf conf; \
|
2013-04-08 13:27:45 +00:00
|
|
|
RAII_VAR(struct ast_frame *, expected_frame, NULL, ast_frame_dtor); \
|
2012-07-23 21:15:26 +00:00
|
|
|
int res; \
|
|
|
|
int i; \
|
|
|
|
\
|
|
|
|
switch (cmd) { \
|
|
|
|
case TEST_INIT: \
|
|
|
|
info->name = STRINGIFY_TESTNAME(TEST_NAME(type_name, put_overflow)); \
|
|
|
|
info->category = "/main/abstract_jb/"; \
|
|
|
|
info->summary = "Test putting frames onto a " literal_type_name " jitterbuffer " \
|
|
|
|
"that ends up overflowing the maximum allowed slots in the buffer"; \
|
|
|
|
info->description = \
|
|
|
|
"This tests putting multiple frames into a " literal_type_name " jitterbuffer " \
|
|
|
|
"until the jitterbuffer overflows"; \
|
|
|
|
return AST_TEST_NOT_RUN; \
|
|
|
|
case TEST_EXECUTE: \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
ast_test_status_update(test, "Executing "STRINGIFY_TESTNAME(TEST_NAME(type_name, put_overflow))"...\n"); \
|
|
|
|
OBTAIN_JITTERBUFFER_IMPL(impl, (type_name), (literal_type_name)); \
|
|
|
|
MAKE_DEFAULT_CONFIG(&conf, impl); \
|
|
|
|
jb->jbobj = impl->create(&conf); \
|
|
|
|
jb->impl = impl; \
|
|
|
|
\
|
|
|
|
expected_frame = create_test_frame(1000, 0); \
|
|
|
|
jb->impl->put_first(jb->jbobj, expected_frame, 1100); \
|
|
|
|
for (i = 1; i <= (overflow_limit); i++) { \
|
|
|
|
expected_frame = create_test_frame(1000 + i * DEFAULT_FRAME_MS, 0); \
|
|
|
|
res = jb->impl->put(jb->jbobj, \
|
|
|
|
expected_frame, \
|
|
|
|
1100 + i * DEFAULT_FRAME_MS); \
|
|
|
|
if (res != AST_JB_IMPL_OK) { \
|
|
|
|
ast_test_status_update(test, "Error: On frame %d, got %d back from put (expected %d)\n", \
|
|
|
|
i, res, AST_JB_IMPL_OK); \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
for (i = (overflow_limit)+1; i < (overflow_limit) + 5; i++) { \
|
|
|
|
expected_frame = create_test_frame(1000 + i * DEFAULT_FRAME_MS, 0); \
|
|
|
|
res = jb->impl->put(jb->jbobj, \
|
|
|
|
expected_frame, \
|
|
|
|
1100 + i * DEFAULT_FRAME_MS); \
|
|
|
|
if (res != AST_JB_IMPL_DROP) { \
|
|
|
|
expected_frame = NULL; \
|
|
|
|
ast_test_status_update(test, "Error: On frame %d, got %d back from put (expected %d)\n", \
|
|
|
|
i, res, AST_JB_IMPL_DROP); \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
ast_frfree(expected_frame); \
|
|
|
|
expected_frame = NULL;\
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
return AST_TEST_PASS; \
|
|
|
|
}
|
|
|
|
|
2013-08-16 17:33:21 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Test putting voice frames into a jitter buffer out of order
|
|
|
|
*
|
2012-07-23 21:15:26 +00:00
|
|
|
* \param type_name The enum type of the jitter buffer to create
|
|
|
|
* \param literal_type_name The literal name of the type - "fixed" or "adaptive"
|
|
|
|
* \param synch_limit The synchronization limit for this particular type of jitter buffer
|
|
|
|
*/
|
|
|
|
#define test_put_out_of_order(type_name, literal_type_name, synch_limit) AST_TEST_DEFINE(TEST_NAME(type_name, put_out_of_order)) {\
|
|
|
|
RAII_VAR(struct ast_jb *, jb, &default_jb, dispose_jitterbuffer); \
|
|
|
|
const struct ast_jb_impl *impl; \
|
|
|
|
struct ast_jb_conf conf; \
|
2021-09-08 19:29:56 +00:00
|
|
|
struct ast_frame *expected_frame = NULL; \
|
|
|
|
struct ast_frame *actual_frame = NULL; \
|
2012-07-23 21:15:26 +00:00
|
|
|
int res; \
|
|
|
|
long next; \
|
|
|
|
int i; \
|
|
|
|
\
|
|
|
|
switch (cmd) { \
|
|
|
|
case TEST_INIT: \
|
|
|
|
info->name = STRINGIFY_TESTNAME(TEST_NAME(type_name, put_out_of_order)); \
|
|
|
|
info->category = "/main/abstract_jb/"; \
|
|
|
|
info->summary = "Test putting out of order frames onto a " literal_type_name " jitterbuffer"; \
|
|
|
|
info->description = \
|
|
|
|
"This tests putting multiple frames into a " literal_type_name " jitterbuffer " \
|
|
|
|
"that arrive out of order. Every 3rd frame is put in out of order."; \
|
|
|
|
return AST_TEST_NOT_RUN; \
|
|
|
|
case TEST_EXECUTE: \
|
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
ast_test_status_update(test, "Executing " STRINGIFY_TESTNAME(TEST_NAME(type_name, put_out_of_order)) "...\n"); \
|
|
|
|
OBTAIN_JITTERBUFFER_IMPL(impl, (type_name), (literal_type_name)); \
|
|
|
|
MAKE_DEFAULT_CONFIG(&conf, impl); \
|
|
|
|
conf.resync_threshold = (synch_limit); \
|
|
|
|
jb->jbobj = impl->create(&conf); \
|
|
|
|
jb->impl = impl; \
|
|
|
|
\
|
|
|
|
expected_frame = create_test_frame(1000, 0); \
|
2021-09-08 19:29:56 +00:00
|
|
|
res = jb->impl->put_first(jb->jbobj, expected_frame, 1100); \
|
|
|
|
if (res != AST_JB_IMPL_OK) { \
|
|
|
|
ast_test_status_update(test, "Error: On first frame, got %d back from put_first (expected %d)\n", \
|
|
|
|
res, AST_JB_IMPL_OK); \
|
|
|
|
ast_frame_dtor(expected_frame); \
|
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
2012-07-23 21:15:26 +00:00
|
|
|
for (i = 1; i <= 10; i++) { \
|
|
|
|
if (i % 3 == 1 && i != 10) { \
|
|
|
|
expected_frame = create_test_frame(1000 + ((i + 1) * DEFAULT_FRAME_MS), 0); \
|
|
|
|
} else if (i % 3 == 2) { \
|
|
|
|
expected_frame = create_test_frame(1000 + ((i - 1) * DEFAULT_FRAME_MS), 0); \
|
|
|
|
} else { \
|
|
|
|
expected_frame = create_test_frame(1000 + i * DEFAULT_FRAME_MS, 0); \
|
|
|
|
} \
|
|
|
|
res = jb->impl->put(jb->jbobj, \
|
|
|
|
expected_frame, \
|
|
|
|
1100 + i * DEFAULT_FRAME_MS); \
|
|
|
|
if (res != AST_JB_IMPL_OK) { \
|
|
|
|
ast_test_status_update(test, "Error: On frame %d, got %d back from put (expected %d)\n", \
|
|
|
|
i, res, AST_JB_IMPL_OK); \
|
2021-09-08 19:29:56 +00:00
|
|
|
ast_frame_dtor(expected_frame); \
|
2012-07-23 21:15:26 +00:00
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
for (i = 0; i <= 10; i++) { \
|
|
|
|
expected_frame = create_test_frame(1000 + i * DEFAULT_FRAME_MS, 0); \
|
|
|
|
next = jb->impl->next(jb->jbobj); \
|
|
|
|
res = jb->impl->get(jb->jbobj, &actual_frame, next, DEFAULT_FRAME_MS); \
|
|
|
|
if (res != AST_JB_IMPL_OK) { \
|
|
|
|
ast_test_status_update(test, "Error: failed to retrieve frame at %ld\n", \
|
|
|
|
next); \
|
2021-09-08 19:29:56 +00:00
|
|
|
ast_frame_dtor(expected_frame); \
|
2012-07-23 21:15:26 +00:00
|
|
|
return AST_TEST_FAIL; \
|
|
|
|
} \
|
|
|
|
VERIFY_FRAME(actual_frame, expected_frame); \
|
2021-09-08 19:29:56 +00:00
|
|
|
ast_frame_dtor(expected_frame); \
|
|
|
|
ast_frame_dtor(actual_frame); \
|
2012-07-23 21:15:26 +00:00
|
|
|
expected_frame = NULL; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
return AST_TEST_PASS; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
test_create_nominal(AST_JB_ADAPTIVE, "adaptive")
|
|
|
|
|
|
|
|
test_put_first(AST_JB_ADAPTIVE, "adaptive")
|
|
|
|
|
|
|
|
test_put(AST_JB_ADAPTIVE, "adaptive")
|
|
|
|
|
|
|
|
test_put_overflow(AST_JB_ADAPTIVE, "adaptive", 10)
|
|
|
|
|
|
|
|
test_put_out_of_order(AST_JB_ADAPTIVE, "adaptive", DEFAULT_FRAME_MS * 2)
|
|
|
|
|
|
|
|
test_create_nominal(AST_JB_FIXED, "fixed")
|
|
|
|
|
|
|
|
test_put_first(AST_JB_FIXED, "fixed")
|
|
|
|
|
|
|
|
test_put(AST_JB_FIXED, "fixed")
|
|
|
|
|
|
|
|
test_put_overflow(AST_JB_FIXED, "fixed", 12)
|
|
|
|
|
|
|
|
test_put_out_of_order(AST_JB_FIXED, "fixed", DEFAULT_CONFIG_RESYNC_THRESHOLD)
|
|
|
|
|
|
|
|
static int unload_module(void)
|
|
|
|
{
|
|
|
|
AST_TEST_UNREGISTER(TEST_NAME(AST_JB_ADAPTIVE, create));
|
|
|
|
AST_TEST_UNREGISTER(TEST_NAME(AST_JB_ADAPTIVE, put_first));
|
|
|
|
AST_TEST_UNREGISTER(TEST_NAME(AST_JB_ADAPTIVE, put));
|
|
|
|
AST_TEST_UNREGISTER(TEST_NAME(AST_JB_ADAPTIVE, put_overflow));
|
|
|
|
AST_TEST_UNREGISTER(TEST_NAME(AST_JB_ADAPTIVE, put_out_of_order));
|
|
|
|
|
|
|
|
AST_TEST_UNREGISTER(TEST_NAME(AST_JB_FIXED, create));
|
|
|
|
AST_TEST_UNREGISTER(TEST_NAME(AST_JB_FIXED, put_first));
|
|
|
|
AST_TEST_UNREGISTER(TEST_NAME(AST_JB_FIXED, put));
|
|
|
|
AST_TEST_UNREGISTER(TEST_NAME(AST_JB_FIXED, put_overflow));
|
|
|
|
AST_TEST_UNREGISTER(TEST_NAME(AST_JB_FIXED, put_out_of_order));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int load_module(void)
|
|
|
|
{
|
|
|
|
AST_TEST_REGISTER(TEST_NAME(AST_JB_ADAPTIVE, create));
|
|
|
|
AST_TEST_REGISTER(TEST_NAME(AST_JB_ADAPTIVE, put_first));
|
|
|
|
AST_TEST_REGISTER(TEST_NAME(AST_JB_ADAPTIVE, put));
|
|
|
|
AST_TEST_REGISTER(TEST_NAME(AST_JB_ADAPTIVE, put_overflow));
|
|
|
|
AST_TEST_REGISTER(TEST_NAME(AST_JB_ADAPTIVE, put_out_of_order));
|
|
|
|
|
|
|
|
AST_TEST_REGISTER(TEST_NAME(AST_JB_FIXED, create));
|
|
|
|
AST_TEST_REGISTER(TEST_NAME(AST_JB_FIXED, put_first));
|
|
|
|
AST_TEST_REGISTER(TEST_NAME(AST_JB_FIXED, put));
|
|
|
|
AST_TEST_REGISTER(TEST_NAME(AST_JB_FIXED, put_overflow));
|
|
|
|
AST_TEST_REGISTER(TEST_NAME(AST_JB_FIXED, put_out_of_order));
|
|
|
|
|
|
|
|
return AST_MODULE_LOAD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Abstract JitterBuffer API Tests");
|