diff options
Diffstat (limited to 'pjsip-apps/src/samples/playsine.c')
-rw-r--r-- | pjsip-apps/src/samples/playsine.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/pjsip-apps/src/samples/playsine.c b/pjsip-apps/src/samples/playsine.c index a1370c24..00cabe47 100644 --- a/pjsip-apps/src/samples/playsine.c +++ b/pjsip-apps/src/samples/playsine.c @@ -86,7 +86,7 @@ static pj_status_t sine_get_frame( pjmedia_port *port, unsigned i, count, left, right; /* Get number of samples */ - count = frame->size / 2 / port->info.channel_count; + count = frame->size / 2 / PJMEDIA_PIA_CCNT(&port->info); left = 0; right = 0; @@ -95,7 +95,7 @@ static pj_status_t sine_get_frame( pjmedia_port *port, *samples++ = sine->samples[left]; ++left; - if (port->info.channel_count == 2) { + if (PJMEDIA_PIA_CCNT(&port->info) == 2) { *samples++ = sine->samples[right]; right += 2; /* higher pitch so we can distinguish left and right. */ if (right >= count) @@ -126,6 +126,7 @@ static pj_status_t create_sine_port(pj_pool_t *pool, pjmedia_port *port; unsigned i; unsigned count; + pj_str_t name; port_data *sine; PJ_ASSERT_RETURN(pool && channel_count > 0 && channel_count <= 2, @@ -135,17 +136,12 @@ static pj_status_t create_sine_port(pj_pool_t *pool, PJ_ASSERT_RETURN(port != NULL, PJ_ENOMEM); /* Fill in port info. */ - port->info.bits_per_sample = 16; - port->info.channel_count = channel_count; - port->info.encoding_name = pj_str("pcm"); - port->info.has_info = 1; - port->info.name = pj_str("sine generator"); - port->info.need_info = 0; - port->info.pt = 0xFF; - port->info.clock_rate = sampling_rate; - port->info.samples_per_frame = sampling_rate * 20 / 1000 * channel_count; - port->info.bytes_per_frame = port->info.samples_per_frame * 2; - port->info.type = PJMEDIA_TYPE_AUDIO; + name = pj_str("sine generator"); + pjmedia_port_info_init(&port->info, &name, + PJMEDIA_SIG_CLASS_PORT_AUD('s', 'i'), + sampling_rate, + channel_count, + 16, sampling_rate * 20 / 1000 * channel_count); /* Set the function to feed frame */ port->get_frame = &sine_get_frame; @@ -154,7 +150,7 @@ static pj_status_t create_sine_port(pj_pool_t *pool, port->port_data.pdata = sine = pj_pool_zalloc(pool, sizeof(port_data)); /* Create samples */ - count = port->info.samples_per_frame / channel_count; + count = PJMEDIA_PIA_SPF(&port->info) / channel_count; sine->samples = pj_pool_alloc(pool, count * sizeof(pj_int16_t)); PJ_ASSERT_RETURN(sine->samples != NULL, PJ_ENOMEM); @@ -244,10 +240,10 @@ int main(int argc, char *argv[]) status = pjmedia_snd_port_create_player( pool, /* pool */ -1, /* use default dev. */ - sine_port->info.clock_rate, /* clock rate. */ - sine_port->info.channel_count, /* # of channels. */ - sine_port->info.samples_per_frame, /* samples per frame. */ - sine_port->info.bits_per_sample, /* bits per sample. */ + PJMEDIA_PIA_SRATE(&sine_port->info),/* clock rate. */ + PJMEDIA_PIA_CCNT(&sine_port->info),/* # of channels. */ + PJMEDIA_PIA_SPF(&sine_port->info), /* samples per frame. */ + PJMEDIA_PIA_BITS(&sine_port->info),/* bits per sample. */ 0, /* options */ &snd_port /* returned port */ ); |