Пример #1
0
static apt_bool_t task_test_run(apt_test_suite_t *suite, int argc, const char * const *argv)
{
	apt_task_t *task;
	apt_task_vtable_t *vtable;

	apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Create Task");
	task = apt_task_create(NULL,NULL,suite->pool);
	if(!task) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Task");
		return FALSE;
	}
	vtable = apt_task_vtable_get(task);
	if(vtable) {
		vtable->run = task_main;
	}

	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;
	}

	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Wait for Task to Complete");
	apt_task_wait_till_complete(task);
	apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Destroy Task");
	apt_task_destroy(task);
	return TRUE;
}
Пример #2
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;
}
Пример #3
0
/** Destroy connection task. */
APT_DECLARE(apt_bool_t) apt_net_client_task_destroy(apt_net_client_task_t *task)
{
	if(task->guard) {
		apr_thread_mutex_destroy(task->guard);
		task->guard = NULL;
	}
	return apt_task_destroy(task->base);
}
Пример #4
0
/** Destroy verification engine */
static apt_bool_t demo_verifier_engine_destroy(mrcp_engine_t *engine)
{
	demo_verifier_engine_t *demo_engine = engine->obj;
	if(demo_engine->task) {
		apt_task_t *task = apt_consumer_task_base_get(demo_engine->task);
		apt_task_destroy(task);
		demo_engine->task = NULL;
	}
	return TRUE;
}
Пример #5
0
void UmcFramework::DestroyTask()
{
	if(m_pTask)
	{
		apt_task_t* pTask = apt_consumer_task_base_get(m_pTask);
		if(pTask)
		{
			apt_task_terminate(pTask,TRUE);
			apt_task_destroy(pTask);
		}
		m_pTask = NULL;
	}
}
Пример #6
0
/** Destroy MRCP client */
MRCP_DECLARE(apt_bool_t) mrcp_client_destroy(mrcp_client_t *client)
{
	apt_task_t *task;
	if(!client || !client->task) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Invalid Client");
		return FALSE;
	}
	task = apt_consumer_task_base_get(client->task);
	apt_task_destroy(task);

	apr_pool_destroy(client->pool);
	return TRUE;
}
Пример #7
0
/** Destroy MRCP server */
MRCP_DECLARE(apt_bool_t) mrcp_server_destroy(mrcp_server_t *server)
{
	apt_task_t *task;
	if(!server || !server->task) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Invalid Server");
		return FALSE;
	}
	task = apt_consumer_task_base_get(server->task);
	apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Destroy Server Task");
	apt_task_destroy(task);

	apr_pool_destroy(server->pool);
	return TRUE;
}
Пример #8
0
/** Destroy demo framework */
apt_bool_t demo_framework_destroy(demo_framework_t *framework)
{
	if(!framework) {
		return FALSE;
	}

	if(framework->task) {
		apt_task_t *task = apt_consumer_task_base_get(framework->task);
		apt_task_terminate(task,TRUE);
		apt_task_destroy(task);
		framework->task = NULL;
	}

	mrcp_client_shutdown(framework->client);
	return mrcp_client_destroy(framework->client);
}
Пример #9
0
/** Destroy MRCP server */
MRCP_DECLARE(apt_bool_t) mrcp_server_destroy(mrcp_server_t *server)
{
	apt_task_t *task;
	if(!server || !server->task) {
		apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Invalid Server");
		return FALSE;
	}

	mrcp_engine_factory_destroy(server->engine_factory);
	mrcp_engine_loader_destroy(server->engine_loader);

	task = apt_consumer_task_base_get(server->task);
	apt_task_destroy(task);

	apr_pool_destroy(server->pool);
	return TRUE;
}
Пример #10
0
/** Destroy connection agent. */
MRCP_DECLARE(apt_bool_t) mrcp_client_connection_agent_destroy(mrcp_connection_agent_t *agent)
{
	apt_log(APT_PRIO_NOTICE,"Destroy MRCPv2 Agent");
	return apt_task_destroy(agent->task);
}
Пример #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;
}
Пример #12
0
/** Destroy poller task */
APT_DECLARE(apt_bool_t) apt_poller_task_destroy(apt_poller_task_t *task)
{
	return apt_task_destroy(task->base);
}
Пример #13
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;
}