Ignore:
Timestamp:
Nov 3, 2008 12:04:28 AM (5 years ago)
Author:
aymeric <aymeric@…>
Branch:
default
Message:

make SET_IMAGE usable by all video source filter

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@146 3f6dc0c8-ddfe-455d-9043-3cd528dc4637

File:
1 edited

Legend:

Unmodified
Added
Removed
  • linphone/mediastreamer2/src/nowebcam.c

    r118 r143  
    116116typedef struct _SIData{ 
    117117        MSVideoSize vsize; 
     118        char nowebcamimage[256]; 
    118119        int index; 
    119120        uint64_t lasttime; 
     
    125126        d->vsize.width=MS_VIDEO_SIZE_CIF_W; 
    126127        d->vsize.height=MS_VIDEO_SIZE_CIF_H; 
     128        memset(d->nowebcamimage, 0, sizeof(d->nowebcamimage)); 
    127129        d->index=-1; 
    128130        d->lasttime=0; 
     
    137139void static_image_preprocess(MSFilter *f){ 
    138140        SIData *d=(SIData*)f->data; 
    139         d->pic=ms_load_nowebcam(&d->vsize,d->index); 
     141  if (d->pic==NULL) 
     142  { 
     143    if (d->nowebcamimage[0] != '\0') 
     144          d->pic=ms_load_jpeg_as_yuv(d->nowebcamimage,&d->vsize); 
     145    else 
     146          d->pic=ms_load_nowebcam(&d->vsize,d->index); 
     147  } 
    140148} 
    141149 
     
    144152        /*output a frame every second*/ 
    145153        if ((f->ticker->time - d->lasttime>1000) || d->lasttime==0){ 
     154    ms_mutex_lock(&f->lock); 
    146155                if (d->pic) { 
    147156                        mblk_t *o=dupb(d->pic); 
     
    150159                        ms_queue_put(f->outputs[0],o); 
    151160                } 
     161    ms_mutex_unlock(&f->lock); 
    152162                d->lasttime=f->ticker->time; 
    153163        } 
     
    176186int static_image_get_pix_fmt(MSFilter *f, void *data){ 
    177187        *(MSPixFmt*)data=MS_YUV420P; 
     188        return 0; 
     189} 
     190 
     191static int static_image_set_image(MSFilter *f, void *arg){ 
     192        SIData *d=(SIData*)f->data; 
     193        char *image = (char *)arg; 
     194  ms_mutex_lock(&f->lock); 
     195        if (image!=NULL && image[0]!='\0') 
     196          snprintf(d->nowebcamimage, sizeof(d->nowebcamimage), "%s", image); 
     197        else 
     198          d->nowebcamimage[0] = '\0'; 
     199 
     200  if (d->pic!=NULL) 
     201                freemsg(d->pic); 
     202 
     203  //if (d->nowebcamimage[0] != '\0') 
     204         // d->pic=ms_load_jpeg_as_yuv(d->nowebcamimage,&d->vsize); 
     205  //else 
     206         // d->pic=ms_load_nowebcam(&d->vsize,d->index); 
     207  ms_mutex_unlock(&f->lock); 
    178208        return 0; 
    179209} 
     
    183213        {       MS_FILTER_GET_VIDEO_SIZE, static_image_get_vsize }, 
    184214        {       MS_FILTER_GET_PIX_FMT, static_image_get_pix_fmt }, 
     215        {       MS_FILTER_SET_IMAGE, static_image_set_image }, 
    185216        {       0,0 } 
    186217}; 
Note: See TracChangeset for help on using the changeset viewer.