2016-05-16 81 views
4

我使用Sinch开发Android视频通话,我遵循Sinch教程和示例。他们大多数工作正常,但我遇到了2个问题,我不知道如何解决它。Android Sinch Video Call无法切换摄像头并恢复视频控制器

1)我无法恢复视频渲染。 场景:当我建立一个通话时,一切正常,然后退出该活动而不挂断电话(因此视频通话仍在进行中)。当我再次开始活动时,localview(我自己的相机)不会继续渲染。这会导致其他手机看到我,就好像视频通话挂起/卡住一样。

@Override 
    public void onServiceConnected(ComponentName name, IBinder svc) 
    { 
     service = ((ServiceChat.ChatBinder) svc).getService(); 
     VideoController controller = service.GetSinchVideoController(); 
     if(controller != null) 
     { 
      // your own face 
      localVideo.addView(controller.getLocalView()); 
      // contact face 
      remoteVideo.addView(controller.getRemoteView()); 
     } 
    } 
    @Override 
    protected void onDestroy() 
    { 
     VideoController controller = service.GetSinchVideoController(); 
     if(controller != null) 
     { 
      localVideo.removeView(controller.getLocalView()); 
      remoteVideo.removeView(controller.getRemoteView()); 
     } 
     super.onDestroy(); 
    } 

2)我遇到的另一个问题是,我不能切换相机

private void SwitchCamera() 
{ 
    VideoController controller = service.GetSinchVideoController(); 
    if(controller.getCaptureDevicePosition() == Camera.CameraInfo.CAMERA_FACING_FRONT) 
    { 
     controller.setCaptureDevicePosition(Camera.CameraInfo.CAMERA_FACING_BACK); 
    } 
    else 
    { 
     controller.setCaptureDevicePosition(Camera.CameraInfo.CAMERA_FACING_FRONT); 
    } 
    //controller.toggleCaptureDevicePosition(); 
} 

,但我得到这个错误

org.webrtc.Logging: VideoCapturerAndroid: Ignoring camera switch request. 
org.webrtc.Logging: VideoCapturerAndroid: Could not switch to camera with id 0 

任何人有任何想法如何解决这些?在此先感谢,对不起,我的英语不好

回答

0

您可以尝试切换你的相机(第二个问题)

VideoController vcLocal = getSinchServiceInterface().getVideoController(); 

上的一些按钮,点击使用下面的代码

vcLocal.toggleCaptureDevicePosition(); 
下面的代码