Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: media/video/capture/mac/video_capture_device_qtkit_mac.mm

Issue 464853002: Mac Video Capture: correct to float the erroneous handling of frame rate as int. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/video/capture/mac/video_capture_device_qtkit_mac.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 waitUntilDone:YES]; 167 waitUntilDone:YES];
168 } 168 }
169 [captureSession_ release]; 169 [captureSession_ release];
170 captureSession_ = nil; 170 captureSession_ = nil;
171 [captureDeviceInput_ release]; 171 [captureDeviceInput_ release];
172 captureDeviceInput_ = nil; 172 captureDeviceInput_ = nil;
173 return YES; 173 return YES;
174 } 174 }
175 } 175 }
176 176
177 - (BOOL)setCaptureHeight:(int)height width:(int)width frameRate:(int)frameRate { 177 - (BOOL)setCaptureHeight:(int)height
178 width:(int)width
179 frameRate:(float)frameRate {
178 if (!captureDeviceInput_) { 180 if (!captureDeviceInput_) {
179 [self sendErrorString:[NSString 181 [self sendErrorString:[NSString
180 stringWithUTF8String:"No video capture device set."]]; 182 stringWithUTF8String:"No video capture device set."]];
181 return NO; 183 return NO;
182 } 184 }
183 if ([[captureSession_ outputs] count] != 1) { 185 if ([[captureSession_ outputs] count] != 1) {
184 [self sendErrorString:[NSString 186 [self sendErrorString:[NSString
185 stringWithUTF8String:"Video capture capabilities already set."]]; 187 stringWithUTF8String:"Video capture capabilities already set."]];
186 return NO; 188 return NO;
187 } 189 }
188 if (frameRate <= 0) { 190 if (frameRate <= 0.0f) {
189 [self sendErrorString:[NSString stringWithUTF8String: "Wrong frame rate."]]; 191 [self sendErrorString:[NSString stringWithUTF8String: "Wrong frame rate."]];
190 return NO; 192 return NO;
191 } 193 }
192 194
193 frameRate_ = frameRate; 195 frameRate_ = frameRate;
194 196
195 QTCaptureDecompressedVideoOutput *output = 197 QTCaptureDecompressedVideoOutput *output =
196 [[captureSession_ outputs] objectAtIndex:0]; 198 [[captureSession_ outputs] objectAtIndex:0];
197 199
198 // Set up desired output properties. The old capture dictionary is used to 200 // Set up desired output properties. The old capture dictionary is used to
199 // retrieve the initial pixel format, which must be maintained. 201 // retrieve the initial pixel format, which must be maintained.
200 NSDictionary* videoSettingsDictionary = @{ 202 NSDictionary* videoSettingsDictionary = @{
201 (id)kCVPixelBufferWidthKey : @(width), 203 (id)kCVPixelBufferWidthKey : @(width),
202 (id)kCVPixelBufferHeightKey : @(height), 204 (id)kCVPixelBufferHeightKey : @(height),
203 (id)kCVPixelBufferPixelFormatTypeKey : [[output pixelBufferAttributes] 205 (id)kCVPixelBufferPixelFormatTypeKey : [[output pixelBufferAttributes]
204 valueForKey:(id)kCVPixelBufferPixelFormatTypeKey] 206 valueForKey:(id)kCVPixelBufferPixelFormatTypeKey]
205 }; 207 };
206 [output setPixelBufferAttributes:videoSettingsDictionary]; 208 [output setPixelBufferAttributes:videoSettingsDictionary];
207 209
208 [output setMinimumVideoFrameInterval:(NSTimeInterval)1/(float)frameRate]; 210 [output setMinimumVideoFrameInterval:(NSTimeInterval)1/frameRate];
209 return YES; 211 return YES;
210 } 212 }
211 213
212 - (BOOL)startCapture { 214 - (BOOL)startCapture {
213 if ([[captureSession_ outputs] count] == 0) { 215 if ([[captureSession_ outputs] count] == 0) {
214 // Capture properties not set. 216 // Capture properties not set.
215 [self sendErrorString:[NSString 217 [self sendErrorString:[NSString
216 stringWithUTF8String:"Video capture device not initialized."]]; 218 stringWithUTF8String:"Video capture device not initialized."]];
217 return NO; 219 return NO;
218 } 220 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 339
338 - (void)sendErrorString:(NSString*)error { 340 - (void)sendErrorString:(NSString*)error {
339 DLOG(ERROR) << [error UTF8String]; 341 DLOG(ERROR) << [error UTF8String];
340 [lock_ lock]; 342 [lock_ lock];
341 if (frameReceiver_) 343 if (frameReceiver_)
342 frameReceiver_->ReceiveError([error UTF8String]); 344 frameReceiver_->ReceiveError([error UTF8String]);
343 [lock_ unlock]; 345 [lock_ unlock];
344 } 346 }
345 347
346 @end 348 @end
OLDNEW
« no previous file with comments | « media/video/capture/mac/video_capture_device_qtkit_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698