Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed PJSUA2 API to get/set Opus config #3935

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading