diff --git a/R5ProTestbed.xcodeproj/project.pbxproj b/R5ProTestbed.xcodeproj/project.pbxproj index 17d2947..5041e64 100644 --- a/R5ProTestbed.xcodeproj/project.pbxproj +++ b/R5ProTestbed.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 487CDBC21E6E4401007FC4EA /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 487CDBC11E6E4401007FC4EA /* libz.tbd */; }; 487CDBC41E6F1A39007FC4EA /* SharedObjectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 487CDBC31E6F1A39007FC4EA /* SharedObjectTest.swift */; }; 48A7171B210A275C007C4AF7 /* PublishStreamManagerTranscodeTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48A7171A210A275C007C4AF7 /* PublishStreamManagerTranscodeTest.swift */; }; + 48B79AE820C6E94E00AAE4E2 /* PublishZoomableTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48B79AE720C6E94E00AAE4E2 /* PublishZoomableTest.swift */; }; 48BB1D811CED140D00D915E5 /* SubscribeSetSizeTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48BB1D801CED140D00D915E5 /* SubscribeSetSizeTest.swift */; }; 48BF80AE1C245AA7000E996E /* PublishOrientationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48BF80AD1C245AA7000E996E /* PublishOrientationTest.swift */; }; 48BF80B11C245D29000E996E /* Info-100.png in Resources */ = {isa = PBXBuildFile; fileRef = 48BF80B01C245D29000E996E /* Info-100.png */; }; @@ -100,6 +101,7 @@ 487CDBC11E6E4401007FC4EA /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; }; 487CDBC31E6F1A39007FC4EA /* SharedObjectTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SharedObjectTest.swift; path = Tests/SharedObject/SharedObjectTest.swift; sourceTree = ""; }; 48A7171A210A275C007C4AF7 /* PublishStreamManagerTranscodeTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PublishStreamManagerTranscodeTest.swift; path = Tests/PublishStreamManagerTranscode/PublishStreamManagerTranscodeTest.swift; sourceTree = ""; }; + 48B79AE720C6E94E00AAE4E2 /* PublishZoomableTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PublishZoomableTest.swift; path = Tests/PublishZoomable/PublishZoomableTest.swift; sourceTree = ""; }; 48BB1D801CED140D00D915E5 /* SubscribeSetSizeTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SubscribeSetSizeTest.swift; sourceTree = ""; }; 48BF80AD1C245AA7000E996E /* PublishOrientationTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PublishOrientationTest.swift; path = Tests/PublishOrientation/PublishOrientationTest.swift; sourceTree = ""; }; 48BF80B01C245D29000E996E /* Info-100.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Info-100.png"; sourceTree = ""; }; @@ -260,6 +262,7 @@ 485345061C23528400D409F3 /* PublishStreamImageTest.swift */, 926794F41D061900004B0BCD /* PublishRemoteCallTest.swift */, 926794F61D06191E004B0BCD /* PublishStreamManagerTest.swift */, + 48B79AE720C6E94E00AAE4E2 /* PublishZoomableTest.swift */, 48A7171A210A275C007C4AF7 /* PublishStreamManagerTranscodeTest.swift */, 487CDBC31E6F1A39007FC4EA /* SharedObjectTest.swift */, 4874D59C1C2216DB00A98102 /* SubscribeTest.swift */, @@ -397,6 +400,7 @@ 480A8794221EA8A500474724 /* PublishTelephonyInterruptTest.swift in Sources */, 4874D59F1C221B9500A98102 /* AdaptiveBitrateControllerTest.swift in Sources */, 48DFEDAC1C21BBC60040B624 /* AppDelegate.swift in Sources */, + 48B79AE820C6E94E00AAE4E2 /* PublishZoomableTest.swift in Sources */, 48DFEDDF1C21EA780040B624 /* Testbed.swift in Sources */, 487C888F1F2F8AB2004157B6 /* PublishHQAudioTest.swift in Sources */, 48BF80AE1C245AA7000E996E /* PublishOrientationTest.swift in Sources */, diff --git a/R5ProTestbed/Info.plist b/R5ProTestbed/Info.plist index 799c56b..b4f704a 100644 --- a/R5ProTestbed/Info.plist +++ b/R5ProTestbed/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 4.4.0 + 5.5.0 CFBundleSignature ???? CFBundleVersion - 1 + 2 LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/R5ProTestbed/Tests/PublishZoomable/PublishZoomableTest.swift b/R5ProTestbed/Tests/PublishZoomable/PublishZoomableTest.swift new file mode 100644 index 0000000..18130ad --- /dev/null +++ b/R5ProTestbed/Tests/PublishZoomable/PublishZoomableTest.swift @@ -0,0 +1,90 @@ +// +// PublishZoomableTest.swift +// R5ProTestbed +// +// Created by Todd Anderson on 12/16/15. +// Copyright © 2018 Infrared5. All rights reserved. +// + +import UIKit +import R5Streaming + +@objc(PublishZoomableTest) +class PublishZoomableTest: BaseTest { + + var cam : AVCaptureDevice? = nil; + var slider : UISlider? = nil; + + override func viewDidAppear(_ animated: Bool) { + + super.viewDidAppear(animated) + + AVAudioSession.sharedInstance().requestRecordPermission { (gotPerm: Bool) -> Void in + + }; + + setupDefaultR5VideoViewController() + + // Set up the configuration + let config = getConfig() + // Set up the connection and stream + let connection = R5Connection(config: config) + + setupPublisher(connection: connection!) + cam = (self.publishStream?.getVideoSource() as! R5Camera).device + + // show preview and debug info + // self.publishStream?.getVideoSource().fps = 2; + self.currentView!.attach(publishStream!) + + self.publishStream!.publish(Testbed.getParameter(param: "stream1") as! String, type: getPublishRecordType ()) + + let screenSize = UIScreen.main.bounds.size + + slider = UISlider(frame: CGRect(x:90, y:UIScreen.main.bounds.height - 30, width:screenSize.width - 180, height:20)) + slider?.minimumValue = 1 + slider?.maximumValue = 5 + slider?.isContinuous = true + slider?.tintColor = UIColor.red + slider?.value = 1 + slider?.isEnabled = false +// slider?.addTarget(self, action: #selector(PublishZoomableTest.sliderValueDidChange(sender:)), for: .valueChanged) + self.view.addSubview(slider!) + + let downBtn = UIButton(frame: CGRect(x: 20, y: screenSize.height - 40, width: 50, height: 34)) + downBtn.backgroundColor = UIColor.darkGray + downBtn.setTitle("-", for: UIControl.State.normal) + view.addSubview(downBtn) + let tap = UITapGestureRecognizer(target: self, action: #selector(onZoomOut)) + downBtn.addGestureRecognizer(tap) + + let upBtn = UIButton(frame: CGRect(x: screenSize.width - 70, y: screenSize.height - 40, width: 50, height: 34)) + upBtn.backgroundColor = UIColor.darkGray + upBtn.setTitle("+", for: UIControl.State.normal) + view.addSubview(upBtn) + let tapIn = UITapGestureRecognizer(target: self, action: #selector(onZoomIn)) + upBtn.addGestureRecognizer(tapIn) + + } + + @objc func onZoomOut () { + let v = (slider?.value)! - 0.5 < 1 ? 1 : (slider?.value)! - 0.5 + updateSliderValue(value: v) + } + + @objc func onZoomIn () { + let v = (slider?.value)! + 0.5 > 5 ? 5 : (slider?.value)! + 0.5 + updateSliderValue(value: v) + } + + func updateSliderValue(value: Float!) { + do { + try cam!.lockForConfiguration() + cam!.ramp(toVideoZoomFactor: CGFloat(value), withRate: 1.0) + cam!.unlockForConfiguration() + slider?.setValue(value, animated: true) + } catch { + // + } + } +} diff --git a/R5ProTestbed/Tests/PublishZoomable/README.md b/R5ProTestbed/Tests/PublishZoomable/README.md new file mode 100644 index 0000000..327ee92 --- /dev/null +++ b/R5ProTestbed/Tests/PublishZoomable/README.md @@ -0,0 +1,17 @@ +# Publishing with live zoom + +This example demonstrates the ability to zoom the camera during a live broadcast. + +## Example Code +- ***[BaseTest.swift](../BaseTest.swift)*** +- ***[PublishZoomableTest.swift](PublishZoomableTest.swift)*** + + +# How to zoom + +1. Access the `AVCaptureDevice` used in capturing the Camera. +2. Utilize the `ramp` API of `AVCaptureDevice` to assign an animated target zoom value. + +# Using the example + +A `UISlider` is used to allow users to define the zoom level of the Camera during a live broadcast. Any subscribers will see the zoom in of the Camera live. \ No newline at end of file diff --git a/R5ProTestbed/tests.plist b/R5ProTestbed/tests.plist index 603891f..4e3d86f 100644 --- a/R5ProTestbed/tests.plist +++ b/R5ProTestbed/tests.plist @@ -309,6 +309,17 @@ class PublishSendTest + publish - Zoomable + + description + A publish example that allows live zoom + LocalProperties + + name + Publish - Zoom + class + PublishZoomableTest + Shared Object description