| 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 == kCVReturnSuccess) { | 216 == kCVReturnSuccess) { |
| 217 void *baseAddress = CVPixelBufferGetBaseAddress(videoFrame); | 217 void *baseAddress = CVPixelBufferGetBaseAddress(videoFrame); |
| 218 size_t bytesPerRow = CVPixelBufferGetBytesPerRow(videoFrame); | 218 size_t bytesPerRow = CVPixelBufferGetBytesPerRow(videoFrame); |
| 219 int frameHeight = CVPixelBufferGetHeight(videoFrame); | 219 int frameHeight = CVPixelBufferGetHeight(videoFrame); |
| 220 int frameSize = bytesPerRow * frameHeight; | 220 int frameSize = bytesPerRow * frameHeight; |
| 221 | 221 |
| 222 // TODO(shess): bytesPerRow may not correspond to frameWidth_*4, | 222 // TODO(shess): bytesPerRow may not correspond to frameWidth_*4, |
| 223 // but VideoCaptureController::OnIncomingCapturedFrame() requires | 223 // but VideoCaptureController::OnIncomingCapturedFrame() requires |
| 224 // it to do so. Plumbing things through is intrusive, for now | 224 // it to do so. Plumbing things through is intrusive, for now |
| 225 // just deliver an adjusted buffer. | 225 // just deliver an adjusted buffer. |
| 226 // TODO(nick): This workaround could probably be eliminated by using |
| 227 // VideoCaptureController::OnIncomingCapturedVideoFrame, which supports |
| 228 // pitches. |
| 226 UInt8* addressToPass = static_cast<UInt8*>(baseAddress); | 229 UInt8* addressToPass = static_cast<UInt8*>(baseAddress); |
| 227 size_t expectedBytesPerRow = frameWidth_ * 4; | 230 size_t expectedBytesPerRow = frameWidth_ * 4; |
| 228 if (bytesPerRow > expectedBytesPerRow) { | 231 if (bytesPerRow > expectedBytesPerRow) { |
| 229 // TODO(shess): frameHeight and frameHeight_ are not the same, | 232 // TODO(shess): frameHeight and frameHeight_ are not the same, |
| 230 // try to do what the surrounding code seems to assume. | 233 // try to do what the surrounding code seems to assume. |
| 231 // Ironically, captureCapability and frameSize are ignored | 234 // Ironically, captureCapability and frameSize are ignored |
| 232 // anyhow. | 235 // anyhow. |
| 233 adjustedFrame_.resize(expectedBytesPerRow * frameHeight); | 236 adjustedFrame_.resize(expectedBytesPerRow * frameHeight); |
| 234 // std::vector is contiguous according to standard. | 237 // std::vector is contiguous according to standard. |
| 235 UInt8* adjustedAddress = &adjustedFrame_[0]; | 238 UInt8* adjustedAddress = &adjustedFrame_[0]; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 253 | 256 |
| 254 // Deliver the captured video frame. | 257 // Deliver the captured video frame. |
| 255 frameReceiver_->ReceiveFrame(addressToPass, frameSize, captureCapability); | 258 frameReceiver_->ReceiveFrame(addressToPass, frameSize, captureCapability); |
| 256 | 259 |
| 257 CVPixelBufferUnlockBaseAddress(videoFrame, kLockFlags); | 260 CVPixelBufferUnlockBaseAddress(videoFrame, kLockFlags); |
| 258 } | 261 } |
| 259 [lock_ unlock]; | 262 [lock_ unlock]; |
| 260 } | 263 } |
| 261 | 264 |
| 262 @end | 265 @end |
| OLD | NEW |