• 十天冲刺(第二阶段)


    一、说在前面

     这是两天的成果有一天忘了sorry老师

    二、完成情况

      今天基本上是完成了视频通话因为语音通话的两者差别基本不打所以语音通话还是上手比较容易的。

      CloudManager.getInstance().setReceivedCallListener(new IRongReceivedCallListener() {
                @Override
                public void onReceivedCall(RongCallSession rongCallSession) {
                   // String call=new Gson().toJson(rongCallSession);
    
                    LogUtils.i("rongCallSession");
    
                    if (!CloudManager.getInstance().isVoIPEnabled(CloudService.this))
                    {
                        return;
                    }
                    //呼叫端
                  String callUserId=  rongCallSession.getCallerUserId();
                  callId=  rongCallSession.getCallId();
                  //播放来电铃声
                    mAudioCallMedia.startPlay(CloudManager.callAudioPath);
                    updateWindowInfo(0, rongCallSession.getMediaType(),callUserId);
    
                    if (rongCallSession.getMediaType().equals(RongCallCommon.CallMediaType.AUDIO))
                    {
                        LogUtils.i("音频通话");
    
                        WindowHelper.getInstance().showView(mFullAudioView);
                    }else if (rongCallSession.getMediaType().equals(RongCallCommon.CallMediaType.VIDEO))
                    {
                        LogUtils.i("vieo");
                        WindowHelper.getInstance().showView(mFullVideoView);
                    }
                    isReceiverTo = 1;
                    isCallOrReceiver=false;
                }
    
                @Override
                public void onCheckPermission(RongCallSession rongCallSession) {
                    LogUtils.i("onCheckPermission"+rongCallSession.toString());
                }
            });
            //监听通话状态
            CloudManager.getInstance().setVoIPCallListener(new IRongCallListener() {
                @Override
                public void onCallOutgoing(RongCallSession rongCallSession, SurfaceView surfaceView) {
             //       String call=new Gson().toJson(rongCallSession);
    
                    LogUtils.i("onCallOutgoing");
                    isCallTo=1;
                    isCallOrReceiver=true;
                    //更新信息
                    String targetId=rongCallSession.getTargetId();
                    updateWindowInfo(1,rongCallSession.getMediaType(),targetId);
    //通话Id
                    callId=  rongCallSession.getCallId();
    
                    if (rongCallSession.getMediaType().equals(RongCallCommon.CallMediaType.AUDIO))
                    {
                        LogUtils.i("音频通话");
                        WindowHelper.getInstance().showView(mFullAudioView);
                    }else if (rongCallSession.getMediaType().equals(RongCallCommon.CallMediaType.VIDEO))
                    {
                        LogUtils.i("音频通话");
                        WindowHelper.getInstance().showView(mFullVideoView);
                        //显示 摄像头
                        mLocalView=surfaceView;
                        video_big_video.addView(mLocalView);
                    }
                }
    
                @Override
                public void onCallConnected(RongCallSession rongCallSession, SurfaceView surfaceView) {
          //          String call=new Gson().toJson(rongCallSession);
    
                    LogUtils.i("onCallConnected");
                    isCallTo=2;
                    isReceiverTo=2;
                    //关闭铃声
                    if (mAudioCallMedia.isPlaying()) {
                        mAudioCallMedia.stopPlay();
                    }
    
                    //开始计时
                    mHandler.sendEmptyMessage(H_TIME_WHAT);
    
                    if (rongCallSession.getMediaType().equals(RongCallCommon.CallMediaType.AUDIO)) {
                        goneAudioView(true, false, true, true, true);
                    } else if (rongCallSession.getMediaType().equals(RongCallCommon.CallMediaType.VIDEO)) {
                        goneVideoView(false, true, true, false, true,true);
                        mLocalView = surfaceView;
                    }
                }
    
                @Override
                public void onCallDisconnected(RongCallSession rongCallSession, RongCallCommon.CallDisconnectedReason callDisconnectedReason) {
                //    String call = new Gson().toJson(rongCallSession);
    
                    LogUtils.i("onCallDisconnected");
                    String callUserId = rongCallSession.getCallerUserId();
                    String recevierId = rongCallSession.getTargetId();
    
                    //关闭计时
                    mHandler.removeMessages(H_TIME_WHAT);
    
                    //铃声挂断
                    mAudioCallMedia.pausePlay();
    
                    //播放挂断铃声
                    mAudioHangupMedia.startPlay(CloudManager.callAudioHangup);
    
                    //重置计时器
                    callTimer = 0;
    
                    if (rongCallSession.getMediaType().equals(RongCallCommon.CallMediaType.AUDIO)) {
                       if (isCallOrReceiver) {
                            if (isCallTo == 1) {
                                //代表只拨打,但是并没有接通
                                saveAudioRecord(recevierId, CallRecord.CALL_STATUS_DIAL);
                            } else if (isCallTo == 2) {
                                saveAudioRecord(recevierId, CallRecord.CALL_STATUS_ANSWER);
                            }
                        } else {
                            if (isReceiverTo == 1) {
                                saveAudioRecord(callUserId, CallRecord.CALL_STATUS_UN_ANSWER);
                            } else if (isReceiverTo == 2) {
                                saveAudioRecord(callUserId, CallRecord.CALL_STATUS_ANSWER);
                            }
                        }
                        WindowHelper.getInstance().hideView(mFullAudioView);
                      WindowHelper.getInstance().hideView(mSmallAudioView);
                    } else if (rongCallSession.getMediaType().equals(RongCallCommon.CallMediaType.VIDEO)) {
                        WindowHelper.getInstance().hideView(mFullVideoView);
    
                        if (isCallOrReceiver) {
                           if (isCallTo == 1) {
                                //代表只拨打,但是并没有接通
                                saveVideoRecord(recevierId, CallRecord.CALL_STATUS_DIAL);
                            } else if (isCallTo == 2) {
                                saveVideoRecord(recevierId, CallRecord.CALL_STATUS_ANSWER);
                            }
                        } else {
                          if (isReceiverTo == 1) {
                               saveVideoRecord(callUserId, CallRecord.CALL_STATUS_UN_ANSWER);
                         } else if (isReceiverTo == 2) {
                              saveVideoRecord(callUserId, CallRecord.CALL_STATUS_ANSWER);
                           }
    
                        }
    
    
    
                    }
    
                        //如果出现异常,可能无法退出
    
                    isCallTo=0;
                    isReceiverTo=0;
    
                }
    

      

  • 相关阅读:
    第一个ADO.NET连接SQl server数据库
    Mysql编码
    SNMP协议报文分析
    物理层计算
    随机产生数组
    c#排序
    c#计算一段代码的时间复杂度
    jwt认证
    drf三大组件之频率认证组件
    drf三大组件之认证组件与权限组件
  • 原文地址:https://www.cnblogs.com/guziteng1/p/13044511.html
Copyright © 2020-2023  润新知