Commit c162da86 authored by Simon Morlat's avatar Simon Morlat

Mediastreamer2's logging facility now directly maps to bctoolbox's facility....

Mediastreamer2's logging facility now directly maps to bctoolbox's facility. Mediastreamer2's logs output into the "mediastreamer2 log domain.
parent 660aac9c
......@@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <bctoolbox/port.h>
#include <bctoolbox/list.h>
#include <ortp/logging.h>
#include <bctoolbox/logging.h>
#include <ortp/port.h>
#include <ortp/str_utils.h>
#include <ortp/payloadtype.h>
......@@ -120,17 +120,17 @@ static MS2_INLINE void ms_debug(const char *fmt,...)
{
va_list args;
va_start (args, fmt);
ortp_logv(ORTP_LOG_DOMAIN, ORTP_DEBUG, fmt, args);
bctbx_logv(BCTBX_LOG_DOMAIN, BCTBX_LOG_DEBUG, fmt, args);
va_end (args);
}
#else
#define ms_debug(fmt, ...)
#endif
#define ms_message ortp_message
#define ms_warning ortp_warning
#define ms_error ortp_error
#define ms_fatal ortp_fatal
#define ms_message bctbx_message
#define ms_warning bctbx_warning
#define ms_error bctbx_error
#define ms_fatal bctbx_fatal
#define ms_return_val_if_fail(_expr_,_ret_)\
if (!(_expr_)) { ms_fatal("assert "#_expr_ "failed"); return (_ret_);}
......
......@@ -71,6 +71,7 @@ add_definitions(
-DMS2_EXPORTS
-DMS2_INTERNAL
-DMS2_FILTERS
-DBCTBX_LOG_DOMAIN="mediastreamer"
)
set(BASE_LIBS
......
......@@ -349,11 +349,11 @@ static void android_snd_read_cb(int event, void* user, void *p_info){
* 1) understand why AudioRecord thread doesn't detach.
* 2) disable logs just for this thread (using a TLS)
*/
int loglevel=ortp_get_log_level_mask(ORTP_LOG_DOMAIN);
ortp_set_log_level_mask(NULL, ORTP_ERROR|ORTP_FATAL);
int loglevel=bctbx_get_log_level_mask(BCTBX_LOG_DOMAIN);
bctbx_set_log_level_mask(NULL, BCTBX_LOG_ERROR|BCTBX_LOG_FATAL);
ad->mTickerSynchronizer = ms_ticker_synchronizer_new();
ms_ticker_set_synchronizer(obj->ticker, ad->mTickerSynchronizer);
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, loglevel);
bctbx_set_log_level_mask(BCTBX_LOG_DOMAIN, loglevel);
}
if (event==AudioRecord::EVENT_MORE_DATA){
AudioRecord::Buffer info;
......
......@@ -421,11 +421,11 @@ static void opensles_recorder_callback(SLAndroidSimpleBufferQueueItf bq, void *c
* 1) understand why AudioRecord thread doesn't detach.
* 2) disable logs just for this thread (using a TLS)
*/
int loglevel=ortp_get_log_level_mask(ORTP_LOG_DOMAIN);
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_ERROR|ORTP_FATAL);
int loglevel=bctbx_get_log_level_mask(BCTBX_LOG_DOMAIN);
bctbx_set_log_level_mask(BCTBX_LOG_DOMAIN, BCTBX_LOG_ERROR|BCTBX_LOG_FATAL);
ictx->mTickerSynchronizer = ms_ticker_synchronizer_new();
ms_ticker_set_synchronizer(obj->ticker, ictx->mTickerSynchronizer);
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, loglevel);
bctbx_set_log_level_mask(BCTBX_LOG_DOMAIN, loglevel);
}
ictx->read_samples += ictx->inBufSize / sizeof(int16_t);
......
......@@ -617,10 +617,10 @@ static MSFilter *alsa_card_create_writer(MSSndCard *card)
void alsa_error_log_handler(const char *file, int line, const char *function, int err, const char *fmt, ...) {
char * format = ms_strdup_printf("also error in %s:%d - %s", file, line, fmt);
char * format = ms_strdup_printf("alsa error in %s:%d - %s", file, line, fmt);
va_list args;
va_start (args, fmt);
ortp_logv(ORTP_LOG_DOMAIN, ORTP_MESSAGE, format, args);
bctbx_logv(BCTBX_LOG_DOMAIN, BCTBX_LOG_MESSAGE, format, args);
va_end (args);
ms_free(format);
}
......
......@@ -172,7 +172,7 @@ void ms_factory_init(MSFactory *obj){
debug_log_enabled=getenv("MEDIASTREAMER_DEBUG");
#endif
if (debug_log_enabled!=NULL && (strcmp("1",debug_log_enabled)==0) ){
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
bctbx_set_log_level(BCTBX_LOG_DOMAIN, BCTBX_LOG_MESSAGE);
}
ms_message("Mediastreamer2 factory " MEDIASTREAMER_VERSION " (git: " MS2_GIT_VERSION ") initialized.");
......
......@@ -121,7 +121,7 @@ static const MSVideoConfiguration snow_conf_list[] = {
void ms_ffmpeg_log_callback(void* ptr, int level, const char* fmt, va_list vl)
{
ortp_logv(ORTP_MESSAGE,fmt,vl);
bctbx_logv(BCTBX_LOG_MESSAGE,fmt,vl);
}
#endif
......
......@@ -92,6 +92,10 @@ set(SOURCE_FILES_C
)
set(SOURCE_FILES_OBJC )
add_definitions(
-DBCTBX_LOG_DOMAIN="mediastreamer"
)
if(ENABLE_VIDEO)
list(APPEND SOURCE_FILES_C mediastreamer2_video_stream_tester.c)
if(ENABLE_PCAP)
......
......@@ -40,7 +40,7 @@ static void log_handler(int lev, const char *fmt, va_list args) {
va_end(cap);
#endif
if (log_file){
ortp_logv_out(ORTP_LOG_DOMAIN, lev, fmt, args);
bctbx_logv_out(BCTBX_LOG_DOMAIN, lev, fmt, args);
}
}
......@@ -90,7 +90,7 @@ int mediastreamer2_tester_set_log_file(const char *filename) {
#ifdef _MSC_VER
#pragma deprecated(message_state_changed_cb)
#endif
ortp_set_log_file(log_file);
bctbx_set_log_file(log_file);
#if defined(__clang__) || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4)
#pragma GCC diagnostic pop
#endif
......
......@@ -84,7 +84,7 @@ void NativeTester::initialize(StorageFolder^ writableDirectory, Platform::Boolea
}
else {
mediastreamer2_tester_init(NULL);
ortp_set_log_level_mask(NULL, (OrtpLogLevel)(ORTP_MESSAGE | ORTP_WARNING | ORTP_ERROR | ORTP_FATAL));
bctbx_set_log_level(NULL, BCTBX_LOG_MESSAGE);
}
char writable_dir[MAX_WRITABLE_DIR_SIZE] = { 0 };
......@@ -116,10 +116,10 @@ bool NativeTester::run(Platform::String^ suiteName, Platform::String^ caseName,
wcstombs(ccasename, wscasename.c_str(), sizeof(ccasename));
if (verbose) {
ortp_set_log_level_mask(NULL, ORTP_MESSAGE | ORTP_WARNING | ORTP_ERROR | ORTP_FATAL);
bctbx_set_log_level(NULL, BCTBX_LOG_MESSAGE);
}
else {
ortp_set_log_level_mask(NULL, ORTP_ERROR | ORTP_FATAL);
bctbx_set_log_level(NULL, BCTBX_LOG_ERROR);
}
bctbx_add_log_handler(log_handler);
return bc_tester_run_tests(wssuitename == all ? 0 : csuitename, wscasename == all ? 0 : ccasename, NULL) != 0;
......@@ -310,7 +310,7 @@ void NativeTester::initMS2()
{
if (_factory == nullptr) {
ortp_init();
ortp_set_log_level_mask(NULL, ORTP_MESSAGE | ORTP_WARNING | ORTP_ERROR | ORTP_FATAL);
bctbx_set_log_level(NULL, BCTBX_LOG_MESSAGE);
bctbx_log_handler_t *log_handler = bctbx_create_log_handler(ms2NativeOutputTraceHandler, NULL, NULL);
bctbx_add_log_handler(log_handler);
_factory = ms_factory_new_with_voip();
......
......@@ -700,12 +700,12 @@ void setup_media_streams(MediastreamDatas* args) {
MSFactory *factory;
ortp_init();
if (args->logfile)
ortp_set_log_file(args->logfile);
bctbx_set_log_file(args->logfile);
if (args->is_verbose) {
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_DEBUG|ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
bctbx_set_log_level(BCTBX_LOG_DOMAIN, BCTBX_LOG_DEBUG);
} else {
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
bctbx_set_log_level(BCTBX_LOG_DOMAIN, BCTBX_LOG_MESSAGE);
}
args->factory = factory = ms_factory_new_with_voip();
......
......@@ -248,9 +248,9 @@ void setup_media_streams(MediastreamDatas *args) {
/*create the rtp session */
ortp_init();
if (args->is_verbose) {
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_DEBUG | ORTP_MESSAGE | ORTP_WARNING | ORTP_ERROR | ORTP_FATAL);
bctbx_set_log_level(BCTBX_LOG_DOMAIN, BCTBX_LOG_DEBUG);
} else {
ortp_set_log_level_mask(ORTP_LOG_DOMAIN, ORTP_MESSAGE | ORTP_WARNING | ORTP_ERROR | ORTP_FATAL);
bctbx_set_log_level(BCTBX_LOG_DOMAIN, BCTBX_LOG_MESSAGE);
}
rtp_profile_set_payload(&av_profile, 110, &payload_type_speex_nb);
......
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