| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" | 5 #import "media/video/capture/mac/video_capture_device_qtkit_mac.h" |
| 6 | 6 |
| 7 #import <QTKit/QTKit.h> | 7 #import <QTKit/QTKit.h> |
| 8 | 8 |
| 9 #include "base/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 | 274 |
| 275 for (size_t y = 0; y < frameHeight; ++y) { | 275 for (size_t y = 0; y < frameHeight; ++y) { |
| 276 memcpy(adjustedAddress + y * expectedBytesPerRow, | 276 memcpy(adjustedAddress + y * expectedBytesPerRow, |
| 277 addressToPass + y * bytesPerRow, | 277 addressToPass + y * bytesPerRow, |
| 278 expectedBytesPerRow); | 278 expectedBytesPerRow); |
| 279 } | 279 } |
| 280 | 280 |
| 281 addressToPass = adjustedAddress; | 281 addressToPass = adjustedAddress; |
| 282 frameSize = frameHeight * expectedBytesPerRow; | 282 frameSize = frameHeight * expectedBytesPerRow; |
| 283 } | 283 } |
| 284 media::VideoCaptureCapability captureCapability; | 284 |
| 285 captureCapability.width = frameWidth; | 285 media::VideoCaptureFormat captureFormat(gfx::Size(frameWidth, frameHeight), |
| 286 captureCapability.height = frameHeight; | 286 frameRate_, |
| 287 captureCapability.frame_rate = frameRate_; | 287 media::PIXEL_FORMAT_UYVY); |
| 288 captureCapability.color = media::PIXEL_FORMAT_UYVY; | |
| 289 | 288 |
| 290 // The aspect ratio dictionary is often missing, in which case we report | 289 // The aspect ratio dictionary is often missing, in which case we report |
| 291 // a pixel aspect ratio of 0:0. | 290 // a pixel aspect ratio of 0:0. |
| 292 int aspectNumerator = 0, aspectDenominator = 0; | 291 int aspectNumerator = 0, aspectDenominator = 0; |
| 293 CFDictionaryRef aspectRatioDict = (CFDictionaryRef)CVBufferGetAttachment( | 292 CFDictionaryRef aspectRatioDict = (CFDictionaryRef)CVBufferGetAttachment( |
| 294 videoFrame, kCVImageBufferPixelAspectRatioKey, NULL); | 293 videoFrame, kCVImageBufferPixelAspectRatioKey, NULL); |
| 295 if (aspectRatioDict) { | 294 if (aspectRatioDict) { |
| 296 CFNumberRef aspectNumeratorRef = (CFNumberRef)CFDictionaryGetValue( | 295 CFNumberRef aspectNumeratorRef = (CFNumberRef)CFDictionaryGetValue( |
| 297 aspectRatioDict, kCVImageBufferPixelAspectRatioHorizontalSpacingKey); | 296 aspectRatioDict, kCVImageBufferPixelAspectRatioHorizontalSpacingKey); |
| 298 CFNumberRef aspectDenominatorRef = (CFNumberRef)CFDictionaryGetValue( | 297 CFNumberRef aspectDenominatorRef = (CFNumberRef)CFDictionaryGetValue( |
| 299 aspectRatioDict, kCVImageBufferPixelAspectRatioVerticalSpacingKey); | 298 aspectRatioDict, kCVImageBufferPixelAspectRatioVerticalSpacingKey); |
| 300 DCHECK(aspectNumeratorRef && aspectDenominatorRef) << | 299 DCHECK(aspectNumeratorRef && aspectDenominatorRef) << |
| 301 "Aspect Ratio dictionary missing its entries."; | 300 "Aspect Ratio dictionary missing its entries."; |
| 302 CFNumberGetValue(aspectNumeratorRef, kCFNumberIntType, &aspectNumerator); | 301 CFNumberGetValue(aspectNumeratorRef, kCFNumberIntType, &aspectNumerator); |
| 303 CFNumberGetValue( | 302 CFNumberGetValue( |
| 304 aspectDenominatorRef, kCFNumberIntType, &aspectDenominator); | 303 aspectDenominatorRef, kCFNumberIntType, &aspectDenominator); |
| 305 } | 304 } |
| 306 | 305 |
| 307 // Deliver the captured video frame. | 306 // Deliver the captured video frame. |
| 308 frameReceiver_->ReceiveFrame(addressToPass, frameSize, captureCapability, | 307 frameReceiver_->ReceiveFrame(addressToPass, frameSize, captureFormat, |
| 309 aspectNumerator, aspectDenominator); | 308 aspectNumerator, aspectDenominator); |
| 310 | 309 |
| 311 CVPixelBufferUnlockBaseAddress(videoFrame, kLockFlags); | 310 CVPixelBufferUnlockBaseAddress(videoFrame, kLockFlags); |
| 312 } | 311 } |
| 313 [lock_ unlock]; | 312 [lock_ unlock]; |
| 314 } | 313 } |
| 315 | 314 |
| 316 - (void)handleNotification:(NSNotification*)errorNotification { | 315 - (void)handleNotification:(NSNotification*)errorNotification { |
| 317 NSError * error = (NSError*)[[errorNotification userInfo] | 316 NSError * error = (NSError*)[[errorNotification userInfo] |
| 318 objectForKey:QTCaptureSessionErrorKey]; | 317 objectForKey:QTCaptureSessionErrorKey]; |
| 319 frameReceiver_->ReceiveError([[error localizedDescription] UTF8String]); | 318 frameReceiver_->ReceiveError([[error localizedDescription] UTF8String]); |
| 320 } | 319 } |
| 321 | 320 |
| 322 @end | 321 @end |
| OLD | NEW |