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

Lyra support #3949

Merged
merged 7 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
115 changes: 115 additions & 0 deletions aconfigure
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ ac_webrtc_instset
ac_no_webrtc
ac_no_yuv
ac_no_srtp
ac_no_lyra_codec
ac_no_bcg729
opus_present
opus_h_present
Expand Down Expand Up @@ -885,6 +886,8 @@ with_opus
enable_opus
with_bcg729
enable_bcg729
with_lyra
enable_lyra
enable_libsrtp
enable_libyuv
enable_libwebrtc
Expand Down Expand Up @@ -1574,6 +1577,7 @@ Optional Features:
autodetect)

--disable-bcg729 Disable bcg729 (default: not disabled)
--disable-lyra Disable lyra (default: not disabled)
--disable-libsrtp Exclude libsrtp in the build
--disable-libyuv Exclude libyuv in the build
--disable-libwebrtc Exclude libwebrtc in the build
Expand Down Expand Up @@ -1641,6 +1645,7 @@ Optional Packages:
--with-silk=DIR Specify alternate SILK prefix
--with-opus=DIR Specify alternate OPUS prefix
--with-bcg729=DIR Specify alternate bcg729 prefix
--with-lyra=DIR Specify alternate lyra prefix

Some influential environment variables:
CC C compiler command
Expand Down Expand Up @@ -10118,6 +10123,116 @@ fi



# Check whether --with-lyra was given.
if test ${with_lyra+y}
then :
withval=$with_lyra;
else $as_nop
with_lyra=no

fi


if test "x$ac_cross_compile" != "x" -a "x$with_lyra" = "xno"; then
enable_lyra=no
fi


# Check whether --enable-lyra was given.
if test ${enable_lyra+y}
then :
enableval=$enable_lyra;
if test "$enable_lyra" = "no"; then
ac_no_lyra_codec=1
printf "%s\n" "#define PJMEDIA_HAS_LYRA_CODEC 0" >>confdefs.h

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Checking if lyra is disabled... yes" >&5
printf "%s\n" "Checking if lyra is disabled... yes" >&6; }
fi

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_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; }
else
LYRA_CXXFLAGS=""
LYRA_LDFLAGS=""
fi

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking lyra usability" >&5
printf %s "checking lyra usability... " >&6; }

LYRA_LIBS="-llyra"

SAVED_LIBS="$LIBS"
SAVED_LDFLAGS="$LDFLAGS"
SAVED_CXXFLAGS="$CXXFLAGS"
SAVED_CPPFLAGS="$CPPFLAGS"

LIBS="$LYRA_LIBS $LIBS"
LDFLAGS="$LYRA_LDFLAGS $LDFLAGS"
CXXFLAGS="$LYRA_CXXFLAGS $CXXFLAGS"
CPPFLAGS="$LYRA_CPPFLAGS $CPPFLAGS"

ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include "lyra_decoder.h"

int
main (void)
{
std::unique_ptr<chromemedia::codec::LyraDecoder> dec = chromemedia::codec::LyraDecoder::Create(8000,1,"");

;
return 0;
}
_ACEOF
if ac_fn_cxx_try_link "$LINENO"
then :

printf "%s\n" "#define PJMEDIA_HAS_LYRA_CODEC 1" >>confdefs.h

LYRA_CPPFLAGS="'-DGLOG_DEPRECATED=__attribute__((deprecated))' '-DGLOG_EXPORT=__attribute__((visibility(\"default\")))' '-DGLOG_NO_EXPORT=__attribute__((visibility(\"default\")))'"
CXXFLAGS="$LYRA_CPPFLAGS $CXXFLAGS"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }

else $as_nop

ac_no_lyra_codec=1
LIBS="$SAVED_LIBS"
LDFLAGS="$SAVED_LDFLAGS"
CXXFLAGS="$SAVED_CXXFLAGS"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }

fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

CPPFLAGS="$SAVED_CPPFLAGS"

fi





# Check whether --enable-libsrtp was given.
if test ${enable_libsrtp+y}
Expand Down
76 changes: 76 additions & 0 deletions aconfigure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2311,6 +2311,82 @@ AC_ARG_ENABLE(bcg729,

])

dnl # lyra prefix
AC_ARG_WITH(lyra,
AS_HELP_STRING([--with-lyra=DIR],
[Specify alternate lyra prefix]),
[],
[with_lyra=no]
)

dnl # Do not use default lyra installation if we are cross-compiling
if test "x$ac_cross_compile" != "x" -a "x$with_lyra" = "xno"; then
enable_lyra=no
fi

dnl # lyra
AC_SUBST(ac_no_lyra_codec)
AC_ARG_ENABLE(lyra,
AS_HELP_STRING([--disable-lyra],
[Disable lyra (default: not disabled)]),
[
if test "$enable_lyra" = "no"; then
[ac_no_lyra_codec=1]
AC_DEFINE(PJMEDIA_HAS_LYRA_CODEC,0)
AC_MSG_RESULT([Checking if lyra is disabled... yes])
fi
],
[
if test "x$with_lyra" != "xno" -a "x$with_lyra" != "x"; then
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_LDFLAGS="-L$LYRA_PREFIX/lib"
AC_MSG_RESULT([Using lyra prefix... $with_lyra])
else
LYRA_CXXFLAGS=""
LYRA_LDFLAGS=""
fi

AC_MSG_CHECKING([lyra usability])

LYRA_LIBS="-llyra"

SAVED_LIBS="$LIBS"
SAVED_LDFLAGS="$LDFLAGS"
SAVED_CXXFLAGS="$CXXFLAGS"
SAVED_CPPFLAGS="$CPPFLAGS"

LIBS="$LYRA_LIBS $LIBS"
LDFLAGS="$LYRA_LDFLAGS $LDFLAGS"
CXXFLAGS="$LYRA_CXXFLAGS $CXXFLAGS"
CPPFLAGS="$LYRA_CPPFLAGS $CPPFLAGS"

AC_LANG_PUSH([C++])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "lyra_decoder.h"
]],
[std::unique_ptr<chromemedia::codec::LyraDecoder> dec = chromemedia::codec::LyraDecoder::Create(8000,1,"");]
)],
[
AC_DEFINE(PJMEDIA_HAS_LYRA_CODEC,1)
dnl # use single quoted preprocessor definition
LYRA_CPPFLAGS="'-DGLOG_DEPRECATED=__attribute__((deprecated))' '-DGLOG_EXPORT=__attribute__((visibility(\"default\")))' '-DGLOG_NO_EXPORT=__attribute__((visibility(\"default\")))'"
CXXFLAGS="$LYRA_CPPFLAGS $CXXFLAGS"
AC_MSG_RESULT(yes)
],
[
[ac_no_lyra_codec=1]
LIBS="$SAVED_LIBS"
LDFLAGS="$SAVED_LDFLAGS"
CXXFLAGS="$SAVED_CXXFLAGS"
AC_MSG_RESULT(no)
])
AC_LANG_POP([C++])
CPPFLAGS="$SAVED_CPPFLAGS"
])



dnl # Include libsrtp
AC_SUBST(ac_no_srtp)
Expand Down
7 changes: 7 additions & 0 deletions pjmedia/build/os-auto.mak.in
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ AC_NO_OPENCORE_AMRNB=@ac_no_opencore_amrnb@
AC_NO_OPENCORE_AMRWB=@ac_no_opencore_amrwb@
AC_NO_BCG729=@ac_no_bcg729@
AC_NO_ANDROID_MEDIACODEC=@ac_no_mediacodec@
AC_NO_LYRA_CODEC=@ac_no_lyra_codec@

export CODEC_OBJS=

Expand Down Expand Up @@ -152,6 +153,12 @@ else
export CODEC_OBJS += and_aud_mediacodec.o and_vid_mediacodec.o
endif

ifeq ($(AC_NO_LYRA_CODEC),1)
export CFLAGS += -DPJMEDIA_HAS_LYRA_CODEC=0
else
export CODEC_OBJS += lyra.o
endif

#
# SRTP
#
Expand Down
1 change: 1 addition & 0 deletions pjmedia/include/pjmedia-codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <pjmedia-codec/ilbc.h>
#include <pjmedia-codec/ipp_codecs.h>
#include <pjmedia-codec/l16.h>
#include <pjmedia-codec/lyra.h>
#include <pjmedia-codec/opencore_amr.h>
#include <pjmedia-codec/openh264.h>
#include <pjmedia-codec/opus.h>
Expand Down
18 changes: 18 additions & 0 deletions pjmedia/include/pjmedia-codec/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,24 @@
#endif


/**
* Enable Lyra codec.
*
* Default: 0
*/
#ifndef PJMEDIA_HAS_LYRA_CODEC
# define PJMEDIA_HAS_LYRA_CODEC 0
#endif

/**
* Lyra default bitrate setting
*
* Default: 3200 (available bitrate:3200, 6000, 9200)
*/
#ifndef PJMEDIA_CODEC_LYRA_DEFAULT_BIT_RATE
# define PJMEDIA_CODEC_LYRA_DEFAULT_BIT_RATE 3200
#endif

/**
* Specify if FFMPEG codecs are available.
*
Expand Down
5 changes: 5 additions & 0 deletions pjmedia/include/pjmedia-codec/config_auto.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@
#undef PJMEDIA_HAS_ANDROID_MEDIACODEC
#endif

/* Lyra codec */
#ifndef PJMEDIA_HAS_LYRA_CODEC
#undef PJMEDIA_HAS_LYRA_CODEC
#endif

#endif /* __PJMEDIA_CODEC_CONFIG_AUTO_H_ */


94 changes: 94 additions & 0 deletions pjmedia/include/pjmedia-codec/lyra.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
* Copyright (C) 2024 Teluu Inc. (http://www.teluu.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __PJMEDIA_CODEC_LYRA_H__
#define __PJMEDIA_CODEC_LYRA_H__

/**
* @file pjmedia-codec/lyra.hpp
* @brief lyra codec.
*/

#include <pjmedia-codec/types.h>

/**
* @defgroup PJMED_LYRA lyra Codec
* @ingroup PJMEDIA_CODEC_CODECS
* @brief Implementation of lyra Codec
* @{
*
* This section describes functions to initialize and register lyra codec
* factory to the codec manager. After the codec factory has been registered,
* application can use @ref PJMEDIA_CODEC API to manipulate the codec.
*
*/

PJ_BEGIN_DECL

typedef struct pjmedia_codec_lyra_config
{
unsigned bit_rate;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Describe the valid & default bitrates too?
And perhaps also clockrates?

pj_str_t model_path;
} pjmedia_codec_lyra_config;

/**
* Initialize and register lyra codec factory to pjmedia endpoint.
*
* @param endpt The pjmedia endpoint.
*
* @return PJ_SUCCESS on success.
*/
PJ_DECL(pj_status_t) pjmedia_codec_lyra_init(pjmedia_endpt *endpt);

/**
* Unregister lyra codec factory from pjmedia endpoint and deinitialize
* the lyra codec library.
*
* @return PJ_SUCCESS on success.
*/
PJ_DECL(pj_status_t) pjmedia_codec_lyra_deinit(void);

/**
* Get the default Lyra configuration.
*
* @param cfg Lyra codec configuration.
*
* @return PJ_SUCCESS on success.
*/
PJ_DECL(pj_status_t)
pjmedia_codec_lyra_get_config( pjmedia_codec_lyra_config *cfg);

/**
* Set the default Lyra configuration.
*
* @param cfg Lyra codec configuration.
*
* @return PJ_SUCCESS on success.
*/
PJ_DECL(pj_status_t)
pjmedia_codec_lyra_set_default_param(const pjmedia_codec_lyra_config *cfg);


PJ_END_DECL


/**
* @}
*/

#endif /* __PJMEDIA_CODEC_LYRA_H__ */

Loading
Loading