void static_image_process(MSFilter *f){ SIData *d=(SIData*)f->data; /*output a frame every second*/ if ((f->ticker->time - d->lasttime>1000) || d->lasttime==0){ if (d->pic) { mblk_t *o=dupb(d->pic); /*prevent mirroring at the output*/ mblk_set_precious_flag(o,1); ms_queue_put(f->outputs[0],o); } d->lasttime=f->ticker->time; } }
void static_image_process(MSFilter *f){ SIData *d=(SIData*)f->data; int frame_interval=(int)(1000/d->fps); /*output a frame whenever needed, i.e. respect the FPS parameter */ if ((f->ticker->time - d->lasttime>frame_interval) || d->lasttime==0){ ms_mutex_lock(&f->lock); if (d->pic) { mblk_t *o=dupmsg(d->pic); /*prevent mirroring at the output*/ mblk_set_precious_flag(o,1); ms_queue_put(f->outputs[0],o); } ms_filter_unlock(f); d->lasttime=f->ticker->time; } }
static void v4w_process(MSFilter * obj){ V4wState *s=(V4wState*)obj->data; mblk_t *m; uint32_t timestamp; int cur_frame; if (s->frame_count==-1){ s->start_time=obj->ticker->time; s->frame_count=0; } cur_frame=(int)((obj->ticker->time-s->start_time)*s->fps/1000.0); if (cur_frame>s->frame_count){ mblk_t *om=NULL; ms_mutex_lock(&s->mutex); /*keep the most recent frame if several frames have been captured */ if (s->rotregvalue!=0){ while((m=getq(&s->rq))!=NULL){ if (om!=NULL) freemsg(om); om=m; } }else { mblk_t *nowebcam = v4w_make_nowebcam(s); if (nowebcam!=NULL){ om=dupmsg(nowebcam); mblk_set_precious_flag(om,1); } } ms_mutex_unlock(&s->mutex); if (om!=NULL){ timestamp=(uint32_t)obj->ticker->time*90;/* rtp uses a 90000 Hz clockrate for video*/ mblk_set_timestamp_info(om,timestamp); ms_queue_put(obj->outputs[0],om); /*ms_message("picture sent");*/ } s->frame_count++; } }
static void v4l_process(MSFilter * obj){ V4lState *s=(V4lState*)obj->data; uint32_t timestamp; int cur_frame; if (s->frame_count==-1){ s->start_time=obj->ticker->time; s->frame_count=0; } cur_frame=((obj->ticker->time-s->start_time)*s->fps/1000.0); if (cur_frame>=s->frame_count){ mblk_t *om=NULL; ms_mutex_lock(&s->mutex); /*keep the most recent frame if several frames have been captured */ if (s->fd!=-1){ om=getq(&s->rq); }else{ if (s->usemire){ om=dupmsg(v4l_make_mire(s)); }else { mblk_t *tmpm=v4l_make_nowebcam(s); if (tmpm) { om=dupmsg(tmpm); mblk_set_precious_flag(om,1); } } } ms_mutex_unlock(&s->mutex); if (om!=NULL){ timestamp=obj->ticker->time*90;/* rtp uses a 90000 Hz clockrate for video*/ mblk_set_timestamp_info(om,timestamp); mblk_set_marker_info(om,TRUE); ms_queue_put(obj->outputs[0],om); /*ms_message("picture sent");*/ s->frame_count++; } }else flushq(&s->rq,0); }