Support compiling with the lastest iOS SDK.
Bug: None Change-Id: I2bc4b4f3eba9c5f6b3a94fce076dc575c5be057d Reviewed-on: https://webrtc-review.googlesource.com/90720 Reviewed-by: Peter Hanspers <peterhanspers@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Kári Helgason <kthelgason@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24163}
This commit is contained in:
committed by
Commit Bot
parent
55bf92adf4
commit
9014324bb1
2
BUILD.gn
2
BUILD.gn
@ -457,7 +457,7 @@ if (rtc_include_tests) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (is_ios || is_mac) {
|
if (is_ios || is_mac) {
|
||||||
deps += [ "sdk:sdk_unittests_objc" ]
|
deps += [ "sdk:rtc_unittests_objc" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -862,7 +862,7 @@ if (is_ios || is_mac) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# TODO(denicija): once all tests are migrated to xctest remove this source set.
|
# TODO(denicija): once all tests are migrated to xctest remove this source set.
|
||||||
rtc_source_set("sdk_unittests_objc") {
|
rtc_source_set("rtc_unittests_objc") {
|
||||||
testonly = true
|
testonly = true
|
||||||
|
|
||||||
sources = [
|
sources = [
|
||||||
|
|||||||
@ -92,6 +92,10 @@
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (MTKView *)createMetalView:(CGRect)frame {
|
||||||
|
return [[MTKViewClass alloc] initWithFrame:frame];
|
||||||
|
}
|
||||||
|
|
||||||
+ (RTCMTLNV12Renderer *)createNV12Renderer {
|
+ (RTCMTLNV12Renderer *)createNV12Renderer {
|
||||||
return [[RTCMTLNV12RendererClass alloc] init];
|
return [[RTCMTLNV12RendererClass alloc] init];
|
||||||
}
|
}
|
||||||
@ -107,7 +111,7 @@
|
|||||||
- (void)configure {
|
- (void)configure {
|
||||||
NSAssert([RTCMTLVideoView isMetalAvailable], @"Metal not availiable on this device");
|
NSAssert([RTCMTLVideoView isMetalAvailable], @"Metal not availiable on this device");
|
||||||
|
|
||||||
self.metalView = [[MTKViewClass alloc] initWithFrame:self.bounds];
|
self.metalView = [RTCMTLVideoView createMetalView:self.bounds];
|
||||||
self.metalView.delegate = self;
|
self.metalView.delegate = self;
|
||||||
self.metalView.contentMode = UIViewContentModeScaleAspectFill;
|
self.metalView.contentMode = UIViewContentModeScaleAspectFill;
|
||||||
[self addSubview:self.metalView];
|
[self addSubview:self.metalView];
|
||||||
@ -194,12 +198,9 @@
|
|||||||
- (RTCVideoRotation)frameRotation {
|
- (RTCVideoRotation)frameRotation {
|
||||||
if (self.rotationOverride) {
|
if (self.rotationOverride) {
|
||||||
RTCVideoRotation rotation;
|
RTCVideoRotation rotation;
|
||||||
#if defined(__IPHONE_11_0) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_11_0)
|
|
||||||
if (@available(iOS 11, *)) {
|
if (@available(iOS 11, *)) {
|
||||||
[self.rotationOverride getValue:&rotation size:sizeof(rotation)];
|
[self.rotationOverride getValue:&rotation size:sizeof(rotation)];
|
||||||
} else
|
} else {
|
||||||
#endif
|
|
||||||
{
|
|
||||||
[self.rotationOverride getValue:&rotation];
|
[self.rotationOverride getValue:&rotation];
|
||||||
}
|
}
|
||||||
return rotation;
|
return rotation;
|
||||||
|
|||||||
@ -194,13 +194,7 @@ CMSampleBufferRef createTestSampleBufferRef() {
|
|||||||
|
|
||||||
- (void)testDelegateCallbackWithValidBufferAndOrientationUpdate {
|
- (void)testDelegateCallbackWithValidBufferAndOrientationUpdate {
|
||||||
#if TARGET_OS_IPHONE
|
#if TARGET_OS_IPHONE
|
||||||
// given
|
[UIDevice.currentDevice setValue:@(UIDeviceOrientationPortraitUpsideDown) forKey:@"orientation"];
|
||||||
UIDevice *currentDeviceMock = OCMClassMock([UIDevice class]);
|
|
||||||
// UpsideDown -> RTCVideoRotation_270.
|
|
||||||
OCMStub(currentDeviceMock.orientation).andReturn(UIDeviceOrientationPortraitUpsideDown);
|
|
||||||
id classMock = OCMClassMock([UIDevice class]);
|
|
||||||
OCMStub([classMock currentDevice]).andReturn(currentDeviceMock);
|
|
||||||
|
|
||||||
CMSampleBufferRef sampleBuffer = createTestSampleBufferRef();
|
CMSampleBufferRef sampleBuffer = createTestSampleBufferRef();
|
||||||
|
|
||||||
// then
|
// then
|
||||||
@ -222,11 +216,6 @@ CMSampleBufferRef createTestSampleBufferRef() {
|
|||||||
fromConnection:self.captureConnectionMock];
|
fromConnection:self.captureConnectionMock];
|
||||||
|
|
||||||
[self.delegateMock verify];
|
[self.delegateMock verify];
|
||||||
|
|
||||||
[(id)currentDeviceMock stopMocking];
|
|
||||||
currentDeviceMock = nil;
|
|
||||||
[classMock stopMocking];
|
|
||||||
classMock = nil;
|
|
||||||
CFRelease(sampleBuffer);
|
CFRelease(sampleBuffer);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -246,11 +235,7 @@ CMSampleBufferRef createTestSampleBufferRef() {
|
|||||||
OCMStub(inputPortMock.device).andReturn(captureDeviceMock);
|
OCMStub(inputPortMock.device).andReturn(captureDeviceMock);
|
||||||
OCMStub(captureDeviceMock.position).andReturn(camera);
|
OCMStub(captureDeviceMock.position).andReturn(camera);
|
||||||
|
|
||||||
// UpsideDown -> RTCVideoRotation_0.
|
[UIDevice.currentDevice setValue:@(deviceOrientation) forKey:@"orientation"];
|
||||||
UIDevice *currentDeviceMock = OCMClassMock([UIDevice class]);
|
|
||||||
OCMStub(currentDeviceMock.orientation).andReturn(deviceOrientation);
|
|
||||||
id classMock = OCMClassMock([UIDevice class]);
|
|
||||||
OCMStub([classMock currentDevice]).andReturn(currentDeviceMock);
|
|
||||||
|
|
||||||
CMSampleBufferRef sampleBuffer = createTestSampleBufferRef();
|
CMSampleBufferRef sampleBuffer = createTestSampleBufferRef();
|
||||||
|
|
||||||
@ -284,10 +269,6 @@ CMSampleBufferRef createTestSampleBufferRef() {
|
|||||||
|
|
||||||
[self.delegateMock verify];
|
[self.delegateMock verify];
|
||||||
|
|
||||||
[(id)currentDeviceMock stopMocking];
|
|
||||||
currentDeviceMock = nil;
|
|
||||||
[classMock stopMocking];
|
|
||||||
classMock = nil;
|
|
||||||
CFRelease(sampleBuffer);
|
CFRelease(sampleBuffer);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -312,11 +293,7 @@ CMSampleBufferRef createTestSampleBufferRef() {
|
|||||||
OCMStub(inputPortMock.device).andReturn(captureDeviceMock);
|
OCMStub(inputPortMock.device).andReturn(captureDeviceMock);
|
||||||
OCMStub(captureDeviceMock.position).andReturn(AVCaptureDevicePositionFront);
|
OCMStub(captureDeviceMock.position).andReturn(AVCaptureDevicePositionFront);
|
||||||
|
|
||||||
// UpsideDown -> RTCVideoRotation_0.
|
[UIDevice.currentDevice setValue:@(UIDeviceOrientationLandscapeLeft) forKey:@"orientation"];
|
||||||
UIDevice *currentDeviceMock = OCMClassMock([UIDevice class]);
|
|
||||||
OCMStub(currentDeviceMock.orientation).andReturn(UIDeviceOrientationLandscapeLeft);
|
|
||||||
id classMock = OCMClassMock([UIDevice class]);
|
|
||||||
OCMStub([classMock currentDevice]).andReturn(currentDeviceMock);
|
|
||||||
|
|
||||||
CMSampleBufferRef sampleBuffer = createTestSampleBufferRef();
|
CMSampleBufferRef sampleBuffer = createTestSampleBufferRef();
|
||||||
|
|
||||||
@ -341,11 +318,6 @@ CMSampleBufferRef createTestSampleBufferRef() {
|
|||||||
fromConnection:self.captureConnectionMock];
|
fromConnection:self.captureConnectionMock];
|
||||||
|
|
||||||
[self.delegateMock verify];
|
[self.delegateMock verify];
|
||||||
|
|
||||||
[(id)currentDeviceMock stopMocking];
|
|
||||||
currentDeviceMock = nil;
|
|
||||||
[classMock stopMocking];
|
|
||||||
classMock = nil;
|
|
||||||
CFRelease(sampleBuffer);
|
CFRelease(sampleBuffer);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,10 +74,9 @@
|
|||||||
return frameMock;
|
return frameMock;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)rendererMockWithSuccessfulSetup:(BOOL)sucess {
|
- (id)rendererMockWithSuccessfulSetup:(BOOL)success {
|
||||||
id rendererMock = OCMProtocolMock(@protocol(RTCMTLRenderer));
|
id rendererMock = OCMClassMock([RTCMTLRenderer class]);
|
||||||
OCMStub([rendererMock addRenderingDestination:[OCMArg any]]).andReturn(sucess);
|
OCMStub([rendererMock addRenderingDestination:[OCMArg any]]).andReturn(success);
|
||||||
|
|
||||||
return rendererMock;
|
return rendererMock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user