mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 21:13:04 +02:00
mac-avcapture: Ability to directly add iOS devices over USB
Closes jp9000/obs-studio#869
This commit is contained in:
parent
54805fe55d
commit
162450c882
@ -6,12 +6,14 @@ find_library(COREFOUNDATION CoreFoundation)
|
||||
find_library(COREMEDIA CoreMedia)
|
||||
find_library(COREVIDEO CoreVideo)
|
||||
find_library(COCOA Cocoa)
|
||||
find_library(COREMEDIAIO CoreMediaIO)
|
||||
|
||||
include_directories(${AVFOUNDATION}
|
||||
${COCOA}
|
||||
${COREFOUNDATION}
|
||||
${COREMEDIA}
|
||||
${COREVIDEO}
|
||||
${COREMEDIAIO}
|
||||
${COCOA})
|
||||
|
||||
set(mac-avcapture_HEADERS
|
||||
@ -36,6 +38,7 @@ target_link_libraries(mac-avcapture
|
||||
${COREFOUNDATION}
|
||||
${COREMEDIA}
|
||||
${COREVIDEO}
|
||||
${COREMEDIAIO}
|
||||
${COCOA})
|
||||
|
||||
install_obs_plugin_with_data(mac-avcapture data)
|
||||
|
@ -2,6 +2,7 @@
|
||||
#import <CoreFoundation/CoreFoundation.h>
|
||||
#import <CoreMedia/CoreMedia.h>
|
||||
#import <CoreVideo/CoreVideo.h>
|
||||
#import <CoreMediaIO/CMIOHardware.h>
|
||||
|
||||
#include <obs-module.h>
|
||||
#include <obs.hpp>
|
||||
@ -780,7 +781,7 @@ static bool init_format(av_capture *capture, AVCaptureDevice *dev)
|
||||
CMMediaType mtype = CMFormatDescriptionGetMediaType(
|
||||
format.formatDescription);
|
||||
// TODO: support other media types
|
||||
if (mtype != kCMMediaType_Video) {
|
||||
if (mtype != kCMMediaType_Video && mtype != kCMMediaType_Muxed) {
|
||||
AVLOG(LOG_ERROR, "CMMediaType '%s' is unsupported",
|
||||
AV_FOURCC_STR(mtype));
|
||||
return false;
|
||||
@ -1247,7 +1248,7 @@ static NSArray *presets(void)
|
||||
AVCaptureSessionPreset640x480,
|
||||
AVCaptureSessionPreset352x288,
|
||||
AVCaptureSessionPreset320x240,
|
||||
//AVCaptureSessionPresetHigh,
|
||||
AVCaptureSessionPresetHigh,
|
||||
//AVCaptureSessionPresetMedium,
|
||||
//AVCaptureSessionPresetLow,
|
||||
//AVCaptureSessionPresetPhoto,
|
||||
@ -1265,6 +1266,7 @@ static NSString *preset_names(NSString *preset)
|
||||
AVCaptureSessionPreset640x480:@"640x480",
|
||||
AVCaptureSessionPreset960x540:@"960x540",
|
||||
AVCaptureSessionPreset1280x720:@"1280x720",
|
||||
AVCaptureSessionPresetHigh:@"High",
|
||||
};
|
||||
NSString *name = preset_names[preset];
|
||||
if (name)
|
||||
@ -2080,12 +2082,16 @@ static obs_properties_t *av_capture_properties(void *capture)
|
||||
TEXT_DEVICE, OBS_COMBO_TYPE_LIST,
|
||||
OBS_COMBO_FORMAT_STRING);
|
||||
obs_property_list_add_string(dev_list, "", "");
|
||||
|
||||
for (AVCaptureDevice *dev in [AVCaptureDevice
|
||||
devicesWithMediaType:AVMediaTypeVideo]) {
|
||||
devices]) {
|
||||
if ([dev hasMediaType: AVMediaTypeVideo] ||
|
||||
[dev hasMediaType: AVMediaTypeMuxed]) {
|
||||
obs_property_list_add_string(dev_list,
|
||||
dev.localizedName.UTF8String,
|
||||
dev.uniqueID.UTF8String);
|
||||
}
|
||||
}
|
||||
|
||||
obs_property_set_modified_callback(dev_list,
|
||||
properties_device_changed);
|
||||
@ -2178,6 +2184,20 @@ OBS_MODULE_USE_DEFAULT_LOCALE("mac-avcapture", "en-US")
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
#ifdef __MAC_10_10
|
||||
// Enable iOS device to show up as AVCapture devices
|
||||
// From WWDC video 2014 #508 at 5:34
|
||||
// https://developer.apple.com/videos/wwdc/2014/#508
|
||||
CMIOObjectPropertyAddress prop = {
|
||||
kCMIOHardwarePropertyAllowScreenCaptureDevices,
|
||||
kCMIOObjectPropertyScopeGlobal,
|
||||
kCMIOObjectPropertyElementMaster
|
||||
};
|
||||
UInt32 allow = 1;
|
||||
CMIOObjectSetPropertyData(kCMIOObjectSystemObject, &prop, 0, NULL,
|
||||
sizeof(allow), &allow);
|
||||
#endif
|
||||
|
||||
obs_source_info av_capture_info = {
|
||||
.id = "av_capture_input",
|
||||
.type = OBS_SOURCE_TYPE_INPUT,
|
||||
|
Loading…
Reference in New Issue
Block a user