Changeset 1366:a623ef968c1a in mediastreamer2
- Timestamp:
- Apr 22, 2011 4:30:42 PM (2 years ago)
- 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. - Files:
-
- 4 edited
-
src/qtcapture.m (modified) (11 diffs)
-
src/qtcapture.m (modified) (8 diffs)
-
tests/mediastream.c (modified) (3 diffs)
-
tests/mediastream.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/qtcapture.m
r1363 r1366 17 17 QTCaptureDecompressedVideoOutput * output; 18 18 QTCaptureSession *session; 19 //QTCaptureDevice *device;20 19 21 20 ms_mutex_t mutex; … … 40 39 @implementation NsMsWebCam 41 40 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 44 42 { 45 43 ms_mutex_lock(&mutex); … … 124 122 125 123 if( fmt == kCVPixelFormatType_420YpCbCr8Planar) 126 return MS_YUV420P;124 {ms_message("FORMAT = MS_YUV420P");return MS_YUV420P;} 127 125 128 126 //else if( fmt == MS_YUYV) … … 130 128 131 129 else if( fmt == kCVPixelFormatType_24RGB) 132 return MS_RGB24;130 {ms_message("FORMAT = MS_RGB24");return MS_RGB24;} 133 131 134 132 //else if( fmt == MS_RGB24_REV) … … 137 135 // return; 138 136 else if( fmt == kUYVY422PixelFormat) 139 return MS_UYVY;137 {ms_message("FORMAT = MS_UYVY");return MS_UYVY;} 140 138 141 139 else if( fmt == kYUVSPixelFormat) 142 return MS_YUY2;140 {ms_message("FORMAT = MS_YUY2");return MS_YUY2;} 143 141 144 142 else if( fmt == k32RGBAPixelFormat) 145 return MS_RGBA32;143 {ms_message("FORMAT = MS_RGBA32");return MS_RGBA32;} 146 144 147 145 } 148 146 } 149 147 } 150 148 ms_warning("The camera wasn't open; using MS_YUV420P pixel format"); 151 149 return MS_YUV420P; 152 150 } … … 174 172 } 175 173 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 } 179 180 180 181 input = [[QTCaptureDeviceInput alloc] initWithDevice:device]; 181 182 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]); 185 191 } 186 192 187 193 -(void) setSize:(MSVideoSize) size 188 194 { 195 ms_message("Set size w=%i, h=%i", size.width, size.height); 189 196 NSDictionary * dic = [NSDictionary dictionaryWithObjectsAndKeys: 190 197 [NSNumber numberWithInteger:size.width], (id)kCVPixelBufferWidthKey, … … 210 217 size.height = [[dic objectForKey:(id)kCVPixelBufferHeightKey] integerValue]; 211 218 } 212 219 ms_message("get size w=%i, h=%i", size.width, size.height); 213 220 return size; 214 221 } … … 234 241 NsMsWebCam * webcam; 235 242 NSAutoreleasePool* myPool; 236 mblk_t *mire;237 243 int frame_ind; 238 244 float fps; 239 245 float start_time; 240 246 int frame_count; 241 bool_t usemire;242 247 }v4mState; 243 248 … … 247 252 s->webcam= [[NsMsWebCam alloc] init]; 248 253 [s->webcam retain]; 249 s->mire=NULL;250 254 s->start_time=0; 251 255 s->frame_count=-1; 252 256 s->fps=15; 253 s->usemire=(getenv("DEBUG")!=NULL);254 257 f->data=s; 255 258 } … … 274 277 v4m_stop(f,NULL); 275 278 276 freemsg(s->mire);277 279 [s->webcam release]; 278 280 [s->myPool release]; 279 281 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;319 282 } 320 283 … … 339 302 om=getq([s->webcam rq]); 340 303 } 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 358 305 if (om!=NULL) 359 306 { -
src/qtcapture.m
r1365 r1366 17 17 QTCaptureDecompressedVideoOutput * output; 18 18 QTCaptureSession *session; 19 //QTCaptureDevice *device;20 19 21 20 ms_mutex_t mutex; … … 40 39 @implementation NsMsWebCam 41 40 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 44 42 { 45 43 ms_mutex_lock(&mutex); … … 124 122 125 123 if( fmt == kCVPixelFormatType_420YpCbCr8Planar) 126 return MS_YUV420P;124 {ms_message("FORMAT = MS_YUV420P");return MS_YUV420P;} 127 125 128 126 //else if( fmt == MS_YUYV) … … 130 128 131 129 else if( fmt == kCVPixelFormatType_24RGB) 132 return MS_RGB24;130 {ms_message("FORMAT = MS_RGB24");return MS_RGB24;} 133 131 134 132 //else if( fmt == MS_RGB24_REV) … … 137 135 // return; 138 136 else if( fmt == kUYVY422PixelFormat) 139 return MS_UYVY;137 {ms_message("FORMAT = MS_UYVY");return MS_UYVY;} 140 138 141 139 else if( fmt == kYUVSPixelFormat) 142 return MS_YUY2;140 {ms_message("FORMAT = MS_YUY2");return MS_YUY2;} 143 141 144 142 else if( fmt == k32RGBAPixelFormat) 145 return MS_RGBA32;143 {ms_message("FORMAT = MS_RGBA32");return MS_RGBA32;} 146 144 147 145 } 148 146 } 149 147 } 150 148 ms_warning("The camera wasn't open; using MS_YUV420P pixel format"); 151 149 return MS_YUV420P; 152 150 } … … 174 172 } 175 173 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 } 179 180 180 181 input = [[QTCaptureDeviceInput alloc] initWithDevice:device]; 181 182 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]); 185 191 } 186 192 187 193 -(void) setSize:(MSVideoSize) size 188 194 { 195 ms_message("Set size w=%i, h=%i", size.width, size.height); 189 196 NSDictionary * dic = [NSDictionary dictionaryWithObjectsAndKeys: 190 197 [NSNumber numberWithInteger:size.width], (id)kCVPixelBufferWidthKey, … … 210 217 size.height = [[dic objectForKey:(id)kCVPixelBufferHeightKey] integerValue]; 211 218 } 212 219 ms_message("get size w=%i, h=%i", size.width, size.height); 213 220 return size; 214 221 } … … 295 302 om=getq([s->webcam rq]); 296 303 } 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 314 305 if (om!=NULL) 315 306 { -
tests/mediastream.c
r1354 r1366 41 41 #include <stdlib.h> 42 42 #include <string.h> 43 44 #ifdef __APPLE__ 45 #include <CoreFoundation/CFRunLoop.h> 46 #endif 43 47 44 48 static int cond=1; … … 435 439 }else{ /* no interactive stuff - continuous debug output */ 436 440 rtp_session_register_event_queue(session,q); 441 442 #ifdef __APPLE__ 443 CFRunLoopRun(); 444 #else 437 445 while(cond) 438 446 { … … 464 472 } 465 473 } 474 #endif // target MAC 466 475 } 467 476 -
tests/mediastream.c
r1354 r1366 41 41 #include <stdlib.h> 42 42 #include <string.h> 43 44 #ifdef __APPLE__ 45 #include <CoreFoundation/CFRunLoop.h> 46 #endif 43 47 44 48 static int cond=1; … … 435 439 }else{ /* no interactive stuff - continuous debug output */ 436 440 rtp_session_register_event_queue(session,q); 441 442 #ifdef __APPLE__ 443 CFRunLoopRun(); 444 #else 437 445 while(cond) 438 446 { … … 464 472 } 465 473 } 474 #endif // target MAC 466 475 } 467 476
Note: See TracChangeset
for help on using the changeset viewer.
