Exemplo n.º 1
0
/** Create demo verification engine */
MRCP_PLUGIN_DECLARE(mrcp_engine_t*) mrcp_plugin_create(apr_pool_t *pool)
{
	demo_verifier_engine_t *demo_engine = apr_palloc(pool,sizeof(demo_verifier_engine_t));
	apt_task_t *task;
	apt_task_vtable_t *vtable;
	apt_task_msg_pool_t *msg_pool;

	msg_pool = apt_task_msg_pool_create_dynamic(sizeof(demo_verifier_msg_t),pool);
	demo_engine->task = apt_consumer_task_create(demo_engine,msg_pool,pool);
	if(!demo_engine->task) {
		return NULL;
	}
	task = apt_consumer_task_base_get(demo_engine->task);
	apt_task_name_set(task,VERIFIER_ENGINE_TASK_NAME);
	vtable = apt_task_vtable_get(task);
	if(vtable) {
		vtable->process_msg = demo_verifier_msg_process;
	}

	/* create engine base */
	return mrcp_engine_create(
				MRCP_VERIFIER_RESOURCE,    /* MRCP resource identifier */
				demo_engine,               /* object to associate */
				&engine_vtable,            /* virtual methods table of engine */
				pool);                     /* pool to allocate memory from */
}
Exemplo n.º 2
0
/** Create MRCP client instance */
MRCP_DECLARE(mrcp_client_t*) mrcp_client_create(apt_dir_layout_t *dir_layout)
{
	mrcp_client_t *client;
	apr_pool_t *pool;
	apt_task_t *task;
	apt_task_vtable_t *vtable;
	apt_task_msg_pool_t *msg_pool;
	
	pool = apt_pool_create();
	if(!pool) {
		return NULL;
	}

	apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create "CLIENT_TASK_NAME);
	client = apr_palloc(pool,sizeof(mrcp_client_t));
	client->pool = pool;
	client->dir_layout = dir_layout;
	client->resource_factory = NULL;
	client->media_engine_table = NULL;
	client->rtp_factory_table = NULL;
	client->sig_agent_table = NULL;
	client->sig_settings_table = NULL;
	client->cnt_agent_table = NULL;
	client->rtp_settings_table = NULL;
	client->profile_table = NULL;
	client->app_table = NULL;
	client->session_table = NULL;
	client->cnt_msg_pool = NULL;

	msg_pool = apt_task_msg_pool_create_dynamic(0,pool);
	client->task = apt_consumer_task_create(client,msg_pool,pool);
	if(!client->task) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Client Task");
		return NULL;
	}
	task = apt_consumer_task_base_get(client->task);
	apt_task_name_set(task,CLIENT_TASK_NAME);
	vtable = apt_task_vtable_get(task);
	if(vtable) {
		vtable->process_msg = mrcp_client_msg_process;
		vtable->on_start_complete = mrcp_client_on_start_complete;
		vtable->on_terminate_complete = mrcp_client_on_terminate_complete;
	}

	client->media_engine_table = apr_hash_make(client->pool);
	client->rtp_factory_table = apr_hash_make(client->pool);
	client->sig_agent_table = apr_hash_make(client->pool);
	client->sig_settings_table = apr_hash_make(client->pool);
	client->cnt_agent_table = apr_hash_make(client->pool);
	client->rtp_settings_table = apr_hash_make(client->pool);
	client->profile_table = apr_hash_make(client->pool);
	client->app_table = apr_hash_make(client->pool);
	
	client->session_table = apr_hash_make(client->pool);

	client->on_start_complete = NULL;
	client->sync_start_object = NULL;
	client->sync_start_mutex = NULL;
	return client;
}
/** Create UniRTSP Signaling Agent */
MRCP_DECLARE(mrcp_sig_agent_t*) mrcp_unirtsp_server_agent_create(rtsp_server_config_t *config, apr_pool_t *pool)
{
	apt_task_vtable_t vtable;
	apt_task_msg_pool_t *msg_pool;
	apt_consumer_task_t *consumer_task;
	mrcp_unirtsp_agent_t *agent;
	agent = apr_palloc(pool,sizeof(mrcp_unirtsp_agent_t));
	agent->sig_agent = mrcp_signaling_agent_create(agent,MRCP_VERSION_1,pool);
	agent->config = config;

	if(rtsp_config_validate(agent,config,pool) == FALSE) {
		return NULL;
	}

	agent->rtsp_server = rtsp_server_create(config->local_ip,config->local_port,config->max_connection_count,
										agent,&session_request_vtable,pool);
	if(!agent->rtsp_server) {
		return NULL;
	}

	msg_pool = apt_task_msg_pool_create_dynamic(0,pool);

	apt_task_vtable_reset(&vtable);
	vtable.destroy = server_destroy;
	vtable.on_start_complete = server_on_start_complete;
	vtable.on_terminate_complete = server_on_terminate_complete;
	consumer_task = apt_consumer_task_create(agent,&vtable,msg_pool,pool);
	agent->sig_agent->task = apt_consumer_task_base_get(consumer_task);
	apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create UniRTSP Agent %s:%hu [%d]",
		config->local_ip,
		config->local_port,
		config->max_connection_count);
	return agent->sig_agent;
}
Exemplo n.º 4
0
/** Create MRCP server instance */
MRCP_DECLARE(mrcp_server_t*) mrcp_server_create(apt_dir_layout_t *dir_layout)
{
	mrcp_server_t *server;
	apr_pool_t *pool;
	apt_task_vtable_t vtable;
	apt_task_msg_pool_t *msg_pool;
	
	if(apr_pool_create(&pool,NULL) != APR_SUCCESS) {
		return NULL;
	}

	apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create MRCP Server");
	server = apr_palloc(pool,sizeof(mrcp_server_t));
	server->pool = pool;
	server->dir_layout = dir_layout;
	server->resource_factory = NULL;
	server->resource_engine_table = NULL;
	server->media_engine_table = NULL;
	server->rtp_factory_table = NULL;
	server->sig_agent_table = NULL;
	server->cnt_agent_table = NULL;
	server->profile_table = NULL;
	server->plugin_table = NULL;
	server->session_table = NULL;
	server->connection_msg_pool = NULL;
	server->resource_engine_msg_pool = NULL;

	apt_task_vtable_reset(&vtable);
	vtable.process_msg = mrcp_server_msg_process;
	vtable.on_start_complete = mrcp_server_on_start_complete;
	vtable.on_terminate_complete = mrcp_server_on_terminate_complete;

	msg_pool = apt_task_msg_pool_create_dynamic(0,pool);

	server->task = apt_consumer_task_create(server, &vtable, msg_pool, pool);
	if(!server->task) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Server Task");
		return NULL;
	}

	server->resource_engine_table = apr_hash_make(server->pool);
	server->media_engine_table = apr_hash_make(server->pool);
	server->rtp_factory_table = apr_hash_make(server->pool);
	server->sig_agent_table = apr_hash_make(server->pool);
	server->cnt_agent_table = apr_hash_make(server->pool);

	server->profile_table = apr_hash_make(server->pool);
	server->plugin_table = apr_hash_make(server->pool);
	
	server->session_table = apr_hash_make(server->pool);
	return server;
}
Exemplo n.º 5
0
static apt_bool_t consumer_task_test_run(apt_test_suite_t *suite, int argc, const char * const *argv)
{
	apt_consumer_task_t *consumer_task;
	apt_task_t *task;
	apt_task_vtable_t *vtable;
	apt_task_msg_pool_t *msg_pool;
	apt_task_msg_t *msg;
	sample_msg_data_t *data;
	int i;
	
	msg_pool = apt_task_msg_pool_create_dynamic(sizeof(sample_msg_data_t),suite->pool);

	apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create Consumer Task");
	consumer_task = apt_consumer_task_create(NULL,msg_pool,suite->pool);
	if(!consumer_task) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Consumer Task");
		return FALSE;
	}
	task = apt_consumer_task_base_get(consumer_task);
	vtable = apt_task_vtable_get(task);
	if(vtable) {
		vtable->process_msg = task_msg_process;
		vtable->on_start_complete = task_on_start_complete;
		vtable->on_terminate_complete = task_on_terminate_complete;
	}

	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Start Task");
	if(apt_task_start(task) == FALSE) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Start Task");
		apt_task_destroy(task);
		return FALSE;
	}

	for(i=0; i<10; i++) {
		msg = apt_task_msg_acquire(msg_pool);
		msg->type = TASK_MSG_USER;
		data = (sample_msg_data_t*) msg->data;

		data->number = i;
		data->timestamp = apr_time_now();
		apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Signal Message [%d]",data->number);
		apt_task_msg_signal(task,msg);
	}

	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Terminate Task [wait till complete]");
	apt_task_terminate(task,TRUE);
	apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Destroy Task");
	apt_task_destroy(task);
	return TRUE;
}
Exemplo n.º 6
0
/** Create MRCP client instance */
MRCP_DECLARE(mrcp_client_t*) mrcp_client_create(apt_dir_layout_t *dir_layout)
{
	mrcp_client_t *client;
	apr_pool_t *pool;
	apt_task_vtable_t vtable;
	apt_task_msg_pool_t *msg_pool;
	
	if(apr_pool_create(&pool,NULL) != APR_SUCCESS) {
		return NULL;
	}

	apt_log(APT_PRIO_NOTICE,"Create MRCP Client");
	client = apr_palloc(pool,sizeof(mrcp_client_t));
	client->pool = pool;
	client->dir_layout = dir_layout;
	client->resource_factory = NULL;
	client->media_engine_table = NULL;
	client->rtp_factory_table = NULL;
	client->sig_agent_table = NULL;
	client->cnt_agent_table = NULL;
	client->profile_table = NULL;
	client->app_table = NULL;
	client->session_table = NULL;
	client->cnt_msg_pool = NULL;

	apt_task_vtable_reset(&vtable);
	vtable.process_msg = mrcp_client_msg_process;
	vtable.on_start_complete = mrcp_client_on_start_complete;
	vtable.on_terminate_complete = mrcp_client_on_terminate_complete;

	msg_pool = apt_task_msg_pool_create_dynamic(0,pool);
	client->task = apt_consumer_task_create(client, &vtable, msg_pool, pool);
	if(!client->task) {
		apt_log(APT_PRIO_WARNING,"Failed to Create Client Task");
		return NULL;
	}

	client->media_engine_table = apr_hash_make(client->pool);
	client->rtp_factory_table = apr_hash_make(client->pool);
	client->sig_agent_table = apr_hash_make(client->pool);
	client->cnt_agent_table = apr_hash_make(client->pool);
	client->profile_table = apr_hash_make(client->pool);
	client->app_table = apr_hash_make(client->pool);
	
	client->session_table = apr_hash_make(client->pool);
	return client;
}
Exemplo n.º 7
0
/** Create demo synthesizer engine */
MRCP_PLUGIN_DECLARE(mrcp_resource_engine_t*) mrcp_plugin_create(apr_pool_t *pool)
{
	/* create demo engine */
	demo_synth_engine_t *demo_engine = apr_palloc(pool,sizeof(demo_synth_engine_t));
	apt_task_vtable_t task_vtable;
	apt_task_msg_pool_t *msg_pool;

	/* create task/thread to run demo engine in the context of this task */
	apt_task_vtable_reset(&task_vtable);
	task_vtable.process_msg = demo_synth_msg_process;
	msg_pool = apt_task_msg_pool_create_dynamic(sizeof(demo_synth_msg_t),pool);
	demo_engine->task = apt_consumer_task_create(demo_engine,&task_vtable,msg_pool,pool);

	/* create resource engine base */
	return mrcp_resource_engine_create(
					MRCP_SYNTHESIZER_RESOURCE, /* MRCP resource identifier */
					demo_engine,               /* object to associate */
					&engine_vtable,            /* virtual methods table of resource engine */
					pool);                     /* pool to allocate memory from */
}
Exemplo n.º 8
0
static apt_bool_t demo_framework_consumer_task_create(demo_framework_t *framework)
{
	apt_task_t *task;
	apt_task_vtable_t *vtable;
	apt_task_msg_pool_t *msg_pool;

	msg_pool = apt_task_msg_pool_create_dynamic(sizeof(framework_task_data_t),framework->pool);
	framework->task = apt_consumer_task_create(framework,msg_pool,framework->pool);
	if(!framework->task) {
		return FALSE;
	}
	task = apt_consumer_task_base_get(framework->task);
	apt_task_name_set(task,FRAMEWORK_TASK_NAME);
	vtable = apt_consumer_task_vtable_get(framework->task);
	if(vtable) {
		vtable->process_msg = demo_framework_msg_process;
		vtable->on_start_complete = demo_framework_on_start_complete;
	}

	return TRUE;
}
Exemplo n.º 9
0
bool UmcFramework::CreateTask()
{
	apt_task_t* pTask;
	apt_task_vtable_t* pVtable;
	apt_task_msg_pool_t* pMsgPool;

	pMsgPool = apt_task_msg_pool_create_dynamic(sizeof(UmcTaskMsg),m_pPool);
	m_pTask = apt_consumer_task_create(this,pMsgPool,m_pPool);
	if(!m_pTask)
		return false;

	pTask = apt_consumer_task_base_get(m_pTask);
	apt_task_name_set(pTask,"Framework Agent");
	pVtable = apt_consumer_task_vtable_get(m_pTask);
	if(pVtable) 
	{
		pVtable->process_msg = UmcProcessMsg;
		pVtable->on_start_complete = UmcOnStartComplete;
		pVtable->on_terminate_complete = UmcOnTerminateComplete;
	}

	apt_task_start(pTask);
	return true;
}
Exemplo n.º 10
0
/** Create MRCP server instance */
MRCP_DECLARE(mrcp_server_t*) mrcp_server_create(apt_dir_layout_t *dir_layout)
{
	mrcp_server_t *server;
	apr_pool_t *pool;
	apt_task_t *task;
	apt_task_vtable_t *vtable;
	apt_task_msg_pool_t *msg_pool;
	
	pool = apt_pool_create();
	if(!pool) {
		return NULL;
	}

	apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create "SERVER_TASK_NAME);
	server = apr_palloc(pool,sizeof(mrcp_server_t));
	server->pool = pool;
	server->dir_layout = dir_layout;
	server->resource_factory = NULL;
	server->engine_factory = NULL;
	server->engine_loader = NULL;
	server->media_engine_table = NULL;
	server->rtp_factory_table = NULL;
	server->sig_agent_table = NULL;
	server->cnt_agent_table = NULL;
	server->rtp_settings_table = NULL;
	server->profile_table = NULL;
	server->session_table = NULL;
	server->connection_msg_pool = NULL;
	server->engine_msg_pool = NULL;

	msg_pool = apt_task_msg_pool_create_dynamic(0,pool);

	server->task = apt_consumer_task_create(server,msg_pool,pool);
	if(!server->task) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Server Task");
		return NULL;
	}
	task = apt_consumer_task_base_get(server->task);
	apt_task_name_set(task,SERVER_TASK_NAME);
	vtable = apt_task_vtable_get(task);
	if(vtable) {
		vtable->process_msg = mrcp_server_msg_process;
		vtable->on_start_request = mrcp_server_on_start_request;
		vtable->on_terminate_request = mrcp_server_on_terminate_request;
		vtable->on_start_complete = mrcp_server_on_start_complete;
		vtable->on_terminate_complete = mrcp_server_on_terminate_complete;
	}

	server->engine_factory = mrcp_engine_factory_create(server->pool);
	server->engine_loader = mrcp_engine_loader_create(server->pool);

	server->media_engine_table = apr_hash_make(server->pool);
	server->rtp_factory_table = apr_hash_make(server->pool);
	server->rtp_settings_table = apr_hash_make(server->pool);
	server->sig_agent_table = apr_hash_make(server->pool);
	server->cnt_agent_table = apr_hash_make(server->pool);

	server->profile_table = apr_hash_make(server->pool);
	
	server->session_table = apr_hash_make(server->pool);
	return server;
}
Exemplo n.º 11
0
/** Run MPF test suite */
static apt_bool_t mpf_test_run(apt_test_suite_t *suite, int argc, const char * const *argv)
{
	mpf_suite_agent_t *agent;
	mpf_codec_manager_t *codec_manager;
	mpf_rtp_config_t *rtp_config;
	mpf_rtp_settings_t *rtp_settings;
	mpf_engine_t *engine;

	apt_task_t *task;
	apt_task_vtable_t *vtable;
	apt_task_msg_pool_t *msg_pool;

	agent = apr_palloc(suite->pool,sizeof(mpf_suite_agent_t));

	agent->dir_layout = apt_default_dir_layout_create(NULL,suite->pool);
	engine = mpf_engine_create("MPF-Engine",suite->pool);
	if(!engine) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create MPF Engine");
		return FALSE;
	}

	codec_manager = mpf_engine_codec_manager_create(suite->pool);
	if(!codec_manager) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Codec Manager");
		return FALSE;
	}
		
	mpf_engine_codec_manager_register(engine,codec_manager);
	agent->engine = engine;

	rtp_config = mpf_rtp_config_alloc(suite->pool);
	apt_string_set(&rtp_config->ip,"127.0.0.1");
	rtp_config->rtp_port_min = 5000;
	rtp_config->rtp_port_max = 6000;

	agent->rtp_config = rtp_config;

	rtp_settings = mpf_rtp_settings_alloc(suite->pool);
	rtp_settings->ptime = 20;
	rtp_settings->jb_config.adaptive = 1;
	rtp_settings->jb_config.time_skew_detection = 1;
	rtp_settings->jb_config.min_playout_delay = 0;
	rtp_settings->jb_config.initial_playout_delay = 50;
	rtp_settings->jb_config.max_playout_delay = 800;
	mpf_codec_manager_codec_list_load(codec_manager,&rtp_settings->codec_list,"PCMU",suite->pool);

	agent->rtp_settings = rtp_settings;

	agent->rtp_termination_factory = mpf_rtp_termination_factory_create(rtp_config,suite->pool);
	agent->file_termination_factory = mpf_file_termination_factory_create(suite->pool);

	agent->rx_session = NULL;
	agent->tx_session = NULL;

	msg_pool = apt_task_msg_pool_create_dynamic(sizeof(mpf_message_t),suite->pool);

	apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create Consumer Task");
	agent->consumer_task = apt_consumer_task_create(agent,msg_pool,suite->pool);
	if(!agent->consumer_task) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Consumer Task");
		return FALSE;
	}
	task = apt_consumer_task_base_get(agent->consumer_task);
	apt_task_name_set(task,"MPF-Tester");
	vtable = apt_task_vtable_get(task);
	if(vtable) {
		vtable->process_msg = mpf_suite_task_msg_process;
		vtable->on_start_complete = mpf_suite_on_start_complete;
		vtable->on_terminate_complete = mpf_suite_on_terminate_complete;
	}

	apt_task_add(task,mpf_task_get(engine));

	apr_thread_mutex_create(&agent->wait_object_mutex,APR_THREAD_MUTEX_UNNESTED,suite->pool);
	apr_thread_cond_create(&agent->wait_object,suite->pool);

	if(apt_task_start(task) == FALSE) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Start Task");
		apt_task_destroy(task);
		return FALSE;
	}

	apr_thread_mutex_lock(agent->wait_object_mutex);
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Wait for Task to Complete");
	apr_thread_cond_wait(agent->wait_object,agent->wait_object_mutex);
	apr_thread_mutex_unlock(agent->wait_object_mutex);
	
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Terminate Task [wait till complete]");
	apt_task_terminate(task,TRUE);
	apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Destroy Task");
	apt_task_destroy(task);

	apr_thread_cond_destroy(agent->wait_object);
	apr_thread_mutex_destroy(agent->wait_object_mutex);
	return TRUE;
}
Exemplo n.º 12
0
/** Run MPF test suite */
static apt_bool_t mpf_test_run(apt_test_suite_t *suite, int argc, const char * const *argv)
{
	mpf_suite_engine_t *suite_engine;
	mpf_codec_manager_t *codec_manager;
	mpf_rtp_config_t *config;
	mpf_engine_t *engine;

	apt_task_t *task;
	apt_task_vtable_t *vtable;
	apt_task_msg_pool_t *msg_pool;

	suite_engine = apr_palloc(suite->pool,sizeof(mpf_suite_engine_t));

	engine = mpf_engine_create(suite->pool);
	if(!engine) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create MPF Engine");
		return FALSE;
	}
	codec_manager = mpf_engine_codec_manager_create(suite->pool);
	if(codec_manager) {
		mpf_engine_codec_manager_register(engine,codec_manager);
	}
	suite_engine->engine = engine;

	config = mpf_rtp_config_alloc(suite->pool);
	apt_string_set(&config->ip,"127.0.0.1");
	config->rtp_port_min = 5000;
	config->rtp_port_min = 6000;
	suite_engine->rtp_termination_factory = mpf_rtp_termination_factory_create(config,suite->pool);
	suite_engine->file_termination_factory = mpf_file_termination_factory_create(suite->pool);

	msg_pool = apt_task_msg_pool_create_dynamic(sizeof(mpf_message_t),suite->pool);

	apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create Consumer Task");
	suite_engine->consumer_task = apt_consumer_task_create(suite_engine,msg_pool,suite->pool);
	if(!suite_engine->consumer_task) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Consumer Task");
		return FALSE;
	}
	task = apt_consumer_task_base_get(suite_engine->consumer_task);
	vtable = apt_task_vtable_get(task);
	if(vtable) {
		vtable->process_msg = mpf_suite_task_msg_process;
		vtable->on_start_complete = mpf_suite_on_start_complete;
		vtable->on_terminate_complete = mpf_suite_on_terminate_complete;
	}

	apt_task_add(task,mpf_task_get(engine));

	apr_thread_mutex_create(&suite_engine->wait_object_mutex,APR_THREAD_MUTEX_UNNESTED,suite->pool);
	apr_thread_cond_create(&suite_engine->wait_object,suite->pool);

	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Start Task");
	if(apt_task_start(task) == FALSE) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Start Task");
		apt_task_destroy(task);
		return FALSE;
	}

	apr_thread_mutex_lock(suite_engine->wait_object_mutex);
	apr_thread_cond_wait(suite_engine->wait_object,suite_engine->wait_object_mutex);
	apr_thread_mutex_unlock(suite_engine->wait_object_mutex);
	
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Terminate Task [wait till complete]");
	apt_task_terminate(task,TRUE);
	apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Destroy Task");
	apt_task_destroy(task);

	apr_thread_cond_destroy(suite_engine->wait_object);
	apr_thread_mutex_destroy(suite_engine->wait_object_mutex);
	return TRUE;
}