summaryrefslogtreecommitdiff
path: root/pjmedia
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2010-08-24 10:45:01 +0000
committerNanang Izzuddin <nanang@teluu.com>2010-08-24 10:45:01 +0000
commit5d4c8098b1eab32df4f5e0fcdc6b539e79419987 (patch)
tree44cff8419bd9de28c748f04e4a30e2aad03ee3f1 /pjmedia
parent69849ceb5944172abcc0cef976fc21ebe07ab5e1 (diff)
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
Diffstat (limited to 'pjmedia')
-rw-r--r--pjmedia/include/pjmedia/port.h2
-rw-r--r--pjmedia/src/pjmedia/stream.c25
2 files changed, 16 insertions, 11 deletions
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;
}