Commit a26e2588 authored by Ghislain MARY's avatar Ghislain MARY

Split init and exit in the two mediastreamer libraries to prevent undefined...

Split init and exit in the two mediastreamer libraries to prevent undefined reference errors at compilation on some systems.
parent d52aa772
......@@ -623,14 +623,7 @@ if test "$filters" = 'true'; then
fi
if test "$ortp_enabled" = 'true'; then
build_voip_library=true
elif test "$filters" = 'true'; then
build_voip_library=true
else
build_voip_library=false;
fi
AM_CONDITIONAL(BUILD_VOIP_LIBRARY, test x$build_voip_library = xtrue)
AM_CONDITIONAL(BUILD_VOIP_LIBRARY, test x$ortp_enabled = xtrue)
dnl check dlopen support in headers and libraries, so that we can use mediastreamer plugins
......
......@@ -162,11 +162,31 @@ MS2_PUBLIC MSList *ms_list_copy(const MSList *list);
/**
* Initialize the mediastreamer2 library.
* Helper macro for backward compatibility.
* Use ms_base_init() and ms_voip_init() instead.
*/
#define ms_init() ms_base_init(), ms_voip_init()
/**
* Helper macro for backward compatibility.
* Use ms_base_exit() and ms_voip_exit() instead.
*/
#define ms_exit() ms_voip_exit(), ms_base_exit()
/**
* Initialize the mediastreamer2 base library.
*
* This must be called once before calling any other API.
*/
MS2_PUBLIC void ms_init(void);
MS2_PUBLIC void ms_base_init(void);
/**
* Initialize the mediastreamer2 VoIP library.
*
* This must be called one before calling any other API.
*/
MS2_PUBLIC void ms_voip_init(void);
/**
* Load plugins from a specific directory.
......@@ -182,11 +202,18 @@ MS2_PUBLIC void ms_init(void);
MS2_PUBLIC int ms_load_plugins(const char *directory);
/**
* Release resource allocated in the mediastreamer2 library.
* Release resource allocated in the mediastreamer2 base library.
*
* This must be called once before closing program.
*/
MS2_PUBLIC void ms_base_exit(void);
/**
* Release resource allocated in the mediastreamer2 VoIP library.
*
* This must be called once before closing program.
*/
MS2_PUBLIC void ms_exit(void);
MS2_PUBLIC void ms_voip_exit(void);
struct _MSSndCardDesc;
......
......@@ -15,9 +15,9 @@ EXTRA_DIST= winsnd2.c winsnd.c winvideo.c \
winvideo2.c msjava.c $(ANDROID_SRC_FILES) \
$(GITVERSION_FILE) yuv2rgb.fs yuv2rgb.vs
BUILT_SOURCES=alldescs.h $(GITVERSION_FILE) yuv2rgb.fs.h yuv2rgb.vs.h
BUILT_SOURCES=basedescs.h $(GITVERSION_FILE) yuv2rgb.fs.h yuv2rgb.vs.h
CLEANFILES=alldescs.h filterdescs.txt $(GITVERSION_FILE) yuv2rgb.fs.h yuv2rgb.vs.h
CLEANFILES=basedescs.h voipdescs.h filterdescs.txt $(GITVERSION_FILE) yuv2rgb.fs.h yuv2rgb.vs.h
INCLUDES=-I$(top_srcdir)/include/
......@@ -46,7 +46,9 @@ nodist_EXTRA_libmediastreamer_base_la_SOURCES = dummy.cxx
if ORTP_ENABLED
libmediastreamer_voip_la_SOURCES+= audiostream.c \
BUILT_SOURCES+=voipdescs.h
libmediastreamer_voip_la_SOURCES+= msvoip.c \
audiostream.c \
ice.c \
msrtp.c \
qualityindicator.c \
......@@ -218,12 +220,17 @@ endif MS2_FILTERS
# Put 2 NULL values at the end of ms_filter-descs[] to prevent a GCC compilation error ('array subscript is above array bounds') when building with the --disable-filters option
alldescs.h: Makefile $(libmediastreamer_base_la_SOURCES) $(libmediastreamer_voip_la_SOURCES)
basedescs.h: Makefile $(libmediastreamer_base_la_SOURCES)
builddir=`pwd` && cd $(srcdir) && \
awk 'BEGIN { FS="[()]" ; }; /^\t*MS_FILTER_DESC_EXPORT/{ printf("%s\n", $$2) } ' > $$builddir/filterdescs.txt $(libmediastreamer_base_la_SOURCES) $(libmediastreamer_voip_la_SOURCES) && \
awk 'BEGIN { print("#include \"mediastreamer2/msfilter.h\"\n") } { printf("extern MSFilterDesc %s;\n",$$1) } ' $$builddir/filterdescs.txt > $$builddir/$@ && \
awk 'BEGIN { print("MSFilterDesc * ms_filter_descs[]={") } { printf("&%s,\n",$$1) } END{ print("NULL,\nNULL\n};\n") } ' $$builddir/filterdescs.txt >> $$builddir/$@
awk 'BEGIN { FS="[()]" ; }; /^\t*MS_FILTER_DESC_EXPORT/{ printf("%s\n", $$2) } ' > $$builddir/basedescs.txt $(libmediastreamer_base_la_SOURCES) && \
awk 'BEGIN { print("#include \"mediastreamer2/msfilter.h\"\n") } { printf("extern MSFilterDesc %s;\n",$$1) } ' $$builddir/basedescs.txt > $$builddir/$@ && \
awk 'BEGIN { print("MSFilterDesc * ms_base_filter_descs[]={") } { printf("&%s,\n",$$1) } END{ print("NULL\n};\n") } ' $$builddir/basedescs.txt >> $$builddir/$@
voipdescs.h: Makefile $(libmediastreamer_voip_la_SOURCES)
builddir=`pwd` && cd $(srcdir) && \
awk 'BEGIN { FS="[()]" ; }; /^\t*MS_FILTER_DESC_EXPORT/{ printf("%s\n", $$2) } ' > $$builddir/voipdescs.txt $(libmediastreamer_voip_la_SOURCES) && \
awk 'BEGIN { print("#include \"mediastreamer2/msfilter.h\"\n") } { printf("extern MSFilterDesc %s;\n",$$1) } ' $$builddir/voipdescs.txt > $$builddir/$@ && \
awk 'BEGIN { print("MSFilterDesc * ms_voip_filter_descs[]={") } { printf("&%s,\n",$$1) } END{ print("NULL\n};\n") } ' $$builddir/voipdescs.txt >> $$builddir/$@
libmediastreamer_base_la_LIBADD= $(ORTP_LIBS) \
......
......@@ -33,15 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2/mscodecutils.h"
#include "mediastreamer2/msfilter.h"
extern void __register_ffmpeg_encoders_if_possible(void);
extern void ms_ffmpeg_check_init();
extern bool_t libmsandroiddisplay_init(void);
extern void libmsandroiddisplaybad_init(void);
extern void libmsandroidopengldisplay_init(void);
#include "alldescs.h"
#include "mediastreamer2/mssndcard.h"
#include "mediastreamer2/mswebcam.h"
#include "basedescs.h"
#if !defined(_WIN32_WCE)
#include <sys/types.h>
......@@ -445,171 +437,6 @@ void ms_unload_plugins(){
#endif
}
#ifdef MS2_FILTERS
#ifdef __ALSA_ENABLED__
extern MSSndCardDesc alsa_card_desc;
#endif
#ifdef HAVE_SYS_SOUNDCARD_H
extern MSSndCardDesc oss_card_desc;
#endif
#ifdef __ARTS_ENABLED__
extern MSSndCardDesc arts_card_desc;
#endif
#ifdef WIN32
extern MSSndCardDesc winsnd_card_desc;
#endif
#ifdef __DIRECTSOUND_ENABLED__
extern MSSndCardDesc winsndds_card_desc;
#endif
#ifdef __MACSND_ENABLED__
extern MSSndCardDesc ca_card_desc;
#endif
#ifdef __PORTAUDIO_ENABLED__
extern MSSndCardDesc pasnd_card_desc;
#endif
#ifdef __MAC_AQ_ENABLED__
extern MSSndCardDesc aq_card_desc;
#endif
#ifdef __PULSEAUDIO_ENABLED__
extern MSSndCardDesc pulse_card_desc;
#endif
#if TARGET_OS_IPHONE
extern MSSndCardDesc au_card_desc;
#endif
#ifdef ANDROID
extern MSSndCardDesc msandroid_sound_card_desc;
#endif
#endif /* MS2_FILTERS */
static MSSndCardDesc * ms_snd_card_descs[]={
#ifdef MS2_FILTERS
#ifdef __ALSA_ENABLED__
&alsa_card_desc,
#endif
#ifdef HAVE_SYS_SOUNDCARD_H
&oss_card_desc,
#endif
#ifdef __ARTS_ENABLED__
&arts_card_desc,
#endif
#ifdef WIN32
&winsnd_card_desc,
#endif
#ifdef __DIRECTSOUND_ENABLED__
&winsndds_card_desc,
#endif
#ifdef __PORTAUDIO_ENABLED__
&pasnd_card_desc,
#endif
#ifdef __MACSND_ENABLED__
&ca_card_desc,
#endif
#ifdef __PULSEAUDIO_ENABLED__
&pulse_card_desc,
#endif
#if TARGET_OS_IPHONE
&au_card_desc,
#endif
#ifdef __MAC_AQ_ENABLED__
&aq_card_desc,
#endif
#ifdef ANDROID
&msandroid_sound_card_desc,
#endif
#endif /* MS2_FILTERS */
NULL
};
#ifdef VIDEO_ENABLED
#ifdef MS2_FILTERS
#ifdef HAVE_LINUX_VIDEODEV_H
extern MSWebCamDesc v4l_desc;
#endif
#ifdef HAVE_LINUX_VIDEODEV2_H
extern MSWebCamDesc v4l2_card_desc;
#endif
#ifdef WIN32
extern MSWebCamDesc ms_vfw_cam_desc;
#endif
#if defined(WIN32) && defined(HAVE_DIRECTSHOW)
extern MSWebCamDesc ms_directx_cam_desc;
#endif
#if defined(__MINGW32__) || defined (HAVE_DIRECTSHOW)
extern MSWebCamDesc ms_dshow_cam_desc;
#endif
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
extern MSWebCamDesc ms_v4m_cam_desc;
#endif
extern MSWebCamDesc static_image_desc;
#if !defined(NO_FFMPEG)
extern MSWebCamDesc mire_desc;
#endif
#ifdef ANDROID
extern MSWebCamDesc ms_android_video_capture_desc;
#endif
#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
extern MSWebCamDesc ms_v4ios_cam_desc;
#endif
#endif /* MS2_FILTERS */
static MSWebCamDesc * ms_web_cam_descs[]={
#ifdef MS2_FILTERS
#ifdef HAVE_LINUX_VIDEODEV2_H
&v4l2_card_desc,
#endif
#ifdef HAVE_LINUX_VIDEODEV_H
&v4l_desc,
#endif
#if defined(WIN32) && defined(HAVE_VFW)
&ms_vfw_cam_desc,
#endif
#if defined(__MINGW32__) || defined (HAVE_DIRECTSHOW)
&ms_dshow_cam_desc,
#endif
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
&ms_v4m_cam_desc,
#endif
#if defined (ANDROID)
&ms_android_video_capture_desc,
#endif
#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
&ms_v4ios_cam_desc,
#endif
#if !defined(NO_FFMPEG)
&mire_desc,
#endif
&static_image_desc,
#endif /*MS2_FILTERS */
NULL
};
#endif
#ifdef ANDROID
#define LOG_DOMAIN "mediastreamer"
static void ms_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
......@@ -626,9 +453,8 @@ static void ms_android_log_handler(OrtpLogLevel lev, const char *fmt, va_list ar
}
#endif
void ms_init(){
void ms_base_init(){
int i;
MSSndCardManager *cm;
#if defined(ENABLE_NLS)
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
......@@ -645,53 +471,19 @@ void ms_init(){
//#endif
ms_message("Mediastreamer2 " MEDIASTREAMER_VERSION " (git: " GIT_VERSION ") starting.");
/* register builtin MSFilter's */
for (i=0;ms_filter_descs[i]!=NULL;i++){
ms_filter_register(ms_filter_descs[i]);
}
ms_message("Registering all soundcard handlers");
cm=ms_snd_card_manager_get();
for (i=0;ms_snd_card_descs[i]!=NULL;i++){
ms_snd_card_manager_register_desc(cm,ms_snd_card_descs[i]);
for (i=0;ms_base_filter_descs[i]!=NULL;i++){
ms_filter_register(ms_base_filter_descs[i]);
}
#ifdef VIDEO_ENABLED
ms_message("Registering all webcam handlers");
{
MSWebCamManager *wm;
wm=ms_web_cam_manager_get();
for (i=0;ms_web_cam_descs[i]!=NULL;i++){
ms_web_cam_manager_register_desc(wm,ms_web_cam_descs[i]);
}
}
#if defined(MS2_FILTERS) && !defined(NO_FFMPEG)
ms_ffmpeg_check_init();
__register_ffmpeg_encoders_if_possible();
#endif
#endif
#ifdef PACKAGE_PLUGINS_DIR
ms_message("Loading ms plugins from [%s]",PACKAGE_PLUGINS_DIR);
ms_load_plugins(PACKAGE_PLUGINS_DIR);
#endif
#if defined(ANDROID) && defined (VIDEO_ENABLED)
if (1) {
libmsandroidopengldisplay_init();
} else {
if (!libmsandroiddisplay_init()) {
libmsandroiddisplaybad_init();
}
}
#endif
ms_message("ms_init() done");
}
void ms_exit(){
void ms_base_exit(){
ms_filter_unregister_all();
ms_snd_card_manager_destroy();
#ifdef VIDEO_ENABLED
ms_web_cam_manager_destroy();
#endif
ms_unload_plugins();
}
......
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2006 Simon MORLAT (simon.morlat@linphone.org)
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.
*/
#ifdef HAVE_CONFIG_H
#include "mediastreamer-config.h"
#include "gitversion.h"
#else
# ifndef MEDIASTREAMER_VERSION
# define MEDIASTREAMER_VERSION "unknown"
# endif
# ifndef GIT_VERSION
# define GIT_VERSION "unknown"
# endif
#endif
#include "mediastreamer2/mscommon.h"
#include "mediastreamer2/mscodecutils.h"
#include "mediastreamer2/msfilter.h"
extern void __register_ffmpeg_encoders_if_possible(void);
extern void ms_ffmpeg_check_init();
extern bool_t libmsandroiddisplay_init(void);
extern void libmsandroiddisplaybad_init(void);
extern void libmsandroidopengldisplay_init(void);
#include "voipdescs.h"
#include "mediastreamer2/mssndcard.h"
#include "mediastreamer2/mswebcam.h"
#ifdef __APPLE__
#include "TargetConditionals.h"
#endif
#ifdef ANDROID
#include <android/log.h>
#endif
#ifdef MS2_FILTERS
#ifdef __ALSA_ENABLED__
extern MSSndCardDesc alsa_card_desc;
#endif
#ifdef HAVE_SYS_SOUNDCARD_H
extern MSSndCardDesc oss_card_desc;
#endif
#ifdef __ARTS_ENABLED__
extern MSSndCardDesc arts_card_desc;
#endif
#ifdef WIN32
extern MSSndCardDesc winsnd_card_desc;
#endif
#ifdef __DIRECTSOUND_ENABLED__
extern MSSndCardDesc winsndds_card_desc;
#endif
#ifdef __MACSND_ENABLED__
extern MSSndCardDesc ca_card_desc;
#endif
#ifdef __PORTAUDIO_ENABLED__
extern MSSndCardDesc pasnd_card_desc;
#endif
#ifdef __MAC_AQ_ENABLED__
extern MSSndCardDesc aq_card_desc;
#endif
#ifdef __PULSEAUDIO_ENABLED__
extern MSSndCardDesc pulse_card_desc;
#endif
#if TARGET_OS_IPHONE
extern MSSndCardDesc au_card_desc;
#endif
#ifdef ANDROID
extern MSSndCardDesc msandroid_sound_card_desc;
#endif
#endif /* MS2_FILTERS */
static MSSndCardDesc * ms_snd_card_descs[]={
#ifdef MS2_FILTERS
#ifdef __ALSA_ENABLED__
&alsa_card_desc,
#endif
#ifdef HAVE_SYS_SOUNDCARD_H
&oss_card_desc,
#endif
#ifdef __ARTS_ENABLED__
&arts_card_desc,
#endif
#ifdef WIN32
&winsnd_card_desc,
#endif
#ifdef __DIRECTSOUND_ENABLED__
&winsndds_card_desc,
#endif
#ifdef __PORTAUDIO_ENABLED__
&pasnd_card_desc,
#endif
#ifdef __MACSND_ENABLED__
&ca_card_desc,
#endif
#ifdef __PULSEAUDIO_ENABLED__
&pulse_card_desc,
#endif
#if TARGET_OS_IPHONE
&au_card_desc,
#endif
#ifdef __MAC_AQ_ENABLED__
&aq_card_desc,
#endif
#ifdef ANDROID
&msandroid_sound_card_desc,
#endif
#endif /* MS2_FILTERS */
NULL
};
#ifdef VIDEO_ENABLED
#ifdef MS2_FILTERS
#ifdef HAVE_LINUX_VIDEODEV_H
extern MSWebCamDesc v4l_desc;
#endif
#ifdef HAVE_LINUX_VIDEODEV2_H
extern MSWebCamDesc v4l2_card_desc;
#endif
#ifdef WIN32
extern MSWebCamDesc ms_vfw_cam_desc;
#endif
#if defined(WIN32) && defined(HAVE_DIRECTSHOW)
extern MSWebCamDesc ms_directx_cam_desc;
#endif
#if defined(__MINGW32__) || defined (HAVE_DIRECTSHOW)
extern MSWebCamDesc ms_dshow_cam_desc;
#endif
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
extern MSWebCamDesc ms_v4m_cam_desc;
#endif
extern MSWebCamDesc static_image_desc;
#if !defined(NO_FFMPEG)
extern MSWebCamDesc mire_desc;
#endif
#ifdef ANDROID
extern MSWebCamDesc ms_android_video_capture_desc;
#endif
#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
extern MSWebCamDesc ms_v4ios_cam_desc;
#endif
#endif /* MS2_FILTERS */
static MSWebCamDesc * ms_web_cam_descs[]={
#ifdef MS2_FILTERS
#ifdef HAVE_LINUX_VIDEODEV2_H
&v4l2_card_desc,
#endif
#ifdef HAVE_LINUX_VIDEODEV_H
&v4l_desc,
#endif
#if defined(WIN32) && defined(HAVE_VFW)
&ms_vfw_cam_desc,
#endif
#if defined(__MINGW32__) || defined (HAVE_DIRECTSHOW)
&ms_dshow_cam_desc,
#endif
#if TARGET_OS_MAC && !TARGET_OS_IPHONE
&ms_v4m_cam_desc,
#endif
#if defined (ANDROID)
&ms_android_video_capture_desc,
#endif
#if TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR
&ms_v4ios_cam_desc,
#endif
#if !defined(NO_FFMPEG)
&mire_desc,
#endif
&static_image_desc,
#endif /*MS2_FILTERS */
NULL
};
#endif
void ms_voip_init(){
MSSndCardManager *cm;
int i;
/* register builtin VoIP MSFilter's */
for (i=0;ms_voip_filter_descs[i]!=NULL;i++){
ms_filter_register(ms_voip_filter_descs[i]);
}
ms_message("Registering all soundcard handlers");
cm=ms_snd_card_manager_get();
for (i=0;ms_snd_card_descs[i]!=NULL;i++){
ms_snd_card_manager_register_desc(cm,ms_snd_card_descs[i]);
}
#ifdef VIDEO_ENABLED
ms_message("Registering all webcam handlers");
{
MSWebCamManager *wm;
wm=ms_web_cam_manager_get();
for (i=0;ms_web_cam_descs[i]!=NULL;i++){
ms_web_cam_manager_register_desc(wm,ms_web_cam_descs[i]);
}
}
#if defined(MS2_FILTERS) && !defined(NO_FFMPEG)
ms_ffmpeg_check_init();
__register_ffmpeg_encoders_if_possible();
#endif
#endif
#ifdef PACKAGE_PLUGINS_DIR
ms_message("Loading ms plugins from [%s]",PACKAGE_PLUGINS_DIR);
ms_load_plugins(PACKAGE_PLUGINS_DIR);
#endif
#if defined(ANDROID) && defined (VIDEO_ENABLED)
if (1) {
libmsandroidopengldisplay_init();
} else {
if (!libmsandroiddisplay_init()) {
libmsandroiddisplaybad_init();
}
}
#endif
ms_message("ms_voip_init() done");
}
void ms_voip_exit(){
ms_snd_card_manager_destroy();
#ifdef VIDEO_ENABLED
ms_web_cam_manager_destroy();
#endif
}
......@@ -25,12 +25,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
int main(int argc, char *argv[]){
ms_init();
ms_base_init();
if (argc<2){
ms_error("Usage: mtudiscover [host]");
return -1;
}
ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
printf("result: %i \n",ms_discover_mtu(argv[1]));
ms_base_exit();
return 0;
}
......@@ -39,7 +39,7 @@ int main(int argc, char *argv[]){
MSFilter *src, *gen, *det, *rec;
MSTicker *ticker;
ms_init();
ms_base_init();
ortp_set_log_level_mask (ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
src=ms_filter_new(MS_FILE_PLAYER_ID);
......@@ -106,7 +106,7 @@ int main(int argc, char *argv[]){
ms_filter_destroy(det);
ms_filter_destroy(rec);
ms_exit();
ms_base_exit();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment