int main() { qeo_factory_t *open_qeo = NULL; qeo_factory_t *closed_qeo = NULL; qeocore_type_t *tsm_type = NULL; qeocore_type_t *dyn_type = NULL; /* create two factories */ assert(NULL != (open_qeo = qeocore_factory_new(QEO_IDENTITY_OPEN))); init_factory(open_qeo); assert(NULL != (closed_qeo = qeocore_factory_new(QEO_IDENTITY_DEFAULT))); init_factory(closed_qeo); /* register TSM type in open domain factory */ assert(NULL != (tsm_type = qeocore_type_register_tsm(open_qeo, org_qeo_system_RegistrationRequest_type, org_qeo_system_RegistrationRequest_type->name))); /* register dynamic type in closed domain factory */ assert(NULL != (dyn_type = types_get(org_qeo_system_RegistrationRequest_type))); assert(QEO_OK == qeocore_type_register(closed_qeo, dyn_type, org_qeo_system_RegistrationRequest_type->name)); /* clean up */ qeocore_type_free(dyn_type); qeocore_type_free(tsm_type); qeocore_factory_close(closed_qeo); qeocore_factory_close(open_qeo); return 0; }
int main(int argc, const char **argv) { qeo_factory_t *factory; qeocore_type_t *type; qeocore_reader_t *reader; qeocore_reader_listener_t listener = { .on_data = on_data_available }; qeocore_writer_t *writer; pthread_t th = 0; /* initialize */ sem_init(&_sync, 0, 0); assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT))); init_factory(factory); assert(NULL != (type = qeocore_type_register_tsm(factory, _tsm, _tsm[0].name))); assert(NULL != (reader = qeocore_reader_open(factory, type, NULL, QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE, &listener, NULL))); assert(NULL != (writer = qeocore_writer_open(factory, type, NULL, QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE, NULL, NULL))); /* start writer thread */ assert(0 == pthread_create(&th, NULL, run, writer)); /* make sure writing has started */ sem_wait(&_sync); /* shutdown reader */ qeocore_reader_close(reader); _closed = 1; /* shutdown writer */ _done = 1; pthread_join(th, NULL); qeocore_writer_close(writer); qeocore_type_free(type); qeocore_factory_close(factory); }
static void run_writer(pid_t peer) { // writer is a type_nest_i writer qeo_factory_t *factory; qeocore_type_t *type_nest_i; qeocore_writer_t *writer; qeocore_data_t *outer=NULL; qeocore_data_t *inner=NULL; int status; /* initialize */ assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT))); init_factory(factory); assert(NULL != (type_nest_i = type_nest_i_register(factory))); assert(NULL != (writer = qeocore_writer_open(factory, type_nest_i, NULL, QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE, NULL, NULL))); log_pid("=================================== writer initialized"); assert(NULL != (outer = qeocore_writer_data_new(writer))); /* fill outer struct */ assert(QEO_OK == qeocore_data_set_member(outer, _outer_int32_id, &_outer_int32_value)); assert(QEO_OK == qeocore_data_set_member(outer, _outer_int8_id, &_outer_int8_value)); assert(QEO_OK == qeocore_data_set_member(outer, _outer_string_id, &_outer_string_value)); assert(QEO_OK == qeocore_data_set_member(outer, _outer_int16_id, &_outer_int16_value)); assert(QEO_OK == qeocore_data_set_member(outer, _outer_int64_id, &_outer_int64_value)); /* fill inner struct */ assert(QEO_OK == qeocore_data_get_member(outer, _inner_id, &inner)); assert(QEO_OK == qeocore_data_set_member(inner, _inner_int32_id, &_inner_int32_value)); assert(QEO_OK == qeocore_data_set_member(inner, _inner_int8_id, &_inner_int8_value)); assert(QEO_OK == qeocore_data_set_member(inner, _inner_string_id, &_inner_string_value)); assert(QEO_OK == qeocore_data_set_member(inner, _inner_int16_id, &_inner_int16_value)); assert(QEO_OK == qeocore_data_set_member(inner, _inner_int64_id, &_inner_int64_value)); assert(QEO_OK == qeocore_data_set_member(outer, _inner_id, &inner)); log_verbose(" =================== _outer_int32_value = %u \n", _outer_int32_value ); log_verbose(" =================== _outer_int8_value = %u \n", _outer_int8_value ); log_verbose(" =================== _outer_int16_value = %u \n", _outer_int16_value ); log_verbose(" =================== _outer_int64_value = %"PRIu64" \n", _outer_int64_value ); log_verbose(" =================== _inner_int32_value = %u \n", _inner_int32_value ); log_verbose(" =================== _inner_int8_value = %u \n", _inner_int8_value ); log_verbose(" =================== _inner_int16_value = %u \n", _inner_int16_value ); log_verbose(" =================== _inner_int64_value = %"PRIu64" \n", _inner_int64_value ); /* write */ assert(QEO_OK == qeocore_writer_write(writer, outer)); log_pid("===================================== writer wrote outer data"); assert(peer == waitpid(peer, &status, 0)); assert(0 == status); log_pid("===================================== writer done"); /* clean up */ qeocore_data_free(inner); qeocore_data_free(outer); qeocore_writer_close(writer); qeocore_type_free(type_nest_i); qeocore_factory_close(factory); }
static void run_writer(pid_t peer) { qeo_factory_t *factory; qeocore_type_t *type; qeocore_writer_t *writer; qeocore_data_t *data, *seqdata; byte_array_t array; int status, i; /* initialize */ assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT))); init_factory(factory); assert(NULL != (type = type_register(factory))); assert(NULL != (writer = qeocore_writer_open(factory, type, NULL, QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE, NULL, NULL))); log_pid("writer initialized"); assert(NULL != (data = qeocore_writer_data_new(writer))); assert(QEO_OK == qeocore_data_set_member(data, _size_id, &_test_size)); /* init sequence */ DDS_SEQ_INIT(array); assert(NULL != (DDS_SEQ_DATA(array) = malloc(_test_size * sizeof(char)))); DDS_SEQ_LENGTH(array) = DDS_SEQ_MAXIMUM(array) = _test_size; for (i = 0; i < _test_size; i++) { DDS_SEQ_ITEM(array, i) = i & 0xff; } assert(QEO_OK == qeocore_data_get_member(data, _buf_id, &seqdata)); assert(QEO_OK == qeocore_data_sequence_set(seqdata, (const qeo_sequence_t *)&array, 0)); assert(QEO_OK == qeocore_data_set_member(data, _buf_id, &seqdata)); /* write */ assert(QEO_OK == qeocore_writer_write(writer, data)); log_pid("writer wrote data"); assert(peer == waitpid(peer, &status, 0)); assert(0 == status); log_pid("writer done"); /* clean up */ free(DDS_SEQ_DATA(array)); qeocore_data_free(seqdata); qeocore_data_free(data); qeocore_writer_close(writer); qeocore_type_free(type); qeocore_factory_close(factory); }
static void run_reader(void) { qeo_factory_t *factory; qeocore_type_t *type_nest_i; qeocore_reader_t *reader; qeocore_reader_listener_t listener = { .on_data = my_on_data_available }; sem_init(&_sync, 0, 0); assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT))); init_factory(factory); assert(NULL != (type_nest_i = type_nest_i_register(factory))); assert(NULL != (reader = qeocore_reader_open(factory, type_nest_i, NULL, QEOCORE_EFLAG_STATE_DATA | QEOCORE_EFLAG_ENABLE, &listener, NULL))); log_pid("=============================== reader initialized"); sem_wait(&_sync); /* wait for sample */ log_pid("=============================== reader done"); sem_destroy(&_sync); qeocore_reader_close(reader); qeocore_type_free(type_nest_i); qeocore_factory_close(factory); }
int main(int argc, const char **argv) { qeo_factory_t *factory; qeocore_reader_t *reader; qeocore_writer_t *writer; qeocore_type_t *type; qeocore_data_t *rdata, *wdata; int i; for (i = 0; i < 2; i++) { /* initialize */ assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT))); init_factory(factory); assert(NULL != (type = nested_type_get(1, 0, 0))); assert(QEO_OK == qeocore_type_register(factory, type, "nested")); assert(NULL != (reader = qeocore_reader_open(factory, type, NULL, QEOCORE_EFLAG_STATE_UPDATE | QEOCORE_EFLAG_ENABLE, NULL, NULL))); assert(NULL != (writer = qeocore_writer_open(factory, type, NULL, QEOCORE_EFLAG_STATE_UPDATE | QEOCORE_EFLAG_ENABLE, NULL, NULL))); /* write */ assert(NULL != (wdata = qeocore_writer_data_new(writer))); fill_data(wdata); assert(QEO_OK == qeocore_writer_write(writer, wdata)); /* check data */ assert(NULL != (rdata = qeocore_reader_data_new(reader))); assert(QEO_OK == qeocore_reader_read(reader, NULL, rdata)); expected_status = QEOCORE_DATA; validate_data(rdata); /* remove */ assert(QEO_OK == qeocore_writer_remove(writer, wdata)); /* clean up */ qeocore_data_free(wdata); qeocore_data_free(rdata); qeocore_writer_close(writer); qeocore_reader_close(reader); qeocore_type_free(type); qeocore_factory_close(factory); } }
int main(int argc, const char **argv) { qeo_factory_t *factory; qeocore_type_t *type; qeocore_reader_t *reader; qeocore_reader_listener_t listener = { .on_data = on_data_available }; qeocore_writer_t *writer; int i = 0; /* initialize */ sem_init(&_sync, 0, 0); sem_init(&_sync_nodata, 0, 0); assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT))); init_factory(factory); assert(NULL != (type = qeocore_type_register_tsm(factory, org_qeo_dynamic_qdm_test_TypeWithStructs_type, org_qeo_dynamic_qdm_test_TypeWithStructs_type[0].name))); assert(NULL != (reader = qeocore_reader_open(factory, type, NULL, QEOCORE_EFLAG_EVENT_DATA, &listener, NULL))); assert(NULL != (writer = qeocore_writer_open(factory, type, NULL, QEOCORE_EFLAG_EVENT_DATA, NULL, NULL))); /* test late enabling of readers/writers */ assert(QEO_OK == qeocore_reader_enable(reader)); assert(QEO_OK == qeocore_writer_enable(writer)); /* send structure */ for(i = 0; i < 20; i++){ log_verbose("testing with %d", i); assert(QEO_OK == write_generated_data(writer, i)); log_verbose("waiting for data"); /* wait for reception */ sem_wait(&_sync); sem_wait(&_sync_nodata); } /* clean up */ qeocore_writer_close(writer); qeocore_reader_close(reader); qeocore_type_free(type); qeocore_factory_close(factory); sem_destroy(&_sync); }
//Wrap start & stop PJ_DECL(pj_status_t) csipsimple_init(pjsua_config *ua_cfg, pjsua_logging_config *log_cfg, pjsua_media_config *media_cfg, csipsimple_config *css_cfg, jobject context) { pj_status_t result; unsigned i; /* Create memory pool for application. */ if(css_var.pool == NULL){ css_var.pool = pjsua_pool_create("css", 1000, 1000); PJ_ASSERT_RETURN(css_var.pool, PJ_ENOMEM); } // Finalize configuration log_cfg->cb = &pj_android_log_msg; // Static cfg extern pj_bool_t pjsip_use_compact_form; extern pj_bool_t pjsip_include_allow_hdr_in_dlg; extern pj_bool_t pjmedia_add_rtpmap_for_static_pt; extern pj_bool_t pjmedia_add_bandwidth_tias_in_sdp; extern pj_bool_t pjsua_no_update; extern pj_bool_t pjmedia_webrtc_use_ns; pjsua_no_update = css_cfg->use_no_update ? PJ_TRUE : PJ_FALSE; pjsip_use_compact_form = css_cfg->use_compact_form_headers ? PJ_TRUE : PJ_FALSE; /* do not transmit Allow header */ pjsip_include_allow_hdr_in_dlg = css_cfg->use_compact_form_headers ? PJ_FALSE : PJ_TRUE; /* Do not include rtpmap for static payload types (<96) */ pjmedia_add_rtpmap_for_static_pt = css_cfg->use_compact_form_sdp ? PJ_FALSE : PJ_TRUE; /* Do not enable bandwidth information inclusion in sdp */ pjmedia_add_bandwidth_tias_in_sdp = css_cfg->add_bandwidth_tias_in_sdp ? PJ_TRUE : PJ_FALSE; /* Use noise suppressor ? */ pjmedia_webrtc_use_ns = css_cfg->use_noise_suppressor ? PJ_TRUE : PJ_FALSE; css_tcp_keep_alive_interval = css_cfg->tcp_keep_alive_interval; css_tls_keep_alive_interval = css_cfg->tls_keep_alive_interval; // Transaction timeouts pjsip_sip_cfg_var.tsx.t1 = css_cfg->tsx_t1_timeout; pjsip_sip_cfg_var.tsx.t2 = css_cfg->tsx_t2_timeout; pjsip_sip_cfg_var.tsx.t4 = css_cfg->tsx_t4_timeout; pjsip_sip_cfg_var.tsx.td = css_cfg->tsx_td_timeout; pjsip_sip_cfg_var.endpt.disable_tcp_switch = css_cfg->disable_tcp_switch; pjsip_sip_cfg_var.endpt.disable_rport = css_cfg->disable_rport; // Audio codec cfg css_var.extra_aud_codecs_cnt = css_cfg->extra_aud_codecs_cnt; for (i = 0; i < css_cfg->extra_aud_codecs_cnt; i++) { dynamic_factory *css_codec = &css_var.extra_aud_codecs[i]; dynamic_factory *cfg_codec = &css_cfg->extra_aud_codecs[i]; pj_strdup_with_null(css_var.pool, &css_codec->shared_lib_path, &cfg_codec->shared_lib_path); pj_strdup_with_null(css_var.pool, &css_codec->init_factory_name, &cfg_codec->init_factory_name); } // Video codec cfg -- For now only destroy is useful but for future // hopefully vid codec mgr will behaves as audio does // Also in this case destroy will become obsolete css_var.extra_vid_codecs_cnt = css_cfg->extra_vid_codecs_cnt; for (i = 0; i < css_cfg->extra_vid_codecs_cnt; i++) { dynamic_factory *css_codec = &css_var.extra_vid_codecs[i]; dynamic_factory *cfg_codec = &css_cfg->extra_vid_codecs[i]; pj_strdup_with_null(css_var.pool, &css_codec->shared_lib_path, &cfg_codec->shared_lib_path); pj_strdup_with_null(css_var.pool, &css_codec->init_factory_name, &cfg_codec->init_factory_name); css_codec = &css_var.extra_vid_codecs_destroy[i]; cfg_codec = &css_cfg->extra_vid_codecs_destroy[i]; pj_strdup_with_null(css_var.pool, &css_codec->shared_lib_path, &cfg_codec->shared_lib_path); pj_strdup_with_null(css_var.pool, &css_codec->init_factory_name, &cfg_codec->init_factory_name); } // ZRTP cfg css_var.default_use_zrtp = css_cfg->use_zrtp; ua_cfg->cb.on_create_media_transport = &on_transport_created_wrapper; #if defined(PJMEDIA_HAS_ZRTP) && PJMEDIA_HAS_ZRTP!=0 pj_ansi_snprintf(css_var.zid_file, sizeof(css_var.zid_file), "%.*s/simple.zid", css_cfg->storage_folder.slen, css_cfg->storage_folder.ptr); #endif JNIEnv *jni_env = 0; ATTACH_JVM(jni_env); css_var.context = (*jni_env)->NewGlobalRef(jni_env, context); DETACH_JVM(jni_env); result = (pj_status_t) pjsua_init(ua_cfg, log_cfg, media_cfg); if (result == PJ_SUCCESS) { /* Ringback tone */ init_ringback_tone(); /* Init audio device */ pj_status_t added_audio = PJ_ENOTFOUND; if (css_cfg->audio_implementation.init_factory_name.slen > 0) { pjmedia_aud_dev_factory* (*init_factory)( pj_pool_factory *pf) = get_library_factory(&css_cfg->audio_implementation); if(init_factory != NULL) { pjmedia_aud_register_factory(init_factory); added_audio = PJ_SUCCESS; PJ_LOG(4, (THIS_FILE, "Loaded audio dev")); } } // Fallback to default audio dev if no one found if (added_audio != PJ_SUCCESS) { pjmedia_aud_register_factory(&pjmedia_android_factory); } // Init video device #if PJMEDIA_HAS_VIDEO // load renderer if (css_cfg->video_render_implementation.init_factory_name.slen > 0) { pjmedia_vid_dev_factory* (*init_factory)( pj_pool_factory *pf) = get_library_factory(&css_cfg->video_render_implementation); if(init_factory != NULL) { pjmedia_vid_register_factory(init_factory, NULL); PJ_LOG(4, (THIS_FILE, "Loaded video render dev")); } } // load capture if (css_cfg->video_capture_implementation.init_factory_name.slen > 0) { pjmedia_vid_dev_factory* (*init_factory)( pj_pool_factory *pf) = get_library_factory(&css_cfg->video_capture_implementation); if(init_factory != NULL) { pjmedia_vid_register_factory(init_factory, NULL); PJ_LOG(4, (THIS_FILE, "Loaded video capture dev")); } } // Load ffmpeg converter pjmedia_converter_mgr* cvrt_mgr = pjmedia_converter_mgr_instance(); if(css_cfg->vid_converter.init_factory_name.slen > 0){ pj_status_t (*init_factory)(pjmedia_converter_mgr* cvrt_mgr) = get_library_factory(&css_cfg->vid_converter); if(init_factory != NULL) { init_factory(cvrt_mgr); PJ_LOG(4, (THIS_FILE, "Loaded video converter")); } } // Load video codecs pjmedia_vid_codec_mgr* vid_mgr = pjmedia_vid_codec_mgr_instance(); for (i = 0; i < css_var.extra_vid_codecs_cnt; i++) { dynamic_factory *codec = &css_var.extra_vid_codecs[i]; pj_status_t (*init_factory)(pjmedia_vid_codec_mgr *mgr, pj_pool_factory *pf) = get_library_factory(codec); if(init_factory != NULL){ pj_status_t status = init_factory(vid_mgr, &pjsua_var.cp.factory); if(status != PJ_SUCCESS) { PJ_LOG(2, (THIS_FILE,"Error loading dynamic codec plugin")); } } } #endif } return result; }
PJ_DEF(pj_status_t) pjmedia_codec_register_audio_codecs(pjmedia_endpt *endpt, const pjmedia_audio_codec_config *c) { pjmedia_audio_codec_config default_cfg; pj_status_t status; PJ_ASSERT_RETURN(endpt, PJ_EINVAL); if (!c) { pjmedia_audio_codec_config_default(&default_cfg); c = &default_cfg; } PJ_ASSERT_RETURN(c->ilbc.mode==20 || c->ilbc.mode==30, PJ_EINVAL); #if PJMEDIA_HAS_PASSTHROUGH_CODECS status = pjmedia_codec_passthrough_init2(endpt, &c->passthough.ilbc); if (status != PJ_SUCCESS) return status; #endif #if PJMEDIA_HAS_SPEEX_CODEC /* Register speex. */ status = pjmedia_codec_speex_init(endpt, c->speex.option, c->speex.quality, c->speex.complexity); if (status != PJ_SUCCESS) return status; #endif #if PJMEDIA_HAS_ILBC_CODEC /* Register iLBC. */ status = pjmedia_codec_ilbc_init(endpt, c->ilbc.mode); if (status != PJ_SUCCESS) return status; #endif /* PJMEDIA_HAS_ILBC_CODEC */ #if PJMEDIA_HAS_GSM_CODEC /* Register GSM */ status = pjmedia_codec_gsm_init(endpt); if (status != PJ_SUCCESS) return status; #endif /* PJMEDIA_HAS_GSM_CODEC */ #if PJMEDIA_HAS_G711_CODEC /* Register PCMA and PCMU */ status = pjmedia_codec_g711_init(endpt); if (status != PJ_SUCCESS) return status; #endif /* PJMEDIA_HAS_G711_CODEC */ #if PJMEDIA_HAS_G722_CODEC status = pjmedia_codec_g722_init(endpt); if (status != PJ_SUCCESS) return status; #endif /* PJMEDIA_HAS_G722_CODEC */ #if PJMEDIA_HAS_L16_CODEC /* Register L16 family codecs */ status = pjmedia_codec_l16_init(endpt, 0); if (status != PJ_SUCCESS) return status; #endif /* PJMEDIA_HAS_L16_CODEC */ #if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC || PJMEDIA_HAS_OPENCORE_AMRWB_CODEC /* Register OpenCORE AMR */ status = pjmedia_codec_opencore_stagefright_init(endpt); if (status != PJ_SUCCESS) return status; #endif #if PJMEDIA_HAS_WEBRTC_CODEC /* Register WEBRTC */ status = pjmedia_codec_webrtc_init(endpt); if (status != PJ_SUCCESS) return status; #endif /* PJMEDIA_HAS_WEBRTC_CODEC */ #if PJMEDIA_HAS_SILK_CODEC status = pjmedia_codec_silk_init(endpt); if (status != PJ_SUCCESS) return status; // Our default config pjmedia_codec_silk_setting silk_settings; silk_settings.complexity = -1; silk_settings.enabled = PJ_TRUE; silk_settings.quality = 3; pjmedia_codec_silk_set_config(8000, &silk_settings); pjmedia_codec_silk_set_config(12000, &silk_settings); pjmedia_codec_silk_set_config(16000, &silk_settings); pjmedia_codec_silk_set_config(24000, &silk_settings); #endif /* PJMEDIA_HAS_SILK_CODEC */ // Dynamic loading of plugins codecs unsigned i; for (i = 0; i < css_var.extra_aud_codecs_cnt; i++) { dynamic_factory *codec = &css_var.extra_aud_codecs[i]; pj_status_t (*init_factory)( pjmedia_endpt *endpt) = get_library_factory(codec); if(init_factory != NULL){ status = init_factory(endpt); if(status != PJ_SUCCESS) { PJ_LOG(2, (THIS_FILE,"Error loading dynamic codec plugin")); } } } // Register opus sdp rewriter // TODO -- get info from registrations made previously + only when opus detected pjsip_opus_sdp_rewriter_init(16000); return PJ_SUCCESS; }
int main(int argc, const char **argv) { pid_t pid; pid = fork(); if (pid == -1) { perror("fork failed"); exit(EXIT_FAILURE); } else if (pid == 0) { log_verbose("=================== WRITER of type 1 \n"); qeo_factory_t *factory; qeocore_type_t *type1; qeocore_writer_t *writer; /* initialize */ assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT))); init_factory(factory); log_verbose(" =================== c qeocore_type_register_tsm(factory, _tsm_type_qdm_version1, _tsm_type_qdm_version1[0].name) \n"); assert(NULL != (type1 = qeocore_type_register_tsm(factory, _tsm_type_qdm_version1, _tsm_type_qdm_version1[0].name))); log_verbose(" =================== c qeocore_writer_open(factory, type1, NULL, QEOCORE_EFLAG_EVENT_DATA, NULL, NULL) \n"); assert(NULL != (writer = qeocore_writer_open(factory, type1, NULL, QEOCORE_EFLAG_EVENT_DATA, NULL, NULL))); /* test late enabling of readers/writers */ log_verbose(" =================== c qeocore_writer_enable(writer) \n"); assert(QEO_OK == qeocore_writer_enable(writer)); /* send structure */ sleep(2); log_verbose(" =================== c qeocore_writer_write(writer, &_type_qdm_version1) \n"); assert(QEO_OK == qeocore_writer_write(writer, &_type_qdm_version1)); sleep(2); /* clean up */ qeocore_writer_close(writer); qeocore_type_free(type1); qeocore_factory_close(factory); _exit(EXIT_SUCCESS); } else { log_verbose("=================== READER of type 2 \n"); qeo_factory_t *factory; qeocore_type_t *type2; qeocore_reader_t *reader; qeocore_reader_listener_t listener = { .on_data = on_data_available }; /* initialize */ sem_init(&_sync, 0, 0); sem_init(&_sync_nodata, 0, 0); assert(NULL != (factory = qeocore_factory_new(QEO_IDENTITY_DEFAULT))); init_factory(factory); log_verbose(" =================== p qeocore_type_register_tsm(factory, _tsm_type_qdm_version2, _tsm_type_qdm_version2[0].name) \n"); assert(NULL != (type2 = qeocore_type_register_tsm(factory, _tsm_type_qdm_version2, _tsm_type_qdm_version2[0].name))); log_verbose(" =================== p qeocore_reader_open(factory, type2, NULL, QEOCORE_EFLAG_EVENT_DATA, &listener, NULL) \n"); assert(NULL != (reader = qeocore_reader_open(factory, type2, NULL, QEOCORE_EFLAG_EVENT_DATA, &listener, NULL))); /* test late enabling of readers/writers */ log_verbose(" =================== p qeocore_reader_enable(reader) \n"); assert(QEO_OK == qeocore_reader_enable(reader)); /* wait for reception */ log_verbose(" =================== p sem_wait(&_sync) \n"); sem_wait(&_sync); log_verbose(" =================== p sem_wait(&_sync_nodata) \n"); sem_wait(&_sync_nodata); /* clean up */ qeocore_reader_close(reader); qeocore_type_free(type2); qeocore_factory_close(factory); sem_destroy(&_sync); int status; (void)waitpid(pid, &status, 0); } return EXIT_SUCCESS; }
PJ_DEF(pj_status_t) pjmedia_codec_register_audio_codecs(pjmedia_endpt *endpt, const pjmedia_audio_codec_config *c) { pjmedia_audio_codec_config default_cfg; pj_status_t status; PJ_ASSERT_RETURN(endpt, PJ_EINVAL); if (!c) { pjmedia_audio_codec_config_default(&default_cfg); c = &default_cfg; } PJ_ASSERT_RETURN(c->ilbc.mode==20 || c->ilbc.mode==30, PJ_EINVAL); #if PJMEDIA_HAS_PASSTHROUGH_CODECS status = pjmedia_codec_passthrough_init2(endpt, &c->passthough.ilbc); if (status != PJ_SUCCESS) return status; #endif #if PJMEDIA_HAS_SPEEX_CODEC /* Register speex. */ status = pjmedia_codec_speex_init(endpt, c->speex.option, c->speex.quality, c->speex.complexity); if (status != PJ_SUCCESS) return status; #endif #if PJMEDIA_HAS_ILBC_CODEC /* Register iLBC. */ status = pjmedia_codec_ilbc_init(endpt, c->ilbc.mode); if (status != PJ_SUCCESS) return status; #endif /* PJMEDIA_HAS_ILBC_CODEC */ #if PJMEDIA_HAS_GSM_CODEC /* Register GSM */ status = pjmedia_codec_gsm_init(endpt); if (status != PJ_SUCCESS) return status; #endif /* PJMEDIA_HAS_GSM_CODEC */ #if PJMEDIA_HAS_G711_CODEC /* Register PCMA and PCMU */ status = pjmedia_codec_g711_init(endpt); if (status != PJ_SUCCESS) return status; #endif /* PJMEDIA_HAS_G711_CODEC */ #if PJMEDIA_HAS_G722_CODEC status = pjmedia_codec_g722_init(endpt); if (status != PJ_SUCCESS) return status; #endif /* PJMEDIA_HAS_G722_CODEC */ #if PJMEDIA_HAS_L16_CODEC /* Register L16 family codecs */ status = pjmedia_codec_l16_init(endpt, 0); if (status != PJ_SUCCESS) return status; #endif /* PJMEDIA_HAS_L16_CODEC */ #if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC || PJMEDIA_HAS_AMR_STAGEFRIGHT_CODEC /* Register OpenCORE AMR-NB */ status = pjmedia_codec_opencore_amrnb_init(endpt); if (status != PJ_SUCCESS) return status; #endif #if PJMEDIA_HAS_WEBRTC_CODEC /* Register WEBRTC */ status = pjmedia_codec_webrtc_init(endpt); if (status != PJ_SUCCESS) return status; #endif /* PJMEDIA_HAS_WEBRTC_CODEC */ #if PJMEDIA_HAS_G729_CODEC /* Register WEBRTC */ status = pjmedia_codec_g729_init(endpt); if (status != PJ_SUCCESS) return status; #endif /* PJMEDIA_HAS_G729_CODEC */ // Dynamic loading of plugins codecs unsigned i; for (i = 0; i < css_var.extra_aud_codecs_cnt; i++) { dynamic_factory *codec = &css_var.extra_aud_codecs[i]; pj_status_t (*init_factory)( pjmedia_endpt *endpt) = get_library_factory(codec); if(init_factory != NULL){ status = init_factory(endpt); if(status != PJ_SUCCESS) { PJ_LOG(2, (THIS_FILE,"Error loading dynamic codec plugin")); } } } return PJ_SUCCESS; }