Skip to content

Commit

Permalink
Merge pull request #165 from red5pro/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Jessica Palmer authored May 21, 2019
2 parents 2110643 + 5602f67 commit 88b95bf
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 2 deletions.
4 changes: 4 additions & 0 deletions R5ProTestbed.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 = "<group>"; };
48A7171A210A275C007C4AF7 /* PublishStreamManagerTranscodeTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PublishStreamManagerTranscodeTest.swift; path = Tests/PublishStreamManagerTranscode/PublishStreamManagerTranscodeTest.swift; sourceTree = "<group>"; };
48B79AE720C6E94E00AAE4E2 /* PublishZoomableTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PublishZoomableTest.swift; path = Tests/PublishZoomable/PublishZoomableTest.swift; sourceTree = "<group>"; };
48BB1D801CED140D00D915E5 /* SubscribeSetSizeTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SubscribeSetSizeTest.swift; sourceTree = "<group>"; };
48BF80AD1C245AA7000E996E /* PublishOrientationTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PublishOrientationTest.swift; path = Tests/PublishOrientation/PublishOrientationTest.swift; sourceTree = "<group>"; };
48BF80B01C245D29000E996E /* Info-100.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Info-100.png"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
4 changes: 2 additions & 2 deletions R5ProTestbed/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>4.4.0</string>
<string>5.5.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<string>2</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
Expand Down
90 changes: 90 additions & 0 deletions R5ProTestbed/Tests/PublishZoomable/PublishZoomableTest.swift
Original file line number Diff line number Diff line change
@@ -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 {
//
}
}
}
17 changes: 17 additions & 0 deletions R5ProTestbed/Tests/PublishZoomable/README.md
Original file line number Diff line number Diff line change
@@ -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.
11 changes: 11 additions & 0 deletions R5ProTestbed/tests.plist
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,17 @@
<key>class</key>
<string>PublishSendTest</string>
</dict>
<key>publish - Zoomable</key>
<dict>
<key>description</key>
<string>A publish example that allows live zoom</string>
<key>LocalProperties</key>
<dict/>
<key>name</key>
<string>Publish - Zoom</string>
<key>class</key>
<string>PublishZoomableTest</string>
</dict>
<key>Shared Object</key>
<dict>
<key>description</key>
Expand Down

0 comments on commit 88b95bf

Please sign in to comment.