Changeset 3750 for pjproject


Ignore:
Timestamp:
Sep 16, 2011 2:32:12 AM (13 years ago)
Author:
ming
Message:

Re #1370: Use GCD instead of NSThread for iOS video device.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-videodev/ios_dev.m

    r3715 r3750  
    9393    UIImageView         *imgView; 
    9494    void                *buf; 
     95    dispatch_queue_t     render_queue; 
    9596     
    9697    pj_timestamp         frame_ts; 
     
    334335    CGImageRelease(quartzImage); 
    335336     
     337    dispatch_async(dispatch_get_main_queue(), 
     338                   ^{[stream->imgView setImage:image];}); 
     339    /* 
    336340    [stream->imgView performSelectorOnMainThread:@selector(setImage:) 
    337341                     withObject:image waitUntilDone:NO]; 
     342     */ 
    338343     
    339344    [pool release]; 
     
    507512            strm->vout_delegate->stream = strm; 
    508513        } 
     514         
     515        strm->render_queue = dispatch_queue_create("com.pjsip.render_queue", 
     516                                                   NULL); 
     517        if (!strm->render_queue) 
     518            goto on_error; 
    509519         
    510520        strm->buf = pj_pool_alloc(pool, strm->frame_size); 
     
    596606    PJ_UNUSED_ARG(stream); 
    597607 
    598     PJ_LOG(4, (THIS_FILE, "Starting qt video stream")); 
     608    PJ_LOG(4, (THIS_FILE, "Starting ios video stream")); 
    599609 
    600610    if (stream->cap_session) { 
     
    619629    pj_memcpy(stream->buf, frame->buf, frame->size); 
    620630    /* Perform video display in a background thread */ 
    621 //    [stream->vout_delegate update_image]; 
     631/*    
     632    [stream->vout_delegate update_image]; 
    622633    [NSThread detachNewThreadSelector:@selector(update_image) 
    623634              toTarget:stream->vout_delegate withObject:nil]; 
     635*/ 
     636    dispatch_async(stream->render_queue, 
     637                   ^{[stream->vout_delegate update_image];}); 
    624638     
    625639    [pool release]; 
     
    635649    PJ_UNUSED_ARG(stream); 
    636650 
    637     PJ_LOG(4, (THIS_FILE, "Stopping qt video stream")); 
     651    PJ_LOG(4, (THIS_FILE, "Stopping ios video stream")); 
    638652 
    639653    if (stream->cap_session && [stream->cap_session isRunning]) 
     
    677691    } 
    678692*/ 
     693    if (stream->render_queue) { 
     694        dispatch_release(stream->render_queue); 
     695        stream->render_queue = NULL; 
     696    } 
    679697 
    680698    pj_pool_release(stream->pool); 
Note: See TracChangeset for help on using the changeset viewer.