Merge pull request #15 from gustavo-em/stop_broadcast
Stopping brodcast extension on click to stop screen share
This commit is contained in:
commit
4a15d78dbd
@ -8,6 +8,7 @@
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
|
||||
792D8E8E283FBED3008471C5 /* main.jsbundle in Resources */ = {isa = PBXBuildFile; fileRef = 792D8E8D283FBED3008471C5 /* main.jsbundle */; };
|
||||
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; };
|
||||
D4107C11428E565249543452 /* libPods-BigbluebuttonMobileSdkExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F8315799A5C1BF7D3955FE7A /* libPods-BigbluebuttonMobileSdkExample.a */; };
|
||||
E34840357A40CF330A083CD4 /* libPods-BigBlueButtonMobileSdkBroadcastExample.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2B60F7CB33D3D557C0DBFB9A /* libPods-BigBlueButtonMobileSdkBroadcastExample.a */; };
|
||||
@ -44,12 +45,12 @@
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = "<group>"; };
|
||||
13B07F961A680F5B00A75B9A /* BigbluebuttonMobileSdkExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = BigbluebuttonMobileSdkExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = BigbluebuttonMobileSdkExample/Images.xcassets; sourceTree = "<group>"; };
|
||||
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = BigbluebuttonMobileSdkExample/Info.plist; sourceTree = "<group>"; };
|
||||
2B60F7CB33D3D557C0DBFB9A /* libPods-BigBlueButtonMobileSdkBroadcastExample.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-BigBlueButtonMobileSdkBroadcastExample.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
64F9B7FFD471972C20137BD6 /* Pods-BigBlueButtonMobileSdkBroadcastExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BigBlueButtonMobileSdkBroadcastExample.debug.xcconfig"; path = "Target Support Files/Pods-BigBlueButtonMobileSdkBroadcastExample/Pods-BigBlueButtonMobileSdkBroadcastExample.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
792D8E8D283FBED3008471C5 /* main.jsbundle */ = {isa = PBXFileReference; lastKnownFileType = text; path = main.jsbundle; sourceTree = "<group>"; };
|
||||
7EC638C00C2D62DDC1E73F8E /* Pods-BigbluebuttonMobileSdkExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BigbluebuttonMobileSdkExample.debug.xcconfig"; path = "Target Support Files/Pods-BigbluebuttonMobileSdkExample/Pods-BigbluebuttonMobileSdkExample.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = BigbluebuttonMobileSdkExample/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
B2C3B4EA07C7BC3E4B51B5D2 /* Pods-BigBlueButtonMobileSdkBroadcastExample.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-BigBlueButtonMobileSdkBroadcastExample.release.xcconfig"; path = "Target Support Files/Pods-BigBlueButtonMobileSdkBroadcastExample/Pods-BigBlueButtonMobileSdkBroadcastExample.release.xcconfig"; sourceTree = "<group>"; };
|
||||
@ -94,10 +95,10 @@
|
||||
13B07FAE1A68108700A75B9A /* BigbluebuttonMobileSdkExample */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
792D8E8D283FBED3008471C5 /* main.jsbundle */,
|
||||
F1CF7F4527D1A4CB00E0C7F1 /* Constants.swift */,
|
||||
F1CF7F4727D1AAAF00E0C7F1 /* AppDelegate.swift */,
|
||||
F1D24A0C27D18E21003B294F /* BigbluebuttonMobileSdkExample.entitlements */,
|
||||
008F07F21AC5B25A0029DE68 /* main.jsbundle */,
|
||||
13B07FB51A68108700A75B9A /* Images.xcassets */,
|
||||
13B07FB61A68108700A75B9A /* Info.plist */,
|
||||
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */,
|
||||
@ -261,6 +262,7 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
792D8E8E283FBED3008471C5 /* main.jsbundle in Resources */,
|
||||
81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */,
|
||||
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
|
||||
);
|
||||
|
@ -67,6 +67,7 @@
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
disableMainThreadChecker = "YES"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
|
4
example/ios/assets/app.json
Normal file
4
example/ios/assets/app.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "BigbluebuttonMobileSdkExample",
|
||||
"displayName": "BigbluebuttonMobileSdk Example"
|
||||
}
|
426
example/ios/main.jsbundle
Normal file
426
example/ios/main.jsbundle
Normal file
File diff suppressed because one or more lines are too long
@ -16,6 +16,7 @@ open class BBBSampleHandler : RPBroadcastSampleHandler {
|
||||
private var setScreenShareRemoteSDPOBserver:NSKeyValueObservation?;
|
||||
private var addScreenShareRemoteIceCandidateObserver:NSKeyValueObservation?;
|
||||
private var onApplicationTerminatedObserver:NSKeyValueObservation?;
|
||||
private var onBroadcastStoppedObserver:NSKeyValueObservation?;
|
||||
private var screenBroadcaster:ScreenBroadcasterService?;
|
||||
|
||||
open func setAppGroupName(appGroupName:String) {
|
||||
@ -44,6 +45,13 @@ open class BBBSampleHandler : RPBroadcastSampleHandler {
|
||||
finishBroadcastGracefully(self)
|
||||
}
|
||||
|
||||
// Handle click in stop broadcast
|
||||
logger.info("Configuring observer for stop broadcast")
|
||||
self.onBroadcastStoppedObserver = userDefaults.observe(\.onBroadcastStopped, options: [.new]) { (defaults, change) in
|
||||
self.logger.info("Observer detected a onBroadcastStopped request!")
|
||||
finishBroadcastGracefully(self)
|
||||
}
|
||||
|
||||
// Listen for createOffer requests from the UI APP
|
||||
logger.info("Configuring observer for createOffer")
|
||||
self.createScreenShareOfferObserver = userDefaults.observe(\.createScreenShareOffer, options: [.new]) { (defaults, change) in
|
||||
|
@ -31,8 +31,11 @@ open class BBBSharedData {
|
||||
public static let onScreenShareLocalIceCandidate = "onScreenShareLocalIceCandidate" // Broadcaster -> UI APP
|
||||
|
||||
public static let onScreenShareSignalingStateChange = "onScreenShareSignalingStateChange" // Broadcaster -> UI APP
|
||||
|
||||
public static let onApplicationTerminated = "onApplicationTerminated" // UI APP -> Broadcaster
|
||||
|
||||
public static let onBroadcastStopped = "onBroadcastStopped" // UI APP -> Broadcaster
|
||||
|
||||
}
|
||||
|
||||
// Get reference to userDefaults object (that's actually the object used to share information among UI APP and the BroadcastUploadExtension APP)
|
||||
|
@ -15,6 +15,11 @@ extension UserDefaults {
|
||||
return string(forKey: BBBSharedData.SharedData.onApplicationTerminated) ?? ""
|
||||
}
|
||||
|
||||
// UI APP -> Broadcaster
|
||||
@objc open dynamic var onBroadcastStopped: String {
|
||||
return string(forKey: BBBSharedData.SharedData.onBroadcastStopped) ?? ""
|
||||
}
|
||||
|
||||
// Broadcaster -> UI APP
|
||||
@objc open dynamic var broadcastPaused: String {
|
||||
return string(forKey: BBBSharedData.SharedData.broadcastPaused) ?? ""
|
||||
|
@ -9,6 +9,7 @@
|
||||
#import "React/RCTBridgeModule.h"
|
||||
@interface RCT_EXTERN_REMAP_MODULE(BBBN_ScreenShareService, ScreenShareServiceManager, NSObject)
|
||||
|
||||
RCT_EXTERN_METHOD(stopScreenShareBroadcastExtension)
|
||||
RCT_EXTERN_METHOD(initializeScreenShare)
|
||||
RCT_EXTERN_METHOD(createScreenShareOffer)
|
||||
RCT_EXTERN_METHOD(setScreenShareRemoteSDP: (NSString *)remoteSDP)
|
||||
|
@ -16,6 +16,12 @@ class ScreenShareServiceManager: NSObject {
|
||||
var audioSession = AVAudioSession.sharedInstance()
|
||||
var player: AVAudioPlayer!
|
||||
|
||||
@objc func stopScreenShareBroadcastExtension() -> Void {
|
||||
BBBSharedData
|
||||
.getUserDefaults(appGroupName: BigBlueButtonSDK.getAppGroupName())
|
||||
.set(BBBSharedData.generatePayload(), forKey: BBBSharedData.SharedData.onBroadcastStopped)
|
||||
}
|
||||
|
||||
// React native exposed method (called when user click the button to share screen)
|
||||
@objc func initializeScreenShare() -> Void {
|
||||
logger.info("initializeScreenShare")
|
||||
|
32
src/methods/stopScreenShare.tsx
Normal file
32
src/methods/stopScreenShare.tsx
Normal file
@ -0,0 +1,32 @@
|
||||
import { stopScreenShareBroadcastExtension as nativeStopScreenShare } from '../native-components/BBBN_ScreenShareService';
|
||||
import nativeEmitter from '../native-messaging/emitter';
|
||||
|
||||
// Reference to the resolver of last call
|
||||
let resolve = (a: String | null) => {
|
||||
console.log(
|
||||
`default resolve function called, this should never happen: ${a}`
|
||||
);
|
||||
};
|
||||
|
||||
// Resolve promise when broadcast is started (this event means that user confirmed the screenshare)
|
||||
nativeEmitter.addListener('onBroadcastFinished', () => {
|
||||
resolve(null);
|
||||
});
|
||||
|
||||
// Entry point of this method
|
||||
function stopScreenShare(instanceId: Number) {
|
||||
return new Promise((res, rej) => {
|
||||
// store the resolver for later call (when event is received)
|
||||
resolve = res;
|
||||
|
||||
try {
|
||||
// call native swift method that triggers the broadcast popup
|
||||
console.log(`[${instanceId}] - >stopScreenShare`);
|
||||
nativeStopScreenShare();
|
||||
} catch (e) {
|
||||
rej(`Call to stopScreenShare failed zzy`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default stopScreenShare;
|
@ -17,3 +17,7 @@ export function setScreenShareRemoteSDP(remoteSDP: string) {
|
||||
export function addScreenShareRemoteIceCandidate(remoteCandidateJson: string) {
|
||||
ScreenShareService.addScreenShareRemoteIceCandidate(remoteCandidateJson);
|
||||
}
|
||||
|
||||
export function stopScreenShareBroadcastExtension() {
|
||||
ScreenShareService.stopScreenShareBroadcastExtension();
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import setScreenShareRemoteSDP from '../methods/setScreenShareRemoteSDP';
|
||||
import setFullAudioRemoteSDP from '../methods/setFullAudioRemoteSDP';
|
||||
import addScreenShareRemoteIceCandidate from '../methods/addScreenShareRemoteIceCandidate';
|
||||
import createFullAudioOffer from '../methods/createFullAudioOffer';
|
||||
import stopScreenShare from '../methods/stopScreenShare';
|
||||
|
||||
function observePromiseResult(
|
||||
instanceId: Number,
|
||||
@ -66,6 +67,9 @@ export function handleWebviewMessage(
|
||||
JSON.stringify(data?.arguments[0])
|
||||
);
|
||||
break;
|
||||
case 'stopScreenShare':
|
||||
promise = stopScreenShare(instanceId)
|
||||
break;
|
||||
default:
|
||||
throw `[${instanceId}] - Unknown method ${data?.method}`;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user