mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-18 23:48:29 +02:00
Update JistiViewController to use new JitsiMeet SDK API
This commit is contained in:
@@ -15,15 +15,17 @@
|
||||
*/
|
||||
|
||||
#import "JitsiViewController.h"
|
||||
@import JitsiMeet;
|
||||
|
||||
static const NSString *kJitsiServerUrl = @"https://jitsi.riot.im/";
|
||||
static const NSString *kJitsiDataErrorKey = @"error";
|
||||
|
||||
@interface JitsiViewController ()
|
||||
{
|
||||
NSString *jitsiUrl;
|
||||
@interface JitsiViewController () <JitsiMeetViewDelegate>
|
||||
|
||||
BOOL video;
|
||||
}
|
||||
// The jitsi-meet SDK view
|
||||
@property (nonatomic, weak) IBOutlet JitsiMeetView *jitsiMeetView;
|
||||
|
||||
@property (nonatomic, strong) NSString *conferenceId;
|
||||
@property (nonatomic) BOOL startWithVideo;
|
||||
|
||||
@end
|
||||
|
||||
@@ -44,14 +46,41 @@ static const NSString *kJitsiServerUrl = @"https://jitsi.riot.im/";
|
||||
return jitsiViewController;
|
||||
}
|
||||
|
||||
#pragma mark - Life cycle
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.jitsiMeetView.delegate = self;
|
||||
|
||||
[self joinConference];
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
}
|
||||
|
||||
#pragma mark - Public
|
||||
|
||||
- (void)openWidget:(Widget*)widget withVideo:(BOOL)aVideo
|
||||
success:(void (^)(void))success
|
||||
failure:(void (^)(NSError *error))failure
|
||||
{
|
||||
video = aVideo;
|
||||
self.startWithVideo = aVideo;
|
||||
_widget = widget;
|
||||
|
||||
MXWeakify(self);
|
||||
|
||||
[_widget widgetUrl:^(NSString * _Nonnull widgetUrl) {
|
||||
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
|
||||
// Extract the jitsi conference id from the widget url
|
||||
NSString *confId;
|
||||
@@ -69,15 +98,11 @@ static const NSString *kJitsiServerUrl = @"https://jitsi.riot.im/";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// And build from it the url to use in jitsi-meet sdk
|
||||
if (confId)
|
||||
{
|
||||
jitsiUrl = [NSString stringWithFormat:@"%@%@", kJitsiServerUrl, confId];
|
||||
}
|
||||
}
|
||||
|
||||
self.conferenceId = confId;
|
||||
|
||||
if (jitsiUrl)
|
||||
if (confId)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
@@ -107,71 +132,72 @@ static const NSString *kJitsiServerUrl = @"https://jitsi.riot.im/";
|
||||
|
||||
- (void)hangup
|
||||
{
|
||||
jitsiUrl = nil;
|
||||
[self.jitsiMeetView leave];
|
||||
}
|
||||
|
||||
// It would have been nicer to ask JitsiMeetView but there is no api.
|
||||
// Dismissing the view controller and releasing it does the job for the moment
|
||||
if (_delegate)
|
||||
#pragma mark - Private
|
||||
|
||||
- (void)joinConference
|
||||
{
|
||||
[self joinConferenceWithId:self.conferenceId];
|
||||
}
|
||||
|
||||
- (void)joinConferenceWithId:(NSString*)conferenceId
|
||||
{
|
||||
if (conferenceId)
|
||||
{
|
||||
[_delegate jitsiViewController:self dismissViewJitsiController:nil];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
|
||||
self.jitsiMeetView.delegate = self;
|
||||
|
||||
// Pass the URL to jitsi-meet sdk
|
||||
[self.jitsiMeetView loadURLObject: @{
|
||||
@"url": jitsiUrl,
|
||||
@"configOverwrite": @{
|
||||
@"startWithVideoMuted": @(!video)
|
||||
}
|
||||
}];
|
||||
|
||||
// TODO: Set up user info but it is not yet available in the jitsi-meet iOS SDK
|
||||
// See https://github.com/jitsi/jitsi-meet/issues/1880
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
{
|
||||
[super didReceiveMemoryWarning];
|
||||
}
|
||||
|
||||
#pragma mark - Actions
|
||||
|
||||
- (IBAction)onBackToAppButtonPressed:(id)sender
|
||||
{
|
||||
if (_delegate)
|
||||
{
|
||||
[_delegate jitsiViewController:self goBackToApp:nil];
|
||||
// TODO: Set up user info but it is not yet available in the jitsi-meet iOS SDK
|
||||
// See https://github.com/jitsi/jitsi-meet/issues/1880
|
||||
|
||||
JitsiMeetConferenceOptions *jitsiMeetConferenceOptions = [JitsiMeetConferenceOptions fromBuilder:^(JitsiMeetConferenceOptionsBuilder * _Nonnull jitsiMeetConferenceOptionsBuilder) {
|
||||
jitsiMeetConferenceOptionsBuilder.room = conferenceId;
|
||||
jitsiMeetConferenceOptionsBuilder.videoMuted = !self.startWithVideo;
|
||||
}];
|
||||
|
||||
[self.jitsiMeetView join:jitsiMeetConferenceOptions];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - JitsiMeetViewDelegate
|
||||
|
||||
- (void)conferenceFailed:(NSDictionary *)data
|
||||
- (void)conferenceWillJoin:(NSDictionary *)data
|
||||
{
|
||||
NSLog(@"[JitsiViewController] conferenceFailed - data: %@", data);
|
||||
}
|
||||
|
||||
- (void)conferenceLeft:(NSDictionary *)data
|
||||
- (void)conferenceJoined:(NSDictionary *)data
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
// The conference is over. Let the delegate close this view controller.
|
||||
if (_delegate)
|
||||
{
|
||||
[_delegate jitsiViewController:self dismissViewJitsiController:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do it ourself
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)conferenceTerminated:(NSDictionary *)data
|
||||
{
|
||||
if (data[kJitsiDataErrorKey] != nil)
|
||||
{
|
||||
NSLog(@"[JitsiViewController] conferenceFailed - data: %@", data);
|
||||
}
|
||||
else
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
// The conference is over. Let the delegate close this view controller.
|
||||
if (self.delegate)
|
||||
{
|
||||
[self.delegate jitsiViewController:self dismissViewJitsiController:nil];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do it ourself
|
||||
[self dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (void)enterPictureInPicture:(NSDictionary *)data
|
||||
{
|
||||
if (self.delegate)
|
||||
{
|
||||
[self.delegate jitsiViewController:self goBackToApp:nil];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user