Marc Lehmann wrote:
On Mon, Apr 06, 2009 at 06:49:25PM +0200, Luca Barbato <[email protected]> 
wrote:
the result is strange:

what is MPA? the current time? and duration?

mpa and h264 are two different rtp streams (audio and video), each of them has an ev_periodic callback sending a packet.

each packet has a timestamp/mtime that tell when it should be played and a duration that tells for how much.

the H264 packet with mtime 0.04 is sent before the mpa one with mtime

what is mtime here? libev doesn't have n mtime in it's watchers, so it is
unclear to me what your problem is.

basically every time the callback gets called a packet is took from a queue, it's duration value is used to set the next time the callback will be called by using ev_periodic_set and then issuing ev_periodic_again within the callback.

if you are wondering about the order of execution fo the callbacks, then note
that this is undefined. if you need a timer to execute before another timer
when both become pending at the same time, you need to use priorities.

is there a recipe for that already?

0.02 even if it is scheduled before and it's deadline is between the 4th and the 5th packet same goes for the following ones.

It is not at all clear to me what this refers to in terms of libev.

Could you make a single example of how two peridiocs were configured, how
they were executed, and how that differes from what you expect?

I wrote a bare loop that is more or less what I'd like to archive and I got the behavior I'd expect so I guess there is something wrong somewhere else in the code, sorry for the noise =)

lu





--

Luca Barbato
Gentoo Council Member
Gentoo/linux Gentoo/PPC
http://dev.gentoo.org/~lu_zero

#include <ev.h>
#include <stdio.h>
#include <malloc.h>
#include <unistd.h>
typedef struct {
    ev_tstamp delay;
    int name;
    int frag;
    ev_tstamp pts;
} delay;

ev_tstamp today;

static void reschedule(struct ev_loop *loop, ev_periodic *w, int revents)
{
    delay *d = w->data;
    ev_tstamp now = ev_now(loop);
    ev_tstamp delay = 0, next_time = now;
    ev_tstamp pts = d->pts;
    if (d->frag) {
        d->frag--;
        delay = 0;
    } else {
        d->frag = d->name;
        delay = d->delay;
        d->pts += d->delay;
    }
    next_time = now + delay;
    fprintf(stderr,"Now %f, pts %f event %d frag %d, delay %f, eta %f\n",
                now-today, pts, d->name, d->frag, d->delay, next_time-today);
    usleep(300);
    ev_periodic_set(w, next_time, 0, NULL);
    ev_periodic_again(loop, w);
}

int main(int argc, char **argv)
{
    struct ev_loop *loop = ev_default_loop(0);
    int n = (argc>1? atoi(argv[1]) : 2);
    int i;
    ev_periodic timer[n];
    today = ev_time ();

    for (i = 0; i < n; i++) {
        delay *d = malloc(sizeof(delay));
        d->delay = 0.02 + 0.01*i;
        d->name = i;
        d->pts = 0;
        timer[i].data = d;
        ev_periodic_init(timer+i, reschedule, today+0.03 ,0, NULL);
        ev_periodic_again(loop, timer+i);
    }

    ev_loop (loop, 0);

    return 0;
}
_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/cgi-bin/mailman/listinfo/libev

Reply via email to