[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}
diff --git a/sdk/objc/unittests/RTCCameraVideoCapturerTests.mm b/sdk/objc/unittests/RTCCameraVideoCapturerTests.mm
index 34551e5..1d47846 100644
--- a/sdk/objc/unittests/RTCCameraVideoCapturerTests.mm
+++ b/sdk/objc/unittests/RTCCameraVideoCapturerTests.mm
@@ -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 @@
 }
 
 - (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 @@
   [[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;
                   }]];