BlueJeans iOS Video SDK - Deprecated
Note: This version of iOS SDK is now deprecated. BlueJeans does not recommend to use this version going forward.
Release Announcement
BlueJeans has released new & updated iOS Client SDK for your integration needs in iOS App. Learn more. It's recommended to migrate to latest version of iOS Client SDK at the earliest.
Overview
The BlueJeans iOS Video Software Development Kit (SDK) enables embedding BlueJeans Video and Audio capabilities into iOS apps. BJNVideo
is a single object that encapsulates all the API’s related to establishing a BlueJeans Video and Audio connection.
The design of the SDK emphasizes simplicity. Developers can quickly integrate BlueJeans video into their applications.
Requirements
This framework requires Swift 5 and Xcode 10.2.1. Swift 5 is ABI stable and thus this framework should also be able to be used with later versions of Swift.
Target deployment requires a minimum of iOS version 10.0.
There are additional software dependencies on frameworks as mentioned in the Dependencies section. All dependent frameworks are included as part of the frameworks bundle.
Installation
Manual
Steps:
- Download
BJNVideoSDK.zip
from here. - Unzip the file and copy
BJNVideoSDK
folder to the root folder where Xcode project(xxxx.xcodeproj file) is located. - Open the Xcode project, click on the project build settings and select the App target -> General Tab.
- Scroll to Embedded Binaries section of Xcode target.
- Select all frameworks found in
BJNVideoSDK/Frameworks
folder. - Drag and drop all frameworks present in
BJNVideoSDK/Frameworks
folder to this section. Make sure the project settings looks like below image after adding it.
Carthage
Add this to your Cartfile:
binary "https://swdl.bluejeans.com/bjnvideosdk/ios/BJNVideoSDK.json" ~> 0.14.0
Then follow the Carthage instructions to add the framework to your application.
Cocoapods
Add this to your Podfile:
pod 'BJNVideoSDK', '~>0.14.0'
Then follow the Cocoapods instructions to add the framework to your application.
Setup
Bitcode Support
BlueJeans’ BJNVideo
SDK cannot support bitcode. To integrate this SDK into your application, you may have to disable bitcode for the target.
To disable bitcode:
- Go to Build Settings tab of Xcode application target in Xcode project settings.
- Search for
Enable Bitcode
- Change the value to
No
User Permissions
In iOS, the user must explicitly grant app permission to access device cameras or microphones for video, or audio capture. Your app must provide an explanation for its use of these capture devices.
Open your application’s Info.plist
and provide a short explanation for both of these Info.plist
keys:
- NSCameraUsageDescription (Privacy - Camera Usage Description)
- NSMicrophoneUsageDescription (Privacy - Microphone Usage Description)
iOS displays this explanation when initially asking the user for permission, and thereafter in the Settings app. Check Apple documentation for more details.
Objective C Project
BJNVideo
SDK is a Swift framework. If you are planning to use it on an Objective C project, make sure you have set Always Embed Swift Standard Libraries
to Yes
for your application target in Xcode project’s Build Settings tab.
Using the SDK
The work needed to add the BlueJeans functionality into your application code is outlined here. Briefly, you will do these steps:
- Include the BlueJeans
BJNVideo
module, and initialize - Create video container(s) for the Remote view, Self view, and if desired Content Share view
- Make the API call to Join the BlueJeans Meeting, and when finished
- Make the API call to Leave the BlueJeans Meeting
There! That is the extent of the work you need to do to make your application join its first BlueJeans meeting.
Include Module
Swift:
import BJNVideo
Objective C:
@import BJNVideo;
or
#import <BJNVideo/BJNVideo.h>
Intialize
BJNVideo
can be initialized as,
Swift:
let video = BJNVideo()
Objective C:
@property (nonatomic, strong) BJNVideo *video;
self.video = [[BJNVideo alloc] init];
Note: Only one instance of BJNVideo
can be present in app at a time. Creating multiple instances may cause unexpected errors. So this can also be initialized in Swift as static let video = BJNVideo()
to avoid this issue.
Join Meeting
Connect to a Video/Audio meeting,
Swift:
video.join(meetingID: "111111111", passcode: "1111", displayName: "John Doe", onSuccess: {
print("Join meeting: Success")
}, onFailure: {})
Objective C:
[self.video joinWithMeetingID:@"111111111" passcode:@"1111" displayName:@"John Doe" onSuccess:^{
NSLog(@"Join meeting success");
} onFailure:^{}];
Leave Meeting
Disconnect from the meeting,
Swift:
video.leave()
Objective C:
[self.video leave];
Remote/Self/Content Video View
Remote/Self/Content Video view can be added to your view controller as follows.
- Create a container view(say
videoContainer
) in Stroyboard/XIB - Set AutoLayout constraints for
videoContainer
view. - Connect the view to this
videoContainer
property in view controller class - Add the following code in view controller’s
viewDidLoad
method.
Swift:
guard let videoView = video.getRemoteVideoInstance() else { return }
videoContainer.addSubview(videoView)
//Set constraints programatically for top, bottom, left and right anchors
videoView.translatesAutoresizingMaskIntoConstraints = false
videoView.leftAnchor.constraint(equalTo: videoContainer.leftAnchor).isActive = true
videoView.rightAnchor.constraint(equalTo: videoContainer.rightAnchor).isActive = true
videoView.topAnchor.constraint(equalTo: videoContainer.topAnchor).isActive = true
videoView.bottomAnchor.constraint(equalTo: videoContainer.bottomAnchor).isActive = true
Objective C:
UIView *videoView = [self.video getRemoteVideoInstance];
if (!videoView) { return; }
[self.videoContainer addSubview:videoView];
//Set constraints programatically for top, bottom, left and right anchors
videoView.translatesAutoresizingMaskIntoConstraints = false;
[[videoView.leftAnchor constraintEqualToAnchor:self.videoContainer.leftAnchor] setActive:true];
[[videoView.rightAnchor constraintEqualToAnchor:self.videoContainer.rightAnchor] setActive:true];
[[videoView.topAnchor constraintEqualToAnchor:self.videoContainer.topAnchor] setActive:true];
[[videoView.bottomAnchor constraintEqualToAnchor:self.videoContainer.bottomAnchor] setActive:true];
Similar code can be used with getSelfViewInstance
and getContentShareInstance
in place of getRemoteVideoInstance
to add it to corresponding container views.
Self Video View Rotation
Self Video view can be added to your view as mentioned in above section. Note that the Self Video view will rotate based on the orientation of the device. The width/height ratio will be inverted when orientation changes. If you would like to crop the Video to a fixed height/width, make sure you have added Self Video view to a container view and set clipsToBounds
property of container view to true
. See below code for details.
Swift:
selfViewContainer.addSubview(selfVideoPreviewView)
selfViewContainer.clipsToBounds = true
selfViewContainer.backgroundColor = .black
Objective C:
[self.selfViewContainer addSubview:selfVideoPreviewView];
self.selfViewContainer.clipsToBounds = true;
self.selfViewContainer.backgroundColor = [UIColor blackColor];
Observing Properties and Updating Values
Observing or modifying BlueJeans Meeting attributes is accomplished through observable properties that are provided in the BJNVideo
instance.
For mutable types, the value can be set as shown here.
Swift:
video.videoMuted.value = true
Your application can be notified and respond to a value change using the following
Swift:
video.videoMuted.onChange {
print("video muted status changed to ", video.videoMuted.value)
}
In Objective C, the value can be set using the following statements
Objective C:
self.video.videoMuted = true;
and observed by subscribing and implementing BJNEventDelegate
methods.
Objective C:
self.video.delegate = self;
#pragma mark : BJNEventDelegate methods
- (void)didMuteVideo {
NSLog(@"videoMuted value changed");
}
Logging
Set log level,
Swift:
video.loggingMode.value = .warning
Objective C:
self.video.loggingMode = LoggingModeWarning;
BJNVideo
uses CocoaLumberjack
and will respect log levels set at the app level.
Important Notes
Background Modes
If you need to support Audio after app moves to background, you need to enable Background Modes -> Audio capability.
- Open Xcode project settings
- Go to Capabilities tab(next to General tab)
- Scroll down to Background Modes section.
- Toggle the switch to ON position for Background Modes.
- Select checkbox with title Audio, AirPlay, and Picture in Picture.
Note: Without this if you join a meeting -> background the app -> foreground it after sometime, the audio will be lost and it will show an error in console as: "Audio, Airplay and Picture in Picture" background mode missing from app capabilities.
Video support in Background
Note that BJNVideo
does not support Video in Background mode. App needs to be in foreground to use the Video capability. Once the app is backgrounded, video streaming will be stopped until user foregrounds the app.
iTunes Connect Error
If you have manually integrated the frameworks, you may get an error while trying to upload your iOS app to iTunes Connect. Since these are dynamic frameworks, it contains simulator archs which causes this behavior. Use the script strip-frameworks.sh
provided in BJNVideo.framework
as follows:
- Open Xcode project and select the app target in build settings.
- Go to Build Phases tab and Click on + (Add a new build phase) button inside the tab on top left.
- Click on New Run Script Phase and make sure it is added after Embed Frameworks section in this tab.
- Add the following command below shell (bin/sh) section. You can modify the path depending on the copied frameworks location in your project’s folder. Otherwise it will throw an error while building the app.
sh ./BJNVideoSDK/Scripts/strip-frameworks.sh
iOS Simulators
Video/Audio capability of BJNVideo
SDK would only work in an iOS Device since iOS Simulator cannot support Camera/Microphone. Hence you may not be able to use iOS Simulators for integrating and testing BJNVideo
SDK features.
Dependencies
Some of the external framework dependencies are:
- CocoaLumberjack - tag: 3.1.0 - Copyright © 2010-2016, Deusty, LLC : BSD
- Swinject - tag: 2.1.0 - Copyright © 2015 Swinject Contributors : MIT
- SWXMLHash - tag: 4.2.3 - Copyright © 2014 David Mohundro : MIT
- facebook/SocketRocket - master - Copyright © 2016-present, Facebook, Inc : BSD
- tonymillion/Reachability - master - Copyright © 2011-2013, Tony Million : BSD-2
License
Copyright © 2019 BlueJeans Network. Refer to LICENSE.txt and LICENSE-3RD-PARTY.txt.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.