From 5d4c8098b1eab32df4f5e0fcdc6b539e79419987 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Tue, 24 Aug 2010 10:45:01 +0000 Subject: Fix #1114: - Fixed bytes_per_frame calculation in stream port. - Fixed sample streamutil.c to use codec info/param for codec bandwidth calculation (was using bytes_per_frame info of stream port). - Doc fix for bytes_per_frame field in pjmedia_port_info. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3292 74dad513-b988-da41-8d7b-12977e46ad98 --- pjmedia/include/pjmedia/port.h | 2 +- pjmedia/src/pjmedia/stream.c | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'pjmedia') diff --git a/pjmedia/include/pjmedia/port.h b/pjmedia/include/pjmedia/port.h index 447c429d..ccfff18d 100644 --- a/pjmedia/include/pjmedia/port.h +++ b/pjmedia/include/pjmedia/port.h @@ -218,7 +218,7 @@ typedef struct pjmedia_port_info unsigned channel_count; /**< Number of channels. */ unsigned bits_per_sample; /**< Bits/sample */ unsigned samples_per_frame; /**< No of samples per frame. */ - unsigned bytes_per_frame; /**< No of samples per frame. */ + unsigned bytes_per_frame; /**< No of bytes per frame. */ } pjmedia_port_info; diff --git a/pjmedia/src/pjmedia/stream.c b/pjmedia/src/pjmedia/stream.c index f6d53d0a..4436da51 100644 --- a/pjmedia/src/pjmedia/stream.c +++ b/pjmedia/src/pjmedia/stream.c @@ -2030,23 +2030,28 @@ PJ_DEF(pj_status_t) pjmedia_stream_create( pjmedia_endpt *endpt, stream->codec_param.info.frm_ptime * stream->codec_param.setting.frm_per_pkt / 1000; - stream->port.info.bytes_per_frame = stream->codec_param.info.max_bps * - stream->codec_param.info.frm_ptime * - stream->codec_param.setting.frm_per_pkt / - 8 / 1000; - if ((stream->codec_param.info.max_bps * stream->codec_param.info.frm_ptime * - stream->codec_param.setting.frm_per_pkt) % 8000 != 0) - { - ++stream->port.info.bytes_per_frame; - } - stream->port.info.format.id = stream->codec_param.info.fmt_id; if (stream->codec_param.info.fmt_id == PJMEDIA_FORMAT_L16) { + /* Raw format */ + stream->port.info.bytes_per_frame = stream->port.info.samples_per_frame * + stream->port.info.bits_per_sample / 8; + stream->port.put_frame = &put_frame; stream->port.get_frame = &get_frame; } else { + /* Encoded format */ + stream->port.info.bytes_per_frame = stream->codec_param.info.max_bps * + stream->codec_param.info.frm_ptime * + stream->codec_param.setting.frm_per_pkt / + 8 / 1000; + if ((stream->codec_param.info.max_bps * stream->codec_param.info.frm_ptime * + stream->codec_param.setting.frm_per_pkt) % 8000 != 0) + { + ++stream->port.info.bytes_per_frame; + } stream->port.info.format.bitrate = stream->codec_param.info.avg_bps; stream->port.info.format.vad = (stream->codec_param.setting.vad != 0); + stream->port.put_frame = &put_frame; stream->port.get_frame = &get_frame_ext; } -- cgit v1.2.3