• 十天冲刺(第二阶段)


    一、说在前面

     这是两天的成果有一天忘了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;
    
                }
    

      

  • 相关阅读:
    Unity3d 检查哪些prefab引用了某个UIAtlas
    Unity3D研究院之Prefab里面的Prefab关联问题(转)
    Unity3d 制作动态Mesh且可以随地面凹凸起伏
    Unity3d 制作物品平滑运动
    Unity3d 保存和使用地形高度
    【小姿势】如何搭建ipa下载web服务器(直接在手机打开浏览器安装)
    NGUI 不写一行代码实现翻拍效果
    Unity Assets目录下的特殊文件夹名称
    Unity3d 扩展自定义类Inspector
    MMO可见格子算法
  • 原文地址:https://www.cnblogs.com/guziteng1/p/13044511.html
Copyright © 2020-2023  润新知