Skip to content

Commit

Permalink
Fixed PJSUA2 API to get/set Opus config (#3935)
Browse files Browse the repository at this point in the history
  • Loading branch information
sauwming authored Apr 23, 2024
1 parent 472bda5 commit 4f3df90
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
2 changes: 0 additions & 2 deletions pjsip/include/pjsua2/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,6 @@ class Endpoint
*/
void resetVideoCodecParam(const string &codec_id) PJSUA2_THROW(Error);

#if defined(PJMEDIA_HAS_OPUS_CODEC) && (PJMEDIA_HAS_OPUS_CODEC!=0)
/**
* Get codec Opus config.
*
Expand All @@ -1794,7 +1793,6 @@ class Endpoint
*/
void setCodecOpusConfig(const CodecOpusConfig &opus_cfg)
PJSUA2_THROW(Error);
#endif

/**
* Enumerate all SRTP crypto-suite names.
Expand Down
39 changes: 23 additions & 16 deletions pjsip/src/pjsua2/endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2490,34 +2490,41 @@ void Endpoint::codecSetParam(const string &codec_id,
PJSUA2_CHECK_EXPR( pjsua_codec_set_param(&codec_str, &pj_param) );
}

#if defined(PJMEDIA_HAS_OPUS_CODEC) && (PJMEDIA_HAS_OPUS_CODEC!=0)

CodecOpusConfig Endpoint::getCodecOpusConfig() const PJSUA2_THROW(Error)
{
pjmedia_codec_opus_config opus_cfg;
CodecOpusConfig config;
CodecOpusConfig config;
#if defined(PJMEDIA_HAS_OPUS_CODEC) && (PJMEDIA_HAS_OPUS_CODEC!=0)
pjmedia_codec_opus_config opus_cfg;

PJSUA2_CHECK_EXPR(pjmedia_codec_opus_get_config(&opus_cfg));
config.fromPj(opus_cfg);
PJSUA2_CHECK_EXPR(pjmedia_codec_opus_get_config(&opus_cfg));
config.fromPj(opus_cfg);
#else
PJSUA2_RAISE_ERROR(PJ_ENOTSUP);
#endif

return config;
return config;
}

void Endpoint::setCodecOpusConfig(const CodecOpusConfig &opus_cfg)
PJSUA2_THROW(Error)
{
const pj_str_t codec_id = {(char *)"opus", 4};
pjmedia_codec_param param;
pjmedia_codec_opus_config new_opus_cfg;

PJSUA2_CHECK_EXPR(pjsua_codec_get_param(&codec_id, &param));
new_opus_cfg = opus_cfg.toPj();

PJSUA2_CHECK_EXPR(pjmedia_codec_opus_set_default_param(&new_opus_cfg,
&param));
}
#if defined(PJMEDIA_HAS_OPUS_CODEC) && (PJMEDIA_HAS_OPUS_CODEC!=0)
const pj_str_t codec_id = {(char *)"opus", 4};
pjmedia_codec_param param;
pjmedia_codec_opus_config new_opus_cfg;

PJSUA2_CHECK_EXPR(pjsua_codec_get_param(&codec_id, &param));
new_opus_cfg = opus_cfg.toPj();

PJSUA2_CHECK_EXPR(pjmedia_codec_opus_set_default_param(&new_opus_cfg,
&param));
#else
PJ_UNUSED_ARG(opus_cfg);

PJSUA2_RAISE_ERROR(PJ_ENOTSUP);
#endif
}

void Endpoint::clearCodecInfoList(CodecInfoVector &codec_list)
{
Expand Down

0 comments on commit 4f3df90

Please sign in to comment.