Android:quickblox 来电视频通话收不到

Posted

技术标签:

【中文标题】Android:quickblox 来电视频通话收不到【英文标题】:Android: quickblox incoming video call not receive 【发布时间】:2017-12-30 19:29:50 【问题描述】:

我使用quickblox 创建视频通话

开始通话,但对方用户无法使用传入服务

视频活动

public class VideoActivity extends E implements QBRTCClientSessionCallbacks,QBRTCClientVideoTracksCallbacks 

    private int userid;
    private Boolean isOutgoing,micE=true,vidE=true;
    private QBRTCSurfaceView surfaceView,remoteview;
    private MediaPlayer mp;
    private QBRTCSession currentsession;
    private QBMediaStreamManager mediaStreamManager;
    private ImageView mic,video;

    @Override
    protected void onCreate(Bundle savedInstanceState) 
        super.onCreate(savedInstanceState);
        setContentView(R.layout.video);
        userid=getIntent().getIntExtra("user", 1);
        userid = 39753771;
        isOutgoing=getIntent().getBooleanExtra("isoutgoing",false);
        isOutgoing = true;
        ProcessCalls();
        InitSignalling();
        if (isOutgoing) 
            //CallUser();
            SetCallerName(userid);
        
        Log.i("errorCheck", "Nz: " + userid);
        Log.i("errorCheck", "Na: " + isOutgoing);
        if(getIntent().getBooleanExtra("service",false))
            Log.i("errorCheck", "x");
        


        mic=(ImageView)findViewById(R.id.mic);
        mic.setOnClickListener(new View.OnClickListener() 
            @Override
            public void onClick(View v) 
                if (micE) 
                    micE = false;
                    AudioManage();
                 else 
                    micE = true;
                    AudioManage();
                
            
        );
        video=(ImageView)findViewById(R.id.video);
        video.setOnClickListener(new View.OnClickListener() 
            @Override
            public void onClick(View v) 
                if (vidE) 
                    vidE = false;
                    VideoManage();
                 else 
                    vidE = true;
                    VideoManage();
                
            
        );

        surfaceView =(QBRTCSurfaceView)findViewById(R.id.localView);
        surfaceView.setMirror(true);
        surfaceView.requestLayout();

        remoteview=(QBRTCSurfaceView)findViewById(R.id.opponentView);
        remoteview.requestLayout();
    

    private void SetCallerName(Integer callerID) 
        TextView callerName=(TextView)findViewById(R.id.callername);
        TextView callertime=(TextView)findViewById(R.id.callTime);
        callerName.setText(callerID + " , You:");
        if(isOutgoing)
            callertime.setText("Calling...");
        

    

    private void InitSignalling() 
        final QBChatService chatService = QBChatService.getInstance();


                Log.i("errorCheck", "ERR1: " + G.userQB);
                chatService.login(G.userQB, new QBEntityCallback() 
                    @Override
                    public void onSuccess(Object result, Bundle params) 
                        Log.i("errorCheck", "R0: " + result);
                        Log.i("errorCheck", "R1: " + params);

                        chatService.getVideoChatWebRTCSignalingManager().addSignalingManagerListener(new QBVideoChatSignalingManagerListener() 
                            @Override
                            public void signalingCreated(QBSignaling qbSignaling, boolean createdLocally) 
                                Log.i("errorCheck", "Q1: " + qbSignaling);
                                Log.i("errorCheck", "Q2: " + createdLocally);
                                if (!createdLocally) 
                                    QBRTCClient.getInstance(VideoActivity.this).addSignaling((QBWebRTCSignaling) qbSignaling);
                                
                            
                        );
                        QBRTCClient.getInstance(G.currentActivity).addSessionCallbacksListener((QBRTCSessionEventsCallback) G.currentActivity);

                        QBRTCConfig.setDebugEnabled(true);
                        QBRTCClient.getInstance(getApplicationContext()).prepareToProcessCalls();

                        Log.i("errorCheck", "chatService1: " + chatService);
                        if(G.userMobile.equals("09139479548")) 
                            CallUser();
                        
                    

                    @Override
                    public void onError(QBResponseException errors) 
                        Log.i("errorCheck", "E1: " + errors);
                    
                );
    

    private void ProcessCalls() 
        QBRTCClient.getInstance(this).prepareToProcessCalls();
    

    private void CallUser() 
        List<Integer> opponents = new ArrayList<Integer>();
        opponents.add(userid);

        Map<String, String> userInfo = new HashMap<>();
        userInfo.put("key", "value");

        QBRTCTypes.QBConferenceType qbConferenceType = QBRTCTypes.QBConferenceType.QB_CONFERENCE_TYPE_VIDEO;
        QBRTCSession session = QBRTCClient.getInstance(G.currentActivity).createNewSessionWithOpponents(opponents, qbConferenceType);

        session.addVideoTrackCallbacksListener(this);

        session.startCall(userInfo);
        Log.i("errorCheck", "QR1: " + session);
        SetCallButtonsDialing(session,userInfo);
        StartDialRinging();
    

    @Override
    public void onReceiveNewSession(QBRTCSession qbrtcSession) 
        Log.i("errorCheck","x");

        qbrtcSession.addVideoTrackCallbacksListener(this);
        Map<String,String> userInfo = qbrtcSession.getUserInfo();
        SetLayoutForReceiveCall(qbrtcSession,userInfo);
    

    private void SetLayoutForReceiveCall(final QBRTCSession qbrtcSession,final Map<String, String> userInfo) 
        final FrameLayout receive=(FrameLayout)findViewById(R.id.answerlayout);
        receive.setVisibility(View.VISIBLE);
        qbrtcSession.addVideoTrackCallbacksListener(this);
        final ImageView calll=(ImageView)findViewById(R.id.answerCall);
        calll.setOnClickListener(new View.OnClickListener() 
            @Override
            public void onClick(View v) 
                // Accept incoming call
                qbrtcSession.acceptCall(userInfo);
                receive.setVisibility(View.GONE);
                SetCallButtonsDialing(qbrtcSession, userInfo);
                StartTimer();
                if (mp != null && mp.isPlaying()) 
                    mp.stop();
                
            
        );

        findViewById(R.id.rejectcall).setOnClickListener(new View.OnClickListener() 
            @Override
            public void onClick(View v) 
                qbrtcSession.rejectCall(userInfo);
                VideoActivity.this.finish();
                if(mp!=null&&mp.isPlaying())
                
                    mp.stop();
                
            
        );
    



    @Override
    public void onUserNoActions(QBRTCSession qbrtcSession, Integer integer) 

        Toast.makeText(this, "no action by user", Toast.LENGTH_SHORT).show();
        if(mp!=null&&mp.isPlaying())
        
            mp.stop();
        
    

    @Override
    public void onSessionStartClose(QBRTCSession qbrtcSession) 
        qbrtcSession.addVideoTrackCallbacksListener(this);
        try 
            qbrtcSession.getMediaStreamManager().setVideoCapturer(new QBRTCCameraVideoCapturer(this, null));
            mediaStreamManager = qbrtcSession.getMediaStreamManager();
         catch (Exception e) 
            e.printStackTrace();
        
    

    @Override
    public void onUserNotAnswer(QBRTCSession qbrtcSession, Integer integer) 

        Toast.makeText(this, "No answer", Toast.LENGTH_SHORT).show();
        if(mp!=null&&mp.isPlaying())
        
            mp.stop();
        
        finish();
    

    @Override
    public void onCallRejectByUser(QBRTCSession qbrtcSession, Integer integer, Map<String, String> map) 
        Toast.makeText(this, "Call rejected", Toast.LENGTH_SHORT).show();
        if(mp!=null&&mp.isPlaying())
        
            mp.stop();
        
        finish();
    

    @Override
    public void onCallAcceptByUser(QBRTCSession qbrtcSession, Integer integer, Map<String, String> map) 
        qbrtcSession.addVideoTrackCallbacksListener(this);
        if(mp!=null&&mp.isPlaying())
        
            mp.stop();
        
        StartTimer();
    

    @Override
    public void onReceiveHangUpFromUser(QBRTCSession qbrtcSession, Integer integer, Map<String, String> map) 
        if(mp!=null&&mp.isPlaying())
        
            mp.stop();
        
        Toast.makeText(this, "Call ended by user", Toast.LENGTH_SHORT).show();
        finish();
    

    @Override
    public void onSessionClosed(QBRTCSession qbrtcSession) 
        if(mp!=null&&mp.isPlaying())
        
            mp.stop();
        
    

    @Override
    public void onLocalVideoTrackReceive(QBRTCSession qbrtcSession, QBRTCVideoTrack qbrtcVideoTrack) 
        Log.i("errorCheck", "WW1: " + qbrtcSession);
        qbrtcVideoTrack.addRenderer(new VideoRenderer(surfaceView));
        surfaceView.setMirror(true);
        surfaceView.requestLayout();
    

    @Override
    public void onRemoteVideoTrackReceive(QBRTCSession qbrtcSession, QBRTCVideoTrack qbrtcVideoTrack, Integer integer) 
        Log.i("errorCheck", "WW2: " + qbrtcSession);

        qbrtcVideoTrack.addRenderer(new VideoRenderer(remoteview));
        mediaStreamManager = qbrtcSession.getMediaStreamManager();
        remoteview.requestLayout();
    

    public void StartDialRinging()
        try 
            mp = MediaPlayer.create(getApplicationContext(), R.raw.beep);
            mp.setLooping(true);
            mp.start();
         catch (Exception e) 
            e.printStackTrace();
        
    

视频通话服务

public class VideoCallService extends Service implements QBRTCClientSessionCallbacks 
    private Timer mTimer = null;
    private Handler mHandler = new Handler();
    public static final int notify = 300000;

    public VideoCallService() 
    

    @Override
    public IBinder onBind(Intent intent) 

        return null;
    



    @Override
    public int onStartCommand(Intent intent, int flags, int startId) 
        try 
            Log.wtf("service", "start");

            if (mTimer != null) 
                Log.wtf("service", "All ready started");
             else 
                mTimer = new Timer();   //recreate new
                mTimer.scheduleAtFixedRate(new TimeDisplay(), 0, notify);
                LoginChatService();
                ProcessCalls();
                InitSignalling();
                QBRTCClient.getInstance(this).addSessionCallbacksListener(this);
            
        catch (Exception e)
            Log.wtf("ex",""+e);
        
        return START_NOT_STICKY;
    

    private void InitSignalling() 

        QBChatService.getInstance().getVideoChatWebRTCSignalingManager()
                .addSignalingManagerListener(new QBVideoChatSignalingManagerListener() 
                    @Override
                    public void signalingCreated(QBSignaling qbSignaling, boolean createdLocally) 
                        if (!createdLocally) 
                            QBRTCClient.getInstance(VideoCallService.this).addSignaling((QBWebRTCSignaling) qbSignaling);
                        
                    
                );

    

    private void ProcessCalls() 
        QBRTCClient.getInstance(this).prepareToProcessCalls();
    


    @Override
    public void onReceiveNewSession(QBRTCSession qbrtcSession) 
        //DataHolder.getInstance().setServiceData(qbrtcSession,qbrtcSession.getUserInfo());
        startActivity(new Intent(this,VideoActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).putExtra("service",true));
    

清单

<service
            android:name=".MyFirebaseMessagingService">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT"/>
            </intent-filter>
        </service>
        <service
            android:name=".MyFirebaseInstanceIDService">
            <intent-filter>
                <action android:name="com.google.firebase.INSTANCE_ID_EVENT"/>
            </intent-filter>
        </service>

        <service android:name=".VideoCallService" />

        <receiver
            android:name="com.google.android.gms.gcm.GcmReceiver"
            android:exported="true"
            android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category android:name="com.quickblox.sample.groupchatwebrtc" />
            </intent-filter>
        </receiver>

        <service
            android:name=".GcmPushListenerService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </service>

        <service
            android:name="com.quickblox.messages.services.gcm.QBGcmPushInstanceIDService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.android.gms.iid.InstanceID" />
            </intent-filter>
        </service>

        <meta-data android:name="com.quickblox.messages.TYPE" android:value="GCM" />
        <meta-data android:name="com.quickblox.messages.SENDER_ID" android:value="1" />
        <meta-data android:name="com.quickblox.messages.QB_ENVIRONMENT" android:value="DEVELOPMENT" />

开始通话后,为对手创建会话

这是我的用户调用者日志

I/org.webrtc.Logging: SurfaceViewRenderer: localView: onMeasure(). New size: 200x200
I/org.webrtc.Logging: EglRenderer: localView: setLayoutAspectRatio: 1.0
I/org.webrtc.Logging: EglRenderer: opponentView: setLayoutAspectRatio: 0.58536583
D/QBASDK: register network listener
D/QBASDK: Connected. Login to chat, currentUser JID: 39753009-65649, resource: android_ffffffff-ac04-0c2d-ffff-ffffd173e4c0
I/errorCheck: R0: null
I/errorCheck: R1: Bundle[]
D/RTCClient.:  Added session CALLBACK listenerapp.x.y.VideoActivity@4288e7f8
I/errorCheck: chatService1: com.quickblox.chat.QBChatService@42f6b478
D/RTCClient.: Call createNewSessionWithOpponents[39753771]conference type=QBConferenceTypevalue='1'
D/RTCClient.QBRTCSession: Create new session
I/errorCheck: Q1: com.quickblox.chat.QBWebRTCSignaling@43156ce0
I/errorCheck: Q2: true
D/RTCClient.: New signalling was added for participant39753771
D/RTCClient.QBRTCSession: Make new channel for oppoennt:39753771com.quickblox.videochat.webrtc.QBPeerChannel@42f23c00
D/RTCClient.QBRTCSession: isInitiator=true
D/RTCClient.QBRTCSession:  ADD VideoTrackCallbacksListener app.x.y.VideoActivity@4288e7f8
D/RTCClient.QBRTCSession: startCall
D/RTCClient.PeerFactoryManager: Creating Peer connection factory 
D/RTCClient.QBRTCSession.SessionWaitingTimers: Stop WaitTimer

但是对于未设置日志的对手(不是传入通知或...)

我该如何解决这个问题?

【问题讨论】:

【参考方案1】:

您可以参考此thread。检查video-sample。在此示例中通过接收推送实现了打开IncomingCallFragment。另外,如果您订阅成功,但没有收到推送,您可以随时检查以下内容:

    检查推送证书:管理面板 -> 推送通知 -> 设置 -> APNS、GCM 等 从管理面板发送推送 -> 推送通知 -> 发送 (link) 您也可以在管理面板中查看推送通知队列选项卡,应该有您的推送日志。它将帮助您了解您的设备发生了什么。

希望这会有所帮助!

【讨论】:

以上是关于Android:quickblox 来电视频通话收不到的主要内容,如果未能解决你的问题,请参考以下文章

使用 Quickblox SDK for Android 更改视频通话的视频通话属性?

Android:quickblox传入的视频通话未收到

android quickBlox 视频通话代码强制关闭点击接收按钮点击

为啥只能在 Android SDK QuickBlox 上进行第一次视频通话?

无法使用 quickblox 在 android 6 上进行视频通话

Quickblox:对离线用户进行视频通话的策略是啥