1. My iPhone 5S Device model is
MF357HN/A and OS Version is
12.0.1(16A404).
2. I’m using
AVPlayer as player.
3. I’m using
“wss://demo.flashphoner.com:8443/manab” to connect with WCS server. And using
"https://wcs5-eu.flashphoner.com” is for recording url’s streaming path.
-> For connecting with the server I’m writing this type of code —
- (FPWCSApi2Session *)connect
{
FPWCSApi2SessionOptions *options = [[FPWCSApi2SessionOptions alloc] init];
NSURL *url =[[NSURL alloc] initWithString:_connectUrl.text];
options.urlServer = [NSString stringWithFormat
"%@://%@:%@", url.scheme, url.host, url.port];
streamName =[NSString stringWithFormat
"iFaceYouLive_%@",[Global getRandNum]];
options.appKey = @"defaultApp";
NSError *error;
session = [FPWCSApi2 createSession
ptions error:&error];
if (error)
{
UIAlertController * alert = [UIAlertController
alertControllerWithTitle
"Failed to connect"
message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okButton = [UIAlertAction
actionWithTitle
"Ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[self onDisconnected];
}];
[alert addAction
kButton];
[self presentViewController:alert animated:YES completion:nil];
return nil;
}
[session on:kFPWCSSessionStatusEstablished callback:^(FPWCSApi2Session *rSession){
[self changeConnectionStatus:[rSession getStatus]];
[self onConnected:rSession];
}];
[session on:kFPWCSSessionStatusDisconnected callback:^(FPWCSApi2Session *rSession){
[self changeConnectionStatus:[rSession getStatus]];
[self onDisconnected];
}];
[session on:kFPWCSSessionStatusFailed callback:^(FPWCSApi2Session *rSession){
[self changeConnectionStatus:[rSession getStatus]];
[self onDisconnected];
}];
[session connect];
return session;
}
-> And for the publishing the video I’m using this code —
- (FPWCSApi2Stream *)publishStream
{
FPWCSApi2Session *session = [FPWCSApi2 getSessions][0];
FPWCSApi2StreamOptions *options = [[FPWCSApi2StreamOptions alloc] init];
options.name = streamName;
options.record = true;
options.display = remotevideoView;
options.constraints = [[FPWCSApi2MediaConstraints alloc] initWithAudio:YES videoWidth:remotevideoView.frame.size.width videoHeight:remotevideoView.frame.size.height];
NSError *error;
if (frontCamera)
{
remotevideoView.transform=CGAffineTransformMakeScale(-1.0, 1.0);
}
else
{
remotevideoView.transform=CGAffineTransformMakeScale(1.0, 1.0);
}
publishStream = [session createStream
ptions error:&error];
[SVProgressHUD dismiss];
[self.view setUserInteractionEnabled:YES];
[self createTimer];
if (!publishStream)
{
UIAlertController * alert = [UIAlertController
alertControllerWithTitle
"Failed to publish"
message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okButton = [UIAlertAction
actionWithTitle
"Ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[self onUnpublished];
}];
[alert addAction
kButton];
[self presentViewController:alert animated:YES completion:nil];
return nil;
}
[publishStream on:kFPWCSStreamStatusPublishing callback:^(FPWCSApi2Stream *rStream){
[self changeStreamStatus:rStream];
[self onPublishing:rStream];
}];
[publishStream on:kFPWCSStreamStatusResize callback:^(FPWCSApi2Stream *rStream){
}];
[publishStream on:kFPWCSStreamStatusUnpublished callback:^(FPWCSApi2Stream *rStream){
[self changeStreamStatus:rStream];
[self onUnpublished];
recordedFile = [rStream getRecordName];
if ([recordedFile length]>0)
{
[self uploadVideoToLocalServer];
}
}];
[publishStream on:kFPWCSStreamStatusFailed callback:^(FPWCSApi2Stream *rStream){
[self changeStreamStatus:rStream];
[self onUnpublished];
}];
if(![publishStream publish:&error])
{
UIAlertController * alert = [UIAlertController
alertControllerWithTitle
"Failed to publish"
message:error.localizedDescription
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okButton = [UIAlertAction
actionWithTitle
"Ok"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[self onUnpublished];
}];
[alert addAction
kButton];
[self presentViewController:alert animated:YES completion:nil];
}
return publishStream;
}
4. My WCS server version is
“5.0.33”.