forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added VideoCaptureDeviceAvFoundation class, implementing the
PlatformVideoCapturingMac protocol. All the protocol methods are NOTIMPLEMENTED(), the static +getDeviceNames() is implemented though and used to enumerate the devices in the system in VideoCaptureDeviceMac if IsAVFoundationSupported()==YES. The rest of the VideoCaptureDeviceMac operations use QTKit still. This CL is part of a larger exercise to add support for Video Capture in Mac > 10.6 using AVFoundation. BUG=288562 Review URL: https://codereview.chromium.org/48983002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233971 0039d316-1c4b-4281-b951-d872f2087c98
- Loading branch information
mcasas@chromium.org
committed
Nov 8, 2013
1 parent
c9390bd
commit 31279ff
Showing
8 changed files
with
148 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,8 @@ MEDIA_EXPORT | |
|
||
- (NSString*)uniqueID; | ||
|
||
- (NSString*)localizedName; | ||
|
||
@end | ||
|
||
MEDIA_EXPORT | ||
|
42 changes: 42 additions & 0 deletions
42
media/video/capture/mac/video_capture_device_avfoundation_mac.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#ifndef MEDIA_VIDEO_CAPTURE_MAC_VIDEO_CAPTURE_DEVICE_AVFOUNDATION_MAC_H_ | ||
#define MEDIA_VIDEO_CAPTURE_MAC_VIDEO_CAPTURE_DEVICE_AVFOUNDATION_MAC_H_ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import "media/video/capture/mac/platform_video_capturing_mac.h" | ||
|
||
namespace media { | ||
class VideoCaptureDeviceMac; | ||
} | ||
|
||
// Class used by VideoCaptureDeviceMac for video capture using AVFoundation API. | ||
@interface VideoCaptureDeviceAVFoundation : NSObject<PlatformVideoCapturingMac> | ||
|
||
// Returns a dictionary of capture devices with friendly name and unique id. | ||
+ (NSDictionary*)deviceNames; | ||
|
||
// Initializes the instance and registers the frame receiver. | ||
- (id)initWithFrameReceiver:(media::VideoCaptureDeviceMac*)frameReceiver; | ||
|
||
// Set the frame receiver. | ||
- (void)setFrameReceiver:(media::VideoCaptureDeviceMac*)frameReceiver; | ||
|
||
// Sets which capture device to use. Returns YES on sucess, NO otherwise. | ||
- (BOOL)setCaptureDevice:(NSString*)deviceId; | ||
|
||
// Configures the capture properties. | ||
- (BOOL)setCaptureHeight:(int)height width:(int)width frameRate:(int)frameRate; | ||
|
||
// Start video capturing. Returns YES on sucess, NO otherwise. | ||
- (BOOL)startCapture; | ||
|
||
// Stops video capturing. | ||
- (void)stopCapture; | ||
|
||
@end | ||
|
||
#endif // MEDIA_VIDEO_CAPTURE_MAC_VIDEO_CAPTURE_DEVICE_AVFOUNDATION_MAC_H_ |
65 changes: 65 additions & 0 deletions
65
media/video/capture/mac/video_capture_device_avfoundation_mac.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright 2013 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import "media/video/capture/mac/video_capture_device_avfoundation_mac.h" | ||
|
||
#include "base/logging.h" | ||
#import "media/video/capture/mac/avfoundation_glue.h" | ||
|
||
@implementation VideoCaptureDeviceAVFoundation | ||
|
||
#pragma mark Class methods | ||
|
||
+ (void)getDeviceNames:(NSMutableDictionary*)deviceNames { | ||
// Calling the +devices method will load NSBundle and create device drivers. | ||
NSArray* devices = [AVCaptureDeviceGlue devices]; | ||
for (CrAVCaptureDevice* device in devices) { | ||
if ([device hasMediaType:AVFoundationGlue::AVMediaTypeVideo()] || | ||
[device hasMediaType:AVFoundationGlue::AVMediaTypeMuxed()]) { | ||
[deviceNames setObject:[device localizedName] | ||
forKey:[device uniqueID]]; | ||
} | ||
} | ||
} | ||
|
||
+ (NSDictionary*)deviceNames { | ||
NSMutableDictionary* deviceNames = | ||
[[[NSMutableDictionary alloc] init] autorelease]; | ||
// The device name retrieval is not going to happen in the main thread, and | ||
// this might cause instabilities (it did in QTKit), so keep an eye here. | ||
[self getDeviceNames:deviceNames]; | ||
return deviceNames; | ||
} | ||
|
||
#pragma mark Public methods | ||
|
||
- (id)initWithFrameReceiver:(media::VideoCaptureDeviceMac*)frameReceiver { | ||
NOTIMPLEMENTED(); | ||
return nil; | ||
} | ||
|
||
- (void)setFrameReceiver:(media::VideoCaptureDeviceMac*)frameReceiver { | ||
NOTIMPLEMENTED(); | ||
} | ||
|
||
- (BOOL)setCaptureDevice:(NSString*)deviceId { | ||
NOTIMPLEMENTED(); | ||
return NO; | ||
} | ||
|
||
- (BOOL)setCaptureHeight:(int)height width:(int)width frameRate:(int)frameRate { | ||
NOTIMPLEMENTED(); | ||
return NO; | ||
} | ||
|
||
- (BOOL)startCapture { | ||
NOTIMPLEMENTED(); | ||
return NO; | ||
} | ||
|
||
- (void)stopCapture { | ||
NOTIMPLEMENTED(); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters