Changeset 1366:a623ef968c1a in mediastreamer2


Ignore:
Timestamp:
Apr 22, 2011 4:30:42 PM (2 years ago)
Author:
Guillaume Beraudo <guillaume.beraudo@…>
Branch:
default
Children:
1367:eb5d88eb5a20, 1375:cc4c4148e0cb
Parents:
1364:c33d4fd25185 (diff), 1365:5b6f906115a9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Add Apple loop + more verbose qtcapture.

Merge branch 'dev_videomac' of git://git.linphone.org/mediastreamer2 into dev_videomac

Conflicts:

acinclude.m4

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/qtcapture.m

    r1363 r1366  
    1717        QTCaptureDecompressedVideoOutput * output; 
    1818        QTCaptureSession *session; 
    19         //QTCaptureDevice *device; 
    2019         
    2120        ms_mutex_t mutex; 
     
    4039@implementation NsMsWebCam  
    4140 
    42 -(void)captureOutput:(QTCaptureOutput *)captureOutput didOutputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection: 
    43 (QTCaptureConnection *)connection 
     41- (void)captureOutput:(QTCaptureOutput *)captureOutput didOutputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection 
    4442{ 
    4543        ms_mutex_lock(&mutex);   
     
    124122                                 
    125123                                if( fmt == kCVPixelFormatType_420YpCbCr8Planar) 
    126                                         return MS_YUV420P; 
     124                                        {ms_message("FORMAT = MS_YUV420P");return MS_YUV420P;} 
    127125                                 
    128126                                //else if( fmt == MS_YUYV) 
     
    130128                                 
    131129                                else if( fmt == kCVPixelFormatType_24RGB) 
    132                                         return MS_RGB24; 
     130                                        {ms_message("FORMAT = MS_RGB24");return MS_RGB24;} 
    133131                                 
    134132                                //else if( fmt == MS_RGB24_REV) 
     
    137135                                //      return; 
    138136                                else if( fmt == kUYVY422PixelFormat) 
    139                                         return MS_UYVY; 
     137                                        {ms_message("FORMAT = MS_UYVY");return MS_UYVY;} 
    140138                                 
    141139                                else if( fmt == kYUVSPixelFormat) 
    142                                         return MS_YUY2; 
     140                                        {ms_message("FORMAT = MS_YUY2");return MS_YUY2;} 
    143141                                 
    144142                                else if( fmt == k32RGBAPixelFormat) 
    145                                         return MS_RGBA32; 
     143                                        {ms_message("FORMAT = MS_RGBA32");return MS_RGBA32;} 
    146144                                 
    147145            } 
    148146        } 
    149147    } 
    150          
     148        ms_warning("The camera wasn't open; using MS_YUV420P pixel format"); 
    151149        return MS_YUV420P; 
    152150} 
     
    174172        } 
    175173         
    176         if(device) 
    177                 if(![device open:&error]) 
    178                         return; 
     174        bool success = [device open:&error]; 
     175        if (success) ms_message("Device opened"); 
     176        else { 
     177                ms_error("%s", [[error localizedDescription] UTF8String]); 
     178                return; 
     179        } 
    179180         
    180181        input = [[QTCaptureDeviceInput alloc] initWithDevice:device]; 
    181182         
    182         [session addInput:input error:&error]; 
    183         [session addOutput:output error:&error]; 
    184  
     183        success = [session addInput:input error:&error]; 
     184        if (success) ms_message("Input added to session"); 
     185        else ms_error("%s", [[error localizedDescription] UTF8String]); 
     186         
     187 
     188        success = [session addOutput:output error:&error]; 
     189        if (success) ms_message("Output added to session"); 
     190        else ms_error("%s", [[error localizedDescription] UTF8String]); 
    185191} 
    186192 
    187193-(void) setSize:(MSVideoSize) size 
    188194{        
     195        ms_message("Set size w=%i, h=%i", size.width, size.height); 
    189196        NSDictionary * dic = [NSDictionary dictionaryWithObjectsAndKeys: 
    190197         [NSNumber numberWithInteger:size.width], (id)kCVPixelBufferWidthKey, 
     
    210217                size.height = [[dic objectForKey:(id)kCVPixelBufferHeightKey] integerValue]; 
    211218        } 
    212          
     219                ms_message("get size w=%i, h=%i", size.width, size.height); 
    213220        return size; 
    214221} 
     
    234241        NsMsWebCam * webcam; 
    235242        NSAutoreleasePool* myPool; 
    236         mblk_t *mire; 
    237243        int frame_ind;   
    238244        float fps; 
    239245        float start_time; 
    240246        int frame_count; 
    241         bool_t usemire; 
    242247}v4mState; 
    243248 
     
    247252        s->webcam= [[NsMsWebCam alloc] init]; 
    248253        [s->webcam retain]; 
    249         s->mire=NULL;    
    250254        s->start_time=0; 
    251255        s->frame_count=-1; 
    252256        s->fps=15; 
    253         s->usemire=(getenv("DEBUG")!=NULL); 
    254257        f->data=s; 
    255258} 
     
    274277        v4m_stop(f,NULL); 
    275278         
    276         freemsg(s->mire); 
    277279        [s->webcam release]; 
    278280        [s->myPool release]; 
    279281        ms_free(s); 
    280 } 
    281  
    282 static mblk_t * v4m_make_mire(v4mState *s){ 
    283         unsigned char *data; 
    284         int i,j,line,pos; 
    285         MSVideoSize vsize = [s->webcam getSize]; 
    286         int patternw=vsize.width/6;  
    287         int patternh=vsize.height/6; 
    288         int red,green=0,blue=0; 
    289         if (s->mire==NULL){ 
    290                 s->mire=allocb(vsize.width*vsize.height*3,0); 
    291                 s->mire->b_wptr=s->mire->b_datap->db_lim; 
    292         } 
    293         data=s->mire->b_rptr; 
    294         for (i=0;i<vsize.height;++i){ 
    295                 line=i*vsize.width*3; 
    296                 if ( ((i+s->frame_ind)/patternh) & 0x1) red=255; 
    297                 else red= 0; 
    298                 for (j=0;j<vsize.width;++j){ 
    299                         pos=line+(j*3); 
    300                          
    301                         if ( ((j+s->frame_ind)/patternw) & 0x1) blue=255; 
    302                         else blue= 0; 
    303                          
    304                         data[pos]=red; 
    305                         data[pos+1]=green; 
    306                         data[pos+2]=blue; 
    307                 } 
    308         } 
    309         s->frame_ind++; 
    310         return s->mire; 
    311 } 
    312  
    313 static mblk_t * v4m_make_nowebcam(v4mState *s){ 
    314         if (s->mire==NULL && s->frame_ind==0){ 
    315                 //s->mire=ms_load_nowebcam(&s->vsize, -1); 
    316         } 
    317         s->frame_ind++; 
    318         return s->mire; 
    319282} 
    320283 
     
    339302                        om=getq([s->webcam rq]); 
    340303                } 
    341                 else 
    342                 { 
    343                         /*if (s->pix_fmt==MS_YUV420P && s->vsize.width==MS_VIDEO_SIZE_CIF_W && s->vsize.height==MS_VIDEO_SIZE_CIF_H) 
    344                     { 
    345                                 if (s->usemire) 
    346                                 { 
    347                                         om=dupmsg(v4m_make_mire(s)); 
    348                                 } 
    349                                 else  
    350                                 { 
    351                                         mblk_t *tmpm=v4m_make_nowebcam(s); 
    352                                         if (tmpm)  
    353                                                 om=dupmsg(tmpm); 
    354                                 } 
    355                     }*/ 
    356                 } 
    357                  
     304 
    358305                if (om!=NULL) 
    359306                { 
  • src/qtcapture.m

    r1365 r1366  
    1717        QTCaptureDecompressedVideoOutput * output; 
    1818        QTCaptureSession *session; 
    19         //QTCaptureDevice *device; 
    2019         
    2120        ms_mutex_t mutex; 
     
    4039@implementation NsMsWebCam  
    4140 
    42 -(void)captureOutput:(QTCaptureOutput *)captureOutput didOutputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection: 
    43 (QTCaptureConnection *)connection 
     41- (void)captureOutput:(QTCaptureOutput *)captureOutput didOutputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection 
    4442{ 
    4543        ms_mutex_lock(&mutex);   
     
    124122                                 
    125123                                if( fmt == kCVPixelFormatType_420YpCbCr8Planar) 
    126                                         return MS_YUV420P; 
     124                                        {ms_message("FORMAT = MS_YUV420P");return MS_YUV420P;} 
    127125                                 
    128126                                //else if( fmt == MS_YUYV) 
     
    130128                                 
    131129                                else if( fmt == kCVPixelFormatType_24RGB) 
    132                                         return MS_RGB24; 
     130                                        {ms_message("FORMAT = MS_RGB24");return MS_RGB24;} 
    133131                                 
    134132                                //else if( fmt == MS_RGB24_REV) 
     
    137135                                //      return; 
    138136                                else if( fmt == kUYVY422PixelFormat) 
    139                                         return MS_UYVY; 
     137                                        {ms_message("FORMAT = MS_UYVY");return MS_UYVY;} 
    140138                                 
    141139                                else if( fmt == kYUVSPixelFormat) 
    142                                         return MS_YUY2; 
     140                                        {ms_message("FORMAT = MS_YUY2");return MS_YUY2;} 
    143141                                 
    144142                                else if( fmt == k32RGBAPixelFormat) 
    145                                         return MS_RGBA32; 
     143                                        {ms_message("FORMAT = MS_RGBA32");return MS_RGBA32;} 
    146144                                 
    147145            } 
    148146        } 
    149147    } 
    150          
     148        ms_warning("The camera wasn't open; using MS_YUV420P pixel format"); 
    151149        return MS_YUV420P; 
    152150} 
     
    174172        } 
    175173         
    176         if(device) 
    177                 if(![device open:&error]) 
    178                         return; 
     174        bool success = [device open:&error]; 
     175        if (success) ms_message("Device opened"); 
     176        else { 
     177                ms_error("%s", [[error localizedDescription] UTF8String]); 
     178                return; 
     179        } 
    179180         
    180181        input = [[QTCaptureDeviceInput alloc] initWithDevice:device]; 
    181182         
    182         [session addInput:input error:&error]; 
    183         [session addOutput:output error:&error]; 
    184  
     183        success = [session addInput:input error:&error]; 
     184        if (success) ms_message("Input added to session"); 
     185        else ms_error("%s", [[error localizedDescription] UTF8String]); 
     186         
     187 
     188        success = [session addOutput:output error:&error]; 
     189        if (success) ms_message("Output added to session"); 
     190        else ms_error("%s", [[error localizedDescription] UTF8String]); 
    185191} 
    186192 
    187193-(void) setSize:(MSVideoSize) size 
    188194{        
     195        ms_message("Set size w=%i, h=%i", size.width, size.height); 
    189196        NSDictionary * dic = [NSDictionary dictionaryWithObjectsAndKeys: 
    190197         [NSNumber numberWithInteger:size.width], (id)kCVPixelBufferWidthKey, 
     
    210217                size.height = [[dic objectForKey:(id)kCVPixelBufferHeightKey] integerValue]; 
    211218        } 
    212          
     219                ms_message("get size w=%i, h=%i", size.width, size.height); 
    213220        return size; 
    214221} 
     
    295302                        om=getq([s->webcam rq]); 
    296303                } 
    297                 else 
    298                 { 
    299                         /*if (s->pix_fmt==MS_YUV420P && s->vsize.width==MS_VIDEO_SIZE_CIF_W && s->vsize.height==MS_VIDEO_SIZE_CIF_H) 
    300                     { 
    301                                 if (s->usemire) 
    302                                 { 
    303                                         om=dupmsg(v4m_make_mire(s)); 
    304                                 } 
    305                                 else  
    306                                 { 
    307                                         mblk_t *tmpm=v4m_make_nowebcam(s); 
    308                                         if (tmpm)  
    309                                                 om=dupmsg(tmpm); 
    310                                 } 
    311                     }*/ 
    312                 } 
    313                  
     304 
    314305                if (om!=NULL) 
    315306                { 
  • tests/mediastream.c

    r1354 r1366  
    4141#include <stdlib.h> 
    4242#include <string.h> 
     43 
     44#ifdef __APPLE__ 
     45#include <CoreFoundation/CFRunLoop.h> 
     46#endif 
    4347 
    4448static int cond=1; 
     
    435439        }else{  /* no interactive stuff - continuous debug output */ 
    436440                rtp_session_register_event_queue(session,q); 
     441 
     442                #ifdef __APPLE__ 
     443                CFRunLoopRun(); 
     444                #else 
    437445                while(cond) 
    438446                { 
     
    464472                        } 
    465473                } 
     474        #endif // target MAC 
    466475                                        } 
    467476         
  • tests/mediastream.c

    r1354 r1366  
    4141#include <stdlib.h> 
    4242#include <string.h> 
     43 
     44#ifdef __APPLE__ 
     45#include <CoreFoundation/CFRunLoop.h> 
     46#endif 
    4347 
    4448static int cond=1; 
     
    435439        }else{  /* no interactive stuff - continuous debug output */ 
    436440                rtp_session_register_event_queue(session,q); 
     441 
     442                #ifdef __APPLE__ 
     443                CFRunLoopRun(); 
     444                #else 
    437445                while(cond) 
    438446                { 
     
    464472                        } 
    465473                } 
     474        #endif // target MAC 
    466475                                        } 
    467476         
Note: See TracChangeset for help on using the changeset viewer.