Forum: iOS

Here is a forum space for SDK: iOS.

140. iOS sdk video ptt camera preview not working

Hi there,

I have some troubles with camera preview and sending camera stream to other users. 

Related tool and software versions:
Xcode: 11.5
Swift: 4
Deployment Target: 10.3
iPhone 6-7

Proptt Sdk: 2.1.2


Here is my code to send video ptt. These are basic of them, maybe I miss something here, but I tried most of the combinations and none of them work.

func onConnected() {
   mVideoChannel = PTTClient.getInstance()?.openVideoAnnouncerChannel(self)
   if let cameraListValue = PTTClient.getInstance()?.getCameraList() {
       let cameraList = cameraListValue.split(separator: ",")
       mVideoChannel?.setCamera(String(cameraList[0]))
    }
}

func onJoined(_ channelInstance: PTTChannel!, memberJson: String!, totalUserCount: Int32) {
   mJoinedChannel = channelInstance
   if self.playView != nil && self.cameraPreview != nil {
        self.setChannelViews(playView: self.playView!, cameraPreview: self.cameraPreview!)
   }
}

func joinChannel(channelId: Int) {
   var chanellToJoin: PTTChannel?
   for (key, value) in mChannelList {
      if key == channelId {
           chanellToJoin = value
       }
   }
        
   if chanellToJoin != nil {
       chanellToJoin?.enableSendVideo = true
       chanellToJoin?.enablePlayVideo = true
       let result = chanellToJoin!.join()
       print("join result: \(result)")
   } else {
       print("channel to join is empty")
   }
}

func startVideoPTT() {
   if mJoinedChannel != nil {
       mJoinedChannel?.foreground = true
       mJoinedChannel?.setCameraPreview(cameraPreview)
       mJoinedChannel?.setPlay(playView)
            
       if mJoinedChannel?.lockStatus == Int32(LOCK_STATE_UNLOCKED.rawValue) || 
          mJoinedChannel?.lockStatus == Int32(LOCK_STATE_REQUEST_UNLOCK.rawValue) {
                mJoinedChannel?.lockPTT()
        }
    } else {
        print("Joined call is null")
    }
}

func setChannelViews(playView: UIView, cameraPreview: UIView)  {
    self.playView = playView
    self.cameraPreview = cameraPreview
        
    if mJoinedChannel != nil {
        mJoinedChannel?.foreground = true
        mJoinedChannel?.setCameraPreview(self.cameraPreview)
        mJoinedChannel?.setPlay(self.playView)
    }
}

I will be glad you can find a solution or you can say here is your fault. Thank you and see you

May 21 '20 at 16:03 (GMT0) created by Melih

 
Hi again,

I actually forget to add some logs about "onTrackDataEncoded" event. After call "lock" method of PttChannel instance, I get below logs continuously and I think first parameter of "onTrackDataEncoded" event is changed. I don't know my problem is related with this event or not but maybe this helps.

2020-05-22 12:40:20.115435+0300 Smart Radio[1555:1267266] -[Smart_Radio.PttService onTrackDataEncoded:lockIndex:trackType:trackDataBuffer:dataLength:timestamp:]: unrecognized selector sent to instance 0x283434150

May 22 '20 at 09:50 (GMT0) created by Melih

 
Hi Melih,
1. Please use iOS SDK 3.01
Currently 2.1.2 is not supported in technically any more.
2. About camera setting
Please refer to below code.

-(void) onConnected
{
    ProPTTClient *client = [ProPTTClient getInstance];
    NSString *cameraList = [client getCameraList];
    NSArray* cameraArray = [cameraList componentsSeparatedByString: @","];
    for(NSString *camera in cameraArray)
    {
        if([camera isEqualToString:@"UIImagePickerControllerCameraDeviceRear"])
        {
            if(_isFrontCamera)
            {
                [client setCamera:camera];
                _isFrontCamera = !_isFrontCamera;
                break;
            }
        }
        else if([camera isEqualToString:@"UIImagePickerControllerCameraDeviceFront"]){
            if(!_isFrontCamera)
            {
                    [client setCamera:camera];
                    _isFrontCamera = !_isFrontCamera;
                    break;
            }
        }
    }
}

?3. About Video PTT

-(void) startVideoPTT { 
[mJoinChannel setCameraPreview:cameraPreview];
[mJoinChannel setPlayView:cameraPreview];
[mJoinChannel lockPTT];
}

Thanks,
ProPTT2

May 22 '20 at 13:08 (GMT0) created by ProPTT2 dev

 
 
Hi,

Problem is downloaded sdk version is 2.1.3 when I click download button of V3 framework for iOS. I printed log information using PTTClient.getInstance()?.sdkVersion and output of 'sdkVersion' member is 2.1.3.

By the way, I made a mistake about sdk version in first post, it's version also is 2.1.3. 

Thanks

May 22 '20 at 14:26 (GMT0) created by Melih

 
 
Sorry, we have patched the SDK module again.
Please check it up again.
Thanks.

May 24 '20 at 08:05 (GMT0) created by ProPTT2 dev

 
 
Hello again,

I downloaded new version (3.0.1) and I tried above code for video ptt but again both camera preview not worked and my video not sent to the other client. 

I also use your ProPTT2 application to receive video ptt which streamed from our app. I joined same channel from both your app and ours. Your ProPTT2 app shows it as a Voice PTT, when I start ptt video functionality from my own application. By the way, I use same above code, the only difference is our app written in Swift. Are there any extra thing which you and I forgot about video ptt?

Thanks

May 28 '20 at 11:44 (GMT0) created by Melih

 
 
I think we don't have any extra things.
Unfortunately, we don't use Swift.
We don't have any comment for Swift.
Sorry.
ProPTT2

May 29 '20 at 14:58 (GMT0) created by ProPTT2 dev

 
 
Actually, we thought that you didn't use Swift. After I posted above question, we figure out problem is lockMediaProfile value. 
Default value of lock lockMediaProfile is 3 because of that video not appearing when ptt started. Maybe default value should be lowest quality which is PROFILE_ID_OPUS8_MJPEG_LOW.rawValue (286330929).

Now, I have some uiview problems about camera preview. I just wonder, is there any placement changes for camera preview uiview in sdk?

Thanks

Jun 3 '20 at 07:47 (GMT0) created by Melih

 
 
"is there any placement changes for camera preview uiview in sdk?"
Could you explain it more detaily?

Jun 3 '20 at 07:57 (GMT0) created by ProPTT2 dev

 
 
I set both playView and cameraPreview to single uiveiw. When someone start video ptt, then all ui constraint of uiview of playview is correct. Position of uiview is correct place. On the other hand, when I start video ptt, I set camera preview to same uiview but uiview is shown bottom right position. I guess, position is 30-50px below and 50-80px right according to original position.

Thanks

Jun 3 '20 at 10:53 (GMT0) created by Melih

 
 
This is removed.

Jul 6 '20 at 03:34 (GMT0) created by ProPTT2 dev

 
 
Hmm..Unfortunately we could not find it.
We have a plan to make the VideoPTT sample project.
Then we think we could check it more
Thanks.

Jun 4 '20 at 03:17 (GMT0) created by ProPTT2 dev

 
 
Hi Melih,
We have released the SDK and HelloVideoPTT sample.
https://dev.proptt2.com/account-download.php
Please try to use them.
Thanks.

Jul 6 '20 at 03:35 (GMT0) created by ProPTT2 dev