summaryrefslogtreecommitdiff
path: root/pjmedia
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2014-02-04 10:13:56 +0000
committerBenny Prijono <bennylp@teluu.com>2014-02-04 10:13:56 +0000
commit0c03f9d1a434ca591f40980eff388daff653ce0d (patch)
tree00bd27f374d46c7825a372e7892de140c1a9e5e4 /pjmedia
parent1342a94d5cbd8820f83ef59adcb18d14f566a3de (diff)
Misc (re #1630): Fixing warnings about variable set but not used with recent gcc
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4728 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjmedia')
-rw-r--r--pjmedia/src/pjmedia-audiodev/bb10_dev.c11
-rw-r--r--pjmedia/src/pjmedia/echo_suppress.c91
-rw-r--r--pjmedia/src/pjmedia/jbuf.c215
-rw-r--r--pjmedia/src/pjmedia/stream.c298
-rw-r--r--pjmedia/src/pjmedia/transport_srtp.c159
-rw-r--r--pjmedia/src/test/jbuf_test.c42
6 files changed, 408 insertions, 408 deletions
diff --git a/pjmedia/src/pjmedia-audiodev/bb10_dev.c b/pjmedia/src/pjmedia-audiodev/bb10_dev.c
index cf8c1b4e..89b3f2c8 100644
--- a/pjmedia/src/pjmedia-audiodev/bb10_dev.c
+++ b/pjmedia/src/pjmedia-audiodev/bb10_dev.c
@@ -500,7 +500,7 @@ static int pb_thread_func (void *arg)
status.status));
if (status.status == SND_PCM_STATUS_READY ||
status.status == SND_PCM_STATUS_UNDERRUN ||
- status.status == SND_PCM_STATUS_ERROR )
+ status.status == SND_PCM_STATUS_ERROR )
{
if (snd_pcm_plugin_prepare (stream->pb_pcm,
SND_PCM_CHANNEL_PLAYBACK) < 0)
@@ -777,7 +777,7 @@ static pj_status_t bb10_open_playback (struct bb10_stream *stream,
TRACE_((THIS_FILE, "bb10_open_playback: pb_frames = %d clock = %d",
stream->pb_frames, param->clock_rate));
-
+
return PJ_SUCCESS;
}
@@ -863,6 +863,7 @@ static pj_status_t bb10_open_capture (struct bb10_stream *stream,
}
frame_size = setup.buf.block.frag_size;
+ PJ_UNUSED_ARG(frame_size); /* Warning about unused var */
/* Set clock rate */
rate = param->clock_rate;
@@ -961,7 +962,7 @@ static pj_status_t bb10_factory_create_stream(pjmedia_aud_dev_factory *f,
}
-/*
+/*
* API: get running parameter
* based on ALSA template
*/
@@ -980,7 +981,7 @@ static pj_status_t bb10_stream_get_param(pjmedia_aud_stream *s,
/*
* API: get capability
- * based on ALSA template
+ * based on ALSA template
*/
static pj_status_t bb10_stream_get_cap(pjmedia_aud_stream *s,
pjmedia_aud_dev_cap cap,
@@ -1042,7 +1043,7 @@ static pj_status_t bb10_stream_set_cap(pjmedia_aud_stream *strm,
if (route == PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER) {
ret = bb10_initialize_playback_ctrl(stream,true);
} else {
- ret = bb10_initialize_playback_ctrl(stream,false);
+ ret = bb10_initialize_playback_ctrl(stream,false);
}
return ret;
diff --git a/pjmedia/src/pjmedia/echo_suppress.c b/pjmedia/src/pjmedia/echo_suppress.c
index ec699d71..c9ff92e4 100644
--- a/pjmedia/src/pjmedia/echo_suppress.c
+++ b/pjmedia/src/pjmedia/echo_suppress.c
@@ -1,5 +1,5 @@
/* $Id$ */
-/*
+/*
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
*
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <pjmedia/types.h>
#include <pjmedia/alaw_ulaw.h>
@@ -77,6 +77,16 @@
#if 0
# define TRACE_(expr) PJ_LOG(5,expr)
+
+static const char *state_names[] =
+{
+ "Null",
+ "local talking",
+ "remote silent",
+ "doubletalk",
+ "remote talking"
+};
+
#else
# define TRACE_(expr)
#endif
@@ -125,23 +135,14 @@ typedef enum talk_state
ST_REM_TALK
} talk_state_t;
-static const char *state_names[] =
-{
- "Null",
- "local talking",
- "remote silent",
- "doubletalk",
- "remote talking"
-};
-
/* Description:
The echo suppressor tries to find the position of echoed signal by looking
- at the correlation between signal played to the speaker (played signal)
+ at the correlation between signal played to the speaker (played signal)
and the signal captured from the microphone (recorded signal).
- To do this, it first divides the frames (from mic and speaker) into
+ To do this, it first divides the frames (from mic and speaker) into
segments, calculate the audio level of the segment, and save the level
information in the playback and record history (play_hist and rec_hist
respectively).
@@ -150,7 +151,7 @@ static const char *state_names[] =
is put in the last position of the array.
The record history size is as large as the template size (tmpl_cnt), since
- we will use the record history as the template to find the best matching
+ we will use the record history as the template to find the best matching
position in the playback history.
Here is the record history buffer:
@@ -187,7 +188,7 @@ static const char *state_names[] =
to the mic signal. The lower the correlation value the better (i.e. more
similar) the signal is. The correlation value is done over the template
duration.
- - the gain scaling factor, that is the ratio between mic signal and
+ - the gain scaling factor, that is the ratio between mic signal and
speaker signal. The ES calculates both the minimum and average ratios.
The ES calculates both the values above for every tail position in the
@@ -209,7 +210,7 @@ static const char *state_names[] =
Processing:
- Once learning is done, the ES will change the level of the mic signal
+ Once learning is done, the ES will change the level of the mic signal
depending on the state of the conversation and according to the ratio that
has been found in the learning phase above.
@@ -263,7 +264,7 @@ typedef struct echo_supp
/*
- * Create.
+ * Create.
*/
PJ_DEF(pj_status_t) echo_supp_create( pj_pool_t *pool,
unsigned clock_rate,
@@ -292,32 +293,32 @@ PJ_DEF(pj_status_t) echo_supp_create( pj_pool_t *pool,
ec->tail_cnt = (pj_uint16_t)(tail_ms / SEGMENT_PTIME);
ec->play_hist_cnt = (pj_uint16_t)(ec->tail_cnt+ec->templ_cnt);
- ec->max_calc = (pj_uint16_t)(MAX_CALC_DURATION_SEC * clock_rate /
+ ec->max_calc = (pj_uint16_t)(MAX_CALC_DURATION_SEC * clock_rate /
ec->samples_per_segment);
- ec->rec_hist = (pj_uint16_t*)
+ ec->rec_hist = (pj_uint16_t*)
pj_pool_alloc(pool, ec->templ_cnt *
sizeof(ec->rec_hist[0]));
/* Note: play history has twice number of elements */
- ec->play_hist = (pj_uint16_t*)
+ ec->play_hist = (pj_uint16_t*)
pj_pool_alloc(pool, ec->play_hist_cnt *
sizeof(ec->play_hist[0]));
ec->corr_sum = (float*)
- pj_pool_alloc(pool, ec->tail_cnt *
+ pj_pool_alloc(pool, ec->tail_cnt *
sizeof(ec->corr_sum[0]));
ec->tmp_corr = (float*)
- pj_pool_alloc(pool, ec->tail_cnt *
+ pj_pool_alloc(pool, ec->tail_cnt *
sizeof(ec->tmp_corr[0]));
ec->min_factor = (float*)
- pj_pool_alloc(pool, ec->tail_cnt *
+ pj_pool_alloc(pool, ec->tail_cnt *
sizeof(ec->min_factor[0]));
ec->avg_factor = (float*)
- pj_pool_alloc(pool, ec->tail_cnt *
+ pj_pool_alloc(pool, ec->tail_cnt *
sizeof(ec->avg_factor[0]));
ec->tmp_factor = (float*)
- pj_pool_alloc(pool, ec->tail_cnt *
+ pj_pool_alloc(pool, ec->tail_cnt *
sizeof(ec->tmp_factor[0]));
echo_supp_reset(ec);
@@ -327,7 +328,7 @@ PJ_DEF(pj_status_t) echo_supp_create( pj_pool_t *pool,
/*
- * Destroy.
+ * Destroy.
*/
PJ_DEF(pj_status_t) echo_supp_destroy(void *state)
{
@@ -393,14 +394,14 @@ PJ_DEF(void) echo_supp_soft_reset(void *state)
/* Set state */
-static void echo_supp_set_state(echo_supp *ec, talk_state_t state,
+static void echo_supp_set_state(echo_supp *ec, talk_state_t state,
unsigned level)
{
PJ_UNUSED_ARG(level);
if (state != ec->talk_state) {
- TRACE_((THIS_FILE, "[%03d.%03d] %s --> %s, level=%u",
- (ec->update_cnt * SEGMENT_PTIME / 1000),
+ TRACE_((THIS_FILE, "[%03d.%03d] %s --> %s, level=%u",
+ (ec->update_cnt * SEGMENT_PTIME / 1000),
((ec->update_cnt * SEGMENT_PTIME) % 1000),
state_names[ec->talk_state],
state_names[state], level));
@@ -469,9 +470,9 @@ static void echo_supp_update(echo_supp *ec, pj_int16_t *rec_frm,
ec->sum_rec_level += ec->rec_hist[i];
} else {
/* Update from previous calculation */
- ec->sum_rec_level = ec->sum_rec_level - old_rec_frm_level +
+ ec->sum_rec_level = ec->sum_rec_level - old_rec_frm_level +
ec->rec_hist[ec->templ_cnt-1];
- ec->rec_corr = ec->rec_corr - ((float)ec->rec_hist[0] /
+ ec->rec_corr = ec->rec_corr - ((float)ec->rec_hist[0] /
old_rec_frm_level) +
((float)ec->rec_hist[ec->templ_cnt-1] /
ec->rec_hist[ec->templ_cnt-2]);
@@ -482,8 +483,8 @@ static void echo_supp_update(echo_supp *ec, pj_int16_t *rec_frm,
* array since we may bail out early if the conversation state is not good
* to detect echo.
*/
- /*
- * First phase: do full calculation for the first position
+ /*
+ * First phase: do full calculation for the first position
*/
if (ec->sum_play_level0 == 0) {
/* Buffer has just been filled up, do full calculation */
@@ -500,9 +501,9 @@ static void echo_supp_update(echo_supp *ec, pj_int16_t *rec_frm,
ec->play_corr0 = play_corr;
} else {
/* Update from previous calculation */
- ec->sum_play_level0 = ec->sum_play_level0 - old_play_frm_level +
+ ec->sum_play_level0 = ec->sum_play_level0 - old_play_frm_level +
ec->play_hist[ec->templ_cnt-1];
- ec->play_corr0 = ec->play_corr0 - ((float)ec->play_hist[0] /
+ ec->play_corr0 = ec->play_corr0 - ((float)ec->play_hist[0] /
old_play_frm_level) +
((float)ec->play_hist[ec->templ_cnt-1] /
ec->play_hist[ec->templ_cnt-2]);
@@ -584,7 +585,7 @@ static void echo_supp_update(echo_supp *ec, pj_int16_t *rec_frm,
/* Update the min and avg gain factor for this tail position */
if (ec->tmp_factor[i] < ec->min_factor[i])
ec->min_factor[i] = ec->tmp_factor[i];
- ec->avg_factor[i] = ((ec->avg_factor[i] * ec->tail_cnt) +
+ ec->avg_factor[i] = ((ec->avg_factor[i] * ec->tail_cnt) +
ec->tmp_factor[i]) /
(ec->tail_cnt + 1);
@@ -609,7 +610,7 @@ static void echo_supp_update(echo_supp *ec, pj_int16_t *rec_frm,
imin = (int)(ec->min_factor[ec->tail_index] * 1000);
iavg = (int)(ec->avg_factor[ec->tail_index] * 1000);
- PJ_LOG(4,(THIS_FILE,
+ PJ_LOG(4,(THIS_FILE,
"Echo suppressor updated at t=%03d.%03ds, echo tail=%d msec"
", factor min/avg=%d.%03d/%d.%03d",
(duration/1000), (duration%1000),
@@ -633,7 +634,7 @@ static void echo_supp_update(echo_supp *ec, pj_int16_t *rec_frm,
imin = (int)(ec->min_factor[ec->tail_index] * 1000);
iavg = (int)(ec->avg_factor[ec->tail_index] * 1000);
- PJ_LOG(4,(THIS_FILE,
+ PJ_LOG(4,(THIS_FILE,
"Echo suppressor learning done at t=%03d.%03ds, tail=%d ms"
", factor min/avg=%d.%03d/%d.%03d",
(duration/1000), (duration%1000),
@@ -646,7 +647,7 @@ static void echo_supp_update(echo_supp *ec, pj_int16_t *rec_frm,
/* Amplify frame */
-static void amplify_frame(pj_int16_t *frm, unsigned length,
+static void amplify_frame(pj_int16_t *frm, unsigned length,
pj_ufloat_t factor)
{
unsigned i;
@@ -656,7 +657,7 @@ static void amplify_frame(pj_int16_t *frm, unsigned length,
}
}
-/*
+/*
* Perform echo cancellation.
*/
PJ_DEF(pj_status_t) echo_supp_cancel_echo( void *state,
@@ -709,8 +710,8 @@ PJ_DEF(pj_status_t) echo_supp_cancel_echo( void *state,
/* Lookup in playback history to get max speaker level, to see
* if remote user is currently talking
*/
- for (i=ec->play_hist_cnt -lookup_cnt -tail_cnt;
- i<ec->play_hist_cnt-tail_cnt; ++i)
+ for (i=ec->play_hist_cnt -lookup_cnt -tail_cnt;
+ i<ec->play_hist_cnt-tail_cnt; ++i)
{
if (ec->play_hist[i] > play_level)
play_level = ec->play_hist[i];
@@ -732,7 +733,7 @@ PJ_DEF(pj_status_t) echo_supp_cancel_echo( void *state,
echo_supp_set_state(ec, ST_DOUBLETALK, rec_level);
} else {
/* Speaker is active, but we've picked up large signal in
- * the microphone. Assume that this is an echo, so bring
+ * the microphone. Assume that this is an echo, so bring
* the level down to minimum too.
*/
factor = ec->min_factor[ec->tail_index] / 2;
@@ -762,7 +763,7 @@ PJ_DEF(pj_status_t) echo_supp_cancel_echo( void *state,
factor = (factor + ec->last_factor*19) / 20;
/* Amplify frame */
- amplify_frame(rec_frm, ec->samples_per_frame,
+ amplify_frame(rec_frm, ec->samples_per_frame,
pj_ufloat_from_float(factor));
ec->last_factor = factor;
@@ -774,7 +775,7 @@ PJ_DEF(pj_status_t) echo_supp_cancel_echo( void *state,
level = pjmedia_linear2ulaw(level) ^ 0xFF;
/* Accumulate average echo residue to see the ES effectiveness */
- ec->residue = ((ec->residue * ec->running_cnt) + level) /
+ ec->residue = ((ec->residue * ec->running_cnt) + level) /
(ec->running_cnt + 1);
++ec->running_cnt;
diff --git a/pjmedia/src/pjmedia/jbuf.c b/pjmedia/src/pjmedia/jbuf.c
index e7fdfe42..373352f6 100644
--- a/pjmedia/src/pjmedia/jbuf.c
+++ b/pjmedia/src/pjmedia/jbuf.c
@@ -1,5 +1,5 @@
/* $Id$ */
-/*
+/*
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
*
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Based on implementation kindly contributed by Switchlab, Ltd.
@@ -35,7 +35,7 @@
/* Invalid sequence number, used as the initial value. */
#define INVALID_OFFSET -9999
-/* Maximum burst length, whenever an operation is bursting longer than
+/* Maximum burst length, whenever an operation is bursting longer than
* this value, JB will assume that the opposite operation was idle.
*/
#define MAX_BURST_MSEC 1000
@@ -46,8 +46,8 @@
#define INIT_CYCLE 10
-/* Minimal difference between JB size and 2*burst-level to perform
- * JB shrinking in static discard algorithm.
+/* Minimal difference between JB size and 2*burst-level to perform
+ * JB shrinking in static discard algorithm.
*/
#define STA_DISC_SAFE_SHRINKING_DIFF 1
@@ -67,13 +67,13 @@ typedef struct jb_framelist_t
pj_size_t *content_len; /**< frame length array */
pj_uint32_t *bit_info; /**< frame bit info array */
pj_uint32_t *ts; /**< timestamp array */
-
+
/* States */
unsigned head; /**< index of head, pointed frame
will be returned by next GET */
- unsigned size; /**< current size of framelist,
+ unsigned size; /**< current size of framelist,
including discarded frames. */
- unsigned discarded_num; /**< current number of discarded
+ unsigned discarded_num; /**< current number of discarded
frames. */
int origin; /**< original index of flist_head */
@@ -91,14 +91,14 @@ struct pjmedia_jbuf
pj_str_t jb_name; /**< jitter buffer name */
pj_size_t jb_frame_size; /**< frame size */
unsigned jb_frame_ptime; /**< frame duration. */
- pj_size_t jb_max_count; /**< capacity of jitter buffer,
+ pj_size_t jb_max_count; /**< capacity of jitter buffer,
in frames */
int jb_init_prefetch; /**< Initial prefetch */
int jb_min_prefetch; /**< Minimum allowable prefetch */
int jb_max_prefetch; /**< Maximum allowable prefetch */
int jb_max_burst; /**< maximum possible burst, whenever
- burst exceeds this value, it
- won't be included in level
+ burst exceeds this value, it
+ won't be included in level
calculation */
int jb_min_shrink_gap; /**< How often can we shrink */
discard_algo jb_discard_algo; /**< Discard algorithm */
@@ -107,27 +107,27 @@ struct pjmedia_jbuf
jb_framelist_t jb_framelist; /**< the buffer */
/* States */
- int jb_level; /**< delay between source &
- destination (calculated according
- of the number of burst get/put
+ int jb_level; /**< delay between source &
+ destination (calculated according
+ of the number of burst get/put
operations) */
- int jb_max_hist_level; /**< max level during the last level
+ int jb_max_hist_level; /**< max level during the last level
calculations */
- int jb_stable_hist; /**< num of times the delay has been
+ int jb_stable_hist; /**< num of times the delay has been
lower then the prefetch num */
- int jb_last_op; /**< last operation executed
+ int jb_last_op; /**< last operation executed
(put/get) */
int jb_eff_level; /**< effective burst level */
- int jb_prefetch; /**< no. of frame to insert before
- removing some (at the beginning
- of the framelist->content
+ int jb_prefetch; /**< no. of frame to insert before
+ removing some (at the beginning
+ of the framelist->content
operation), the value may be
continuously updated based on
current frame burst level. */
pj_bool_t jb_prefetching; /**< flag if jbuf is prefetching. */
- int jb_status; /**< status is 'init' until the first
+ int jb_status; /**< status is 'init' until the first
'put' operation */
- int jb_init_cycle_cnt; /**< status is 'init' until the first
+ int jb_init_cycle_cnt; /**< status is 'init' until the first
'put' operation */
int jb_discard_ref; /**< Seq # of last frame deleted or
@@ -136,7 +136,7 @@ struct pjmedia_jbuf
to perform discard (in frm) */
/* Statistics */
- pj_math_stat jb_delay; /**< Delay statistics of jitter buffer
+ pj_math_stat jb_delay; /**< Delay statistics of jitter buffer
(in ms) */
pj_math_stat jb_burst; /**< Burst statistics (in frames) */
unsigned jb_lost; /**< Number of lost frames. */
@@ -164,7 +164,7 @@ struct pjmedia_jbuf
-/* Enabling this would log the jitter buffer state about once per
+/* Enabling this would log the jitter buffer state about once per
* second.
*/
#if 0
@@ -180,7 +180,7 @@ static unsigned jb_framelist_remove_head(jb_framelist_t *framelist,
static pj_status_t jb_framelist_init( pj_pool_t *pool,
jb_framelist_t *framelist,
unsigned frame_size,
- unsigned max_count)
+ unsigned max_count)
{
PJ_ASSERT_RETURN(pool && framelist, PJ_EINVAL);
@@ -188,24 +188,24 @@ static pj_status_t jb_framelist_init( pj_pool_t *pool,
framelist->frame_size = frame_size;
framelist->max_count = max_count;
- framelist->content = (char*)
+ framelist->content = (char*)
pj_pool_alloc(pool,
- framelist->frame_size*
+ framelist->frame_size*
framelist->max_count);
framelist->frame_type = (int*)
- pj_pool_alloc(pool,
+ pj_pool_alloc(pool,
sizeof(framelist->frame_type[0])*
framelist->max_count);
framelist->content_len = (pj_size_t*)
- pj_pool_alloc(pool,
+ pj_pool_alloc(pool,
sizeof(framelist->content_len[0])*
framelist->max_count);
framelist->bit_info = (pj_uint32_t*)
- pj_pool_alloc(pool,
+ pj_pool_alloc(pool,
sizeof(framelist->bit_info[0])*
framelist->max_count);
framelist->ts = (pj_uint32_t*)
- pj_pool_alloc(pool,
+ pj_pool_alloc(pool,
sizeof(framelist->ts[0])*
framelist->max_count);
@@ -213,13 +213,13 @@ static pj_status_t jb_framelist_init( pj_pool_t *pool,
}
-static pj_status_t jb_framelist_destroy(jb_framelist_t *framelist)
+static pj_status_t jb_framelist_destroy(jb_framelist_t *framelist)
{
PJ_UNUSED_ARG(framelist);
return PJ_SUCCESS;
}
-static pj_status_t jb_framelist_reset(jb_framelist_t *framelist)
+static pj_status_t jb_framelist_reset(jb_framelist_t *framelist)
{
framelist->head = 0;
framelist->origin = INVALID_OFFSET;
@@ -227,39 +227,39 @@ static pj_status_t jb_framelist_reset(jb_framelist_t *framelist)
framelist->discarded_num = 0;
- //pj_bzero(framelist->content,
- // framelist->frame_size *
+ //pj_bzero(framelist->content,
+ // framelist->frame_size *
// framelist->max_count);
pj_memset(framelist->frame_type,
PJMEDIA_JB_MISSING_FRAME,
- sizeof(framelist->frame_type[0]) *
+ sizeof(framelist->frame_type[0]) *
framelist->max_count);
- pj_bzero(framelist->content_len,
- sizeof(framelist->content_len[0]) *
+ pj_bzero(framelist->content_len,
+ sizeof(framelist->content_len[0]) *
framelist->max_count);
//pj_bzero(framelist->bit_info,
- // sizeof(framelist->bit_info[0]) *
+ // sizeof(framelist->bit_info[0]) *
// framelist->max_count);
return PJ_SUCCESS;
}
-static unsigned jb_framelist_size(const jb_framelist_t *framelist)
+static unsigned jb_framelist_size(const jb_framelist_t *framelist)
{
return framelist->size;
}
-static unsigned jb_framelist_eff_size(const jb_framelist_t *framelist)
+static unsigned jb_framelist_eff_size(const jb_framelist_t *framelist)
{
return (framelist->size - framelist->discarded_num);
}
-static int jb_framelist_origin(const jb_framelist_t *framelist)
+static int jb_framelist_origin(const jb_framelist_t *framelist)
{
return framelist->origin;
}
@@ -270,7 +270,7 @@ static pj_bool_t jb_framelist_get(jb_framelist_t *framelist,
pjmedia_jb_frame_type *p_type,
pj_uint32_t *bit_info,
pj_uint32_t *ts,
- int *seq)
+ int *seq)
{
if (framelist->size) {
pj_bool_t prev_discarded = PJ_FALSE;
@@ -295,11 +295,11 @@ static pj_bool_t jb_framelist_get(jb_framelist_t *framelist,
if (bit_info)
*bit_info = 0;
} else {
- pj_memcpy(frame,
- framelist->content +
+ pj_memcpy(frame,
+ framelist->content +
framelist->head * framelist->frame_size,
framelist->frame_size);
- *p_type = (pjmedia_jb_frame_type)
+ *p_type = (pjmedia_jb_frame_type)
framelist->frame_type[framelist->head];
if (size)
*size = framelist->content_len[framelist->head];
@@ -311,7 +311,7 @@ static pj_bool_t jb_framelist_get(jb_framelist_t *framelist,
if (seq)
*seq = framelist->origin;
- //pj_bzero(framelist->content +
+ //pj_bzero(framelist->content +
// framelist->head * framelist->frame_size,
// framelist->frame_size);
framelist->frame_type[framelist->head] = PJMEDIA_JB_MISSING_FRAME;
@@ -322,7 +322,7 @@ static pj_bool_t jb_framelist_get(jb_framelist_t *framelist,
framelist->origin++;
framelist->head = (framelist->head + 1) % framelist->max_count;
framelist->size--;
-
+
return PJ_TRUE;
}
}
@@ -341,7 +341,7 @@ static pj_bool_t jb_framelist_peek(jb_framelist_t *framelist,
pjmedia_jb_frame_type *type,
pj_uint32_t *bit_info,
pj_uint32_t *ts,
- int *seq)
+ int *seq)
{
unsigned pos, idx;
@@ -366,7 +366,7 @@ static pj_bool_t jb_framelist_peek(jb_framelist_t *framelist,
if (frame)
*frame = framelist->content + pos*framelist->frame_size;
if (type)
- *type = (pjmedia_jb_frame_type)
+ *type = (pjmedia_jb_frame_type)
framelist->frame_type[pos];
if (size)
*size = framelist->content_len[pos];
@@ -383,9 +383,9 @@ static pj_bool_t jb_framelist_peek(jb_framelist_t *framelist,
/* Remove oldest frames as many as param 'count' */
static unsigned jb_framelist_remove_head(jb_framelist_t *framelist,
- unsigned count)
+ unsigned count)
{
- if (count > framelist->size)
+ if (count > framelist->size)
count = framelist->size;
if (count) {
@@ -409,7 +409,7 @@ static unsigned jb_framelist_remove_head(jb_framelist_t *framelist,
}
}
- //pj_bzero(framelist->content +
+ //pj_bzero(framelist->content +
// framelist->head * framelist->frame_size,
// step1*framelist->frame_size);
pj_memset(framelist->frame_type+framelist->head,
@@ -439,7 +439,7 @@ static unsigned jb_framelist_remove_head(jb_framelist_t *framelist,
framelist->head = (framelist->head + count) % framelist->max_count;
framelist->size -= count;
}
-
+
return count;
}
@@ -548,9 +548,9 @@ enum pjmedia_jb_op
};
-PJ_DEF(pj_status_t) pjmedia_jbuf_create(pj_pool_t *pool,
+PJ_DEF(pj_status_t) pjmedia_jbuf_create(pj_pool_t *pool,
const pj_str_t *name,
- unsigned frame_size,
+ unsigned frame_size,
unsigned ptime,
unsigned max_count,
pjmedia_jbuf **p_jb)
@@ -596,7 +596,7 @@ PJ_DEF(pj_status_t) pjmedia_jbuf_set_fixed( pjmedia_jbuf *jb,
PJ_ASSERT_RETURN(jb, PJ_EINVAL);
PJ_ASSERT_RETURN(prefetch <= jb->jb_max_count, PJ_EINVAL);
- jb->jb_min_prefetch = jb->jb_max_prefetch =
+ jb->jb_min_prefetch = jb->jb_max_prefetch =
jb->jb_prefetch = jb->jb_init_prefetch = prefetch;
pjmedia_jbuf_set_discard(jb, PJMEDIA_JB_DISCARD_NONE);
@@ -675,12 +675,12 @@ PJ_DEF(pj_status_t) pjmedia_jbuf_destroy(pjmedia_jbuf *jb)
" delay (min/max/avg/dev)=%d/%d/%d/%d ms\n"
" burst (min/max/avg/dev)=%d/%d/%d/%d frames\n"
" lost=%d discard=%d empty=%d",
- jb_framelist_size(&jb->jb_framelist),
- jb_framelist_eff_size(&jb->jb_framelist),
+ jb_framelist_size(&jb->jb_framelist),
+ jb_framelist_eff_size(&jb->jb_framelist),
jb->jb_prefetch, jb->jb_eff_level,
- jb->jb_delay.min, jb->jb_delay.max, jb->jb_delay.mean,
+ jb->jb_delay.min, jb->jb_delay.max, jb->jb_delay.mean,
pj_math_stat_get_stddev(&jb->jb_delay),
- jb->jb_burst.min, jb->jb_burst.max, jb->jb_burst.mean,
+ jb->jb_burst.min, jb->jb_burst.max, jb->jb_burst.mean,
pj_math_stat_get_stddev(&jb->jb_burst),
jb->jb_lost, jb->jb_discard, jb->jb_empty));
@@ -704,14 +704,14 @@ static void jbuf_calculate_jitter(pjmedia_jbuf *jb)
if (jb->jb_level < jb->jb_eff_level) {
enum { STABLE_HISTORY_LIMIT = 20 };
-
+
jb->jb_stable_hist++;
-
- /* Only update the effective level (and prefetch) if 'stable'
+
+ /* Only update the effective level (and prefetch) if 'stable'
* condition is reached (not just short time impulse)
*/
if (jb->jb_stable_hist > STABLE_HISTORY_LIMIT) {
-
+
diff = (jb->jb_eff_level - jb->jb_max_hist_level) / 3;
if (diff < 1)
@@ -723,7 +723,7 @@ static void jbuf_calculate_jitter(pjmedia_jbuf *jb)
/* Update prefetch based on level */
if (jb->jb_init_prefetch) {
jb->jb_prefetch = jb->jb_eff_level;
- if (jb->jb_prefetch < jb->jb_min_prefetch)
+ if (jb->jb_prefetch < jb->jb_min_prefetch)
jb->jb_prefetch = jb->jb_min_prefetch;
if (jb->jb_prefetch > jb->jb_max_prefetch)
jb->jb_prefetch = jb->jb_max_prefetch;
@@ -735,6 +735,7 @@ static void jbuf_calculate_jitter(pjmedia_jbuf *jb)
TRACE__((jb->jb_name.ptr,"jb updated(1), lvl=%d pre=%d, size=%d",
jb->jb_eff_level, jb->jb_prefetch, cur_size));
+ PJ_UNUSED_ARG(cur_size); /* Warning about unused var */
}
}
@@ -758,7 +759,7 @@ static void jbuf_calculate_jitter(pjmedia_jbuf *jb)
/* Do not reset max_hist_level. */
//jb->jb_max_hist_level = 0;
- TRACE__((jb->jb_name.ptr,"jb updated(2), lvl=%d pre=%d, size=%d",
+ TRACE__((jb->jb_name.ptr,"jb updated(2), lvl=%d pre=%d, size=%d",
jb->jb_eff_level, jb->jb_prefetch, cur_size));
}
@@ -777,11 +778,11 @@ static void jbuf_discard_static(pjmedia_jbuf *jb)
* its size is twice of current burst level, there can be drift.
*
* Moreover, normally drift level is quite low, so JB shouldn't need
- * to shrink aggresively, it will shrink maximum one frame per
- * PJMEDIA_JBUF_DISC_MIN_GAP ms. Theoritically, JB may handle drift level
+ * to shrink aggresively, it will shrink maximum one frame per
+ * PJMEDIA_JBUF_DISC_MIN_GAP ms. Theoritically, JB may handle drift level
* as much as = FRAME_PTIME/PJMEDIA_JBUF_DISC_MIN_GAP * 100%
*
- * Whenever there is drift, where PUT > GET, this method will keep
+ * Whenever there is drift, where PUT > GET, this method will keep
* the latency (JB size) as much as twice of burst level.
*/
@@ -796,8 +797,8 @@ static void jbuf_discard_static(pjmedia_jbuf *jb)
if (diff >= STA_DISC_SAFE_SHRINKING_DIFF) {
int seq_origin;
- /* Check and adjust jb_discard_ref, in case there was
- * seq restart
+ /* Check and adjust jb_discard_ref, in case there was
+ * seq restart
*/
seq_origin = jb_framelist_origin(&jb->jb_framelist);
if (seq_origin < jb->jb_discard_ref)
@@ -813,7 +814,7 @@ static void jbuf_discard_static(pjmedia_jbuf *jb)
jb->jb_discard_ref = jb_framelist_origin(&jb->jb_framelist);
jb->jb_discard += diff;
- TRACE__((jb->jb_name.ptr,
+ TRACE__((jb->jb_name.ptr,
"JB shrinking %d frame(s), cur size=%d", diff,
jb_framelist_eff_size(&jb->jb_framelist)));
}
@@ -845,7 +846,7 @@ static void jbuf_discard_progressive(pjmedia_jbuf *jb)
else if (burst_level >= PJMEDIA_JBUF_PRO_DISC_MAX_BURST)
T = PJMEDIA_JBUF_PRO_DISC_T2;
else
- T = PJMEDIA_JBUF_PRO_DISC_T1 +
+ T = PJMEDIA_JBUF_PRO_DISC_T1 +
(PJMEDIA_JBUF_PRO_DISC_T2 - PJMEDIA_JBUF_PRO_DISC_T1) *
(burst_level - PJMEDIA_JBUF_PRO_DISC_MIN_BURST) /
(PJMEDIA_JBUF_PRO_DISC_MAX_BURST-PJMEDIA_JBUF_PRO_DISC_MIN_BURST);
@@ -873,14 +874,14 @@ static void jbuf_discard_progressive(pjmedia_jbuf *jb)
/* Check if we need to discard now */
if (last_seq >= (jb->jb_discard_ref + (int)jb->jb_discard_dist)) {
int discard_seq;
-
+
discard_seq = jb->jb_discard_ref + jb->jb_discard_dist;
if (discard_seq < jb_framelist_origin(&jb->jb_framelist))
discard_seq = jb_framelist_origin(&jb->jb_framelist);
jb_framelist_discard(&jb->jb_framelist, discard_seq);
- TRACE__((jb->jb_name.ptr,
+ TRACE__((jb->jb_name.ptr,
"Discard #%d: ref=#%d dist=%d orig=%d size=%d/%d "
"burst=%d/%d",
discard_seq,
@@ -896,7 +897,7 @@ static void jbuf_discard_progressive(pjmedia_jbuf *jb)
jb->jb_discard_ref = discard_seq;
}
}
-
+
PJ_INLINE(void) jbuf_update(pjmedia_jbuf *jb, int oper)
{
@@ -904,8 +905,8 @@ PJ_INLINE(void) jbuf_update(pjmedia_jbuf *jb, int oper)
jb->jb_last_op = oper;
if (jb->jb_status == JB_STATUS_INITIALIZING) {
- /* Switch status 'initializing' -> 'processing' after some OP
- * switch cycles and current OP is GET (burst level is calculated
+ /* Switch status 'initializing' -> 'processing' after some OP
+ * switch cycles and current OP is GET (burst level is calculated
* based on PUT burst), so burst calculation is guaranted to be
* performed right after the status switching.
*/
@@ -921,10 +922,10 @@ PJ_INLINE(void) jbuf_update(pjmedia_jbuf *jb, int oper)
}
}
- /* Perform jitter calculation based on PUT burst-level only, since
+ /* Perform jitter calculation based on PUT burst-level only, since
* GET burst-level may not be accurate, e.g: when VAD is active.
* Note that when burst-level is too big, i.e: exceeds jb_max_burst,
- * the GET op may be idle, in this case, we better skip the jitter
+ * the GET op may be idle, in this case, we better skip the jitter
* calculation.
*/
if (oper == JB_OP_GET && jb->jb_level <= jb->jb_max_burst)
@@ -939,28 +940,28 @@ PJ_INLINE(void) jbuf_update(pjmedia_jbuf *jb, int oper)
}
}
-PJ_DEF(void) pjmedia_jbuf_put_frame( pjmedia_jbuf *jb,
- const void *frame,
- pj_size_t frame_size,
+PJ_DEF(void) pjmedia_jbuf_put_frame( pjmedia_jbuf *jb,
+ const void *frame,
+ pj_size_t frame_size,
int frame_seq)
{
pjmedia_jbuf_put_frame3(jb, frame, frame_size, 0, frame_seq, 0, NULL);
}
-PJ_DEF(void) pjmedia_jbuf_put_frame2(pjmedia_jbuf *jb,
- const void *frame,
- pj_size_t frame_size,
+PJ_DEF(void) pjmedia_jbuf_put_frame2(pjmedia_jbuf *jb,
+ const void *frame,
+ pj_size_t frame_size,
pj_uint32_t bit_info,
int frame_seq,
pj_bool_t *discarded)
{
- pjmedia_jbuf_put_frame3(jb, frame, frame_size, bit_info, frame_seq, 0,
+ pjmedia_jbuf_put_frame3(jb, frame, frame_size, bit_info, frame_seq, 0,
discarded);
}
-PJ_DEF(void) pjmedia_jbuf_put_frame3(pjmedia_jbuf *jb,
- const void *frame,
- pj_size_t frame_size,
+PJ_DEF(void) pjmedia_jbuf_put_frame3(pjmedia_jbuf *jb,
+ const void *frame,
+ pj_size_t frame_size,
pj_uint32_t bit_info,
int frame_seq,
pj_uint32_t ts,
@@ -977,7 +978,7 @@ PJ_DEF(void) pjmedia_jbuf_put_frame3(pjmedia_jbuf *jb,
status = jb_framelist_put_at(&jb->jb_framelist, frame_seq, frame,
(unsigned)min_frame_size, bit_info, ts,
PJMEDIA_JB_NORMAL_FRAME);
-
+
/* Jitter buffer is full, remove some older frames */
while (status == PJ_ETOOMANY) {
int distance;
@@ -1009,7 +1010,7 @@ PJ_DEF(void) pjmedia_jbuf_put_frame3(pjmedia_jbuf *jb,
if (status == PJ_SUCCESS) {
if (jb->jb_prefetching) {
- TRACE__((jb->jb_name.ptr, "PUT prefetch_cnt=%d/%d",
+ TRACE__((jb->jb_name.ptr, "PUT prefetch_cnt=%d/%d",
new_size, jb->jb_prefetch));
if (new_size >= jb->jb_prefetch)
jb->jb_prefetching = PJ_FALSE;
@@ -1023,8 +1024,8 @@ PJ_DEF(void) pjmedia_jbuf_put_frame3(pjmedia_jbuf *jb,
/*
* Get frame from jitter buffer.
*/
-PJ_DEF(void) pjmedia_jbuf_get_frame( pjmedia_jbuf *jb,
- void *frame,
+PJ_DEF(void) pjmedia_jbuf_get_frame( pjmedia_jbuf *jb,
+ void *frame,
char *p_frame_type)
{
pjmedia_jbuf_get_frame3(jb, frame, NULL, p_frame_type, NULL,
@@ -1034,8 +1035,8 @@ PJ_DEF(void) pjmedia_jbuf_get_frame( pjmedia_jbuf *jb,
/*
* Get frame from jitter buffer.
*/
-PJ_DEF(void) pjmedia_jbuf_get_frame2(pjmedia_jbuf *jb,
- void *frame,
+PJ_DEF(void) pjmedia_jbuf_get_frame2(pjmedia_jbuf *jb,
+ void *frame,
pj_size_t *size,
char *p_frame_type,
pj_uint32_t *bit_info)
@@ -1047,8 +1048,8 @@ PJ_DEF(void) pjmedia_jbuf_get_frame2(pjmedia_jbuf *jb,
/*
* Get frame from jitter buffer.
*/
-PJ_DEF(void) pjmedia_jbuf_get_frame3(pjmedia_jbuf *jb,
- void *frame,
+PJ_DEF(void) pjmedia_jbuf_get_frame3(pjmedia_jbuf *jb,
+ void *frame,
pj_size_t *size,
char *p_frame_type,
pj_uint32_t *bit_info,
@@ -1077,7 +1078,7 @@ PJ_DEF(void) pjmedia_jbuf_get_frame3(pjmedia_jbuf *jb,
pj_bool_t res;
/* Try to retrieve a frame from frame list */
- res = jb_framelist_get(&jb->jb_framelist, frame, size, &ftype,
+ res = jb_framelist_get(&jb->jb_framelist, frame, size, &ftype,
bit_info, ts, seq);
if (res) {
/* We've successfully retrieved a frame from the frame list, but
@@ -1096,7 +1097,7 @@ PJ_DEF(void) pjmedia_jbuf_get_frame3(pjmedia_jbuf *jb,
/* We've just retrieved one frame, so add one to cur_size */
cur_size = jb_framelist_eff_size(&jb->jb_framelist) + 1;
- pj_math_stat_update(&jb->jb_delay,
+ pj_math_stat_update(&jb->jb_delay,
cur_size*jb->jb_frame_ptime);
}
} else {
@@ -1128,16 +1129,16 @@ PJ_DEF(pj_status_t) pjmedia_jbuf_get_state( const pjmedia_jbuf *jb,
state->frame_size = (unsigned)jb->jb_frame_size;
state->min_prefetch = jb->jb_min_prefetch;
state->max_prefetch = jb->jb_max_prefetch;
-
+
state->burst = jb->jb_eff_level;
state->prefetch = jb->jb_prefetch;
state->size = jb_framelist_eff_size(&jb->jb_framelist);
-
+
state->avg_delay = jb->jb_delay.mean;
state->min_delay = jb->jb_delay.min;
state->max_delay = jb->jb_delay.max;
state->dev_delay = pj_math_stat_get_stddev(&jb->jb_delay);
-
+
state->avg_burst = jb->jb_burst.mean;
state->empty = jb->jb_empty;
state->discard = jb->jb_discard;
@@ -1149,8 +1150,8 @@ PJ_DEF(pj_status_t) pjmedia_jbuf_get_state( const pjmedia_jbuf *jb,
PJ_DEF(void) pjmedia_jbuf_peek_frame( pjmedia_jbuf *jb,
unsigned offset,
- const void **frame,
- pj_size_t *size,
+ const void **frame,
+ pj_size_t *size,
char *p_frm_type,
pj_uint32_t *bit_info,
pj_uint32_t *ts,
@@ -1170,7 +1171,7 @@ PJ_DEF(void) pjmedia_jbuf_peek_frame( pjmedia_jbuf *jb,
}
-PJ_DEF(unsigned) pjmedia_jbuf_remove_frame(pjmedia_jbuf *jb,
+PJ_DEF(unsigned) pjmedia_jbuf_remove_frame(pjmedia_jbuf *jb,
unsigned frame_cnt)
{
unsigned count, last_discard_num;
diff --git a/pjmedia/src/pjmedia/stream.c b/pjmedia/src/pjmedia/stream.c
index d051dc43..7ecb6388 100644
--- a/pjmedia/src/pjmedia/stream.c
+++ b/pjmedia/src/pjmedia/stream.c
@@ -1,5 +1,5 @@
/* $Id$ */
-/*
+/*
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
*
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <pjmedia/stream.h>
#include <pjmedia/errno.h>
@@ -184,16 +184,16 @@ struct pjmedia_stream
* This happens for example with G.722 and MPEG audio codecs.
*/
pj_bool_t has_g722_mpeg_bug;
- /**< Flag to specify whether
- normalization process
+ /**< Flag to specify whether
+ normalization process
is needed */
unsigned rtp_tx_ts_len_per_pkt;
/**< Normalized ts length per packet
- transmitted according to
+ transmitted according to
'erroneous' definition */
unsigned rtp_rx_ts_len_per_frame;
/**< Normalized ts length per frame
- received according to
+ received according to
'erroneous' definition */
unsigned rtp_rx_last_cnt;/**< Nb of frames in last pkt */
unsigned rtp_rx_check_cnt;
@@ -202,11 +202,11 @@ struct pjmedia_stream
#endif
#if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)
- pj_uint32_t rtcp_xr_last_tx; /**< RTCP XR tx time
+ pj_uint32_t rtcp_xr_last_tx; /**< RTCP XR tx time
in timestamp. */
pj_uint32_t rtcp_xr_interval; /**< Interval, in timestamp. */
- pj_sockaddr rtcp_xr_dest; /**< Additional remote RTCP XR
- dest. If sin_family is
+ pj_sockaddr rtcp_xr_dest; /**< Additional remote RTCP XR
+ dest. If sin_family is
zero, it will be ignored*/
unsigned rtcp_xr_dest_len; /**< Length of RTCP XR dest
address */
@@ -230,8 +230,8 @@ struct pjmedia_stream
/* RFC 2833 digit */
-static const char digitmap[16] = { '0', '1', '2', '3',
- '4', '5', '6', '7',
+static const char digitmap[16] = { '0', '1', '2', '3',
+ '4', '5', '6', '7',
'8', '9', '*', '#',
'A', 'B', 'C', 'D'};
@@ -284,7 +284,7 @@ PJ_INLINE(int) trace_jb_print_timestamp(char **buf, pj_ssize_t len)
return 0;
}
-PJ_INLINE(int) trace_jb_print_state(pjmedia_stream *stream,
+PJ_INLINE(int) trace_jb_print_state(pjmedia_stream *stream,
char **buf, pj_ssize_t len)
{
char *p = *buf;
@@ -459,7 +459,7 @@ static void send_keep_alive_packet(pjmedia_stream *stream)
pkt_len);
#else
-
+
PJ_UNUSED_ARG(stream);
#endif
@@ -497,12 +497,12 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
samples_required = PJMEDIA_PIA_SPF(&stream->port.info);
samples_per_frame = stream->codec_param.info.frm_ptime *
stream->codec_param.info.clock_rate *
- stream->codec_param.info.channel_cnt /
+ stream->codec_param.info.channel_cnt /
1000;
p_out_samp = (pj_int16_t*) frame->buf;
- for (samples_count=0; samples_count < samples_required;
- samples_count += samples_per_frame)
+ for (samples_count=0; samples_count < samples_required;
+ samples_count += samples_per_frame)
{
char frame_type;
pj_size_t frame_size;
@@ -517,11 +517,11 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
#endif
if (frame_type == PJMEDIA_JB_MISSING_FRAME) {
-
+
/* Activate PLC */
- if (stream->codec->op->recover &&
+ if (stream->codec->op->recover &&
stream->codec_param.setting.plc &&
- stream->plc_cnt < stream->max_plc_cnt)
+ stream->plc_cnt < stream->max_plc_cnt)
{
pjmedia_frame frame_out;
@@ -560,16 +560,16 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
/* Jitter buffer is empty. If this is the first "empty" state,
* activate PLC to smoothen the fade-out, otherwise zero
- * the frame.
+ * the frame.
*/
//Using this "if" will only invoke PLC for the first packet
//lost and not the subsequent ones.
//if (frame_type != stream->jb_last_frm) {
if (1) {
/* Activate PLC to smoothen the missing frame */
- if (stream->codec->op->recover &&
+ if (stream->codec->op->recover &&
stream->codec_param.setting.plc &&
- stream->plc_cnt < stream->max_plc_cnt)
+ stream->plc_cnt < stream->max_plc_cnt)
{
pjmedia_frame frame_out;
@@ -589,7 +589,7 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
stream->plc_cnt < stream->max_plc_cnt);
with_plc = ", plc invoked";
- }
+ }
}
if (samples_count < samples_required) {
@@ -603,8 +603,8 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
/* Report changing frame type event */
pjmedia_jbuf_get_state(stream->jb, &jb_state);
- PJ_LOG(5,(stream->port.info.name.ptr,
- "Jitter buffer empty (prefetch=%d)%s",
+ PJ_LOG(5,(stream->port.info.name.ptr,
+ "Jitter buffer empty (prefetch=%d)%s",
jb_state.prefetch, with_plc));
stream->jb_last_frm = frame_type;
@@ -622,9 +622,9 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
pj_assert(frame_type == PJMEDIA_JB_ZERO_PREFETCH_FRAME);
/* Always activate PLC when it's available.. */
- if (stream->codec->op->recover &&
+ if (stream->codec->op->recover &&
stream->codec_param.setting.plc &&
- stream->plc_cnt < stream->max_plc_cnt)
+ stream->plc_cnt < stream->max_plc_cnt)
{
pjmedia_frame frame_out;
@@ -644,7 +644,7 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
stream->plc_cnt < stream->max_plc_cnt);
with_plc = ", plc invoked";
- }
+ }
if (samples_count < samples_required) {
pjmedia_zero_samples(p_out_samp + samples_count,
@@ -657,8 +657,8 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
/* Report changing frame type event */
pjmedia_jbuf_get_state(stream->jb, &jb_state);
- PJ_LOG(5,(stream->port.info.name.ptr,
- "Jitter buffer is bufferring (prefetch=%d)%s",
+ PJ_LOG(5,(stream->port.info.name.ptr,
+ "Jitter buffer is bufferring (prefetch=%d)%s",
jb_state.prefetch, with_plc));
stream->jb_last_frm = frame_type;
@@ -683,19 +683,19 @@ static pj_status_t get_frame( pjmedia_port *port, pjmedia_frame *frame)
frame_out.buf = p_out_samp + samples_count;
frame_out.size = frame->size - samples_count*BYTES_PER_SAMPLE;
status = pjmedia_codec_decode( stream->codec, &frame_in,
- (unsigned)frame_out.size,
+ (unsigned)frame_out.size,
&frame_out);
if (status != 0) {
- LOGERR_((port->info.name.ptr, "codec decode() error",
+ LOGERR_((port->info.name.ptr, "codec decode() error",
status));
- pjmedia_zero_samples(p_out_samp + samples_count,
+ pjmedia_zero_samples(p_out_samp + samples_count,
samples_per_frame);
}
if (stream->jb_last_frm != frame_type) {
/* Report changing frame type event */
- PJ_LOG(5,(stream->port.info.name.ptr,
+ PJ_LOG(5,(stream->port.info.name.ptr,
"Jitter buffer starts returning normal frames "
"(after %d empty/lost)",
stream->jb_last_frm_cnt, stream->jb_last_frm));
@@ -752,7 +752,7 @@ static pj_status_t get_frame_ext( pjmedia_port *port, pjmedia_frame *frame)
samples_required = PJMEDIA_PIA_SPF(&stream->port.info);
samples_per_frame = stream->codec_param.info.frm_ptime *
stream->codec_param.info.clock_rate *
- stream->codec_param.info.channel_cnt /
+ stream->codec_param.info.channel_cnt /
1000;
pj_bzero(f, sizeof(pjmedia_frame_ext));
@@ -773,7 +773,7 @@ static pj_status_t get_frame_ext( pjmedia_port *port, pjmedia_frame *frame)
#if TRACE_JB
trace_jb_get(stream, frame_type, frame_size);
#endif
-
+
/* Unlock jitter buffer mutex. */
pj_mutex_unlock( stream->jb_mutex );
@@ -790,7 +790,7 @@ static pj_status_t get_frame_ext( pjmedia_port *port, pjmedia_frame *frame)
status = pjmedia_codec_decode( stream->codec, &frame_in,
0, frame);
if (status != PJ_SUCCESS) {
- LOGERR_((port->info.name.ptr, "codec decode() error",
+ LOGERR_((port->info.name.ptr, "codec decode() error",
status));
pjmedia_frame_ext_append_subframe(f, NULL, 0,
(pj_uint16_t)samples_per_frame);
@@ -798,7 +798,7 @@ static pj_status_t get_frame_ext( pjmedia_port *port, pjmedia_frame *frame)
if (stream->jb_last_frm != frame_type) {
/* Report changing frame type event */
- PJ_LOG(5,(stream->port.info.name.ptr,
+ PJ_LOG(5,(stream->port.info.name.ptr,
"Jitter buffer starts returning normal frames "
"(after %d empty/lost)",
stream->jb_last_frm_cnt, stream->jb_last_frm));
@@ -816,7 +816,7 @@ static pj_status_t get_frame_ext( pjmedia_port *port, pjmedia_frame *frame)
if (stream->codec->op->recover) {
status = pjmedia_codec_recover(stream->codec, 0, frame);
}
-
+
/* No PLC or PLC failed */
if (!stream->codec->op->recover || status != PJ_SUCCESS) {
pjmedia_frame_ext_append_subframe(f, NULL, 0,
@@ -839,8 +839,8 @@ static pj_status_t get_frame_ext( pjmedia_port *port, pjmedia_frame *frame)
/* Report changing frame type event */
pjmedia_jbuf_get_state(stream->jb, &jb_state);
- PJ_LOG(5,(stream->port.info.name.ptr,
- "Jitter buffer empty (prefetch=%d)",
+ PJ_LOG(5,(stream->port.info.name.ptr,
+ "Jitter buffer empty (prefetch=%d)",
jb_state.prefetch));
stream->jb_last_frm = frame_type;
@@ -858,7 +858,7 @@ static pj_status_t get_frame_ext( pjmedia_port *port, pjmedia_frame *frame)
/* Report changing frame type event */
pjmedia_jbuf_get_state(stream->jb, &jb_state);
- PJ_LOG(5,(stream->port.info.name.ptr,
+ PJ_LOG(5,(stream->port.info.name.ptr,
"Jitter buffer is bufferring (prefetch=%d)",
jb_state.prefetch));
@@ -878,23 +878,21 @@ static pj_status_t get_frame_ext( pjmedia_port *port, pjmedia_frame *frame)
/*
* Transmit DTMF
*/
-static void create_dtmf_payload(pjmedia_stream *stream,
+static void create_dtmf_payload(pjmedia_stream *stream,
struct pjmedia_frame *frame_out,
int forced_last, int *first, int *last)
{
pjmedia_rtp_dtmf_event *event;
struct dtmf *digit = &stream->tx_dtmf_buf[0];
- pj_uint32_t cur_ts;
pj_assert(sizeof(pjmedia_rtp_dtmf_event) == 4);
*first = *last = 0;
event = (pjmedia_rtp_dtmf_event*) frame_out->buf;
- cur_ts = pj_ntohl(stream->enc->rtp.out_hdr.ts);
if (digit->duration == 0) {
- PJ_LOG(5,(stream->port.info.name.ptr, "Sending DTMF digit id %c",
+ PJ_LOG(5,(stream->port.info.name.ptr, "Sending DTMF digit id %c",
digitmap[digit->event]));
*first = 1;
}
@@ -987,14 +985,14 @@ static pj_status_t send_rtcp(pjmedia_stream *stream,
/* Update RTCP XR with current JB states */
pjmedia_jbuf_get_state(stream->jb, &jb_state);
-
+
i = jb_state.avg_delay;
- status = pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
+ status = pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
PJMEDIA_RTCP_XR_INFO_JB_NOM, i);
pj_assert(status == PJ_SUCCESS);
i = jb_state.max_delay;
- status = pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
+ status = pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
PJMEDIA_RTCP_XR_INFO_JB_MAX, i);
pj_assert(status == PJ_SUCCESS);
@@ -1007,9 +1005,9 @@ static pj_status_t send_rtcp(pjmedia_stream *stream,
/* Send the RTCP XR to third-party destination if specified */
if (stream->rtcp_xr_dest_len) {
- pjmedia_transport_send_rtcp2(stream->transport,
+ pjmedia_transport_send_rtcp2(stream->transport,
&stream->rtcp_xr_dest,
- stream->rtcp_xr_dest_len,
+ stream->rtcp_xr_dest_len,
xr_pkt, xr_len);
}
@@ -1049,13 +1047,13 @@ static pj_status_t send_rtcp(pjmedia_stream *stream,
*/
static void check_tx_rtcp(pjmedia_stream *stream, pj_uint32_t timestamp)
{
- /* Note that timestamp may represent local or remote timestamp,
+ /* Note that timestamp may represent local or remote timestamp,
* depending on whether this function is called from put_frame()
* or get_frame().
*/
if (stream->rtcp_last_tx == 0) {
-
+
stream->rtcp_last_tx = timestamp;
} else if (timestamp - stream->rtcp_last_tx >= stream->rtcp_interval) {
@@ -1066,7 +1064,7 @@ static void check_tx_rtcp(pjmedia_stream *stream, pj_uint32_t timestamp)
if (stream->rtcp.xr_enabled) {
if (stream->rtcp_xr_last_tx == 0) {
stream->rtcp_xr_last_tx = timestamp;
- } else if (timestamp - stream->rtcp_xr_last_tx >=
+ } else if (timestamp - stream->rtcp_xr_last_tx >=
stream->rtcp_xr_interval)
{
with_xr = PJ_TRUE;
@@ -1130,7 +1128,7 @@ static void rebuffer(pjmedia_stream *stream,
}
/* How many samples are needed */
- count = stream->codec_param.info.enc_ptime *
+ count = stream->codec_param.info.enc_ptime *
PJMEDIA_PIA_SRATE(&stream->port.info) / 1000;
/* See if we have enough samples */
@@ -1153,7 +1151,7 @@ static void rebuffer(pjmedia_stream *stream,
/**
* put_frame_imp()
*/
-static pj_status_t put_frame_imp( pjmedia_port *port,
+static pj_status_t put_frame_imp( pjmedia_port *port,
pjmedia_frame *frame )
{
pjmedia_stream *stream = (pjmedia_stream*) port->port_data.pdata;
@@ -1174,7 +1172,7 @@ static pj_status_t put_frame_imp( pjmedia_port *port,
{
pj_uint32_t dtx_duration;
- dtx_duration = pj_timestamp_diff32(&stream->last_frm_ts_sent,
+ dtx_duration = pj_timestamp_diff32(&stream->last_frm_ts_sent,
&frame->timestamp);
if (dtx_duration >
PJMEDIA_STREAM_KA_INTERVAL * PJMEDIA_PIA_SRATE(&stream->port.info))
@@ -1193,7 +1191,7 @@ static pj_status_t put_frame_imp( pjmedia_port *port,
/* Number of samples in the frame */
if (frame->type == PJMEDIA_FRAME_TYPE_AUDIO)
- ts_len = ((unsigned)frame->size >> 1) /
+ ts_len = ((unsigned)frame->size >> 1) /
stream->codec_param.info.channel_cnt;
else if (frame->type == PJMEDIA_FRAME_TYPE_EXTENDED)
ts_len = PJMEDIA_PIA_SPF(&stream->port.info) /
@@ -1205,7 +1203,7 @@ static pj_status_t put_frame_imp( pjmedia_port *port,
stream->tx_duration += ts_len;
#if defined(PJMEDIA_HANDLE_G722_MPEG_BUG) && (PJMEDIA_HANDLE_G722_MPEG_BUG!=0)
- /* Handle special case for audio codec with RTP timestamp inconsistence
+ /* Handle special case for audio codec with RTP timestamp inconsistence
* e.g: G722, MPEG audio.
*/
if (stream->has_g722_mpeg_bug)
@@ -1224,7 +1222,7 @@ static pj_status_t put_frame_imp( pjmedia_port *port,
samples_per_frame = stream->enc_samples_per_pkt;
- /* If we have DTMF digits in the queue, transmit the digits.
+ /* If we have DTMF digits in the queue, transmit the digits.
* Otherwise encode the PCM buffer.
*/
if (stream->tx_dtmf_count) {
@@ -1234,17 +1232,17 @@ static pj_status_t put_frame_imp( pjmedia_port *port,
/* Encapsulate into RTP packet. Note that:
* - RTP marker should be set on the beginning of a new event
- * - RTP timestamp is constant for the same packet.
+ * - RTP timestamp is constant for the same packet.
*/
- status = pjmedia_rtp_encode_rtp( &channel->rtp,
- stream->tx_event_pt, first,
+ status = pjmedia_rtp_encode_rtp( &channel->rtp,
+ stream->tx_event_pt, first,
(int)frame_out.size,
- (first ? rtp_ts_len : 0),
- (const void**)&rtphdr,
+ (first ? rtp_ts_len : 0),
+ (const void**)&rtphdr,
&rtphdrlen);
if (last) {
- /* This is the last packet for the event.
+ /* This is the last packet for the event.
* Increment the RTP timestamp of the RTP session, for next
* RTP packets.
*/
@@ -1271,7 +1269,7 @@ static pj_status_t put_frame_imp( pjmedia_port *port,
stream->codec_param.info.frm_ptime *
stream->codec_param.info.channel_cnt *
stream->codec_param.info.clock_rate/1000 <
- PJ_ARRAY_SIZE(zero_frame))
+ PJ_ARRAY_SIZE(zero_frame))
{
pjmedia_frame silence_frame;
@@ -1282,23 +1280,23 @@ static pj_status_t put_frame_imp( pjmedia_port *port,
stream->codec_param.info.clock_rate / 1000;
silence_frame.type = PJMEDIA_FRAME_TYPE_AUDIO;
silence_frame.timestamp.u32.lo = pj_ntohl(stream->enc->rtp.out_hdr.ts);
-
+
/* Encode! */
status = pjmedia_codec_encode( stream->codec, &silence_frame,
- channel->out_pkt_size -
+ channel->out_pkt_size -
sizeof(pjmedia_rtp_hdr),
&frame_out);
if (status != PJ_SUCCESS) {
- LOGERR_((stream->port.info.name.ptr,
+ LOGERR_((stream->port.info.name.ptr,
"Codec encode() error", status));
return status;
}
/* Encapsulate. */
- status = pjmedia_rtp_encode_rtp( &channel->rtp,
- channel->pt, 0,
- (int)frame_out.size, rtp_ts_len,
- (const void**)&rtphdr,
+ status = pjmedia_rtp_encode_rtp( &channel->rtp,
+ channel->pt, 0,
+ (int)frame_out.size, rtp_ts_len,
+ (const void**)&rtphdr,
&rtphdrlen);
@@ -1308,41 +1306,41 @@ static pj_status_t put_frame_imp( pjmedia_port *port,
(frame->type == PJMEDIA_FRAME_TYPE_EXTENDED))
{
/* Encode! */
- status = pjmedia_codec_encode( stream->codec, frame,
- channel->out_pkt_size -
+ status = pjmedia_codec_encode( stream->codec, frame,
+ channel->out_pkt_size -
sizeof(pjmedia_rtp_hdr),
&frame_out);
if (status != PJ_SUCCESS) {
- LOGERR_((stream->port.info.name.ptr,
+ LOGERR_((stream->port.info.name.ptr,
"Codec encode() error", status));
return status;
}
/* Encapsulate. */
- status = pjmedia_rtp_encode_rtp( &channel->rtp,
- channel->pt, 0,
- (int)frame_out.size, rtp_ts_len,
- (const void**)&rtphdr,
+ status = pjmedia_rtp_encode_rtp( &channel->rtp,
+ channel->pt, 0,
+ (int)frame_out.size, rtp_ts_len,
+ (const void**)&rtphdr,
&rtphdrlen);
} else {
/* Just update RTP session's timestamp. */
- status = pjmedia_rtp_encode_rtp( &channel->rtp,
- 0, 0,
- 0, rtp_ts_len,
- (const void**)&rtphdr,
+ status = pjmedia_rtp_encode_rtp( &channel->rtp,
+ 0, 0,
+ 0, rtp_ts_len,
+ (const void**)&rtphdr,
&rtphdrlen);
}
if (status != PJ_SUCCESS) {
- LOGERR_((stream->port.info.name.ptr,
+ LOGERR_((stream->port.info.name.ptr,
"RTP encode_rtp() error", status));
return status;
}
- /* Check if now is the time to transmit RTCP SR/RR report.
+ /* Check if now is the time to transmit RTCP SR/RR report.
* We only do this when stream direction is not "decoding only", because
* when it is, check_tx_rtcp() will be handled by get_frame().
*/
@@ -1413,7 +1411,7 @@ static pj_status_t put_frame_imp( pjmedia_port *port,
* to transmit. This function encodes the PCM frame, pack it into
* RTP packet, and transmit to peer.
*/
-static pj_status_t put_frame( pjmedia_port *port,
+static pj_status_t put_frame( pjmedia_port *port,
pjmedia_frame *frame )
{
pjmedia_stream *stream = (pjmedia_stream*) port->port_data.pdata;
@@ -1461,7 +1459,7 @@ static pj_status_t put_frame( pjmedia_port *port,
* after transmitting for VAD_SUSPEND_SEC seconds.
*/
if (stream->vad_enabled != stream->codec_param.setting.vad &&
- (stream->tx_duration - stream->ts_vad_disabled) >
+ (stream->tx_duration - stream->ts_vad_disabled) >
PJMEDIA_PIA_SRATE(&stream->port.info) *
PJMEDIA_STREAM_VAD_SUSPEND_MSEC / 1000)
{
@@ -1478,7 +1476,7 @@ static pj_status_t put_frame( pjmedia_port *port,
pjmedia_frame tmp_rebuffer_frame;
pj_status_t status = PJ_SUCCESS;
- /* Copy original frame to temporary frame since we need
+ /* Copy original frame to temporary frame since we need
* to modify it.
*/
pj_memcpy(&tmp_rebuffer_frame, frame, sizeof(pjmedia_frame));
@@ -1545,7 +1543,7 @@ static void dump_bin(const char *buf, unsigned len)
/*
* Handle incoming DTMF digits.
*/
-static void handle_incoming_dtmf( pjmedia_stream *stream,
+static void handle_incoming_dtmf( pjmedia_stream *stream,
const void *payload, unsigned payloadlen)
{
pjmedia_rtp_dtmf_event *event = (pjmedia_rtp_dtmf_event*) payload;
@@ -1571,7 +1569,7 @@ static void handle_incoming_dtmf( pjmedia_stream *stream,
/* Ignore unknown event. */
if (event->event > 15) {
- PJ_LOG(5,(stream->port.info.name.ptr,
+ PJ_LOG(5,(stream->port.info.name.ptr,
"Ignored RTP pkt with bad DTMF event %d",
event->event));
return;
@@ -1590,7 +1588,7 @@ static void handle_incoming_dtmf( pjmedia_stream *stream,
*/
if (stream->dtmf_cb) {
- stream->dtmf_cb(stream, stream->dtmf_cb_user_data,
+ stream->dtmf_cb(stream, stream->dtmf_cb_user_data,
digitmap[event->event]);
} else {
@@ -1600,7 +1598,7 @@ static void handle_incoming_dtmf( pjmedia_stream *stream,
pj_mutex_lock(stream->jb_mutex);
if (stream->rx_dtmf_count >= PJ_ARRAY_SIZE(stream->rx_dtmf_buf)) {
/* DTMF digits overflow. Discard the oldest digit. */
- pj_array_erase(stream->rx_dtmf_buf,
+ pj_array_erase(stream->rx_dtmf_buf,
sizeof(stream->rx_dtmf_buf[0]),
stream->rx_dtmf_count, 0);
--stream->rx_dtmf_count;
@@ -1613,9 +1611,9 @@ static void handle_incoming_dtmf( pjmedia_stream *stream,
/*
* This callback is called by stream transport on receipt of packets
- * in the RTP socket.
+ * in the RTP socket.
*/
-static void on_rx_rtp( void *data,
+static void on_rx_rtp( void *data,
void *pkt,
pj_ssize_t bytes_read)
@@ -1631,7 +1629,7 @@ static void on_rx_rtp( void *data,
/* Check for errors */
if (bytes_read < 0) {
- LOGERR_((stream->port.info.name.ptr, "RTP recv() error",
+ LOGERR_((stream->port.info.name.ptr, "RTP recv() error",
(pj_status_t)-bytes_read));
return;
}
@@ -1659,9 +1657,9 @@ static void on_rx_rtp( void *data,
pjmedia_rtp_session_update2(&channel->rtp, hdr, &seq_st,
hdr->pt != stream->rx_event_pt);
if (seq_st.status.value) {
- TRC_ ((stream->port.info.name.ptr,
+ TRC_ ((stream->port.info.name.ptr,
"RTP status: badpt=%d, badssrc=%d, dup=%d, "
- "outorder=%d, probation=%d, restart=%d",
+ "outorder=%d, probation=%d, restart=%d",
seq_st.status.flag.badpt,
seq_st.status.flag.badssrc,
seq_st.status.flag.dup,
@@ -1736,8 +1734,8 @@ static void on_rx_rtp( void *data,
status = pjmedia_codec_parse(stream->codec, (void*)payload,
payloadlen, &ts, &count, frames);
if (status != PJ_SUCCESS) {
- LOGERR_((stream->port.info.name.ptr,
- "Codec parse() error",
+ LOGERR_((stream->port.info.name.ptr,
+ "Codec parse() error",
status));
count = 0;
}
@@ -1745,17 +1743,17 @@ static void on_rx_rtp( void *data,
#if defined(PJMEDIA_HANDLE_G722_MPEG_BUG) && (PJMEDIA_HANDLE_G722_MPEG_BUG!=0)
/* This code is used to learn the samples per frame value that is put
* by remote endpoint, for codecs with inconsistent clock rate such
- * as G.722 or MPEG audio. We need to learn the samples per frame
+ * as G.722 or MPEG audio. We need to learn the samples per frame
* value as it is used as divider when inserting frames into the
* jitter buffer.
*/
if (stream->has_g722_mpeg_bug) {
if (stream->rtp_rx_check_cnt) {
- /* Make sure the detection performed only on two consecutive
+ /* Make sure the detection performed only on two consecutive
* packets with valid RTP sequence and no wrapped timestamp.
*/
- if (seq_st.diff == 1 && stream->rtp_rx_last_ts &&
- ts.u64 > stream->rtp_rx_last_ts &&
+ if (seq_st.diff == 1 && stream->rtp_rx_last_ts &&
+ ts.u64 > stream->rtp_rx_last_ts &&
stream->rtp_rx_last_cnt > 0)
{
unsigned peer_frm_ts_diff;
@@ -1767,8 +1765,8 @@ static void on_rx_rtp( void *data,
PJMEDIA_PIA_CCNT(&stream->port.info);
/* Get remote frame timestamp span */
- peer_frm_ts_diff =
- ((pj_uint32_t)ts.u64-stream->rtp_rx_last_ts) /
+ peer_frm_ts_diff =
+ ((pj_uint32_t)ts.u64-stream->rtp_rx_last_ts) /
stream->rtp_rx_last_cnt;
/* Possibilities remote's samples per frame for G.722
@@ -1777,7 +1775,7 @@ static void on_rx_rtp( void *data,
* of silence frames.
*/
if (stream->codec_param.info.pt == PJMEDIA_RTP_PT_G722 &&
- (peer_frm_ts_diff == frm_ts_span ||
+ (peer_frm_ts_diff == frm_ts_span ||
peer_frm_ts_diff == (frm_ts_span>>1)))
{
if (peer_frm_ts_diff < stream->rtp_rx_ts_len_per_frame)
@@ -1789,9 +1787,9 @@ static void on_rx_rtp( void *data,
if (--stream->rtp_rx_check_cnt == 0) {
PJ_LOG(4, (THIS_FILE, "G722 codec used, remote"
- " samples per frame detected = %d",
+ " samples per frame detected = %d",
stream->rtp_rx_ts_len_per_frame));
-
+
/* Reset jitter buffer once detection done */
pjmedia_jbuf_reset(stream->jb);
}
@@ -1810,12 +1808,12 @@ static void on_rx_rtp( void *data,
}
} else {
- ts_span = stream->codec_param.info.frm_ptime *
+ ts_span = stream->codec_param.info.frm_ptime *
stream->codec_param.info.clock_rate /
1000;
}
#else
- ts_span = stream->codec_param.info.frm_ptime *
+ ts_span = stream->codec_param.info.frm_ptime *
stream->codec_param.info.clock_rate /
1000;
#endif
@@ -1841,7 +1839,7 @@ static void on_rx_rtp( void *data,
/* Check if now is the time to transmit RTCP SR/RR report.
- * We only do this when stream direction is "decoding only",
+ * We only do this when stream direction is "decoding only",
* because otherwise check_tx_rtcp() will be handled by put_frame()
*/
if (stream->dir == PJMEDIA_DIR_DECODING) {
@@ -1849,7 +1847,7 @@ static void on_rx_rtp( void *data,
}
if (status != 0) {
- LOGERR_((stream->port.info.name.ptr, "Jitter buffer put() error",
+ LOGERR_((stream->port.info.name.ptr, "Jitter buffer put() error",
status));
pkt_discarded = PJ_TRUE;
goto on_return;
@@ -1879,17 +1877,17 @@ on_return:
/*
* This callback is called by stream transport on receipt of packets
- * in the RTCP socket.
+ * in the RTCP socket.
*/
static void on_rx_rtcp( void *data,
- void *pkt,
+ void *pkt,
pj_ssize_t bytes_read)
{
pjmedia_stream *stream = (pjmedia_stream*) data;
/* Check for errors */
if (bytes_read < 0) {
- LOGERR_((stream->port.info.name.ptr, "RTCP recv() error",
+ LOGERR_((stream->port.info.name.ptr, "RTCP recv() error",
(pj_status_t)-bytes_read));
return;
}
@@ -1910,7 +1908,7 @@ static pj_status_t create_channel( pj_pool_t *pool,
{
pjmedia_channel *channel;
pj_status_t status;
-
+
/* Allocate memory for channel descriptor */
channel = PJ_POOL_ZALLOC_T(pool, pjmedia_channel);
@@ -1923,13 +1921,13 @@ static pj_status_t create_channel( pj_pool_t *pool,
channel->paused = 1;
channel->pt = pt;
-
+
/* Allocate buffer for outgoing packet. */
if (param->type == PJMEDIA_TYPE_AUDIO) {
- channel->out_pkt_size = sizeof(pjmedia_rtp_hdr) +
- stream->codec_param.info.max_bps *
- PJMEDIA_MAX_FRAME_DURATION_MS /
+ channel->out_pkt_size = sizeof(pjmedia_rtp_hdr) +
+ stream->codec_param.info.max_bps *
+ PJMEDIA_MAX_FRAME_DURATION_MS /
8 / 1000;
if (channel->out_pkt_size > PJMEDIA_MAX_MTU -
PJMEDIA_STREAM_RESV_PAYLOAD_LEN)
@@ -2077,8 +2075,8 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
if (info->param)
stream->codec_param = *info->param;
else {
- status = pjmedia_codec_mgr_get_default_param(stream->codec_mgr,
- &info->fmt,
+ status = pjmedia_codec_mgr_get_default_param(stream->codec_mgr,
+ &info->fmt,
&stream->codec_param);
if (status != PJ_SUCCESS)
goto err_cleanup;
@@ -2136,7 +2134,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
/* If encoder and decoder's ptime are asymmetric, then we need to
* create buffer on the encoder side. This could happen for example
- * with iLBC
+ * with iLBC
*/
if (stream->codec_param.info.enc_ptime!=0 &&
stream->codec_param.info.enc_ptime!=stream->codec_param.info.frm_ptime)
@@ -2184,7 +2182,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
if (stream->codec_param.info.max_rx_frame_size > 0) {
stream->frame_size = stream->codec_param.info.max_rx_frame_size;
} else {
- stream->frame_size = stream->codec_param.info.max_bps *
+ stream->frame_size = stream->codec_param.info.max_bps *
stream->codec_param.info.frm_ptime / 8 / 1000;
if ((stream->codec_param.info.max_bps *
stream->codec_param.info.frm_ptime) % 8000 != 0)
@@ -2217,7 +2215,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
/* Init jitter buffer parameters: */
if (info->jb_max >= stream->codec_param.info.frm_ptime)
- jb_max = (info->jb_max + stream->codec_param.info.frm_ptime - 1) /
+ jb_max = (info->jb_max + stream->codec_param.info.frm_ptime - 1) /
stream->codec_param.info.frm_ptime;
else
jb_max = 500 / stream->codec_param.info.frm_ptime;
@@ -2242,7 +2240,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
/* Create jitter buffer */
status = pjmedia_jbuf_create(pool, &stream->port.info.name,
- stream->frame_size,
+ stream->frame_size,
stream->codec_param.info.frm_ptime,
jb_max, &stream->jb);
if (status != PJ_SUCCESS)
@@ -2254,7 +2252,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
/* Create decoder channel: */
- status = create_channel( pool, stream, PJMEDIA_DIR_DECODING,
+ status = create_channel( pool, stream, PJMEDIA_DIR_DECODING,
info->rx_pt, info, &stream->dec);
if (status != PJ_SUCCESS)
goto err_cleanup;
@@ -2262,7 +2260,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
/* Create encoder channel: */
- status = create_channel( pool, stream, PJMEDIA_DIR_ENCODING,
+ status = create_channel( pool, stream, PJMEDIA_DIR_ENCODING,
info->tx_pt, info, &stream->enc);
if (status != PJ_SUCCESS)
goto err_cleanup;
@@ -2315,9 +2313,9 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
stream->out_rtcp_pkt = pj_pool_alloc(pool, stream->out_rtcp_pkt_size);
/* Only attach transport when stream is ready. */
- status = pjmedia_transport_attach(tp, stream, &info->rem_addr,
- &info->rem_rtcp,
- pj_sockaddr_get_len(&info->rem_addr),
+ status = pjmedia_transport_attach(tp, stream, &info->rem_addr,
+ &info->rem_rtcp,
+ pj_sockaddr_get_len(&info->rem_addr),
&on_rx_rtp, &on_rx_rtcp);
if (status != PJ_SUCCESS)
goto err_cleanup;
@@ -2335,8 +2333,8 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
if (info->rtcp_xr_interval != 0)
stream->rtcp_xr_interval = info->rtcp_xr_interval;
else
- stream->rtcp_xr_interval = (PJMEDIA_RTCP_INTERVAL +
- (pj_rand() % 8000)) *
+ stream->rtcp_xr_interval = (PJMEDIA_RTCP_INTERVAL +
+ (pj_rand() % 8000)) *
info->fmt.clock_rate / 1000;
/* Additional third-party RTCP XR destination */
@@ -2348,19 +2346,19 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
/* jitter buffer adaptive info */
i = PJMEDIA_RTCP_XR_JB_ADAPTIVE;
- pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
+ pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
PJMEDIA_RTCP_XR_INFO_CONF_JBA,
i);
/* Jitter buffer aggressiveness info (estimated) */
i = 7;
- pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
+ pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
PJMEDIA_RTCP_XR_INFO_CONF_JBR,
i);
/* Jitter buffer absolute maximum delay */
i = jb_max * stream->codec_param.info.frm_ptime;
- pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
+ pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
PJMEDIA_RTCP_XR_INFO_JB_ABS_MAX,
i);
@@ -2373,7 +2371,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
#else
i = PJMEDIA_RTCP_XR_PLC_DIS;
#endif
- pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
+ pjmedia_rtcp_xr_update_info(&stream->rtcp.xr_session,
PJMEDIA_RTCP_XR_INFO_CONF_PLC,
i);
}
@@ -2395,13 +2393,13 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt,
char trace_name[PJ_MAXPATH];
pj_ssize_t len;
- pj_ansi_snprintf(trace_name, sizeof(trace_name),
+ pj_ansi_snprintf(trace_name, sizeof(trace_name),
TRACE_JB_PATH_PREFIX "%s.csv",
stream->port.info.name.ptr);
status = pj_file_open(pool, trace_name, PJ_O_WRONLY, &stream->trace_jb_fd);
if (status != PJ_SUCCESS) {
stream->trace_jb_fd = TRACE_JB_INVALID_FD;
- PJ_LOG(3,(THIS_FILE, "Failed creating RTP trace file '%s'",
+ PJ_LOG(3,(THIS_FILE, "Failed creating RTP trace file '%s'",
trace_name));
} else {
stream->trace_jb_buf = (char*)pj_pool_alloc(pool, PJ_LOG_MAX_SIZE);
@@ -2489,7 +2487,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_destroy( pjmedia_stream *stream )
}
}
- /* Detach from transport
+ /* Detach from transport
* MUST NOT hold stream mutex while detaching from transport, as
* it may cause deadlock. See ticket #460 for the details.
*/
@@ -2512,7 +2510,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_destroy( pjmedia_stream *stream )
}
/* Free mutex */
-
+
if (stream->jb_mutex) {
pj_mutex_destroy(stream->jb_mutex);
stream->jb_mutex = NULL;
@@ -2723,9 +2721,9 @@ PJ_DEF(pj_status_t) pjmedia_stream_dial_dtmf( pjmedia_stream *stream,
if (stream->tx_event_pt < 0) {
return PJMEDIA_RTP_EREMNORFC2833;
}
-
+
pj_mutex_lock(stream->jb_mutex);
-
+
if (stream->tx_dtmf_count+digit_char->slen >=
(long)PJ_ARRAY_SIZE(stream->tx_dtmf_buf))
{
@@ -2734,7 +2732,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_dial_dtmf( pjmedia_stream *stream,
int i;
/* convert ASCII digits into payload type first, to make sure
- * that all digits are valid.
+ * that all digits are valid.
*/
for (i=0; i<digit_char->slen; ++i) {
unsigned pt;
@@ -2743,7 +2741,7 @@ PJ_DEF(pj_status_t) pjmedia_stream_dial_dtmf( pjmedia_stream *stream,
if (dig >= '0' && dig <= '9')
{
pt = dig - '0';
- }
+ }
else if (dig >= 'a' && dig <= 'd')
{
pt = dig - 'a' + 12;
@@ -2829,9 +2827,9 @@ PJ_DEF(pj_status_t) pjmedia_stream_get_dtmf( pjmedia_stream *stream,
* Set callback to be called upon receiving DTMF digits.
*/
PJ_DEF(pj_status_t) pjmedia_stream_set_dtmf_callback(pjmedia_stream *stream,
- void (*cb)(pjmedia_stream*,
- void *user_data,
- int digit),
+ void (*cb)(pjmedia_stream*,
+ void *user_data,
+ int digit),
void *user_data)
{
PJ_ASSERT_RETURN(stream, PJ_EINVAL);
diff --git a/pjmedia/src/pjmedia/transport_srtp.c b/pjmedia/src/pjmedia/transport_srtp.c
index e82c10a8..8844f2fa 100644
--- a/pjmedia/src/pjmedia/transport_srtp.c
+++ b/pjmedia/src/pjmedia/transport_srtp.c
@@ -1,5 +1,5 @@
/* $Id$ */
-/*
+/*
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
*
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <pjmedia/transport_srtp.h>
@@ -45,7 +45,7 @@
/* Maximum SRTP crypto key length */
#define MAX_KEY_LEN 128
-/* Initial value of probation counter. When probation counter > 0,
+/* Initial value of probation counter. When probation counter > 0,
* it means SRTP is in probation state, and it may restart when
* srtp_unprotect() returns err_status_replay_*
*/
@@ -76,14 +76,14 @@ static crypto_suite crypto_suites[] = {
{"NULL", NULL_CIPHER, 0, NULL_AUTH, 0, 0, 0, sec_serv_none},
/* cipher AES_CM, auth HMAC_SHA1, auth tag len = 10 octets */
- {"AES_CM_128_HMAC_SHA1_80", AES_128_ICM, 30, HMAC_SHA1, 20, 10, 10,
+ {"AES_CM_128_HMAC_SHA1_80", AES_128_ICM, 30, HMAC_SHA1, 20, 10, 10,
sec_serv_conf_and_auth},
/* cipher AES_CM, auth HMAC_SHA1, auth tag len = 4 octets */
{"AES_CM_128_HMAC_SHA1_32", AES_128_ICM, 30, HMAC_SHA1, 20, 4, 10,
sec_serv_conf_and_auth},
- /*
+ /*
* F8_128_HMAC_SHA1_8 not supported by libsrtp?
* {"F8_128_HMAC_SHA1_8", NULL_CIPHER, 0, NULL_AUTH, 0, 0, 0, sec_serv_none}
*/
@@ -124,18 +124,18 @@ typedef struct transport_srtp
void (*rtcp_cb)(void *user_data,
void *pkt,
pj_ssize_t size);
-
+
/* Transport information */
pjmedia_transport *member_tp; /**< Underlying transport. */
/* SRTP usage policy of peer. This field is updated when media is starting.
* This is useful when SRTP is in optional mode and peer is using mandatory
- * mode, so when local is about to reinvite/update, it should offer
+ * mode, so when local is about to reinvite/update, it should offer
* RTP/SAVP instead of offering RTP/AVP.
*/
pjmedia_srtp_use peer_use;
- /* When probation counter > 0, it means SRTP is in probation state,
+ /* When probation counter > 0, it means SRTP is in probation state,
* and it may restart when srtp_unprotect() returns err_status_replay_*
*/
unsigned probation_cnt;
@@ -205,7 +205,7 @@ static pj_status_t transport_destroy (pjmedia_transport *tp);
-static pjmedia_transport_op transport_srtp_op =
+static pjmedia_transport_op transport_srtp_op =
{
&transport_get_info,
&transport_attach,
@@ -238,17 +238,17 @@ const char* get_libsrtp_errstr(int err)
"couldn't allocate memory", /* err_status_alloc_fail = 3 */
"couldn't deallocate properly", /* err_status_dealloc_fail = 4 */
"couldn't initialize", /* err_status_init_fail = 5 */
- "can't process as much data as requested",
+ "can't process as much data as requested",
/* err_status_terminus = 6 */
"authentication failure", /* err_status_auth_fail = 7 */
"cipher failure", /* err_status_cipher_fail = 8 */
"replay check failed (bad index)", /* err_status_replay_fail = 9 */
- "replay check failed (index too old)",
+ "replay check failed (index too old)",
/* err_status_replay_old = 10 */
"algorithm failed test routine", /* err_status_algo_fail = 11 */
"unsupported operation", /* err_status_no_such_op = 12 */
"no appropriate context found", /* err_status_no_ctx = 13 */
- "unable to perform desired validation",
+ "unable to perform desired validation",
/* err_status_cant_check = 14 */
"can't use key any more", /* err_status_key_expired = 15 */
"error in use of socket", /* err_status_socket_err = 16 */
@@ -285,17 +285,17 @@ PJ_DEF(pj_status_t) pjmedia_srtp_init_lib(pjmedia_endpt *endpt)
err_status_t err;
err = srtp_init();
- if (err != err_status_ok) {
- PJ_LOG(4, (THIS_FILE, "Failed to initialize libsrtp: %s",
+ if (err != err_status_ok) {
+ PJ_LOG(4, (THIS_FILE, "Failed to initialize libsrtp: %s",
get_libsrtp_errstr(err)));
return PJMEDIA_ERRNO_FROM_LIBSRTP(err);
}
if (pjmedia_endpt_atexit(endpt, pjmedia_srtp_deinit_lib) != PJ_SUCCESS)
{
- /* There will be memory leak when it fails to schedule libsrtp
+ /* There will be memory leak when it fails to schedule libsrtp
* deinitialization, however the memory leak could be harmless,
- * since in modern OS's memory used by an application is released
+ * since in modern OS's memory used by an application is released
* when the application terminates.
*/
PJ_LOG(4, (THIS_FILE, "Failed to register libsrtp deinit."));
@@ -306,7 +306,7 @@ PJ_DEF(pj_status_t) pjmedia_srtp_init_lib(pjmedia_endpt *endpt)
#else
PJ_UNUSED_ARG(endpt);
#endif
-
+
return PJ_SUCCESS;
}
@@ -337,7 +337,7 @@ static void pjmedia_srtp_deinit_lib(pjmedia_endpt *endpt)
err = srtp_deinit();
#endif
if (err != err_status_ok) {
- PJ_LOG(4, (THIS_FILE, "Failed to deinitialize libsrtp: %s",
+ PJ_LOG(4, (THIS_FILE, "Failed to deinitialize libsrtp: %s",
get_libsrtp_errstr(err)));
}
@@ -349,7 +349,7 @@ static int get_crypto_idx(const pj_str_t* crypto_name)
{
int i;
int cs_cnt = sizeof(crypto_suites)/sizeof(crypto_suites[0]);
-
+
/* treat unspecified crypto_name as crypto 'NULL' */
if (crypto_name->slen == 0)
return 0;
@@ -420,7 +420,7 @@ PJ_DEF(pj_status_t) pjmedia_transport_srtp_create(
PJ_ASSERT_RETURN(endpt && tp && p_tp, PJ_EINVAL);
/* Check crypto availability */
- if (opt && opt->crypto_count == 0 &&
+ if (opt && opt->crypto_count == 0 &&
opt->use == PJMEDIA_SRTP_MANDATORY)
return PJMEDIA_SRTP_ESDPREQCRYPTO;
@@ -434,8 +434,8 @@ PJ_DEF(pj_status_t) pjmedia_transport_srtp_create(
return PJMEDIA_SRTP_ENOTSUPCRYPTO;
/* check key length */
- if (opt->crypto[i].key.slen &&
- opt->crypto[i].key.slen <
+ if (opt->crypto[i].key.slen &&
+ opt->crypto[i].key.slen <
(pj_ssize_t)crypto_suites[cs_idx].cipher_key_len)
return PJMEDIA_SRTP_EINKEYLEN;
}
@@ -505,7 +505,7 @@ PJ_DEF(pj_status_t) pjmedia_transport_srtp_create(
* Initialize and start SRTP session with the given parameters.
*/
PJ_DEF(pj_status_t) pjmedia_transport_srtp_start(
- pjmedia_transport *tp,
+ pjmedia_transport *tp,
const pjmedia_srtp_crypto *tx,
const pjmedia_srtp_crypto *rx)
{
@@ -517,7 +517,6 @@ PJ_DEF(pj_status_t) pjmedia_transport_srtp_start(
int au_tx_idx = 0;
int cr_rx_idx = 0;
int au_rx_idx = 0;
- int crypto_suites_cnt;
pj_status_t status = PJ_SUCCESS;
PJ_ASSERT_RETURN(tp && tx && rx, PJ_EINVAL);
@@ -528,8 +527,6 @@ PJ_DEF(pj_status_t) pjmedia_transport_srtp_start(
pjmedia_transport_srtp_stop(tp);
}
- crypto_suites_cnt = sizeof(crypto_suites)/sizeof(crypto_suites[0]);
-
/* Get encryption and authentication method */
cr_tx_idx = au_tx_idx = get_crypto_idx(&tx->name);
if (tx->flags & PJMEDIA_SRTP_NO_ENCRYPTION)
@@ -544,7 +541,7 @@ PJ_DEF(pj_status_t) pjmedia_transport_srtp_start(
au_rx_idx = 0;
/* Check whether the crypto-suite requested is supported */
- if (cr_tx_idx == -1 || cr_rx_idx == -1 || au_tx_idx == -1 ||
+ if (cr_tx_idx == -1 || cr_rx_idx == -1 || au_tx_idx == -1 ||
au_rx_idx == -1)
{
status = PJMEDIA_SRTP_ENOTSUPCRYPTO;
@@ -647,7 +644,7 @@ PJ_DEF(pj_status_t) pjmedia_transport_srtp_start(
b64_len = pj_ansi_sprintf(b64, "--key too long--");
else
b64[b64_len] = '\0';
-
+
PJ_LOG(5, (srtp->pool->obj_name, "TX: %s key=%s",
srtp->tx_policy.name.ptr, b64));
if (srtp->tx_policy.flags) {
@@ -699,13 +696,13 @@ PJ_DEF(pj_status_t) pjmedia_transport_srtp_stop(pjmedia_transport *srtp)
err = srtp_dealloc(p_srtp->srtp_rx_ctx);
if (err != err_status_ok) {
- PJ_LOG(4, (p_srtp->pool->obj_name,
+ PJ_LOG(4, (p_srtp->pool->obj_name,
"Failed to dealloc RX SRTP context: %s",
get_libsrtp_errstr(err)));
}
err = srtp_dealloc(p_srtp->srtp_tx_ctx);
if (err != err_status_ok) {
- PJ_LOG(4, (p_srtp->pool->obj_name,
+ PJ_LOG(4, (p_srtp->pool->obj_name,
"Failed to dealloc TX SRTP context: %s",
get_libsrtp_errstr(err)));
}
@@ -752,7 +749,7 @@ static pj_status_t transport_get_info(pjmedia_transport *tp,
spc_info_idx = info->specific_info_cnt++;
info->spc_info[spc_info_idx].type = PJMEDIA_TRANSPORT_TYPE_SRTP;
info->spc_info[spc_info_idx].cbsize = sizeof(srtp_info);
- pj_memcpy(&info->spc_info[spc_info_idx].buffer, &srtp_info,
+ pj_memcpy(&info->spc_info[spc_info_idx].buffer, &srtp_info,
sizeof(srtp_info));
return pjmedia_transport_get_info(srtp->member_tp, info);
@@ -781,7 +778,7 @@ static pj_status_t transport_attach(pjmedia_transport *tp,
pj_lock_release(srtp->mutex);
/* Attach itself to transport */
- status = pjmedia_transport_attach(srtp->member_tp, srtp, rem_addr,
+ status = pjmedia_transport_attach(srtp->member_tp, srtp, rem_addr,
rem_rtcp, addr_len, &srtp_rtp_cb,
&srtp_rtcp_cb);
if (status != PJ_SUCCESS) {
@@ -841,12 +838,12 @@ static pj_status_t transport_send_rtp( pjmedia_transport *tp,
pj_lock_release(srtp->mutex);
if (err == err_status_ok) {
- status = pjmedia_transport_send_rtp(srtp->member_tp,
+ status = pjmedia_transport_send_rtp(srtp->member_tp,
srtp->rtp_tx_buffer, len);
} else {
status = PJMEDIA_ERRNO_FROM_LIBSRTP(err);
}
-
+
return status;
}
@@ -869,7 +866,7 @@ static pj_status_t transport_send_rtcp2(pjmedia_transport *tp,
err_status_t err;
if (srtp->bypass_srtp) {
- return pjmedia_transport_send_rtcp2(srtp->member_tp, addr, addr_len,
+ return pjmedia_transport_send_rtcp2(srtp->member_tp, addr, addr_len,
pkt, size);
}
@@ -902,7 +899,7 @@ static pj_status_t transport_simulate_lost(pjmedia_transport *tp,
unsigned pct_lost)
{
transport_srtp *srtp = (transport_srtp *) tp;
-
+
PJ_ASSERT_RETURN(tp, PJ_EINVAL);
return pjmedia_transport_simulate_lost(srtp->member_tp, dir, pct_lost);
@@ -964,13 +961,13 @@ static void srtp_rtp_cb( void *user_data, void *pkt, pj_ssize_t size)
return;
}
err = srtp_unprotect(srtp->srtp_rx_ctx, (pj_uint8_t*)pkt, &len);
- if (srtp->probation_cnt > 0 &&
- (err == err_status_replay_old || err == err_status_replay_fail))
+ if (srtp->probation_cnt > 0 &&
+ (err == err_status_replay_old || err == err_status_replay_fail))
{
/* Handle such condition that stream is updated (RTP seq is reinited
- * & SRTP is restarted), but some old packets are still coming
+ * & SRTP is restarted), but some old packets are still coming
* so SRTP is learning wrong RTP seq. While the newly inited RTP seq
- * comes, SRTP thinks the RTP seq is replayed, so srtp_unprotect()
+ * comes, SRTP thinks the RTP seq is replayed, so srtp_unprotect()
* will return err_status_replay_*. Restarting SRTP can resolve this.
*/
pjmedia_srtp_crypto tx, rx;
@@ -981,7 +978,7 @@ static void srtp_rtp_cb( void *user_data, void *pkt, pj_ssize_t size)
status = pjmedia_transport_srtp_start((pjmedia_transport*)srtp,
&tx, &rx);
if (status != PJ_SUCCESS) {
- PJ_LOG(5,(srtp->pool->obj_name, "Failed to restart SRTP, err=%s",
+ PJ_LOG(5,(srtp->pool->obj_name, "Failed to restart SRTP, err=%s",
get_libsrtp_errstr(err)));
} else if (!srtp->bypass_srtp) {
err = srtp_unprotect(srtp->srtp_rx_ctx, (pj_uint8_t*)pkt, &len);
@@ -989,8 +986,8 @@ static void srtp_rtp_cb( void *user_data, void *pkt, pj_ssize_t size)
}
if (err != err_status_ok) {
- PJ_LOG(5,(srtp->pool->obj_name,
- "Failed to unprotect SRTP, pkt size=%d, err=%s",
+ PJ_LOG(5,(srtp->pool->obj_name,
+ "Failed to unprotect SRTP, pkt size=%d, err=%s",
size, get_libsrtp_errstr(err)));
} else {
cb = srtp->rtp_cb;
@@ -1035,7 +1032,7 @@ static void srtp_rtcp_cb( void *user_data, void *pkt, pj_ssize_t size)
}
err = srtp_unprotect_rtcp(srtp->srtp_rx_ctx, (pj_uint8_t*)pkt, &len);
if (err != err_status_ok) {
- PJ_LOG(5,(srtp->pool->obj_name,
+ PJ_LOG(5,(srtp->pool->obj_name,
"Failed to unprotect SRTCP, pkt size=%d, err=%s",
size, get_libsrtp_errstr(err)));
} else {
@@ -1055,7 +1052,7 @@ static void srtp_rtcp_cb( void *user_data, void *pkt, pj_ssize_t size)
* and set buffer_len = 0.
*/
static pj_status_t generate_crypto_attr_value(pj_pool_t *pool,
- char *buffer, int *buffer_len,
+ char *buffer, int *buffer_len,
pjmedia_srtp_crypto *crypto,
int tag)
{
@@ -1087,7 +1084,7 @@ static pj_status_t generate_crypto_attr_value(pj_pool_t *pool,
do {
key_ok = PJ_TRUE;
- err = crypto_get_random((unsigned char*)key,
+ err = crypto_get_random((unsigned char*)key,
crypto_suites[cs_idx].cipher_key_len);
if (err != err_status_ok) {
PJ_LOG(5,(THIS_FILE, "Failed generating random key: %s",
@@ -1099,7 +1096,7 @@ static pj_status_t generate_crypto_attr_value(pj_pool_t *pool,
} while (!key_ok);
crypto->key.ptr = (char*)
- pj_pool_zalloc(pool,
+ pj_pool_zalloc(pool,
crypto_suites[cs_idx].cipher_key_len);
pj_memcpy(crypto->key.ptr, key, crypto_suites[cs_idx].cipher_key_len);
crypto->key.slen = crypto_suites[cs_idx].cipher_key_len;
@@ -1117,13 +1114,13 @@ static pj_status_t generate_crypto_attr_value(pj_pool_t *pool,
}
b64_key[b64_key_len] = '\0';
-
+
PJ_ASSERT_RETURN(*buffer_len >= (crypto->name.slen + \
b64_key_len + 16), PJ_ETOOSMALL);
/* Print the crypto attribute value. */
print_len = pj_ansi_snprintf(buffer, *buffer_len, "%d %s inline:%s",
- tag,
+ tag,
crypto_suites[cs_idx].name,
b64_key);
if (print_len < 1 || print_len >= *buffer_len)
@@ -1205,7 +1202,7 @@ static pj_status_t parse_attr_crypto(pj_pool_t *pool,
/* Decode key */
crypto->key.ptr = (char*) pj_pool_zalloc(pool, MAX_KEY_LEN);
itmp = MAX_KEY_LEN;
- status = pj_base64_decode(&tmp, (pj_uint8_t*)crypto->key.ptr,
+ status = pj_base64_decode(&tmp, (pj_uint8_t*)crypto->key.ptr,
&itmp);
if (status != PJ_SUCCESS) {
PJ_LOG(4,(THIS_FILE, "Failed decoding crypto key from base64"));
@@ -1226,7 +1223,7 @@ static pj_status_t transport_media_create(pjmedia_transport *tp,
unsigned member_tp_option;
PJ_ASSERT_RETURN(tp, PJ_EINVAL);
-
+
pj_bzero(&srtp->rx_policy_neg, sizeof(srtp->rx_policy_neg));
pj_bzero(&srtp->tx_policy_neg, sizeof(srtp->tx_policy_neg));
@@ -1274,7 +1271,7 @@ BYPASS_SRTP:
member_tp_option &= ~PJMEDIA_TPMED_NO_TRANSPORT_CHECKING;
PROPAGATE_MEDIA_CREATE:
- return pjmedia_transport_media_create(srtp->member_tp, sdp_pool,
+ return pjmedia_transport_media_create(srtp->member_tp, sdp_pool,
member_tp_option, sdp_remote,
media_index);
}
@@ -1296,7 +1293,7 @@ static pj_status_t transport_encode_sdp(pjmedia_transport *tp,
unsigned i, j;
PJ_ASSERT_RETURN(tp && sdp_pool && sdp_local, PJ_EINVAL);
-
+
pj_bzero(&srtp->rx_policy_neg, sizeof(srtp->rx_policy_neg));
pj_bzero(&srtp->tx_policy_neg, sizeof(srtp->tx_policy_neg));
@@ -1306,7 +1303,7 @@ static pj_status_t transport_encode_sdp(pjmedia_transport *tp,
m_loc = sdp_local->media[media_index];
/* Bypass if media transport is not RTP/AVP or RTP/SAVP */
- if (pj_stricmp(&m_loc->desc.transport, &ID_RTP_AVP) != 0 &&
+ if (pj_stricmp(&m_loc->desc.transport, &ID_RTP_AVP) != 0 &&
pj_stricmp(&m_loc->desc.transport, &ID_RTP_SAVP) != 0)
goto BYPASS_SRTP;
@@ -1317,12 +1314,12 @@ static pj_status_t transport_encode_sdp(pjmedia_transport *tp,
* http://trac.pjsip.org/repos/ticket/1079
*/
/*
- if (pjmedia_sdp_media_find_attr(m_loc, &ID_INACTIVE, NULL) ||
+ if (pjmedia_sdp_media_find_attr(m_loc, &ID_INACTIVE, NULL) ||
(m_rem && pjmedia_sdp_media_find_attr(m_rem, &ID_INACTIVE, NULL)))
goto BYPASS_SRTP;
*/
- /* Check remote media transport & set local media transport
+ /* Check remote media transport & set local media transport
* based on SRTP usage option.
*/
if (srtp->offerer_side) {
@@ -1332,7 +1329,7 @@ static pj_status_t transport_encode_sdp(pjmedia_transport *tp,
case PJMEDIA_SRTP_DISABLED:
goto BYPASS_SRTP;
case PJMEDIA_SRTP_OPTIONAL:
- m_loc->desc.transport =
+ m_loc->desc.transport =
(srtp->peer_use == PJMEDIA_SRTP_MANDATORY)?
ID_RTP_SAVP : ID_RTP_AVP;
break;
@@ -1355,7 +1352,7 @@ static pj_status_t transport_encode_sdp(pjmedia_transport *tp,
/* If buffer_len==0, just skip the crypto attribute. */
if (buffer_len) {
pj_strset(&attr_value, buffer, buffer_len);
- attr = pjmedia_sdp_attr_create(srtp->pool, ID_CRYPTO.ptr,
+ attr = pjmedia_sdp_attr_create(srtp->pool, ID_CRYPTO.ptr,
&attr_value);
m_loc->attr[m_loc->attr_count++] = attr;
}
@@ -1400,11 +1397,11 @@ static pj_status_t transport_encode_sdp(pjmedia_transport *tp,
has_crypto_attr = PJ_TRUE;
- status = parse_attr_crypto(srtp->pool, m_rem->attr[i],
+ status = parse_attr_crypto(srtp->pool, m_rem->attr[i],
&tmp_rx_crypto, &tags[cr_attr_count]);
if (status != PJ_SUCCESS)
return status;
-
+
/* Check duplicated tag */
for (j=0; j<cr_attr_count; ++j) {
if (tags[j] == tags[cr_attr_count]) {
@@ -1416,7 +1413,7 @@ static pj_status_t transport_encode_sdp(pjmedia_transport *tp,
if (matched_idx == -1) {
/* lets see if the crypto-suite offered is supported */
for (j=0; j<srtp->setting.crypto_count; ++j)
- if (pj_stricmp(&tmp_rx_crypto.name,
+ if (pj_stricmp(&tmp_rx_crypto.name,
&srtp->setting.crypto[j].name) == 0)
{
int cs_idx = get_crypto_idx(&tmp_rx_crypto.name);
@@ -1433,11 +1430,11 @@ static pj_status_t transport_encode_sdp(pjmedia_transport *tp,
// raw_test_key,
// hex_test_key,
// strlen(hex_test_key));
- //pj_strset(test_key, raw_test_key,
+ //pj_strset(test_key, raw_test_key,
// crypto_suites[cs_idx].cipher_key_len);
/* EO Force to use test key */
- if (tmp_rx_crypto.key.slen !=
+ if (tmp_rx_crypto.key.slen !=
(int)crypto_suites[cs_idx].cipher_key_len)
return PJMEDIA_SRTP_EINKEYLEN;
@@ -1458,11 +1455,11 @@ static pj_status_t transport_encode_sdp(pjmedia_transport *tp,
case PJMEDIA_SRTP_OPTIONAL:
/* bypass SRTP when no crypto-attr and remote uses RTP/AVP */
- if (!has_crypto_attr &&
+ if (!has_crypto_attr &&
pj_stricmp(&m_rem->desc.transport, &ID_RTP_AVP) == 0)
goto BYPASS_SRTP;
/* bypass SRTP when nothing match and remote uses RTP/AVP */
- else if (matched_idx == -1 &&
+ else if (matched_idx == -1 &&
pj_stricmp(&m_rem->desc.transport, &ID_RTP_AVP) == 0)
goto BYPASS_SRTP;
break;
@@ -1484,7 +1481,7 @@ static pj_status_t transport_encode_sdp(pjmedia_transport *tp,
return PJMEDIA_SRTP_ENOTSUPCRYPTO;
}
- /* we have to generate crypto answer,
+ /* we have to generate crypto answer,
* with srtp->tx_policy_neg matched the offer
* and rem_tag contains matched offer tag.
*/
@@ -1496,18 +1493,18 @@ static pj_status_t transport_encode_sdp(pjmedia_transport *tp,
return status;
srtp->tx_policy_neg = srtp->setting.crypto[matched_idx];
-
+
/* If buffer_len==0, just skip the crypto attribute. */
if (buffer_len) {
pj_strset(&attr_value, buffer, buffer_len);
- attr = pjmedia_sdp_attr_create(sdp_pool, ID_CRYPTO.ptr,
+ attr = pjmedia_sdp_attr_create(sdp_pool, ID_CRYPTO.ptr,
&attr_value);
m_loc->attr[m_loc->attr_count++] = attr;
}
/* At this point, we get valid rx_policy_neg & tx_policy_neg. */
}
-
+
}
goto PROPAGATE_MEDIA_CREATE;
@@ -1518,7 +1515,7 @@ BYPASS_SRTP:
//srtp->bypass_srtp = PJ_TRUE;
PROPAGATE_MEDIA_CREATE:
- return pjmedia_transport_encode_sdp(srtp->member_tp, sdp_pool,
+ return pjmedia_transport_encode_sdp(srtp->member_tp, sdp_pool,
sdp_local, sdp_remote, media_index);
}
@@ -1547,7 +1544,7 @@ static pj_status_t transport_media_start(pjmedia_transport *tp,
/* For answerer side, this function will just have to start SRTP */
- /* Check remote media transport & set local media transport
+ /* Check remote media transport & set local media transport
* based on SRTP usage option.
*/
if (srtp->offerer_side) {
@@ -1560,7 +1557,7 @@ static pj_status_t transport_media_start(pjmedia_transport *tp,
} else if (srtp->setting.use == PJMEDIA_SRTP_OPTIONAL) {
// Regardless the answer's transport type (RTP/AVP or RTP/SAVP),
// the answer must be processed through in optional mode.
- // Please note that at this point transport type is ensured to be
+ // Please note that at this point transport type is ensured to be
// RTP/AVP or RTP/SAVP, see transport_media_create()
//if (pj_stricmp(&m_rem->desc.transport, &m_loc->desc.transport)) {
//DEACTIVATE_MEDIA(pool, m_loc);
@@ -1573,7 +1570,7 @@ static pj_status_t transport_media_start(pjmedia_transport *tp,
}
}
}
-
+
if (srtp->offerer_side) {
/* find supported crypto-suite, get the tag, and assign policy_local */
pjmedia_srtp_crypto tmp_tx_crypto;
@@ -1592,7 +1589,7 @@ static pj_status_t transport_media_start(pjmedia_transport *tp,
has_crypto_attr = PJ_TRUE;
- status = parse_attr_crypto(srtp->pool, m_rem->attr[i],
+ status = parse_attr_crypto(srtp->pool, m_rem->attr[i],
&tmp_tx_crypto, &rem_tag);
if (status != PJ_SUCCESS)
return status;
@@ -1605,7 +1602,7 @@ static pj_status_t transport_media_start(pjmedia_transport *tp,
}
/* match the crypto name */
- if (pj_stricmp(&tmp_tx_crypto.name,
+ if (pj_stricmp(&tmp_tx_crypto.name,
&srtp->setting.crypto[rem_tag-1].name) != 0)
{
DEACTIVATE_MEDIA(pool, m_loc);
@@ -1633,7 +1630,7 @@ static pj_status_t transport_media_start(pjmedia_transport *tp,
}
/* Make sure we have the SRTP policies */
- if (srtp_crypto_empty(&srtp->tx_policy_neg) ||
+ if (srtp_crypto_empty(&srtp->tx_policy_neg) ||
srtp_crypto_empty(&srtp->rx_policy_neg))
{
goto BYPASS_SRTP;
@@ -1670,7 +1667,7 @@ BYPASS_SRTP:
}
PROPAGATE_MEDIA_START:
- return pjmedia_transport_media_start(srtp->member_tp, pool,
+ return pjmedia_transport_media_start(srtp->member_tp, pool,
sdp_local, sdp_remote,
media_index);
}
@@ -1684,7 +1681,7 @@ static pj_status_t transport_media_stop(pjmedia_transport *tp)
status = pjmedia_transport_media_stop(srtp->member_tp);
if (status != PJ_SUCCESS)
- PJ_LOG(4, (srtp->pool->obj_name,
+ PJ_LOG(4, (srtp->pool->obj_name,
"SRTP failed stop underlying media transport."));
return pjmedia_transport_srtp_stop(tp);
@@ -1719,10 +1716,10 @@ PJ_DEF(pj_status_t) pjmedia_transport_srtp_decrypt_pkt(pjmedia_transport *tp,
err = srtp_unprotect(srtp->srtp_rx_ctx, pkt, pkt_len);
else
err = srtp_unprotect_rtcp(srtp->srtp_rx_ctx, pkt, pkt_len);
-
+
if (err != err_status_ok) {
- PJ_LOG(5,(srtp->pool->obj_name,
- "Failed to unprotect SRTP, pkt size=%d, err=%s",
+ PJ_LOG(5,(srtp->pool->obj_name,
+ "Failed to unprotect SRTP, pkt size=%d, err=%s",
*pkt_len, get_libsrtp_errstr(err)));
}
diff --git a/pjmedia/src/test/jbuf_test.c b/pjmedia/src/test/jbuf_test.c
index 309459b0..a84b5414 100644
--- a/pjmedia/src/test/jbuf_test.c
+++ b/pjmedia/src/test/jbuf_test.c
@@ -1,5 +1,5 @@
/* $Id$ */
-/*
+/*
* Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
* Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
*
@@ -15,7 +15,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <ctype.h>
@@ -47,7 +47,7 @@ typedef struct test_cond_t {
int delay_min; /**< Minimum delay, in frames. */
} test_cond_t;
-static pj_bool_t parse_test_headers(char *line, test_param_t *param,
+static pj_bool_t parse_test_headers(char *line, test_param_t *param,
test_cond_t *cond)
{
char *p = line;
@@ -56,7 +56,7 @@ static pj_bool_t parse_test_headers(char *line, test_param_t *param,
/* Test params. */
char mode_st[16];
- sscanf(p+1, "%s %u %u %u", mode_st, &param->init_prefetch,
+ sscanf(p+1, "%s %u %u %u", mode_st, &param->init_prefetch,
&param->min_prefetch, &param->max_prefetch);
param->adaptive = (pj_ansi_stricmp(mode_st, "adaptive") == 0);
@@ -102,7 +102,7 @@ static pj_bool_t parse_test_headers(char *line, test_param_t *param,
return PJ_TRUE;
}
-static pj_bool_t process_test_data(char data, pjmedia_jbuf *jb,
+static pj_bool_t process_test_data(char data, pjmedia_jbuf *jb,
pj_uint16_t *seq, pj_uint16_t *last_seq)
{
char frame[1];
@@ -155,9 +155,11 @@ static pj_bool_t process_test_data(char data, pjmedia_jbuf *jb,
pjmedia_jb_state state;
pjmedia_jbuf_get_state(jb, &state);
- printf("seq=%d\t%c\tsize=%d\tprefetch=%d\n",
+ printf("seq=%d\t%c\tsize=%d\tprefetch=%d\n",
*last_seq, toupper(data), state.size, state.prefetch);
}
+#else
+ PJ_UNUSED_ARG(print_state); /* Warning about variable set but unused */
#endif
return PJ_TRUE;
@@ -170,7 +172,7 @@ int jbuf_main(void)
int old_log_level;
int rc = 0;
const char* input_filename = "Jbtest.dat";
- const char* input_search_path[] = {
+ const char* input_search_path[] = {
"../build",
"pjmedia/build",
"build"
@@ -191,7 +193,7 @@ int jbuf_main(void)
input = fopen(input_path, "rt");
}
}
-
+
/* Failed to open test data file. */
if (input == NULL) {
printf("Failed to open test data file, Jbtest.dat\n");
@@ -244,8 +246,8 @@ int jbuf_main(void)
pjmedia_jbuf_reset(jb);
if (param.adaptive) {
- pjmedia_jbuf_set_adaptive(jb,
- param.init_prefetch,
+ pjmedia_jbuf_set_adaptive(jb,
+ param.init_prefetch,
param.min_prefetch,
param.max_prefetch);
} else {
@@ -254,8 +256,8 @@ int jbuf_main(void)
#ifdef REPORT
pjmedia_jbuf_get_state(jb, &state);
- printf("Initial\tsize=%d\tprefetch=%d\tmin.pftch=%d\tmax.pftch=%d\n",
- state.size, state.prefetch, state.min_prefetch,
+ printf("Initial\tsize=%d\tprefetch=%d\tmin.pftch=%d\tmax.pftch=%d\n",
+ state.size, state.prefetch, state.min_prefetch,
state.max_prefetch);
#endif
@@ -263,7 +265,7 @@ int jbuf_main(void)
/* Test session start */
while (1) {
char c;
-
+
/* Get next line of test data */
if (!p || *p == 0) {
p = fgets(line, sizeof(line), input);
@@ -301,24 +303,24 @@ int jbuf_main(void)
printf("Summary:\n");
printf(" size=%d prefetch=%d\n", state.size, state.prefetch);
printf(" delay (min/max/avg/dev)=%d/%d/%d/%d ms\n",
- state.min_delay, state.max_delay, state.avg_delay,
+ state.min_delay, state.max_delay, state.avg_delay,
state.dev_delay);
- printf(" lost=%d discard=%d empty=%d burst(avg)=%d\n",
+ printf(" lost=%d discard=%d empty=%d burst(avg)=%d\n",
state.lost, state.discard, state.empty, state.avg_burst);
/* Evaluate test session */
if (cond.burst >= 0 && (int)state.avg_burst > cond.burst) {
- printf("! 'Burst' should be %d, it is %d\n",
+ printf("! 'Burst' should be %d, it is %d\n",
cond.burst, state.avg_burst);
rc |= 1;
}
if (cond.delay >= 0 && (int)state.avg_delay/JB_PTIME > cond.delay) {
- printf("! 'Delay' should be %d, it is %d\n",
+ printf("! 'Delay' should be %d, it is %d\n",
cond.delay, state.avg_delay/JB_PTIME);
rc |= 2;
}
if (cond.delay_min >= 0 && (int)state.min_delay/JB_PTIME > cond.delay_min) {
- printf("! 'Minimum delay' should be %d, it is %d\n",
+ printf("! 'Minimum delay' should be %d, it is %d\n",
cond.delay_min, state.min_delay/JB_PTIME);
rc |= 32;
}
@@ -328,12 +330,12 @@ int jbuf_main(void)
rc |= 4;
}
if (cond.empty >= 0 && (int)state.empty > cond.empty) {
- printf("! 'Empty' should be %d, it is %d\n",
+ printf("! 'Empty' should be %d, it is %d\n",
cond.empty, state.empty);
rc |= 8;
}
if (cond.lost >= 0 && (int)state.lost > cond.lost) {
- printf("! 'Lost' should be %d, it is %d\n",
+ printf("! 'Lost' should be %d, it is %d\n",
cond.lost, state.lost);
rc |= 16;
}