Exemplo n.º 1
0
/** Generate RTSP transport */
static apt_bool_t rtsp_transport_generate(rtsp_transport_t *transport, apt_text_stream_t *text_stream)
{
    const apt_str_t *protocol = apt_string_table_str_get(rtsp_transport_string_table,RTSP_TRANSPORT_COUNT,transport->protocol);
    const apt_str_t *profile = apt_string_table_str_get(rtsp_profile_string_table,RTSP_PROFILE_COUNT,transport->profile);
    if(!protocol || !profile) {
        return FALSE;
    }
    apt_string_value_generate(protocol,text_stream);
    apt_text_char_insert(text_stream,'/');
    apt_string_value_generate(profile,text_stream);

    if(transport->delivery != RTSP_DELIVERY_NONE) {
        const apt_str_t *delivery = NULL;
        rtsp_transport_attrib_e attrib = RTSP_TRANSPORT_ATTRIB_NONE;
        if(transport->delivery == RTSP_DELIVERY_UNICAST) {
            attrib = RTSP_TRANSPORT_ATTRIB_UNICAST;
        }
        else if(transport->delivery == RTSP_DELIVERY_MULTICAST) {
            attrib = RTSP_TRANSPORT_ATTRIB_MULTICAST;
        }
        delivery = apt_string_table_str_get(rtsp_transport_attrib_string_table,RTSP_TRANSPORT_ATTRIB_COUNT,attrib);
        if(!delivery) {
            return FALSE;
        }

        apt_text_char_insert(text_stream,';');
        apt_string_value_generate(delivery,text_stream);
    }

    if(rtsp_port_range_is_valid(&transport->client_port_range) == TRUE) {
        apt_text_char_insert(text_stream,';');
        rtsp_port_range_generate(RTSP_TRANSPORT_ATTRIB_CLIENT_PORT,&transport->client_port_range,text_stream);
    }
    if(rtsp_port_range_is_valid(&transport->server_port_range) == TRUE) {
        apt_text_char_insert(text_stream,';');
        rtsp_port_range_generate(RTSP_TRANSPORT_ATTRIB_SERVER_PORT,&transport->server_port_range,text_stream);
    }

    if(transport->mode.length) {
        const apt_str_t *str;
        str = apt_string_table_str_get(rtsp_transport_attrib_string_table,RTSP_TRANSPORT_ATTRIB_COUNT,RTSP_TRANSPORT_ATTRIB_MODE);
        if(str) {
            apt_text_char_insert(text_stream,';');
            apt_string_value_generate(str,text_stream);
            apt_text_char_insert(text_stream,'=');
            apt_string_value_generate(&transport->mode,text_stream);
        }
    }
    return TRUE;
}
Exemplo n.º 2
0
/** Generate RTSP header */
RTSP_DECLARE(apt_bool_t) rtsp_header_generate(rtsp_header_t *header, apt_text_stream_t *text_stream)
{
    const apt_str_t *name;
    apr_size_t i;
    rtsp_header_property_t property_set;

    property_set = header->property_set;
    for(i=0; i<RTSP_HEADER_FIELD_COUNT && property_set != 0; i++) {
        if(rtsp_header_property_check(&property_set,i) == TRUE) {
            name = apt_string_table_str_get(rtsp_header_string_table,RTSP_HEADER_FIELD_COUNT,i);
            if(!name) {
                continue;
            }

            apt_text_header_name_generate(name,text_stream);
            rtsp_header_field_generate(header,i,text_stream);
            apt_text_eol_insert(text_stream);

            rtsp_header_property_remove(&property_set,i);
        }
    }

    apt_text_eol_insert(text_stream);
    return TRUE;
}
Exemplo n.º 3
0
/** Generate RTSP header field */
static apr_size_t rtsp_header_field_generate(rtsp_header_t *header, apr_size_t id, apt_text_stream_t *value)
{
    switch(id) {
    case RTSP_HEADER_FIELD_CSEQ:
        apt_size_value_generate(header->cseq,value);
        break;
    case RTSP_HEADER_FIELD_TRANSPORT:
        rtsp_transport_generate(&header->transport,value);
        break;
    case RTSP_HEADER_FIELD_SESSION_ID:
        apt_string_value_generate(&header->session_id,value);
        break;
    case RTSP_HEADER_FIELD_RTP_INFO:
        apt_string_value_generate(&header->rtp_info,value);
        break;
    case RTSP_HEADER_FIELD_CONTENT_TYPE:
    {
        const apt_str_t *name = apt_string_table_str_get(rtsp_content_type_string_table,RTSP_CONTENT_TYPE_COUNT,header->content_type);
        if(name) {
            apt_string_value_generate(name,value);
        }
        break;
    }
    case RTSP_HEADER_FIELD_CONTENT_LENGTH:
        apt_size_value_generate(header->content_length,value);
        break;
    default:
        break;
    }
    return TRUE;
}
Exemplo n.º 4
0
MRCP_DECLARE(apt_bool_t) mrcp_header_generate(mrcp_header_accessor_t *accessor, apt_text_stream_t *text_stream)
{
	const apt_str_t *name;
	apr_size_t i;
	mrcp_header_property_t property_set;

	if(!accessor->vtable) {
		return FALSE;
	}

	property_set = accessor->property_set;
	for(i=0; i<accessor->vtable->field_count && property_set != 0; i++) {
		if(mrcp_header_property_check(&property_set,i) == TRUE) {
			name = apt_string_table_str_get(accessor->vtable->field_table,accessor->vtable->field_count,i);
			if(!name) {
				continue;
			}
			
			apt_text_header_name_generate(name,text_stream);
			if(accessor->empty_values == FALSE) {
				accessor->vtable->generate_field(accessor,i,text_stream);
			}
			apt_text_eol_insert(text_stream);
			
			mrcp_header_property_remove(&property_set,i);
		}
	}
	return TRUE;
}
Exemplo n.º 5
0
MRCP_DECLARE(apt_bool_t) mrcp_header_generate(mrcp_header_accessor_t *accessor, apt_text_stream_t *text_stream)
{
	const apt_str_t *name;
	apr_size_t i,j;
	char prop;

	if(!accessor->vtable) {
		return FALSE;
	}

	for(i=0, j=0; i<accessor->vtable->field_count && j<accessor->counter; i++) {
		prop = accessor->properties[i];
		if((prop & MRCP_HEADER_FIELD_NAME) == MRCP_HEADER_FIELD_NAME) {
			j++;
			name = apt_string_table_str_get(accessor->vtable->field_table,accessor->vtable->field_count,i);
			if(!name) continue;
			
			apt_text_header_name_generate(name,text_stream);
			if((prop & MRCP_HEADER_FIELD_VALUE) == MRCP_HEADER_FIELD_VALUE) {
				accessor->vtable->generate_field(accessor,i,text_stream);
			}
			apt_text_eol_insert(text_stream);
		}
	}

	return TRUE;
}
Exemplo n.º 6
0
MRCP_DECLARE(const apt_str_t*) mrcp_recog_completion_cause_get(mrcp_recog_completion_cause_e completion_cause, mrcp_version_e version)
{
	const apt_str_table_item_t *table = v2_completion_cause_string_table;
	if(version == MRCP_VERSION_1) {
		table = v1_completion_cause_string_table;
	}

	return apt_string_table_str_get(table,RECOGNIZER_COMPLETION_CAUSE_COUNT,completion_cause);
}
static apt_bool_t apt_string_table_value_pgenerate(const apt_str_table_item_t *string_table, apr_size_t count, apr_size_t id, apt_str_t *str, apr_pool_t *pool)
{
	const apt_str_t *name = apt_string_table_str_get(string_table,count,id);
	if(!name) {
		return FALSE;
	}

	apt_string_copy(str,name,pool);
	return TRUE;
}
Exemplo n.º 8
0
/** Generate MRCP request-state used in MRCP response and event */
static apt_bool_t mrcp_request_state_generate(mrcp_request_state_e request_state, apt_text_stream_t *stream)
{
	const apt_str_t *name;
	name = apt_string_table_str_get(mrcp_request_state_string_table,MRCP_REQUEST_STATE_COUNT,request_state);
	if(request_state < MRCP_REQUEST_STATE_COUNT) {
		memcpy(stream->pos,name->buf,name->length);
		stream->pos += name->length;
	}
	return TRUE;
}
static apt_bool_t apt_string_table_value_generate(const apt_str_table_item_t *string_table, apr_size_t count, apr_size_t id, apt_text_stream_t *stream)
{
	const apt_str_t *name = apt_string_table_str_get(string_table,count,id);
	if(!name) {
		return FALSE;
	}

	memcpy(stream->pos,name->buf,name->length);
	stream->pos += name->length;
	return TRUE;
}
Exemplo n.º 10
0
/** Generate RTSP transport port range */
static apt_bool_t rtsp_port_range_generate(rtsp_transport_attrib_e attrib, const rtsp_port_range_t *port_range, apt_text_stream_t *text_stream)
{
    const apt_str_t *str;
    str = apt_string_table_str_get(rtsp_transport_attrib_string_table,RTSP_TRANSPORT_ATTRIB_COUNT,attrib);
    if(!str) {
        return FALSE;
    }
    apt_string_value_generate(str,text_stream);
    apt_text_char_insert(text_stream,'=');
    apt_size_value_generate(port_range->min,text_stream);
    if(port_range->max > port_range->min) {
        apt_text_char_insert(text_stream,'-');
        apt_size_value_generate(port_range->max,text_stream);
    }
    return TRUE;
}
Exemplo n.º 11
0
/** Generate completion-cause */
MRCP_DECLARE(apt_bool_t) mrcp_completion_cause_generate(const apt_str_table_item_t table[], apr_size_t size, apr_size_t cause, apt_text_stream_t *stream)
{
	int length;
	const apt_str_t *name = apt_string_table_str_get(table,size,cause);
	if(!name) {
		return FALSE;
	}
	length = sprintf(stream->pos,"%03"APR_SIZE_T_FMT" ",cause);
	if(length <= 0) {
		return FALSE;
	}
	stream->pos += length;

	memcpy(stream->pos,name->buf,name->length);
	stream->pos += name->length;
	return TRUE;
}
Exemplo n.º 12
0
/** Generate completion-cause */
APT_DECLARE(apt_bool_t) apt_completion_cause_generate(const apt_str_table_item_t table[], apr_size_t size, apr_size_t cause, apt_str_t *str, apr_pool_t *pool)
{
	char buf[256];
	int length;
	const apt_str_t *name = apt_string_table_str_get(table,size,cause);
	if(!name) {
		return FALSE;
	}
	length = sprintf(buf,"%03"APR_SIZE_T_FMT" ",cause);
	if(length <= 0) {
		return FALSE;
	}

	memcpy(buf+length,name->buf,name->length);
	apt_string_assign_n(str,buf,name->length + length,pool);
	return TRUE;
}
Exemplo n.º 13
0
MPF_DECLARE(const apt_str_t*) mpf_rtp_direction_str_get(mpf_stream_direction_e direction)
{
	mpf_rtp_attrib_e attrib_id = RTP_ATTRIB_UNKNOWN;
	switch(direction) {
		case STREAM_DIRECTION_SEND:
			attrib_id = RTP_ATTRIB_SENDONLY;
			break;
		case STREAM_DIRECTION_RECEIVE:
			attrib_id = RTP_ATTRIB_RECVONLY;
			break;
		case STREAM_DIRECTION_DUPLEX:
			attrib_id = RTP_ATTRIB_SENDRECV;
			break;
		default:
			break;
	}
	return apt_string_table_str_get(mpf_rtp_attrib_table,RTP_ATTRIB_COUNT,attrib_id);
}
Exemplo n.º 14
0
/** Generate completion-cause */
APT_DECLARE(apt_bool_t) apt_completion_cause_generate(const apt_str_table_item_t table[], apr_size_t size, apr_size_t cause, apt_str_t *str, apr_pool_t *pool)
{
	const apt_str_t *name = apt_string_table_str_get(table,size,cause);
	if(!name) {
		return FALSE;
	}

	/* 3 digits + 1 space + name->length */
	str->length = 4 + name->length;
	str->buf = apr_palloc(pool,str->length + 1);

	if(sprintf(str->buf,"%03"APR_SIZE_T_FMT" ",cause) != 4) {
		return FALSE;
	}

	memcpy(str->buf+4,name->buf,name->length);
	str->buf[str->length] = '\0';
	return TRUE;
}
Exemplo n.º 15
0
/** Generate MRCPv2 recognizer header */
static apt_bool_t mrcp_v2_recog_header_generate(mrcp_header_accessor_t *accessor, apr_size_t id, apt_text_stream_t *value)
{
	mrcp_recog_header_t *recog_header = accessor->data;
	if(id == RECOGNIZER_HEADER_CONFIDENCE_THRESHOLD) {
		return apt_float_value_generate(recog_header->confidence_threshold,value);
	}
	else if(id == RECOGNIZER_HEADER_SENSITIVITY_LEVEL) {
		return apt_float_value_generate(recog_header->sensitivity_level,value);
	}
	else if(id == RECOGNIZER_HEADER_SPEED_VS_ACCURACY) {
		return apt_float_value_generate(recog_header->speed_vs_accuracy,value);
	}
	else if(id == RECOGNIZER_HEADER_COMPLETION_CAUSE) {
		const apt_str_t *name = apt_string_table_str_get(
			v2_completion_cause_string_table,
			RECOGNIZER_COMPLETION_CAUSE_COUNT,
			recog_header->completion_cause);
		return mrcp_completion_cause_generate(recog_header->completion_cause,name,value);
	}
	return mrcp_recog_header_generate(recog_header,id,value);
}
Exemplo n.º 16
0
MPF_DECLARE(const apt_str_t*) mpf_rtp_attrib_str_get(mpf_rtp_attrib_e attrib_id)
{
	return apt_string_table_str_get(mpf_rtp_attrib_table,RTP_ATTRIB_COUNT,attrib_id);
}
Exemplo n.º 17
0
/** Get resource name associated with specified resource id */
MRCP_DECLARE(const apt_str_t*) mrcp_resource_name_get(mrcp_resource_factory_t *resource_factory, mrcp_resource_id resource_id)
{
	return apt_string_table_str_get(resource_factory->string_table,resource_factory->resource_count,resource_id);
}
Exemplo n.º 18
0
MRCP_DECLARE(const apt_str_t*) mrcp_synth_completion_cause_get(mrcp_synth_completion_cause_e completion_cause, mrcp_version_e version)
{
	return apt_string_table_str_get(completion_cause_string_table,SYNTHESIZER_COMPLETION_CAUSE_COUNT,completion_cause);
}
Exemplo n.º 19
0
MRCP_DECLARE(const apt_str_t*) mrcp_connection_type_get(mrcp_connection_type_e connection_type)
{
    return apt_string_table_str_get(mrcp_connection_value_table,MRCP_CONNECTION_TYPE_COUNT,connection_type);
}
Exemplo n.º 20
0
MRCP_DECLARE(const apt_str_t*) mrcp_setup_type_get(mrcp_setup_type_e setup_type)
{
    return apt_string_table_str_get(mrcp_setup_value_table,MRCP_SETUP_TYPE_COUNT,setup_type);
}
Exemplo n.º 21
0
MRCP_DECLARE(const apt_str_t*) mrcp_attrib_str_get(mrcp_attrib_e attrib_id)
{
    return apt_string_table_str_get(mrcp_attrib_table,MRCP_ATTRIB_COUNT,attrib_id);
}
Exemplo n.º 22
0
MRCP_DECLARE(const apt_str_t*) mrcp_proto_get(mrcp_proto_type_e proto)
{
    return apt_string_table_str_get(mrcp_proto_type_table,MRCP_PROTO_COUNT,proto);
}
Exemplo n.º 23
0
MRCP_DECLARE(const apt_str_t*) mrcp_recorder_completion_cause_get(
									mrcp_recorder_completion_cause_e completion_cause, 
									mrcp_version_e version)
{
	return apt_string_table_str_get(completion_cause_string_table,RECORDER_COMPLETION_CAUSE_COUNT,completion_cause);
}