Пример #1
0
/* RFC 4317 - section 5.1 */
static int rfc4317_section5_1(struct oa *oa)
{
	int err = 0;

	err |= oa_init(oa);

	if (err)
		return err;

	err = oa_offeranswer(oa,
			     "v=0\r\n"
			     "o=alice 2890844526 2890844526 IN IP4 1.2.3.4\r\n"
			     "s=-\r\n"
			     "c=IN IP4 1.2.3.4\r\n"
			     "t=0 0\r\n"
			     ,
			     "v=0\r\n"
			     "o=bob 2808844564 2808844564 IN IP4 5.6.7.8\r\n"
			     "s=-\r\n"
			     "c=IN IP4 5.6.7.8\r\n"
			     "t=0 0\r\n");
	return err;
}
Пример #2
0
static int oa_addmedia(struct oa *oa, bool local,
		       const char *mname, uint16_t port, const char *transp,
		       enum sdp_dir dir, uint32_t ncodec, ...)
{
	struct sdp_media *m;
	va_list ap;
	int err;

	err = oa_init(oa);
	if (err)
		return err;

	err = sdp_media_add(&m, local ? oa->alice : oa->bob,
			    mname, port, transp);
	if (err)
		return err;

	sdp_media_set_ldir(m, dir);

	va_start(ap, ncodec);

	while (ncodec--) {
		const char *id = va_arg(ap, char *);
		const char *cname = va_arg(ap, char *);
		int srate = va_arg(ap, int);

		err = sdp_format_add(NULL, m, false, id, cname, srate, 1,
				     NULL, NULL, NULL, false, NULL);
		if (err)
			break;
	}

	va_end(ap);

	return err;
}
Пример #3
0
int strat_goto_avoid(int x, int y, int flags)
{
    int i, len, ret;
    int retry_count;
    int opp_x, opp_y;
    poly_t *pol_opp;
    point_t *p;
    oa_init();

    /* The robot will try 3 times before giving up. */
    for(retry_count=0;retry_count<3;retry_count++) {

        /* Creates one polygon for each opponent robot. */
        for(i=0;i<robot.beacon.nb_beacon;i++) {
            pol_opp = oa_new_poly(4);

            strat_da_rel_to_xy_abs(robot.beacon.beacon[i].direction, robot.beacon.beacon[i].distance*10,
                   &opp_x, &opp_y);

            NOTICE(0, "Op is at %d;%d", opp_x, opp_y);
            create_opp_polygon(pol_opp, 800, 0);

            /* Checks if the arrival point is in an opponent. */
            if(is_point_in_poly(pol_opp, x, y)) {
                WARNING(0, "Destination point is in opponent.");
                return END_ERROR;
            }
        }

        /* Sets starting and ending point of the path. */
        oa_start_end_points(position_get_x_s16(&robot.pos), position_get_x_s16(&robot.pos), x, y);

        /* Computes the path */
        len = oa_process();

        /* Checks if a path was found. */
        if(len == 0) {
            WARNING(0, "Cannot find a suitable path.");
            return END_ERROR;
        }

        p = oa_get_path();
        /* For all the points in the path. */
        for(i=0;i<len;i++) {
            /* Goes to the point. */
            trajectory_goto_forward_xy_abs(&robot.traj, p->x, p->y);

            /* Waits for the completion of the trajectory. */
            ret = wait_traj_end(flags);

            /* If we were blocked or met an obstacle, we will retry. */
            if(ret == END_BLOCKING || ret == END_OBSTACLE) {
                WARNING(0, "Retry");
                break; // we retry once more
            } else if(!TRAJ_SUCCESS(ret)) {
                /* If it was an other error, we simply abort and return it. */
                WARNING(0, "Unknown error code : %d", ret);
                return ret;
            }

            /* Increments pointer to load next point. */
            p++;
        }

        /* If we reached last point, no need to retry. */
        if(ret == END_TRAJ)
            return END_TRAJ;
    }

    /* If we reach here, it means 3 try were not enough. */
    return END_ERROR;
}