Sinch视频聊天,无法显示远程视频

Sinch video chat , cannot get remote video displayed

我目前正在试用 Android Sinch SDK,因此我目前正在开发一个测试应用程序来尝试一些功能。我成功地进行了语音应用程序到应用程序的通话,但是在尝试视频应用程序到应用程序通话时遇到了问题:建立连接后,呼叫者可以显示远程视频,但接收者无法显示远程视频(两者都可以显示他们的本地视频)。 这是我的代码:

呼叫监听器

public class SinchVidListner implements VideoCallListener {
    private Activity a ;
    private TextView callState ;
    private Button dec ;
    private LinearLayout gl ;


    public SinchVidListner(Activity act)
    {
        a=act;
        callState = (TextView) a.findViewById(R.id.fullscreen_content);
        dec=(Button) a.findViewById(R.id.Decline) ;

    }
    @Override
    public void onVideoTrackAdded(Call call) {

        //remoteView = vc.getRemoteView();
    }

    @Override
    public void onCallProgressing(Call call) {
        callState.setText("Ringing");
    }

    @Override
    public void onCallEstablished(Call call) {
        DataHolder.getInstance().stop();
        a.setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
        callState.setText("");
        dec.setVisibility(View.GONE);
        if (! DataHolder.getInstance().isVidadd())
        {VideoController vc = DataHolder.getInstance().getClient().getVideoController();
         gl= (LinearLayout) a.findViewById(R.id.trust) ;
            gl.removeAllViews();
            gl.addView(vc.getLocalView());
            DataHolder.getInstance().setVidadd(true);}
    }

    @Override
    public void onCallEnded(Call call) {
        DataHolder.getInstance().setCall(null);
        Button button = (Button) a.findViewById(R.id.call) ;
        button.setText("Call");
        a.setVolumeControlStream(AudioManager.USE_DEFAULT_STREAM_TYPE);
        gl.removeAllViews();
        callState.setText("Call ended");
        DataHolder.getInstance().stop();
        dec.setVisibility(View.GONE);

    }

    @Override
    public void onShouldSendPushNotification(Call call, List<PushPair> list) {

    }
}

来电监听

public class SinchCallClientListener implements CallClientListener {
    Activity a ;
    Call call ;
    public SinchCallClientListener(Activity activity) {
        a=activity ;
    }

    @Override
    public void onIncomingCall(CallClient callClient, Call incomingCall) {
        Button button = (Button) a.findViewById(R.id.call) ;
        //call = incomingCall;
        //call.answer();
        if (! incomingCall.getDetails().isVideoOffered())
        {incomingCall.addCallListener(new SinchCallListener(a));}
        else
        {
            DataHolder.getInstance().setVidadd(false);
            incomingCall.addCallListener(new SinchVidListner(a));
        }
        DataHolder.getInstance().setCall(incomingCall);
        TextView callState = (TextView) a.findViewById(R.id.fullscreen_content);
        callState.setText("Ringing");
        button.setText("Answer");
        Button dec = (Button) a.findViewById(R.id.Decline) ;
        dec.setVisibility(View.VISIBLE);
        DataHolder.getInstance().play();

    }
}

来电/挂断/接听实现

public void makecall(View v)
   {//DataHolder.getInstance().getCall().addCallListener(new SinchCallListener(this));
        int type = DataHolder.getInstance().getType();
       call=DataHolder.getInstance().getCall() ;
       if (call == null) {//make a call
           if (type==R.id.next) //when it's a just voice call
           {call=sinchClient.getCallClient().callUser(recipientId) ;
           call.addCallListener(new SinchCallListener(this));}
           else //when it's a Video call
           {
               call=sinchClient.getCallClient().callUserVideo(recipientId) ;
               DataHolder.getInstance().setClient(sinchClient);
               call.addCallListener(new SinchVidListner(this));

           }
           DataHolder.getInstance().setCall(call);
           button.setText("Hang Up");

       } else if (button.getText()=="Hang Up"){ //hangup
           call.hangup();
           call=null ;
           DataHolder.getInstance().setCall(call) ;
           button.setText("Call");
       }
       else { //answer
           DataHolder.getInstance().stop();
           call.answer();
           if (type==R.id.next) //when it's a just voice call
           {call.addCallListener(new SinchCallListener(this));}
           else // it's video call
           {   DataHolder.getInstance().setClient(sinchClient);
               call.addCallListener(new SinchVidListner(this));}
           button.setText("Hang Up");
       }
   }

请随时向我询问进一步的说明,谢谢。

您需要在添加的视频轨道上添加远程视频

  @Override
public void onVideoTrackAdded(Call call) {
    // Get a reference to your SinchClient, in the samples this is done through the service interface:
    VideoController vc = getSinchServiceInterface().getVideoController();
    View myPreview = vc.getLocalView();
    View remoteView = vc.getRemoteView();
    // Add the views to your view hierarchy
    ...
}