Skip to content

Commit

Permalink
Modification based on comments:
Browse files Browse the repository at this point in the history
- Update some doc
- Change field setting name
- Remove un-needed code
- Suppress compile warning
  • Loading branch information
trengginas committed May 20, 2024
1 parent 688174c commit c2041cc
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 22 deletions.
2 changes: 1 addition & 1 deletion aconfigure
Original file line number Diff line number Diff line change
Expand Up @@ -10157,7 +10157,7 @@ else $as_nop
if test "x$with_lyra" != "xno" -a "x$with_lyra" != "x"; then
LYRA_PREFIX=$with_lyra
LYRA_CPPFLAGS="-DGLOG_DEPRECATED=__attribute__((deprecated)) -DGLOG_EXPORT=__attribute__((visibility(\"default\"))) -DGLOG_NO_EXPORT=__attribute__((visibility(\"default\")))"
LYRA_CXXFLAGS="-std=c++17 -I$LYRA_PREFIX/include/com_google_absl -I$LYRA_PREFIX/include/gulrak_filesystem -I$LYRA_PREFIX/include/com_google_glog/src -I$LYRA_PREFIX"
LYRA_CXXFLAGS="-std=c++17 -Wno-deprecated-builtins -I$LYRA_PREFIX/include/com_google_absl -I$LYRA_PREFIX/include/gulrak_filesystem -I$LYRA_PREFIX/include/com_google_glog/src -I$LYRA_PREFIX"
LYRA_LDFLAGS="-L$LYRA_PREFIX/lib"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Using lyra prefix... $with_lyra" >&5
printf "%s\n" "Using lyra prefix... $with_lyra" >&6; }
Expand Down
2 changes: 1 addition & 1 deletion aconfigure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2342,7 +2342,7 @@ AC_ARG_ENABLE(lyra,
LYRA_PREFIX=$with_lyra
dnl # inside autoconf, single quoted preprocessor definition will raise error
LYRA_CPPFLAGS="-DGLOG_DEPRECATED=__attribute__((deprecated)) -DGLOG_EXPORT=__attribute__((visibility(\"default\"))) -DGLOG_NO_EXPORT=__attribute__((visibility(\"default\")))"
LYRA_CXXFLAGS="-std=c++17 -I$LYRA_PREFIX/include/com_google_absl -I$LYRA_PREFIX/include/gulrak_filesystem -I$LYRA_PREFIX/include/com_google_glog/src -I$LYRA_PREFIX"
LYRA_CXXFLAGS="-std=c++17 -Wno-deprecated-builtins -I$LYRA_PREFIX/include/com_google_absl -I$LYRA_PREFIX/include/gulrak_filesystem -I$LYRA_PREFIX/include/com_google_glog/src -I$LYRA_PREFIX"
LYRA_LDFLAGS="-L$LYRA_PREFIX/lib"
AC_MSG_RESULT([Using lyra prefix... $with_lyra])
else
Expand Down
22 changes: 20 additions & 2 deletions pjmedia/include/pjmedia-codec/lyra.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,26 @@ PJ_BEGIN_DECL
*/
typedef struct pjmedia_codec_lyra_config
{
unsigned bit_rate; /**< The expected bit rate from remote. */
pj_str_t model_path; /**< The path to the model files. */
/**
* The value represents the decoder bitrate requested by the receiver.
* Endpoints can be configured with different bitrates. For example,
* the local endpoint might be set to a bitrate of 3200, while
* the remote endpoint is set to 6000. In this scenario, the remote
* endpoint will send data at 3200 bitrate, while the local endpoint
* will send data at 6000 bitrate.
*/
unsigned bit_rate;

/**
* Lyra required some additional (model) files, including
* \b lyra_config.binarypb , \b lyragan.tflite , \b quantizer.tflite and
* \b soundstream_encoder.tflite .
* This setting represents the folder containing the above files.
* The specified folder should contain these files. If an invalid folder
* is provided, the codec creation will fail.
*/
pj_str_t model_path;

} pjmedia_codec_lyra_config;

/**
Expand Down
8 changes: 4 additions & 4 deletions pjmedia/include/pjmedia-codec/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ enum pjmedia_audio_pt
PJMEDIA_RTP_PT_G7221_RSV1, /**< G722.1 reserve */
PJMEDIA_RTP_PT_G7221_RSV2, /**< G722.1 reserve */
PJMEDIA_RTP_PT_OPUS, /**< OPUS */
PJMEDIA_RTP_PT_LYRA_8, /**< LYRA @ 8Kbps */
PJMEDIA_RTP_PT_LYRA_16, /**< LYRA @ 16Kbps */
PJMEDIA_RTP_PT_LYRA_32, /**< LYRA @ 32Kbps */
PJMEDIA_RTP_PT_LYRA_48, /**< LYRA @ 48Kbps */
PJMEDIA_RTP_PT_LYRA_8, /**< LYRA @ 8KHz */
PJMEDIA_RTP_PT_LYRA_16, /**< LYRA @ 16KHz */
PJMEDIA_RTP_PT_LYRA_32, /**< LYRA @ 32KHz */
PJMEDIA_RTP_PT_LYRA_48, /**< LYRA @ 48KHz */
#if PJMEDIA_CODEC_L16_HAS_8KHZ_MONO
PJMEDIA_RTP_PT_L16_8KHZ_MONO, /**< L16 @ 8KHz, mono */
#endif
Expand Down
2 changes: 0 additions & 2 deletions pjmedia/src/pjmedia-codec/lyra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,6 @@ static pj_status_t lyra_codec_recover(pjmedia_codec *codec,
unsigned samples_per_frame = lyra_data->samples_per_frame;
pj_status_t status;

//PJ_LOG(4, (THIS_FILE, "Codec recover"));

/* output_buf_len is unreferenced when building in Release mode */
PJ_UNUSED_ARG(output_buf_len);

Expand Down
21 changes: 19 additions & 2 deletions pjsip/include/pjsua2/media.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2646,8 +2646,25 @@ struct CodecOpusConfig
*/
struct CodecLyraConfig
{
unsigned bit_rate; /**< The expected bit rate from remote. */
string model_path; /**< The path to the model files. */
/**
* The value represents the decoder bitrate requested by the receiver.
* Endpoints can be configured with different bitrates. For example,
* the local endpoint might be set to a bitrate of 3200, while
* the remote endpoint is set to 6000. In this scenario, the remote
* endpoint will send data at 3200 bitrate, while the local endpoint
* will send data at 6000 bitrate.
*/
unsigned bitRate;

/**
* Lyra required some additional (model) files, including
* \b lyra_config.binarypb , \b lyragan.tflite , \b quantizer.tflite and
* \b soundstream_encoder.tflite .
* This setting represents the folder containing the above files.
* The specified folder should contain these files. If an invalid folder
* is provided, the codec creation will fail.
*/
string modelPath;

pjmedia_codec_lyra_config toPj() const;
void fromPj(const pjmedia_codec_lyra_config &config);
Expand Down
20 changes: 10 additions & 10 deletions pjsip/src/pjsua2/media.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,15 +305,15 @@ static pj_status_t get_frame(pjmedia_port *port, pjmedia_frame *frame)
mport->onFrameRequested(frame_);
frame->type = frame_.type;
frame->size = PJ_MIN(frame_.buf.size(), frame_.size);

#if ((defined(_MSVC_LANG) && _MSVC_LANG <= 199711L) || __cplusplus <= 199711L)
/* C++98 does not have Vector::data() */
if (frame->size > 0)

#if ((defined(_MSVC_LANG) && _MSVC_LANG <= 199711L) || __cplusplus <= 199711L)
/* C++98 does not have Vector::data() */
if (frame->size > 0)
pj_memcpy(frame->buf, &frame_.buf[0], frame->size);
#else
/* Newer than C++98 */
/* Newer than C++98 */
pj_memcpy(frame->buf, frame_.buf.data(), frame->size);
#endif
#endif


return PJ_SUCCESS;
Expand Down Expand Up @@ -2036,16 +2036,16 @@ pjmedia_codec_lyra_config CodecLyraConfig::toPj() const
{
pjmedia_codec_lyra_config config;

config.bit_rate = bit_rate;
config.model_path = str2Pj(model_path);
config.bit_rate = bitRate;
config.model_path = str2Pj(modelPath);

return config;
}

void CodecLyraConfig::fromPj(const pjmedia_codec_lyra_config &config)
{
bit_rate = config.bit_rate;
model_path = pj2Str(config.model_path);
bitRate = config.bit_rate;
modelPath = pj2Str(config.model_path);
}

///////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit c2041cc

Please sign in to comment.