Intel® Collaboration Suite for WebRTC
Community support and discussions on the Intel® Collaboration Suite for WebRTC (Intel® CS for WebRTC).
Announcements
Intel Customer Support will be observing the Martin Luther King holiday on Monday, Jan. 17, and will return on Tues. Jan. 18.
For the latest information on Intel’s response to the Log4j/Log4Shell vulnerability, please see Intel-SA-00646

how switch camera in ios?

snow__fly
Beginner
713 Views

      hi!

            how switch camera in ios? 

          I use :

               self.myCamera = AVCaptureDevice.defaultDevice(withDeviceType: .builtInWideAngleCamera, mediaType: AVMediaTypeVideo, position: .front)

              let cameraid=self.myCamera?.uniqueID

              self.myCameraPar=RTCLocalCameraStreamParameters(videoEnabled: true, audioEnabled: true)
            // [parameters setResolutionWidth:352 height:288];
                self.myCameraPar?.setResolutionWidth(352, height: 288)
            
                self.myCameraPar?.setCameraId(cameraid!) 
            
                self.localCanmerStream=RTCLocalCameraStream(parameters: self.myCameraPar!)

          I switch camera,but no success! 

             /*

 let session =  AVCaptureSession()
            
            do {
                let    Input1 = try AVCaptureDeviceInput(device: self.myCamera)
                let    Input2 = try AVCaptureDeviceInput(device: self.myCamera2)
                
                session.beginConfiguration()
                
                
                session.removeInput(Input1)
                
                let b =  session.canAddInput(Input2)
                if(b)
                {
                    session.addInput(Input2)
                    print("okOKokok")
                }
                else
                {
                    print("nononono")
                }
               
                
                session.commitConfiguration()
                session.startRunning()

   */

 I look at API  "RTCAVFoundationVideoSource" ,but I can not use.

        let t = RTCAVFoundationVideoSource.init(constraints: <#T##RTCMediaConstraints!#>)
            
            t?.useBackCamera = true 

 

 

0 Kudos
22 Replies
Ferhat_D_
Beginner
658 Views

Hi,

I 've set source and localstream like below 

source = RTCAVFoundationVideoSource(constraints: mediaConstraints)

source?.useBackCamera = true

localStream = RTCLocalCameraStream(audioEnabled: true, videoSource: source!, error: nil)

and after this just use useBackCamera (true|false)  inside my changeCamera() function. I didn't use any cameraParameter.

 

 

 

 

 

 

 

 

 

 

YanbinZ_Intel
Employee
658 Views

For iOS SDK , switch camera can be done through set useBackCamera as Yes /NO

Following is example code , you can include it to your SwitchCamera() function and it will switch camera over successive calls when i is even or odd

    static int i = 0;
    NSDictionary *mandatoryConstraints = @{@"minWidth" : @"640", @"minHeight" : @"480",@"maxWidth" : @"640", @"maxHeight" : @"480", @"maxFrameRate":@"24", @"minFrameRate":@"24"};
    RTCMediaConstraints* constraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:mandatoryConstraints optionalConstraints:nil];
    RTCAVFoundationVideoSource* source=[[RTCAVFoundationVideoSource alloc] initWithConstraints:constraints];
    if((i++)%2 == 1){
      source.useBackCamera = YES;
    }else{
      source.useBackCamera = NO;
    }
    NSError *err=[[NSError alloc]init];
    _localStream=[[RTCLocalCameraStream alloc]initWithAudioEnabled:YES VideoSource:source error: &err];

 

 

 

snow__fly
Beginner
658 Views

Hi , Thank you all。   My problem has been solved

 //////////////////////////////////////////////////////

 let mandatoryConstraints = ["minWidth":"640","minHeight":"480","maxWidth":"640","maxHeight":"480","maxFrameRate":"16","minFrameRate":"16"]
                
                let constraints = RTCMediaConstraints(mandatoryConstraints: mandatoryConstraints, optionalConstraints: nil)
                
                self.mVideoSource = RTCAVFoundationVideoSource(constraints: constraints)
                
                self.mVideoSource?.useBackCamera = false
                
                self.mIsBackCamera = false
                
                self.localCanmerStream=RTCLocalCameraStream(audioEnabled: true, videoSource: self.mVideoSource!, error: nil)

 

func switchCamera()
        {
            if mIsBackCamera
            {
                self.mVideoSource?.useBackCamera = false
                mIsBackCamera = false
            }
            else
            {
                self.mVideoSource?.useBackCamera = true
                mIsBackCamera = true
            }
        }

//////////////////////////////////////////////////////////////////////////////////////////

                                                          Thinks!

 

 

  

Deepesh__NAik
Beginner
658 Views

How to switch camera in v4.0 of iOS client using ICSLocalStream?

krishna__venkata
Beginner
658 Views

Hello Team,

we are also having same issue, how to switch camera in v4.1 for using ICSLocalStream?

Jianjun_Z_Intel
Employee
658 Views

Hi Deepesh and krishna,

ICSLocalStream can be initialized with a RTCMediaStream. You can switch position on its associated RTCCameraVideoCapturer.

krishna__venkata
Beginner
658 Views

Hello Jianjun,

Thanks for your reply,

with out using initialise with media stream working good.

           let constraints = ICSStreamConstraints.init()

           constraints.audio = true

            constraints.video = ICSVideoTrackConstraints.init()

            constraints.video?.frameRate = 24  //need to check waht is heighest and lowset and why we need to set

            constraints.video?.resolution = CGSize(width: 640, height: 480) //is based on device we need to change, its our local stream resilution

              if self.isFrontCam == false {

                constraints.video?.devicePosition = .front //as per out camera we need to set front or back, by default its setting as front

            }

            else{

                constraints.video?.devicePosition = .back //as per out camera we need to set front or back, by default its setting as front

            }

            var errorObj : NSError?

           self.localVideoStream = ICSLocalStream.init(constratins: constraints, error: &errorObj).  //local video stream is created

            localVideoView.captureSession = captureSource.captureSession //RTCCameraVideoCapturer also started

         self.localVideoStream.attach(self.remoteVideoVioew!)  //local stream is getting renderview.

 

But as per the response if we created the ICSLocalStream with  RTCMediaStream,for local itself its not adding to renderview getting only black scrren.

For this after hitting the Join Api in the response we will get conference information objection, that object is subclass of ICSStream(which contains mediaStream object). As we check with  the stream object it doesn't contains any RTCMediaStream, project is getting crashed.

Sample code :

            let icsSourceinf = ICSStreamSourceInfo.init()

            icsSourceinf.audio = .mic

            icsSourceinf.video = .camera

            let remoteStreamObj = currentConfInfo.remoteStreams.first as! ICSRemoteStream

            rtcMediaStream = remoteStreamObj.mediaStream as? RTCMediaStream

             if rtcMediaStream == nil {

                rtcMediaStream = localVideoStream2.mediaStream // to resolve the crash checked the condition and added localstream

            }            

            localVideoStream = ICSLocalStream.init(mediaStream: rtcMediaStream!, source: icsSourceinf)

            localVideoView.captureSession = captureSource.captureSession

 

Please help us how to use ICSLocalStream with media object.

As we noticed this method contains peer connectivity properties, our aim is to create conference call.

 

 

 

JJ_Lin
Beginner
658 Views

same here.
Would like to switch camera position while conference call.
Seems Android SDK has a method called switchCamera but iOS hasn't.
Trying to find some solution. Stuck here for almost a week. :'(

K__Srujan
Beginner
658 Views

Hi Team,

I have the same issue. Kindly, give us an update, to solve the above?

Jianjun_Z_Intel
Employee
658 Views

Hi krishna,

The issue may be fixed by https://github.com/open-media-streamer/oms-client-native/commit/98c9c31f34b162774bec0abb89364011df06c885. But it is not included in v4.1.

K__Srujan
Beginner
658 Views

Hi Jianjun,

Thanks for your response.

We are using v4.1 SDKs for iOS,Android and Server side and we cannot depend OMS Client.( i.e the link you given above).

Does it have any possible solution using your SDK / WebRTC SDK which you have provided?

krishna__venkata
Beginner
658 Views

Hello Jianjuan,

How to fix the issue, we cannot find solution in v4.1.1. for ICSLocalStream to switch camera. If we republish the local stream for one instance its working fine. If we trigger same call again with out restart the application the remote itself not binding to opposite device getting issues as 

2019-02-06 17:45:27.604415+0530 VideoConf_Swift[9961:1784648] Failed to make complete framebuffer object 8cd6

2019-02-06 17:45:27.604732+0530 VideoConf_Swift[9961:1784648] Failed to bind EAGLDrawable: <CAEAGLLayer: 0x281c9c640> to GL_RENDERBUFFER 1

 

How to resolve this issue, please help us

 

Jianjun_Z_Intel
Employee
658 Views

Above commit is included in v4.1.1.

张__俞
Beginner
658 Views

Yanbin Z. (Intel) wrote:

For iOS SDK , switch camera can be done through set useBackCamera as Yes /NO

Following is example code , you can include it to your SwitchCamera() function and it will switch camera over successive calls when i is even or odd

    static int i = 0;
    NSDictionary *mandatoryConstraints = @{@"minWidth" : @"640", @"minHeight" : @"480",@"maxWidth" : @"640", @"maxHeight" : @"480", @"maxFrameRate":@"24", @"minFrameRate":@"24"};
    RTCMediaConstraints* constraints = [[RTCMediaConstraints alloc] initWithMandatoryConstraints:mandatoryConstraints optionalConstraints:nil];
    RTCAVFoundationVideoSource* source=[[RTCAVFoundationVideoSource alloc] initWithConstraints:constraints];
    if((i++)%2 == 1){
      source.useBackCamera = YES;
    }else{
      source.useBackCamera = NO;
    }
    NSError *err=[[NSError alloc]init];
    _localStream=[[RTCLocalCameraStream alloc]initWithAudioEnabled:YES VideoSource:source error: &err];

 

 

 

RTCAVFoundationVideoSource and RTCLocalCameraStream dose not provide in WebRTC.framework,how can i get it ?thank you very much!
张__俞
Beginner
658 Views

snow f. wrote:

Hi , Where can I find RTCLocalCameraStream? thanks

 //////////////////////////////////////////////////////

 let mandatoryConstraints = ["minWidth":"640","minHeight":"480","maxWidth":"640","maxHeight":"480","maxFrameRate":"16","minFrameRate":"16"]
                
                let constraints = RTCMediaConstraints(mandatoryConstraints: mandatoryConstraints, optionalConstraints: nil)
                
                self.mVideoSource = RTCAVFoundationVideoSource(constraints: constraints)
                
                self.mVideoSource?.useBackCamera = false
                
                self.mIsBackCamera = false
                
                self.localCanmerStream=RTCLocalCameraStream(audioEnabled: true, videoSource: self.mVideoSource!, error: nil)

 

func switchCamera()
        {
            if mIsBackCamera
            {
                self.mVideoSource?.useBackCamera = false
                mIsBackCamera = false
            }
            else
            {
                self.mVideoSource?.useBackCamera = true
                mIsBackCamera = true
            }
        }

//////////////////////////////////////////////////////////////////////////////////////////

                                                          Thinks!

 

 

  

Lai__Jing
Beginner
658 Views

hi guys,

 

Regarding camera switch on iOS, did you manage to do that without republishing?  We are struggling, and getting stuck.  If any of you be able to do that, would you kindly share the source code block implementation?  Thanks in advances!

K__Srujan
Beginner
658 Views

Jianjun Z. (Intel) wrote:

Hi Deepesh and krishna,

ICSLocalStream can be initialized with a RTCMediaStream. You can switch position on its associated RTCCameraVideoCapturer.

 

Hi Jianjun,

How are you?

Could you please give us sample example for creating local stream with RTCMediaStream, as we are unable to create local stream with it.
Kindly do the needful as it is high priority issue from our end.

 

K__Srujan
Beginner
658 Views

K, Srujan wrote:

Quote:

Jianjun Z. (Intel) wrote:

 

Hi Deepesh and krishna,

ICSLocalStream can be initialized with a RTCMediaStream. You can switch position on its associated RTCCameraVideoCapturer.

 

 

 

Hi Jianjun,

How are you?

Could you please give us sample example for creating local stream with RTCMediaStream, as we are unable to create local stream with it.
Kindly do the needful as it is high priority issue from our end.

 

 

Hello,

Any update would be appreciated?

K__Srujan
Beginner
658 Views

Hi @Jianjun Z.

Could you please help us out by giving an example of creating local stream with RTCMediaStream?

K__Srujan
Beginner
337 Views

Hello Team,

Any update would be appreciated?

Reply