Exemple #1
0
/** Parse RTSP header */
RTSP_DECLARE(apt_bool_t) rtsp_header_parse(rtsp_header_t *header, apt_text_stream_t *text_stream, apr_pool_t *pool)
{
    apt_pair_t pair;
    apt_bool_t result = FALSE;

    do {
        if(apt_text_header_read(text_stream,&pair) == TRUE) {
            if(pair.name.length) {
                /* parse header_field (name/value) */
                rtsp_header_field_id id = apt_string_table_id_find(rtsp_header_string_table,RTSP_HEADER_FIELD_COUNT,&pair.name);
                if(id < RTSP_HEADER_FIELD_COUNT) {
                    if(rtsp_header_field_parse(header,id,&pair.value,pool) == TRUE) {
                        rtsp_header_property_add(&header->property_set,id);
                    }
                }
            }
            else {
                /* empty header -> exit */
                result = TRUE;
                break;
            }
        }
    }
    while(apt_text_is_eos(text_stream) == FALSE);

    return result;
}
Exemple #2
0
/** Parse RTSP header field */
static apt_bool_t rtsp_header_field_parse(rtsp_header_t *header, rtsp_header_field_id id, const apt_str_t *value, apr_pool_t *pool)
{
    apt_bool_t status = TRUE;
    switch(id) {
    case RTSP_HEADER_FIELD_CSEQ:
        header->cseq = apt_size_value_parse(value);
        break;
    case RTSP_HEADER_FIELD_TRANSPORT:
        status = rtsp_transport_parse(&header->transport,value,pool);
        break;
    case RTSP_HEADER_FIELD_SESSION_ID:
        status = rtsp_session_id_parse(&header->session_id,value,pool);
        break;
    case RTSP_HEADER_FIELD_RTP_INFO:
        apt_string_copy(&header->rtp_info,value,pool);
        break;
    case RTSP_HEADER_FIELD_CONTENT_TYPE:
        header->content_type = apt_string_table_id_find(rtsp_content_type_string_table,RTSP_CONTENT_TYPE_COUNT,value);
        break;
    case RTSP_HEADER_FIELD_CONTENT_LENGTH:
        header->content_length = apt_size_value_parse(value);
        break;
    default:
        status = FALSE;
    }
    return status;
}
Exemple #3
0
/** Parse RTSP transport protocol (RTP/AVP[/UDP]) */
static apt_bool_t rtsp_transport_protocol_parse(rtsp_transport_t *transport, const apt_str_t *value)
{
    apt_str_t field;
    apt_text_stream_t stream;

    stream.text = *value;
    stream.pos = stream.text.buf;

    /* set the defaults */
    transport->protocol = RTSP_TRANSPORT_RTP;
    transport->profile = RTSP_PROFILE_AVP;
    transport->lower_protocol = RTSP_LOWER_TRANSPORT_UDP;

    /* read transport protocol (RTP) */
    if(apt_text_field_read(&stream,'/',TRUE,&field) == FALSE) {
        return FALSE;
    }
    transport->protocol = apt_string_table_id_find(rtsp_transport_string_table,RTSP_TRANSPORT_COUNT,&field);
    if(transport->protocol >= RTSP_TRANSPORT_COUNT) {
        return FALSE;
    }

    /* read transport profile (AVP) */
    if(apt_text_field_read(&stream,'/',TRUE,&field) == FALSE) {
        return FALSE;
    }
    transport->profile = apt_string_table_id_find(rtsp_profile_string_table,RTSP_PROFILE_COUNT,&field);
    if(transport->profile >= RTSP_PROFILE_COUNT) {
        return FALSE;
    }

    /* read optional lower transport protocol (UDP) */
    if(apt_text_field_read(&stream,'/',TRUE,&field) == TRUE) {
        transport->lower_protocol = apt_string_table_id_find(rtsp_lower_transport_string_table,RTSP_LOWER_TRANSPORT_COUNT,&field);
        if(transport->lower_protocol >= RTSP_LOWER_TRANSPORT_COUNT) {
            return FALSE;
        }
    }

    return TRUE;
}
MRCP_DECLARE(apt_bool_t) mrcp_header_parse(mrcp_header_accessor_t *accessor, const apt_pair_t *pair, apr_pool_t *pool)
{
	size_t id;
	if(!accessor->vtable) {
		return FALSE;
	}

	id = apt_string_table_id_find(accessor->vtable->field_table,accessor->vtable->field_count,&pair->name);
	if(id >= accessor->vtable->field_count) {
		return FALSE;
	}

	if(accessor->vtable->parse_field(accessor,id,&pair->value,pool) == FALSE) {
		return FALSE;
	}
	
	mrcp_header_property_add(&accessor->property_set,id);
	return TRUE;
}
Exemple #5
0
/** Parse RTSP transport */
static apt_bool_t rtsp_transport_attrib_parse(rtsp_transport_t *transport, const apt_str_t *field, apr_pool_t *pool)
{
    rtsp_transport_attrib_e attrib;
    apt_str_t name;
    apt_text_stream_t stream;

    stream.text = *field;
    stream.pos = stream.text.buf;

    /* read attrib name */
    if(apt_text_field_read(&stream,'=',TRUE,&name) == FALSE) {
        return FALSE;
    }

    attrib = apt_string_table_id_find(rtsp_transport_attrib_string_table,RTSP_TRANSPORT_ATTRIB_COUNT,&name);
    switch(attrib) {
    case RTSP_TRANSPORT_ATTRIB_CLIENT_PORT:
        rtsp_port_range_parse(&transport->client_port_range,&stream);
        break;
    case RTSP_TRANSPORT_ATTRIB_SERVER_PORT:
        rtsp_port_range_parse(&transport->client_port_range,&stream);
        break;
    case RTSP_TRANSPORT_ATTRIB_SOURCE:
        rtsp_transport_attrib_value_parse(&transport->source,&stream,pool);
        break;
    case RTSP_TRANSPORT_ATTRIB_DESTINATION:
        rtsp_transport_attrib_value_parse(&transport->destination,&stream,pool);
        break;
    case RTSP_TRANSPORT_ATTRIB_UNICAST:
        transport->delivery = RTSP_DELIVERY_UNICAST;
        break;
    case RTSP_TRANSPORT_ATTRIB_MULTICAST:
        transport->delivery = RTSP_DELIVERY_MULTICAST;
        break;
    case RTSP_TRANSPORT_ATTRIB_MODE:
        rtsp_transport_attrib_value_parse(&transport->mode,&stream,pool);
        break;
    default:
        break;
    }
    return TRUE;
}
MPF_DECLARE(mpf_rtp_attrib_e) mpf_rtp_attrib_id_find(const apt_str_t *attrib)
{
	return apt_string_table_id_find(mpf_rtp_attrib_table,RTP_ATTRIB_COUNT,attrib);
}
/** Find resource id associated with specified resource name */
MRCP_DECLARE(mrcp_resource_id) mrcp_resource_id_find(mrcp_resource_factory_t *resource_factory, const apt_str_t *resource_name)
{
	return apt_string_table_id_find(resource_factory->string_table,resource_factory->resource_count,resource_name);
}
MRCP_DECLARE(mrcp_connection_type_e) mrcp_connection_type_find(const apt_str_t *attrib)
{
    return apt_string_table_id_find(mrcp_connection_value_table,MRCP_CONNECTION_TYPE_COUNT,attrib);
}
MRCP_DECLARE(mrcp_setup_type_e) mrcp_setup_type_find(const apt_str_t *attrib)
{
    return apt_string_table_id_find(mrcp_setup_value_table,MRCP_SETUP_TYPE_COUNT,attrib);
}
MRCP_DECLARE(mrcp_attrib_e) mrcp_attrib_id_find(const apt_str_t *attrib)
{
    return apt_string_table_id_find(mrcp_attrib_table,MRCP_ATTRIB_COUNT,attrib);
}
MRCP_DECLARE(mrcp_proto_type_e) mrcp_proto_find(const apt_str_t *attrib)
{
    return apt_string_table_id_find(mrcp_proto_type_table,MRCP_PROTO_COUNT,attrib);
}
Exemple #12
0
/** Parse MRCP request-state used in MRCP response and event */
static APR_INLINE mrcp_request_state_e mrcp_request_state_parse(const apt_str_t *request_state_str)
{
	return apt_string_table_id_find(mrcp_request_state_string_table,MRCP_REQUEST_STATE_COUNT,request_state_str);
}
static APR_INLINE apr_size_t apt_string_table_value_parse(const apt_str_table_item_t *string_table, size_t count, const apt_str_t *value)
{
	return apt_string_table_id_find(string_table,count,value);
}