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

Side by Side Diff: media/video/capture/mac/video_capture_device_avfoundation_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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_avfoundation_mac.h" 5 #import "media/video/capture/mac/video_capture_device_avfoundation_mac.h"
6 6
7 #import <CoreVideo/CoreVideo.h> 7 #import <CoreVideo/CoreVideo.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 return NO; 164 return NO;
165 } 165 }
166 [captureVideoDataOutput_ 166 [captureVideoDataOutput_
167 setSampleBufferDelegate:self 167 setSampleBufferDelegate:self
168 queue:dispatch_get_global_queue( 168 queue:dispatch_get_global_queue(
169 DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)]; 169 DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)];
170 [captureSession_ addOutput:captureVideoDataOutput_]; 170 [captureSession_ addOutput:captureVideoDataOutput_];
171 return YES; 171 return YES;
172 } 172 }
173 173
174 - (BOOL)setCaptureHeight:(int)height width:(int)width frameRate:(int)frameRate { 174 - (BOOL)setCaptureHeight:(int)height
175 width:(int)width
176 frameRate:(float)frameRate {
175 // Check if either of VideoCaptureDeviceMac::AllocateAndStart() or 177 // Check if either of VideoCaptureDeviceMac::AllocateAndStart() or
176 // VideoCaptureDeviceMac::ReceiveFrame() is calling here, depending on the 178 // VideoCaptureDeviceMac::ReceiveFrame() is calling here, depending on the
177 // running state. VCDM::ReceiveFrame() calls here to change aspect ratio. 179 // running state. VCDM::ReceiveFrame() calls here to change aspect ratio.
178 DCHECK((![captureSession_ isRunning] && 180 DCHECK((![captureSession_ isRunning] &&
179 main_thread_checker_.CalledOnValidThread()) || 181 main_thread_checker_.CalledOnValidThread()) ||
180 callback_thread_checker_.CalledOnValidThread()); 182 callback_thread_checker_.CalledOnValidThread());
181 183
182 frameWidth_ = width; 184 frameWidth_ = width;
183 frameHeight_ = height; 185 frameHeight_ = height;
184 frameRate_ = frameRate; 186 frameRate_ = frameRate;
(...skipping 16 matching lines...) Expand all
201 CrAVCaptureConnection* captureConnection = [captureVideoDataOutput_ 203 CrAVCaptureConnection* captureConnection = [captureVideoDataOutput_
202 connectionWithMediaType:AVFoundationGlue::AVMediaTypeVideo()]; 204 connectionWithMediaType:AVFoundationGlue::AVMediaTypeVideo()];
203 // Check selector existence, related to bugs http://crbug.com/327532 and 205 // Check selector existence, related to bugs http://crbug.com/327532 and
204 // http://crbug.com/328096. 206 // http://crbug.com/328096.
205 // CMTimeMake accepts integer argumenst but |frameRate| is float, round it. 207 // CMTimeMake accepts integer argumenst but |frameRate| is float, round it.
206 if ([captureConnection 208 if ([captureConnection
207 respondsToSelector:@selector(isVideoMinFrameDurationSupported)] && 209 respondsToSelector:@selector(isVideoMinFrameDurationSupported)] &&
208 [captureConnection isVideoMinFrameDurationSupported]) { 210 [captureConnection isVideoMinFrameDurationSupported]) {
209 [captureConnection setVideoMinFrameDuration: 211 [captureConnection setVideoMinFrameDuration:
210 CoreMediaGlue::CMTimeMake(media::kFrameRatePrecision, 212 CoreMediaGlue::CMTimeMake(media::kFrameRatePrecision,
211 frameRate * media::kFrameRatePrecision)]; 213 (int)(frameRate * media::kFrameRatePrecision))];
212 } 214 }
213 if ([captureConnection 215 if ([captureConnection
214 respondsToSelector:@selector(isVideoMaxFrameDurationSupported)] && 216 respondsToSelector:@selector(isVideoMaxFrameDurationSupported)] &&
215 [captureConnection isVideoMaxFrameDurationSupported]) { 217 [captureConnection isVideoMaxFrameDurationSupported]) {
216 [captureConnection setVideoMaxFrameDuration: 218 [captureConnection setVideoMaxFrameDuration:
217 CoreMediaGlue::CMTimeMake(media::kFrameRatePrecision, 219 CoreMediaGlue::CMTimeMake(media::kFrameRatePrecision,
218 frameRate * media::kFrameRatePrecision)]; 220 (int)(frameRate * media::kFrameRatePrecision))];
219 } 221 }
220 return YES; 222 return YES;
221 } 223 }
222 224
223 - (BOOL)startCapture { 225 - (BOOL)startCapture {
224 DCHECK(main_thread_checker_.CalledOnValidThread()); 226 DCHECK(main_thread_checker_.CalledOnValidThread());
225 if (!captureSession_) { 227 if (!captureSession_) {
226 DLOG(ERROR) << "Video capture session not initialized."; 228 DLOG(ERROR) << "Video capture session not initialized.";
227 return NO; 229 return NO;
228 } 230 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 290 }
289 291
290 - (void)sendErrorString:(NSString*)error { 292 - (void)sendErrorString:(NSString*)error {
291 DLOG(ERROR) << [error UTF8String]; 293 DLOG(ERROR) << [error UTF8String];
292 base::AutoLock lock(lock_); 294 base::AutoLock lock(lock_);
293 if (frameReceiver_) 295 if (frameReceiver_)
294 frameReceiver_->ReceiveError([error UTF8String]); 296 frameReceiver_->ReceiveError([error UTF8String]);
295 } 297 }
296 298
297 @end 299 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698