| 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/capture/video/mac/video_capture_device_qtkit_mac.h" | 5 #import "media/capture/video/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" |
| 11 #include "media/base/timestamp_constants.h" |
| 11 #include "media/base/video_capture_types.h" | 12 #include "media/base/video_capture_types.h" |
| 12 #include "media/capture/video/mac/video_capture_device_mac.h" | 13 #include "media/capture/video/mac/video_capture_device_mac.h" |
| 13 #include "media/capture/video/video_capture_device.h" | 14 #include "media/capture/video/video_capture_device.h" |
| 14 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
| 15 | 16 |
| 16 @implementation VideoCaptureDeviceQTKit | 17 @implementation VideoCaptureDeviceQTKit |
| 17 | 18 |
| 18 #pragma mark Class methods | 19 #pragma mark Class methods |
| 19 | 20 |
| 20 + (void)getDeviceNames:(NSMutableDictionary*)deviceNames { | 21 + (void)getDeviceNames:(NSMutableDictionary*)deviceNames { |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 CFNumberRef aspectDenominatorRef = (CFNumberRef)CFDictionaryGetValue( | 319 CFNumberRef aspectDenominatorRef = (CFNumberRef)CFDictionaryGetValue( |
| 319 aspectRatioDict, kCVImageBufferPixelAspectRatioVerticalSpacingKey); | 320 aspectRatioDict, kCVImageBufferPixelAspectRatioVerticalSpacingKey); |
| 320 DCHECK(aspectNumeratorRef && aspectDenominatorRef) | 321 DCHECK(aspectNumeratorRef && aspectDenominatorRef) |
| 321 << "Aspect Ratio dictionary missing its entries."; | 322 << "Aspect Ratio dictionary missing its entries."; |
| 322 CFNumberGetValue(aspectNumeratorRef, kCFNumberIntType, &aspectNumerator); | 323 CFNumberGetValue(aspectNumeratorRef, kCFNumberIntType, &aspectNumerator); |
| 323 CFNumberGetValue(aspectDenominatorRef, kCFNumberIntType, | 324 CFNumberGetValue(aspectDenominatorRef, kCFNumberIntType, |
| 324 &aspectDenominator); | 325 &aspectDenominator); |
| 325 } | 326 } |
| 326 | 327 |
| 327 // Deliver the captured video frame. | 328 // Deliver the captured video frame. |
| 329 const QTTime qt_timestamp = [sampleBuffer presentationTime]; |
| 330 base::TimeDelta timestamp; |
| 331 if (!(qt_timestamp.flags & kQTTimeIsIndefinite) && qt_timestamp.timeScale) { |
| 332 timestamp = base::TimeDelta::FromMicroseconds( |
| 333 qt_timestamp.timeValue * base::TimeTicks::kMicrosecondsPerSecond / |
| 334 qt_timestamp.timeScale); |
| 335 } else { |
| 336 timestamp = media::kNoTimestamp(); |
| 337 } |
| 328 frameReceiver_->ReceiveFrame(addressToPass, frameSize, captureFormat, | 338 frameReceiver_->ReceiveFrame(addressToPass, frameSize, captureFormat, |
| 329 aspectNumerator, aspectDenominator); | 339 aspectNumerator, aspectDenominator, timestamp); |
| 330 | 340 |
| 331 CVPixelBufferUnlockBaseAddress(videoFrame, kLockFlags); | 341 CVPixelBufferUnlockBaseAddress(videoFrame, kLockFlags); |
| 332 } | 342 } |
| 333 [lock_ unlock]; | 343 [lock_ unlock]; |
| 334 } | 344 } |
| 335 | 345 |
| 336 - (void)handleNotification:(NSNotification*)errorNotification { | 346 - (void)handleNotification:(NSNotification*)errorNotification { |
| 337 NSError* error = (NSError*) | 347 NSError* error = (NSError*) |
| 338 [[errorNotification userInfo] objectForKey:QTCaptureSessionErrorKey]; | 348 [[errorNotification userInfo] objectForKey:QTCaptureSessionErrorKey]; |
| 339 [self sendErrorString: | 349 [self sendErrorString: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 351 | 361 |
| 352 - (void)sendLogString:(NSString*)message { | 362 - (void)sendLogString:(NSString*)message { |
| 353 DVLOG(1) << [message UTF8String]; | 363 DVLOG(1) << [message UTF8String]; |
| 354 [lock_ lock]; | 364 [lock_ lock]; |
| 355 if (frameReceiver_) | 365 if (frameReceiver_) |
| 356 frameReceiver_->LogMessage([message UTF8String]); | 366 frameReceiver_->LogMessage([message UTF8String]); |
| 357 [lock_ unlock]; | 367 [lock_ unlock]; |
| 358 } | 368 } |
| 359 | 369 |
| 360 @end | 370 @end |
| OLD | NEW |