Changeset 05f184decf17ab405efb648ce3d2c1e8a2ef1450 for modules/access
- Timestamp:
- 18/07/08 00:42:53 (4 months ago)
- git-parent:
- Files:
-
- modules/access/qtcapture.m (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/access/qtcapture.m
rb65ca27 r05f184d 48 48 static int Control( demux_t *, int, va_list ); 49 49 50 typedef struct qtcapture_block_t51 {52 block_t block;53 CVImageBufferRef imageBuffer;54 block_free_t pf_original_release;55 } qtcapture_block_t;56 57 static void qtcapture_block_release( block_t *p_block )58 {59 qtcapture_block_t * p_qtblock = (qtcapture_block_t *)p_block;60 CVBufferRelease(p_qtblock->imageBuffer);61 CVPixelBufferUnlockBaseAddress(p_qtblock->imageBuffer, 0);62 p_qtblock->pf_original_release( &p_qtblock->block );63 }64 65 static block_t * qtcapture_block_new( void * p_buffer,66 int i_buffer,67 CVImageBufferRef imageBufferToRelease )68 {69 qtcapture_block_t * p_qtblock;70 71 /* Build block */72 p_qtblock = malloc( sizeof( qtcapture_block_t ) );73 if(!p_qtblock) return NULL;74 75 /* Fill all fields */76 block_Init( &p_qtblock->block, p_buffer, i_buffer );77 p_qtblock->block.pf_release = qtcapture_block_release;78 p_qtblock->imageBuffer = imageBufferToRelease;79 80 return (block_t *)p_qtblock;81 }82 83 84 50 /***************************************************************************** 85 51 * Module descriptor … … 107 73 - (id)init; 108 74 - (void)outputVideoFrame:(CVImageBufferRef)videoFrame withSampleBuffer:(QTSampleBuffer *)sampleBuffer fromConnection:(QTCaptureConnection *)connection; 109 - ( block_t *)blockWithCurrentFrame;75 - (mtime_t)copyCurrentFrameToBuffer:(void *)buffer; 110 76 @end 111 77 … … 146 112 currentPts = 1000000L / [sampleBuffer presentationTime].timeScale * [sampleBuffer presentationTime].timeValue; 147 113 } 148 149 114 CVBufferRelease(imageBufferToRelease); 150 115 } 151 116 152 - ( block_t *)blockWithCurrentFrame117 - (mtime_t)copyCurrentFrameToBuffer:(void *)buffer 153 118 { 154 119 CVImageBufferRef imageBuffer; 155 120 mtime_t pts; 156 block_t * p_block = NULL;157 121 158 122 if(!currentImageBuffer || currentPts == previousPts ) 159 return NULL;123 return 0; 160 124 161 125 @synchronized (self) 162 126 { 163 // Released in the p_block release method.164 127 imageBuffer = CVBufferRetain(currentImageBuffer); 165 128 pts = previousPts = currentPts; 166 129 167 168 // Unlocked in the p_block release method.169 130 CVPixelBufferLockBaseAddress(imageBuffer, 0); 170 131 void * pixels = CVPixelBufferGetBaseAddress(imageBuffer); 171 p_block = qtcapture_block_new( imageBuffer, CVPixelBufferGetDataSize( imageBuffer ), 172 imageBuffer ); 173 p_block->i_pts = currentPts; 174 } 175 176 return p_block; 132 memcpy( buffer, pixels, CVPixelBufferGetBytesPerRow(imageBuffer) * CVPixelBufferGetHeight(imageBuffer) ); 133 CVPixelBufferUnlockBaseAddress(imageBuffer, 0); 134 } 135 136 CVBufferRelease(imageBuffer); 137 138 return currentPts; 177 139 } 178 140 … … 380 342 block_t *p_block; 381 343 344 p_block = block_New( p_demux, p_sys->width * 345 p_sys->height * 2 /* FIXME */ ); 346 if( !p_block ) 347 { 348 msg_Err( p_demux, "cannot get block" ); 349 return 0; 350 } 351 382 352 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 383 353 384 354 @synchronized (p_sys->output) 385 355 { 386 p_block = [p_sys->output blockWithCurrentFrame];387 } 388 389 if( !p_block )356 p_block->i_pts = [p_sys->output copyCurrentFrameToBuffer: p_block->p_buffer]; 357 } 358 359 if( !p_block->i_pts ) 390 360 { 391 361 /* Nothing to display yet, just forget */ 362 block_Release( p_block ); 392 363 [pool release]; 393 364 msleep( 10000 );
