Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it compatible with Web Conferencing Sample #37

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ScreenShare/ScreenShare.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.antmedia.ios.sdk</string>
<string>group.io.antmedia.ios.webrtc.sample</string>
</array>
</dict>
</plist>
82 changes: 15 additions & 67 deletions WebRTC-Sample-App/ConferenceViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ open class ConferenceViewController: UIViewController , AVCaptureVideoDataOutput
//keeps which remoteView renders which track according to the index
var remoteViewTrackMap: [RTCVideoTrack?] = [];

var publishStream:Bool = false;

var conferenceClient: AntMediaClient?;
var playing = false

func generateRandomAlphanumericString(length: Int) -> String {
let characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
return String((0..<length).map{ _ in characters.randomElement()! })
}

func initRenderer(view: UIView)
{
#if arch(arm64)
Expand Down Expand Up @@ -71,15 +73,20 @@ open class ConferenceViewController: UIViewController , AVCaptureVideoDataOutput
self.conferenceClient?.delegate = self
self.conferenceClient?.setWebSocketServerUrl(url: self.clientUrl)
self.conferenceClient?.setLocalView(container: self.localView)
self.conferenceClient?.joinRoom(roomId: roomId)

//this publishes stream to the room
self.publisherStreamId = generateRandomAlphanumericString(length: 10);
self.conferenceClient?.publish(streamId: self.publisherStreamId, token: "", mainTrackId: roomId);

//this plays the streams in the room
self.conferenceClient?.play(streamId: self.roomId);
}

open override func viewWillDisappear(_ animated: Bool) {
self.conferenceClient?.leaveFromRoom()
}

public func removePlayers() {
self.playing = false;
Run.onMainThread { [self] in
var i = 0;

Expand All @@ -101,56 +108,17 @@ open class ConferenceViewController: UIViewController , AVCaptureVideoDataOutput

extension ConferenceViewController: AntMediaClientDelegate
{
public func clientDidDisconnect(_ message: String) {

removePlayers();

}

public func clientHasError(_ message: String) {

}

public func streamIdToPublish(streamId: String) {

Run.onMainThread {

AntMediaClient.printf("stream id to publish \(streamId)")
self.publisherStreamId = streamId;

//if you can mute and close the camera, you can do that here
//self.conferenceClient?.setAudioTrack(enableTrack: false)
//self.conferenceClient?.setVideoTrack(enableTrack: false)


self.conferenceClient?.publish(streamId: self.publisherStreamId)
}
public func dataReceivedFromDataChannel(streamId: String, data: Data, binary: Bool) {

}

public func newStreamsJoined(streams: [String]) {
for stream in streams {
AntMediaClient.printf("New stream in the room: \(stream)")
}

Run.onMainThread {
if (!self.playing) {
self.playing = true;
self.conferenceClient?.play(streamId: self.roomId);
AntMediaClient.printf("Calling play command for stream\(self.roomId)")
}
}

}

public func streamsLeft(streams: [String])
{
for stream in streams {
AntMediaClient.printf("Stream(\(stream)) left the room")
}
public func clientDidDisconnect(_ message: String) {
removePlayers();
}


public func playStarted(streamId: String) {
print("play started");
AntMediaClient.speakerOn();
Expand Down Expand Up @@ -241,36 +209,16 @@ extension ConferenceViewController: AntMediaClientDelegate
removePlayers();
}



public func publishStarted(streamId: String) {
AntMediaClient.printf("Publish started for stream:\(streamId)")
}

public func publishFinished(streamId: String) {
AntMediaClient.printf("Publish finished for stream:\(streamId)")

}

public func disconnected(streamId: String) {

}

public func audioSessionDidStartPlayOrRecord(streamId: String) {

}

public func dataReceivedFromDataChannel(streamId: String, data: Data, binary: Bool) {

}

public func streamInformation(streamInfo: [StreamInformation]) {

}

public func videoView(_ videoView: RTCVideoRenderer, didChangeVideoSize size: CGSize) {
AntMediaClient.printf("Video size changed to " + String(Int(size.width)) + "x" + String(Int(size.height)) + ". These changes are not handled in Simulator for now")

}
}

4 changes: 3 additions & 1 deletion WebRTC-Sample-App/WebRTC-Sample-App.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.antmedia.ios.sdk</string>
<string>group.io.antmedia.ios.webrtc.sample</string>
</array>
</dict>
</plist>
12 changes: 12 additions & 0 deletions WebRTC-Sample-App/WebRTC-Sample-AppDebug.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.security.application-groups</key>
<array>
<string>group.io.antmedia.ios.webrtc.sample</string>
</array>
</dict>
</plist>
40 changes: 23 additions & 17 deletions WebRTCiOSSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
A8522FE02B832967007BC5A8 /* WebRTC-Sample-AppDebug.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "WebRTC-Sample-AppDebug.entitlements"; sourceTree = "<group>"; };
A8B965F42A06969900D67CA1 /* ScreenShare.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = ScreenShare.appex; sourceTree = BUILT_PRODUCTS_DIR; };
A8B965F52A06969900D67CA1 /* ReplayKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ReplayKit.framework; path = System/Library/Frameworks/ReplayKit.framework; sourceTree = SDKROOT; };
A8B965F82A06969900D67CA1 /* SampleHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleHandler.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -320,6 +321,7 @@
A8DAC0042A063AB30007CDE7 /* WebRTC-Sample-App */ = {
isa = PBXGroup;
children = (
A8522FE02B832967007BC5A8 /* WebRTC-Sample-AppDebug.entitlements */,
A8B966022A0698EC00D67CA1 /* WebRTC-Sample-App.entitlements */,
A8DAC0A22A0672040007CDE7 /* LaunchScreen.storyboard */,
A8DAC0402A063BC00007CDE7 /* ConferenceViewController.swift */,
Expand Down Expand Up @@ -755,7 +757,7 @@
CODE_SIGN_ENTITLEMENTS = ScreenShare/ScreenShare.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 2YK9J8G25K;
DEVELOPMENT_TEAM = MJU7KX4L7S;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ScreenShare/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = ScreenShare;
Expand All @@ -767,7 +769,7 @@
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.antmedia.ios.WebRTC-Sample-App.ScreenShare";
PRODUCT_BUNDLE_IDENTIFIER = io.antmedia.ios.webrtc.sample.screen.share;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -782,7 +784,7 @@
CODE_SIGN_ENTITLEMENTS = ScreenShare/ScreenShare.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 2YK9J8G25K;
DEVELOPMENT_TEAM = MJU7KX4L7S;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ScreenShare/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = ScreenShare;
Expand All @@ -794,7 +796,7 @@
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.antmedia.ios.WebRTC-Sample-App.ScreenShare";
PRODUCT_BUNDLE_IDENTIFIER = io.antmedia.ios.webrtc.sample.screen.share;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_EMIT_LOC_STRINGS = YES;
Expand Down Expand Up @@ -1027,10 +1029,11 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "WebRTC-Sample-App/WebRTC-Sample-App.entitlements";
CODE_SIGN_ENTITLEMENTS = "WebRTC-Sample-App/WebRTC-Sample-AppDebug.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 2YK9J8G25K;
DEVELOPMENT_TEAM = MJU7KX4L7S;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "WebRTC-Sample-App/Info.plist";
INFOPLIST_KEY_CFBundleDisplayName = "WebRTC Sample";
Expand All @@ -1047,8 +1050,9 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.antmedia.ios.WebRTC-Sample-App";
PRODUCT_BUNDLE_IDENTIFIER = io.antmedia.ios.webrtc.sample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
Expand All @@ -1065,9 +1069,10 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "WebRTC-Sample-App/WebRTC-Sample-App.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 2YK9J8G25K;
DEVELOPMENT_TEAM = MJU7KX4L7S;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "WebRTC-Sample-App/Info.plist";
INFOPLIST_KEY_CFBundleDisplayName = "WebRTC Sample";
Expand All @@ -1084,8 +1089,9 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.antmedia.ios.WebRTC-Sample-App";
PRODUCT_BUNDLE_IDENTIFIER = io.antmedia.ios.webrtc.sample;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
Expand All @@ -1102,11 +1108,11 @@
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 2YK9J8G25K;
DEVELOPMENT_TEAM = MJU7KX4L7S;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.2;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.antmedia.ios.WebRTC-Sample-AppTests";
PRODUCT_BUNDLE_IDENTIFIER = io.antmedia.ios.webrtc.sample.AppTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
Expand All @@ -1122,11 +1128,11 @@
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 2YK9J8G25K;
DEVELOPMENT_TEAM = MJU7KX4L7S;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.2;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.antmedia.ios.WebRTC-Sample-AppTests";
PRODUCT_BUNDLE_IDENTIFIER = io.antmedia.ios.webrtc.sample.AppTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
Expand All @@ -1141,11 +1147,11 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 2YK9J8G25K;
DEVELOPMENT_TEAM = MJU7KX4L7S;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.2;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.antmedia.ios.WebRTC-Sample-AppUITests";
PRODUCT_BUNDLE_IDENTIFIER = io.antmedia.ios.webrtc.sample.AppUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
Expand All @@ -1160,11 +1166,11 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 2YK9J8G25K;
DEVELOPMENT_TEAM = MJU7KX4L7S;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 16.2;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "io.antmedia.ios.WebRTC-Sample-AppUITests";
PRODUCT_BUNDLE_IDENTIFIER = io.antmedia.ios.webrtc.sample.AppUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
Expand Down
Binary file not shown.
Loading
Loading