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