Esempio n. 1
0
static int rtsp_get_media_uri(void *sdp, int media, char* uri, size_t bytes, const char* sessionuri)
{
	char path[256] = {0};
	const char* control;

	// C.1.1 Control URL (p81)
	// If this attribute contains only an asterisk (*), then the URL is
	// treated as if it were an empty embedded URL, and thus inherits the entire base URL.
	control = sdp_media_attribute_find(sdp, media, "control");
	if(!control || 0==*control || '*' == *control)
		control = "";
	strncpy(uri, control, bytes-1);

	if(!isAbsoluteURL(uri) && sessionuri && *sessionuri)
	{
		if(*uri)
		{
			uri_join(path, sizeof(path), sessionuri, uri);
			sessionuri = path;
		}
		strncpy(uri, sessionuri, bytes-1);
	}

	return 0;
}
Esempio n. 2
0
// rfc 2326 C.1.1 Control URL (p81)
// look for a base URL in the following order:
// 1. The RTSP Content-Base field
// 2. The RTSP Content-Location field
// 3. The RTSP request URL
static int rtsp_get_session_uri(void *sdp, char* uri, size_t bytes, const char* requri, const char* baseuri, const char* location)
{
	char path[256] = {0};
	const char* control;

	// C.1.1 Control URL (p81)
	// If this attribute contains only an asterisk (*), then the URL is
	// treated as if it were an empty embedded URL, and thus inherits the entire base URL.
	control = sdp_attribute_find(sdp, "control");
	if(!control || 0==*control || '*' == *control)
		control = "";
	strncpy(uri, control, bytes-1);

	if(!isAbsoluteURL(uri) && baseuri && *baseuri)
	{
		if(*uri)
		{
			uri_join(path, sizeof(path), baseuri, uri);
			baseuri = path;
		}
		strncpy(uri, baseuri, bytes-1);	
	}

	if(!isAbsoluteURL(uri) && location && *location)
	{
		if(*uri)
		{
			uri_join(path, sizeof(path), location, uri);
			location = path;
		}
		strncpy(uri, location, bytes-1);
	}

	if(!isAbsoluteURL(uri) && requri && *requri)
	{
		if(*uri)
		{
			uri_join(path, sizeof(path), requri, uri);
			requri = path;
		}
		strncpy(uri, requri, bytes-1);
	}

	return 0;
}
Esempio n. 3
0
static EjsAny *invokeUriOperator(Ejs *ejs, EjsUri *lhs, int opcode,  EjsUri *rhs, void *data)
{
    EjsAny      *result;

    if (rhs == 0 || TYPE(lhs) != TYPE(rhs)) {
        if ((result = coerceUriOperands(ejs, lhs, opcode, rhs)) != 0) {
            return result;
        }
    }

    /*  Types now match, both Uris
     */
    switch (opcode) {
    case EJS_OP_COMPARE_STRICTLY_EQ:
    case EJS_OP_COMPARE_EQ:
        if (lhs == rhs || (lhs->uri == rhs->uri)) {
            return ESV(true);
        }
        return ejsCreateBoolean(ejs,  same(ejs, lhs->uri, rhs->uri, 1));

    case EJS_OP_COMPARE_NE:
    case EJS_OP_COMPARE_STRICTLY_NE:
        return ejsCreateBoolean(ejs,  !same(ejs, lhs->uri, rhs->uri, 1));

    /*  NOTE: these only compare the paths */
    case EJS_OP_COMPARE_LT:
        return ejsCreateBoolean(ejs,  scmp(lhs->uri->path, rhs->uri->path) < 0);

    case EJS_OP_COMPARE_LE:
        return ejsCreateBoolean(ejs,  scmp(lhs->uri->path, rhs->uri->path) <= 0);

    case EJS_OP_COMPARE_GT:
        return ejsCreateBoolean(ejs,  scmp(lhs->uri->path, rhs->uri->path) > 0);

    case EJS_OP_COMPARE_GE:
        return ejsCreateBoolean(ejs,  scmp(lhs->uri->path, rhs->uri->path) >= 0);

    /*  
        Unary operators
     */
    case EJS_OP_COMPARE_NOT_ZERO:
        return ((lhs->uri->path) ? ESV(true): ESV(false));

    case EJS_OP_COMPARE_ZERO:
        return ((lhs->uri->path == 0) ? ESV(true): ESV(false));


    case EJS_OP_COMPARE_UNDEFINED:
    case EJS_OP_COMPARE_NULL:
    case EJS_OP_COMPARE_FALSE:
    case EJS_OP_COMPARE_TRUE:
        return ESV(false);

    /*  
        Binary operators
     */
    case EJS_OP_ADD:
        return uri_join(ejs, lhs, 1, (EjsObj**) &rhs);

    default:
        ejsThrowTypeError(ejs, "Opcode %d not implemented for type %@", opcode, TYPE(lhs)->qname.name);
        return 0;
    }
    assure(0);
}