Quickblox Flutter SDK-正在进行通话,但视频没有流

问题描述

我是新手,它已经过去了几天,我正在努力使用alpha sdk进行视频通话。我可以拨打电话,可以听见音频,但不能播放视频(没有本地视频,也没有远程视频流)

所有权限都从设置中授予应用。

Android手机转android模拟器-音频正常工作,但没有视频 Android手机到Android手机-音频正常工作,但没有视频 Android手机转IOS模拟器-音频正常工作,但无视频。

  • SDK初始化很好

  • 聊天已连接

  • WebRTC初始化在调用之前可以正常工作。

  • 我进行视频通话

      startCall(opponentIds) async{
    
      bool connected = await QB.chat.isConnected();
      print('starting call'+connected.toString());
      int sessionType = QBRTCSessionTypes.VIDEO;
    
      try {
        QBRTCSession session = await QB.webrtc.call(opponentIds,sessionType);
        print('starting call'+session.toString());
        sessionId = session.id;
        play(myQBUserId,opponentIds[0],session.id);
      } on PlatformException catch (e) {
        print('error while initializing call'+e.toString());
      }
    }
    
  • ListenforCall

      _listenForCall() async {
      print('listening for call');
      String eventName = QBRTCEventTypes.CALL;
      try {
        await QB.webrtc.subscribeRTCEvent(eventName,(data) async {
          Map<String,Object> payloadMap = new Map<String,Object>.from(data["payload"]);
          Map<String,Object> sessionMap = new Map<String,Object>.from(payloadMap["session"]);
          String sessionId = sessionMap["id"];
          int initiatorId = sessionMap["initiatorId"];
          int callType = sessionMap["type"];
    
          setState(() {
            this.sessionId = sessionId;
            _incomingCall = true;
          });
          play(myQBUserId,initiatorId,sessionId);
        });
    
        await QB.webrtc.subscribeRTCEvent(QBRTCEventTypes.RECEIVED_VIDEO_TRACK,Object>.from(payloadMap["session"]);
          String sessionId = sessionMap["id"];
          int initiatorId = sessionMap["initiatorId"];
          int callType = sessionMap["type"];
    
          print('receiving video even from initiator:'+initiatorId.toString());
    
          this.sessionId = sessionId;
          setState(() {
            _callStarted = true;
          });
    
          await QB.webrtc.enableAudio(sessionId,enable: true);
    
          await QB.webrtc.enableVideo(sessionId,enable: true);
    
        });
    
      } on PlatformException catch (e) {
        print('error while listening for calls'+e.toString());
      }
    }
    
  • 接听电话

      _acceptCall() async{
      try {
    
        QBRTCSession session = await QB.webrtc.accept(sessionId);
        print('listening call'+session.id+',initiatorid:'+session.initiatorId.toString());
        sessionId = session.id;
        play(myQBUserId,session.initiatorId,sessionId);
        setState(() {
          _callStarted = true;
        });
    
      } on PlatformException catch (e) {
        // Some error occured,look at the exception message for more details
      }
    }
    
  • 结束通话

      _endCall() async{
      try {
        QBRTCSession session = await QB.webrtc.hangUp(sessionId);
        setState(() {
          _callStarted = false;
          _incomingCall = false;
        });
      } on PlatformException catch (e) {
        // Some error occured,look at the exception message for more details
      }
    }
    
  • 来自-https://docs.quickblox.com/docs/flutter-video-calling#setup-video-chat-layouts

    视频通话布局
    RTCVideoViewController _localVideoViewController;
RTCVideoViewController _remoteVideoViewController;
...
child: new Container(
  margin: new EdgeInsets.fromLTRB(10.0,10.0,10.0),width: 160.0,height: 160.0,child: RTCVideoView(
    onVideoViewCreated: _onLocalVideoViewCreated,),decoration: new Boxdecoration(color: Colors.black54),)
 
...

child: new Container(
  margin: new EdgeInsets.fromLTRB(10.0,child: RTCVideoView(
    onVideoViewCreated: _onRemoteVideoViewCreated,)
  
...

void _onLocalVideoViewCreated(RTCVideoViewController controller) {
  _localVideoViewController = controller;
}

void _onRemoteVideoViewCreated(RTCVideoViewController controller) {
  _remoteVideoViewController = controller;
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)