[ios] Fix two rtc_unittests that fail when using lld as linker
setExif: would create a CFDictionary using NULL for keyCallBacks and
valueCallBacks. This has the effect of comparing the keys of the
dictionary by pointer instead of by value. With ld64, this works
because it always dedupes identical constant CFSTR("foo") literal,
but lld currently doesn't do this.
Using kCFTypeDictionaryKeyCallBacks and kCFTypeDictionaryValueCallBacks
fixes the problem with lld and is "more correct" in general: Now the
dictionary would work with computed CFStrings too, it shows up better
in CFShow() output, etc.
While here, also fix a memory leak in setExif:.
Bug: chromium:1251763
Change-Id: I43c96d2189a4a77fe3bd0dfb3e33623925b0f900
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232760
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#35067}
This commit is contained in:
parent
4c8be521f1
commit
b3c9d3da8f
@ -20,6 +20,7 @@
|
||||
#import "components/capturer/RTCCameraVideoCapturer.h"
|
||||
#import "helpers/AVCaptureSession+DevicePosition.h"
|
||||
#import "helpers/RTCDispatcher.h"
|
||||
#import "helpers/scoped_cftyperef.h"
|
||||
|
||||
#if TARGET_OS_IPHONE
|
||||
// Helper method.
|
||||
@ -281,9 +282,10 @@ CMSampleBufferRef createTestSampleBufferRef() {
|
||||
}
|
||||
|
||||
- (void)setExif:(CMSampleBufferRef)sampleBuffer {
|
||||
CFMutableDictionaryRef exif = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, NULL, NULL);
|
||||
CFDictionarySetValue(exif, CFSTR("LensModel"), CFSTR("iPhone SE back camera 4.15mm f/2.2"));
|
||||
CMSetAttachment(sampleBuffer, CFSTR("{Exif}"), exif, kCMAttachmentMode_ShouldPropagate);
|
||||
rtc::ScopedCFTypeRef<CFMutableDictionaryRef> exif(CFDictionaryCreateMutable(
|
||||
kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
|
||||
CFDictionarySetValue(exif.get(), CFSTR("LensModel"), CFSTR("iPhone SE back camera 4.15mm f/2.2"));
|
||||
CMSetAttachment(sampleBuffer, CFSTR("{Exif}"), exif.get(), kCMAttachmentMode_ShouldPropagate);
|
||||
}
|
||||
|
||||
- (void)testRotationFrame {
|
||||
@ -307,8 +309,8 @@ CMSampleBufferRef createTestSampleBufferRef() {
|
||||
[[self.delegateMock expect] capturer:self.capturer
|
||||
didCaptureVideoFrame:[OCMArg checkWithBlock:^BOOL(RTC_OBJC_TYPE(RTCVideoFrame) *
|
||||
expectedFrame) {
|
||||
// Front camera and landscape left should return 180. But the frame says its
|
||||
// from the back camera, so rotation should be 0.
|
||||
// Front camera and landscape left should return 180. But the frame's exif
|
||||
// we add below says its from the back camera, so rotation should be 0.
|
||||
EXPECT_EQ(expectedFrame.rotation, RTCVideoRotation_0);
|
||||
return YES;
|
||||
}]];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user