Fixed deprecation warnings on Mac and iOS (#3837)
This commit is contained in:
parent
53d96cd5b8
commit
d762276861
|
@ -20,8 +20,8 @@ if test "$*" = "--help" -o "$*" = "-h"; then
|
||||||
echo " ARCH Optional flags to specify target architecture, e.g."
|
echo " ARCH Optional flags to specify target architecture, e.g."
|
||||||
echo " ARCH=\"-arch armv7\". Default is arm64."
|
echo " ARCH=\"-arch armv7\". Default is arm64."
|
||||||
echo " MIN_IOS Optional flags to specify minimum supported iOS"
|
echo " MIN_IOS Optional flags to specify minimum supported iOS"
|
||||||
echo " versions, e.g. MIN_IOS=\"-miphoneos-version-min=10.0\". "
|
echo " versions, e.g. MIN_IOS=\"-miphoneos-version-min=11.0\". "
|
||||||
echo " Default is 7.0."
|
echo " Default is 11.0."
|
||||||
echo ""
|
echo ""
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
@ -123,7 +123,7 @@ if test "${ARCH_VAL}" = "arm64e"; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test "${MIN_IOS}" = ""; then
|
if test "${MIN_IOS}" = ""; then
|
||||||
MIN_IOS_VER="7.0"
|
MIN_IOS_VER="11.0"
|
||||||
echo "$F: MIN_IOS is not specified, choosing ${MIN_IOS_VER}"
|
echo "$F: MIN_IOS is not specified, choosing ${MIN_IOS_VER}"
|
||||||
MIN_IOS="-miphoneos-version-min=${MIN_IOS_VER}"
|
MIN_IOS="-miphoneos-version-min=${MIN_IOS_VER}"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -143,6 +143,9 @@ static void activesock_destroy_iphone_os_stream(pj_activesock_t *asock)
|
||||||
|
|
||||||
static void activesock_create_iphone_os_stream(pj_activesock_t *asock)
|
static void activesock_create_iphone_os_stream(pj_activesock_t *asock)
|
||||||
{
|
{
|
||||||
|
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \
|
||||||
|
__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0)
|
||||||
|
|
||||||
if (ios_bg_support && asock->bg_setting && asock->stream_oriented) {
|
if (ios_bg_support && asock->bg_setting && asock->stream_oriented) {
|
||||||
activesock_destroy_iphone_os_stream(asock);
|
activesock_destroy_iphone_os_stream(asock);
|
||||||
|
|
||||||
|
@ -164,6 +167,8 @@ static void activesock_create_iphone_os_stream(pj_activesock_t *asock)
|
||||||
activesock_destroy_iphone_os_stream(asock);
|
activesock_destroy_iphone_os_stream(asock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,12 @@
|
||||||
#define COREAUDIO_MAC 1
|
#define COREAUDIO_MAC 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (TARGET_OS_OSX && defined(__MAC_12_0))
|
||||||
|
#define AUDIO_OBJECT_ELEMENT_MAIN kAudioObjectPropertyElementMain;
|
||||||
|
#else
|
||||||
|
#define AUDIO_OBJECT_ELEMENT_MAIN kAudioObjectPropertyElementMaster;
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <AudioUnit/AudioUnit.h>
|
#include <AudioUnit/AudioUnit.h>
|
||||||
#include <AudioToolbox/AudioConverter.h>
|
#include <AudioToolbox/AudioConverter.h>
|
||||||
#if COREAUDIO_MAC
|
#if COREAUDIO_MAC
|
||||||
|
@ -447,7 +453,7 @@ static pj_status_t ca_factory_refresh(pjmedia_aud_dev_factory *f)
|
||||||
/* Find out how many audio devices there are */
|
/* Find out how many audio devices there are */
|
||||||
addr.mSelector = kAudioHardwarePropertyDevices;
|
addr.mSelector = kAudioHardwarePropertyDevices;
|
||||||
addr.mScope = kAudioObjectPropertyScopeGlobal;
|
addr.mScope = kAudioObjectPropertyScopeGlobal;
|
||||||
addr.mElement = kAudioObjectPropertyElementMaster;
|
addr.mElement = AUDIO_OBJECT_ELEMENT_MAIN;
|
||||||
ostatus = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &addr,
|
ostatus = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &addr,
|
||||||
0, NULL, &dev_size);
|
0, NULL, &dev_size);
|
||||||
if (ostatus != noErr) {
|
if (ostatus != noErr) {
|
||||||
|
@ -492,7 +498,7 @@ static pj_status_t ca_factory_refresh(pjmedia_aud_dev_factory *f)
|
||||||
/* Find default audio input device */
|
/* Find default audio input device */
|
||||||
addr.mSelector = kAudioHardwarePropertyDefaultInputDevice;
|
addr.mSelector = kAudioHardwarePropertyDefaultInputDevice;
|
||||||
addr.mScope = kAudioObjectPropertyScopeGlobal;
|
addr.mScope = kAudioObjectPropertyScopeGlobal;
|
||||||
addr.mElement = kAudioObjectPropertyElementMaster;
|
addr.mElement = AUDIO_OBJECT_ELEMENT_MAIN;
|
||||||
size = sizeof(dev_id);
|
size = sizeof(dev_id);
|
||||||
|
|
||||||
ostatus = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
ostatus = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
||||||
|
@ -544,7 +550,7 @@ static pj_status_t ca_factory_refresh(pjmedia_aud_dev_factory *f)
|
||||||
/* Get device name */
|
/* Get device name */
|
||||||
addr.mSelector = kAudioDevicePropertyDeviceName;
|
addr.mSelector = kAudioDevicePropertyDeviceName;
|
||||||
addr.mScope = kAudioObjectPropertyScopeGlobal;
|
addr.mScope = kAudioObjectPropertyScopeGlobal;
|
||||||
addr.mElement = kAudioObjectPropertyElementMaster;
|
addr.mElement = AUDIO_OBJECT_ELEMENT_MAIN;
|
||||||
size = sizeof(cdi->info.name);
|
size = sizeof(cdi->info.name);
|
||||||
AudioObjectGetPropertyData(cdi->dev_id, &addr,
|
AudioObjectGetPropertyData(cdi->dev_id, &addr,
|
||||||
0, NULL,
|
0, NULL,
|
||||||
|
|
|
@ -313,23 +313,34 @@ static pj_status_t darwin_factory_refresh(pjmedia_vid_dev_factory *f)
|
||||||
if (NSClassFromString(@"AVCaptureSession")) {
|
if (NSClassFromString(@"AVCaptureSession")) {
|
||||||
NSArray *dev_list = NULL;
|
NSArray *dev_list = NULL;
|
||||||
|
|
||||||
#if (TARGET_OS_IPHONE && defined(__IPHONE_10_0)) || \
|
if (@available(macOS 10.15, iOS 10.0, *)) {
|
||||||
(TARGET_OS_OSX && defined(__MAC_10_15))
|
|
||||||
if (__builtin_available(macOS 10.15, iOS 10.0, *)) {
|
|
||||||
/* Starting in iOS 10 and macOS 10.15, [AVCaptureDevice devices]
|
/* Starting in iOS 10 and macOS 10.15, [AVCaptureDevice devices]
|
||||||
* is deprecated and replaced by AVCaptureDeviceDiscoverySession.
|
* is deprecated and replaced by AVCaptureDeviceDiscoverySession.
|
||||||
*/
|
*/
|
||||||
AVCaptureDeviceDiscoverySession *dds;
|
AVCaptureDeviceDiscoverySession *dds;
|
||||||
NSArray<AVCaptureDeviceType> *dev_types =
|
NSMutableArray<AVCaptureDeviceType> *dev_types =
|
||||||
@[AVCaptureDeviceTypeBuiltInWideAngleCamera
|
[NSMutableArray arrayWithCapacity:5];
|
||||||
#if TARGET_OS_OSX && defined(__MAC_10_15)
|
|
||||||
, AVCaptureDeviceTypeExternalUnknown
|
[dev_types addObject:AVCaptureDeviceTypeBuiltInWideAngleCamera];
|
||||||
#endif
|
|
||||||
#if TARGET_OS_IPHONE && defined(__IPHONE_10_0)
|
#if TARGET_OS_IPHONE && defined(__IPHONE_10_0)
|
||||||
, AVCaptureDeviceTypeBuiltInDuoCamera
|
// Deprecated in iOS 10.2
|
||||||
, AVCaptureDeviceTypeBuiltInTelephotoCamera
|
// AVCaptureDeviceTypeBuiltInDuoCamera
|
||||||
|
[dev_types addObject:AVCaptureDeviceTypeBuiltInTelephotoCamera];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (TARGET_OS_IPHONE && defined(__IPHONE_17_0)) || \
|
||||||
|
(TARGET_OS_OSX && defined(__MAC_14_0))
|
||||||
|
if (@available(macOS 14.0, iOS 17.0, *)) {
|
||||||
|
[dev_types addObject:AVCaptureDeviceTypeExternal];
|
||||||
|
} else {
|
||||||
|
# if (TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED < 140000)
|
||||||
|
[dev_types addObject:AVCaptureDeviceTypeExternalUnknown];
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif TARGET_OS_OSX
|
||||||
|
[dev_types addObject:AVCaptureDeviceTypeExternalUnknown];
|
||||||
#endif
|
#endif
|
||||||
];
|
|
||||||
|
|
||||||
dds = [AVCaptureDeviceDiscoverySession
|
dds = [AVCaptureDeviceDiscoverySession
|
||||||
discoverySessionWithDeviceTypes:dev_types
|
discoverySessionWithDeviceTypes:dev_types
|
||||||
|
@ -338,13 +349,11 @@ static pj_status_t darwin_factory_refresh(pjmedia_vid_dev_factory *f)
|
||||||
|
|
||||||
dev_list = [dds devices];
|
dev_list = [dds devices];
|
||||||
} else {
|
} else {
|
||||||
#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_15
|
#if (TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_15) || \
|
||||||
|
(TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0)
|
||||||
dev_list = [AVCaptureDevice devices];
|
dev_list = [AVCaptureDevice devices];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
dev_list = [AVCaptureDevice devices];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (AVCaptureDevice *device in dev_list) {
|
for (AVCaptureDevice *device in dev_list) {
|
||||||
if (![device hasMediaType:AVMediaTypeVideo] ||
|
if (![device hasMediaType:AVMediaTypeVideo] ||
|
||||||
|
@ -1040,6 +1049,32 @@ static pj_status_t darwin_stream_get_cap(pjmedia_vid_dev_stream *s,
|
||||||
return PJMEDIA_EVID_INVCAP;
|
return PJMEDIA_EVID_INVCAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static pj_bool_t set_orientation(struct darwin_stream *strm)
|
||||||
|
{
|
||||||
|
#if (TARGET_OS_OSX && __MAC_OS_X_VERSION_MIN_REQUIRED < 140000) || \
|
||||||
|
(TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < 170000)
|
||||||
|
|
||||||
|
const AVCaptureVideoOrientation cap_ori[4] =
|
||||||
|
{
|
||||||
|
AVCaptureVideoOrientationLandscapeLeft, /* NATURAL */
|
||||||
|
AVCaptureVideoOrientationPortrait, /* 90DEG */
|
||||||
|
AVCaptureVideoOrientationLandscapeRight, /* 180DEG */
|
||||||
|
AVCaptureVideoOrientationPortraitUpsideDown, /* 270DEG */
|
||||||
|
};
|
||||||
|
AVCaptureConnection *vidcon;
|
||||||
|
|
||||||
|
vidcon = [strm->video_output
|
||||||
|
connectionWithMediaType:AVMediaTypeVideo];
|
||||||
|
if ([vidcon isVideoOrientationSupported]) {
|
||||||
|
vidcon.videoOrientation = cap_ori[strm->param.orient-1];
|
||||||
|
return PJ_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return PJ_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* API: set capability */
|
/* API: set capability */
|
||||||
static pj_status_t darwin_stream_set_cap(pjmedia_vid_dev_stream *s,
|
static pj_status_t darwin_stream_set_cap(pjmedia_vid_dev_stream *s,
|
||||||
pjmedia_vid_dev_cap cap,
|
pjmedia_vid_dev_cap cap,
|
||||||
|
@ -1242,6 +1277,7 @@ static pj_status_t darwin_stream_set_cap(pjmedia_vid_dev_stream *s,
|
||||||
case PJMEDIA_VID_DEV_CAP_ORIENTATION:
|
case PJMEDIA_VID_DEV_CAP_ORIENTATION:
|
||||||
{
|
{
|
||||||
pjmedia_orient orient = *(pjmedia_orient *)pval;
|
pjmedia_orient orient = *(pjmedia_orient *)pval;
|
||||||
|
pj_bool_t support_ori = PJ_FALSE;
|
||||||
|
|
||||||
pj_assert(orient >= PJMEDIA_ORIENT_UNKNOWN &&
|
pj_assert(orient >= PJMEDIA_ORIENT_UNKNOWN &&
|
||||||
orient <= PJMEDIA_ORIENT_ROTATE_270DEG);
|
orient <= PJMEDIA_ORIENT_ROTATE_270DEG);
|
||||||
|
@ -1263,30 +1299,35 @@ static pj_status_t darwin_stream_set_cap(pjmedia_vid_dev_stream *s,
|
||||||
|
|
||||||
return PJ_SUCCESS;
|
return PJ_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AVCaptureVideoOrientation cap_ori[4] =
|
|
||||||
{
|
|
||||||
AVCaptureVideoOrientationLandscapeLeft, /* NATURAL */
|
|
||||||
AVCaptureVideoOrientationPortrait, /* 90DEG */
|
|
||||||
AVCaptureVideoOrientationLandscapeRight, /* 180DEG */
|
|
||||||
AVCaptureVideoOrientationPortraitUpsideDown, /* 270DEG */
|
|
||||||
};
|
|
||||||
AVCaptureConnection *vidcon;
|
|
||||||
pj_bool_t support_ori = PJ_TRUE;
|
|
||||||
|
|
||||||
pj_assert(strm->param.dir == PJMEDIA_DIR_CAPTURE);
|
pj_assert(strm->param.dir == PJMEDIA_DIR_CAPTURE);
|
||||||
|
|
||||||
if (!strm->video_output)
|
if (!strm->video_output)
|
||||||
return PJMEDIA_EVID_NOTREADY;
|
return PJMEDIA_EVID_NOTREADY;
|
||||||
|
|
||||||
vidcon = [strm->video_output
|
#if (TARGET_OS_IPHONE && defined(__IPHONE_17_0)) || \
|
||||||
connectionWithMediaType:AVMediaTypeVideo];
|
(TARGET_OS_OSX && defined(__MAC_14_0))
|
||||||
if ([vidcon isVideoOrientationSupported]) {
|
if (@available(macOS 14.0, iOS 17.0, *)) {
|
||||||
vidcon.videoOrientation = cap_ori[strm->param.orient-1];
|
|
||||||
|
const CGFloat cap_ori[4] = { 0, 90, 180, 270};
|
||||||
|
AVCaptureConnection *vidcon;
|
||||||
|
|
||||||
|
vidcon = [strm->video_output
|
||||||
|
connectionWithMediaType:AVMediaTypeVideo];
|
||||||
|
if ([vidcon isVideoRotationAngleSupported:
|
||||||
|
cap_ori[strm->param.orient-1]])
|
||||||
|
{
|
||||||
|
vidcon.videoRotationAngle = cap_ori[strm->param.orient-1];
|
||||||
|
support_ori = PJ_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
support_ori = PJ_FALSE;
|
support_ori = set_orientation(strm);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
support_ori = set_orientation(strm);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!strm->conv.conv) {
|
if (!strm->conv.conv) {
|
||||||
pj_status_t status;
|
pj_status_t status;
|
||||||
pjmedia_rect_size orig_size;
|
pjmedia_rect_size orig_size;
|
||||||
|
|
Loading…
Reference in New Issue