Changeset 209188 in webkit
- Timestamp:
- Dec 1, 2016 11:27:25 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r209187 r209188 1 2016-12-01 Eric Carlson <eric.carlson@apple.com> 2 3 [MediaStream][Mac] Video presets sometimes don't work 4 https://bugs.webkit.org/show_bug.cgi?id=165214 5 <rdar://problem/29444533> 6 7 Reviewed by Jer Noble. 8 9 * platform/mediastream/mac/AVVideoCaptureSource.h: 10 * platform/mediastream/mac/AVVideoCaptureSource.mm: 11 (WebCore::AVVideoCaptureSource::setPreset): Set videoSettings width and height. 12 (WebCore::AVVideoCaptureSource::setupCaptureSession): Store videoSettings object for later use. 13 Set videoSettings width and height. 14 (WebCore::AVVideoCaptureSource::bestSessionPresetForVideoDimensions): 15 (WebCore::AVVideoCaptureSource::sizeForPreset): New. 16 1 17 2016-12-01 Antoine Quint <graouts@apple.com> 2 18 -
trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.h
r208985 r209188 87 87 RetainPtr<CMSampleBufferRef> m_buffer; 88 88 RetainPtr<CGImageRef> m_lastImage; 89 RetainPtr<AVCaptureVideoDataOutput> m_videoOutput; 89 90 90 91 Vector<Float64> m_videoFrameTimeStamps; -
trunk/Source/WebCore/platform/mediastream/mac/AVVideoCaptureSource.mm
r209141 r209188 334 334 } 335 335 336 static IntSize sizeForPreset(NSString* preset) 337 { 338 if (!preset) 339 return { }; 340 341 if ([preset isEqualToString:AVCaptureSessionPreset1280x720]) 342 return { 1280, 720 }; 343 344 if ([preset isEqualToString:AVCaptureSessionPreset960x540]) 345 return { 960, 540 }; 346 347 if ([preset isEqualToString:AVCaptureSessionPreset640x480]) 348 return { 640, 480 }; 349 350 if ([preset isEqualToString:AVCaptureSessionPreset352x288]) 351 return { 352, 288 }; 352 353 if ([preset isEqualToString:AVCaptureSessionPreset320x240]) 354 return { 320, 240 }; 355 356 return { }; 357 358 } 359 336 360 bool AVVideoCaptureSource::setPreset(NSString *preset) 337 361 { … … 340 364 return true; 341 365 } 342 m_pendingPreset = nullptr; 343 if (!preset) 366 367 auto size = sizeForPreset(preset); 368 if (size.width() == m_width && size.height() == m_height) 344 369 return true; 345 370 346 371 @try { 347 372 session().sessionPreset = preset; 373 #if PLATFORM(MAC) 374 auto settingsDictionary = @{ (NSString*)kCVPixelBufferPixelFormatTypeKey: @(videoCaptureFormat), (NSString*)kCVPixelBufferWidthKey: @(size.width()), (NSString*)kCVPixelBufferHeightKey: @(size.height()), }; 375 [m_videoOutput setVideoSettings:settingsDictionary]; 376 #endif 348 377 } @catch(NSException *exception) { 349 378 LOG(Media, "AVVideoCaptureSource::applySize(%p), exception thrown configuring device: <%s> %s", this, [[exception name] UTF8String], [[exception reason] UTF8String]); … … 399 428 void AVVideoCaptureSource::setupCaptureSession() 400 429 { 401 if (m_pendingPreset)402 setPreset(m_pendingPreset.get());403 404 430 NSError *error = nil; 405 431 RetainPtr<AVCaptureDeviceInputType> videoIn = adoptNS([allocAVCaptureDeviceInputInstance() initWithDevice:device() error:&error]); … … 415 441 [session() addInput:videoIn.get()]; 416 442 417 RetainPtr<AVCaptureVideoDataOutputType> videoOutput = adoptNS([allocAVCaptureVideoDataOutputInstance() init]); 418 RetainPtr<NSDictionary> settingsDictionary = adoptNS([[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:videoCaptureFormat], kCVPixelBufferPixelFormatTypeKey, nil]); 419 [videoOutput setVideoSettings:settingsDictionary.get()]; 420 [videoOutput setAlwaysDiscardsLateVideoFrames:YES]; 421 setVideoSampleBufferDelegate(videoOutput.get()); 422 423 if (![session() canAddOutput:videoOutput.get()]) { 443 m_videoOutput = adoptNS([allocAVCaptureVideoDataOutputInstance() init]); 444 auto settingsDictionary = adoptNS([[NSMutableDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:videoCaptureFormat], kCVPixelBufferPixelFormatTypeKey, nil]); 445 if (m_pendingPreset) { 446 #if PLATFORM(MAC) 447 auto size = sizeForPreset(m_pendingPreset.get()); 448 [settingsDictionary.get() setObject:[NSNumber numberWithInt:size.width()] forKey:(NSString*)kCVPixelBufferWidthKey]; 449 [settingsDictionary.get() setObject:[NSNumber numberWithInt:size.height()] forKey:(NSString*)kCVPixelBufferHeightKey]; 450 #endif 451 } 452 453 [m_videoOutput setVideoSettings:settingsDictionary.get()]; 454 [m_videoOutput setAlwaysDiscardsLateVideoFrames:YES]; 455 setVideoSampleBufferDelegate(m_videoOutput.get()); 456 457 if (![session() canAddOutput:m_videoOutput.get()]) { 424 458 LOG(Media, "AVVideoCaptureSource::setupCaptureSession(%p), unable to add video sample buffer output delegate", this); 425 459 return; 426 460 } 427 [session() addOutput:videoOutput.get()]; 461 [session() addOutput:m_videoOutput.get()]; 462 463 #if PLATFORM(IOS) 464 setPreset(m_pendingPreset.get()); 465 #endif 466 428 467 } 429 468 … … 568 607 } 569 608 570 NSString *AVVideoCaptureSource::bestSessionPresetForVideoDimensions(std::optional<int> width, std::optional<int> height) const609 NSString* AVVideoCaptureSource::bestSessionPresetForVideoDimensions(std::optional<int> width, std::optional<int> height) const 571 610 { 572 611 if (!width && !height)
Note: See TracChangeset
for help on using the changeset viewer.