From 297d802cc278998b3f1d360b31bc079a4f6cc483 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Fri, 31 Aug 2012 11:42:17 +0000 Subject: Fix #1579: Update Symbian APS/VAS to use new pjmedia_format. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4243 74dad513-b988-da41-8d7b-12977e46ad98 --- pjmedia/include/pjmedia-audiodev/audiodev.h | 6 +++ pjmedia/src/pjmedia-audiodev/symb_aps_dev.cpp | 56 +++++++++++++++---------- pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp | 60 ++++++++++++++++----------- 3 files changed, 75 insertions(+), 47 deletions(-) (limited to 'pjmedia') diff --git a/pjmedia/include/pjmedia-audiodev/audiodev.h b/pjmedia/include/pjmedia-audiodev/audiodev.h index 32fd08ad..f2f78e3d 100644 --- a/pjmedia/include/pjmedia-audiodev/audiodev.h +++ b/pjmedia/include/pjmedia-audiodev/audiodev.h @@ -424,6 +424,12 @@ typedef struct pjmedia_aud_param */ pj_bool_t cng_enabled; + /** + * Enable/disable VAD. This setting is optional, and will only be used + * if PJMEDIA_AUD_DEV_CAP_VAD is set in the flags. + */ + pj_bool_t vad_enabled; + } pjmedia_aud_param; diff --git a/pjmedia/src/pjmedia-audiodev/symb_aps_dev.cpp b/pjmedia/src/pjmedia-audiodev/symb_aps_dev.cpp index 309aaf59..6ff08567 100644 --- a/pjmedia/src/pjmedia-audiodev/symb_aps_dev.cpp +++ b/pjmedia/src/pjmedia-audiodev/symb_aps_dev.cpp @@ -973,7 +973,8 @@ static void RecCb(TAPSCommBuffer &buf, void *user_data) { unsigned samples_got; - samples_got = strm->param.ext_fmt.bitrate == 15200? 160 : 240; + samples_got = + strm->param.ext_fmt.det.aud.avg_bps == 15200? 160 : 240; /* Check if we got a normal frame. */ if (buf.iBuffer[0] == 1 && buf.iBuffer[1] == 0) { @@ -1171,9 +1172,9 @@ static void PlayCb(TAPSCommBuffer &buf, void *user_data) sf = pjmedia_frame_ext_get_subframe(frame, 0); samples_cnt = frame->samples_cnt / frame->subframe_cnt; - pj_assert((strm->param.ext_fmt.bitrate == 15200 && + pj_assert((strm->param.ext_fmt.det.aud.avg_bps == 15200 && samples_cnt == 160) || - (strm->param.ext_fmt.bitrate != 15200 && + (strm->param.ext_fmt.det.aud.avg_bps != 15200 && samples_cnt == 240)); if (sf->data && sf->bitlen) { @@ -1391,34 +1392,41 @@ static pj_status_t factory_init(pjmedia_aud_dev_factory *f) } if (supported) { + pjmedia_format ext_fmt; + switch(i) { case 0: /* AMRNB */ - af->dev_info.ext_fmt[fmt_cnt].id = PJMEDIA_FORMAT_AMR; - af->dev_info.ext_fmt[fmt_cnt].bitrate = 7400; - af->dev_info.ext_fmt[fmt_cnt].vad = PJ_TRUE; + pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_AMR, + 8000, 1, 16, 20, 7400, 12200); + af->dev_info.ext_fmt[fmt_cnt] = ext_fmt; + //af->dev_info.ext_fmt[fmt_cnt].vad = PJ_TRUE; ++fmt_cnt; break; case 1: /* G.711 */ - af->dev_info.ext_fmt[fmt_cnt].id = PJMEDIA_FORMAT_PCMU; - af->dev_info.ext_fmt[fmt_cnt].bitrate = 64000; - af->dev_info.ext_fmt[fmt_cnt].vad = PJ_FALSE; + pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_PCMU, + 8000, 1, 16, 20, 64000, 64000); + af->dev_info.ext_fmt[fmt_cnt] = ext_fmt; + //af->dev_info.ext_fmt[fmt_cnt].vad = PJ_FALSE; ++fmt_cnt; - af->dev_info.ext_fmt[fmt_cnt].id = PJMEDIA_FORMAT_PCMA; - af->dev_info.ext_fmt[fmt_cnt].bitrate = 64000; - af->dev_info.ext_fmt[fmt_cnt].vad = PJ_FALSE; + pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_PCMA, + 8000, 1, 16, 20, 64000, 64000); + af->dev_info.ext_fmt[fmt_cnt] = ext_fmt; + //af->dev_info.ext_fmt[fmt_cnt].vad = PJ_FALSE; ++fmt_cnt; g711_supported = PJ_TRUE; break; case 2: /* G.729 */ - af->dev_info.ext_fmt[fmt_cnt].id = PJMEDIA_FORMAT_G729; - af->dev_info.ext_fmt[fmt_cnt].bitrate = 8000; - af->dev_info.ext_fmt[fmt_cnt].vad = PJ_FALSE; + pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_G729, + 8000, 1, 16, 20, 8000, 8000); + af->dev_info.ext_fmt[fmt_cnt] = ext_fmt; + //af->dev_info.ext_fmt[fmt_cnt].vad = PJ_FALSE; ++fmt_cnt; break; case 3: /* iLBC */ - af->dev_info.ext_fmt[fmt_cnt].id = PJMEDIA_FORMAT_ILBC; - af->dev_info.ext_fmt[fmt_cnt].bitrate = 13333; - af->dev_info.ext_fmt[fmt_cnt].vad = PJ_TRUE; + pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_ILBC, + 8000, 1, 16, 30, 13333, 15200); + af->dev_info.ext_fmt[fmt_cnt] = ext_fmt; + //af->dev_info.ext_fmt[fmt_cnt].vad = PJ_TRUE; ++fmt_cnt; break; } @@ -1570,18 +1578,18 @@ static pj_status_t factory_create_stream(pjmedia_aud_dev_factory *f, /* Set audio engine mode. */ if (strm->param.ext_fmt.id == PJMEDIA_FORMAT_AMR) { - aps_setting.mode = (TAPSCodecMode)strm->param.ext_fmt.bitrate; + aps_setting.mode = (TAPSCodecMode)strm->param.ext_fmt.det.aud.avg_bps; } else if (strm->param.ext_fmt.id == PJMEDIA_FORMAT_PCMU || strm->param.ext_fmt.id == PJMEDIA_FORMAT_L16 || (strm->param.ext_fmt.id == PJMEDIA_FORMAT_ILBC && - strm->param.ext_fmt.bitrate != 15200)) + strm->param.ext_fmt.det.aud.avg_bps != 15200)) { aps_setting.mode = EULawOr30ms; } else if (strm->param.ext_fmt.id == PJMEDIA_FORMAT_PCMA || (strm->param.ext_fmt.id == PJMEDIA_FORMAT_ILBC && - strm->param.ext_fmt.bitrate == 15200)) + strm->param.ext_fmt.det.aud.avg_bps == 15200)) { aps_setting.mode = EALawOr20ms; } @@ -1596,11 +1604,13 @@ static pj_status_t factory_create_stream(pjmedia_aud_dev_factory *f, { aps_setting.vad = EFalse; } else { - aps_setting.vad = strm->param.ext_fmt.vad; + aps_setting.vad = (strm->param.flags & PJMEDIA_AUD_DEV_CAP_VAD) && + strm->param.vad_enabled; } /* Set other audio engine attributes. */ - aps_setting.plc = strm->param.plc_enabled; + aps_setting.plc = (strm->param.flags & PJMEDIA_AUD_DEV_CAP_PLC) && + strm->param.plc_enabled; aps_setting.cng = aps_setting.vad; aps_setting.loudspk = strm->param.output_route==PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER; diff --git a/pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp b/pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp index bcd9d75a..ca421d25 100644 --- a/pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp +++ b/pjmedia/src/pjmedia-audiodev/symb_vas_dev.cpp @@ -1015,7 +1015,8 @@ static void RecCb(CVoIPDataBuffer *buf, void *user_data) { unsigned samples_got; - samples_got = strm->param.ext_fmt.bitrate == 15200? 160 : 240; + samples_got = + strm->param.ext_fmt.det.aud.avg_bps == 15200? 160 : 240; /* Check if we got a normal or SID frame. */ if (buffer[0] != 0) { @@ -1214,9 +1215,9 @@ static void PlayCb(CVoIPDataBuffer *buf, void *user_data) sf = pjmedia_frame_ext_get_subframe(frame, 0); samples_cnt = frame->samples_cnt / frame->subframe_cnt; - pj_assert((strm->param.ext_fmt.bitrate == 15200 && + pj_assert((strm->param.ext_fmt.det.aud.avg_bps == 15200 && samples_cnt == 160) || - (strm->param.ext_fmt.bitrate != 15200 && + (strm->param.ext_fmt.det.aud.avg_bps != 15200 && samples_cnt == 240)); if (sf->data && sf->bitlen) { @@ -1230,7 +1231,8 @@ static void PlayCb(CVoIPDataBuffer *buf, void *user_data) buffer.Append(0); /* VAS iLBC frame is 20ms or 30ms */ - frame_len = strm->param.ext_fmt.bitrate == 15200? 38 : 50; + frame_len = + strm->param.ext_fmt.det.aud.avg_bps == 15200? 38 : 50; buffer.AppendFill(0, frame_len); } @@ -1244,7 +1246,8 @@ static void PlayCb(CVoIPDataBuffer *buf, void *user_data) buffer.Append(0); /* VAS iLBC frame is 20ms or 30ms */ - frame_len = strm->param.ext_fmt.bitrate == 15200? 38 : 50; + frame_len = + strm->param.ext_fmt.det.aud.avg_bps == 15200? 38 : 50; buffer.AppendFill(0, frame_len); } @@ -1408,40 +1411,47 @@ static pj_status_t factory_init(pjmedia_aud_dev_factory *f) vas_factory_ = NULL; for (TInt i = 0; i < dnlink_formats.Count(); i++) { + pjmedia_format ext_fmt; + /* Format must be supported by both downlink & uplink. */ if (uplink_formats.Find(dnlink_formats[i]) == KErrNotFound) continue; switch (dnlink_formats[i]) { case EAMR_NB: - af->dev_info.ext_fmt[ext_fmt_cnt].id = PJMEDIA_FORMAT_AMR; - af->dev_info.ext_fmt[ext_fmt_cnt].bitrate = 7400; - af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_TRUE; + pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_AMR, + 8000, 1, 16, 20, 7400, 12200); + af->dev_info.ext_fmt[ext_fmt_cnt] = ext_fmt; + //af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_TRUE; break; case EG729: - af->dev_info.ext_fmt[ext_fmt_cnt].id = PJMEDIA_FORMAT_G729; - af->dev_info.ext_fmt[ext_fmt_cnt].bitrate = 8000; - af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_FALSE; + pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_G729, + 8000, 1, 16, 20, 8000, 8000); + af->dev_info.ext_fmt[ext_fmt_cnt] = ext_fmt; + //af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_FALSE; break; case EILBC: - af->dev_info.ext_fmt[ext_fmt_cnt].id = PJMEDIA_FORMAT_ILBC; - af->dev_info.ext_fmt[ext_fmt_cnt].bitrate = 13333; - af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_TRUE; + pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_ILBC, + 8000, 1, 16, 30, 13333, 15200); + af->dev_info.ext_fmt[ext_fmt_cnt] = ext_fmt; + //af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_TRUE; break; case EG711: #if PJMEDIA_AUDIO_DEV_SYMB_VAS_VERSION==2 case EG711_10MS: #endif - af->dev_info.ext_fmt[ext_fmt_cnt].id = PJMEDIA_FORMAT_PCMU; - af->dev_info.ext_fmt[ext_fmt_cnt].bitrate = 64000; - af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_FALSE; + pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_PCMU, + 8000, 1, 16, 20, 64000, 64000); + af->dev_info.ext_fmt[ext_fmt_cnt] = ext_fmt; + //af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_FALSE; ++ext_fmt_cnt; - af->dev_info.ext_fmt[ext_fmt_cnt].id = PJMEDIA_FORMAT_PCMA; - af->dev_info.ext_fmt[ext_fmt_cnt].bitrate = 64000; - af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_FALSE; + pjmedia_format_init_audio(&ext_fmt, PJMEDIA_FORMAT_PCMA, + 8000, 1, 16, 20, 64000, 64000); + af->dev_info.ext_fmt[ext_fmt_cnt] = ext_fmt; + //af->dev_info.ext_fmt[ext_fmt_cnt].vad = PJ_FALSE; break; default: @@ -1616,7 +1626,7 @@ static pj_status_t factory_create_stream(pjmedia_aud_dev_factory *f, } else if (strm->param.ext_fmt.id == PJMEDIA_FORMAT_AMR) { - vas_setting.mode = strm->param.ext_fmt.bitrate; + vas_setting.mode = strm->param.ext_fmt.det.aud.avg_bps; } else if (strm->param.ext_fmt.id == PJMEDIA_FORMAT_PCMU) { @@ -1628,7 +1638,7 @@ static pj_status_t factory_create_stream(pjmedia_aud_dev_factory *f, } else if (strm->param.ext_fmt.id == PJMEDIA_FORMAT_ILBC) { - if (strm->param.ext_fmt.bitrate == 15200) + if (strm->param.ext_fmt.det.aud.avg_bps == 15200) vas_setting.mode = CVoIPFormatIntfc::EiLBC20mSecFrame; else vas_setting.mode = CVoIPFormatIntfc::EiLBC30mSecFrame; @@ -1647,11 +1657,13 @@ static pj_status_t factory_create_stream(pjmedia_aud_dev_factory *f, { vas_setting.vad = EFalse; } else { - vas_setting.vad = strm->param.ext_fmt.vad; + vas_setting.vad = (strm->param.flags & PJMEDIA_AUD_DEV_CAP_VAD) && + strm->param.vad_enabled; } /* Set other audio engine attributes. */ - vas_setting.plc = strm->param.plc_enabled; + vas_setting.plc = (strm->param.flags & PJMEDIA_AUD_DEV_CAP_PLC) && + strm->param.plc_enabled; vas_setting.cng = vas_setting.vad; vas_setting.loudspk = strm->param.output_route==PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER; -- cgit v1.2.3