无法在 WebRTC 中绑定 EAGLDrawable 反应本机

Failed to bind EAGLDrawable in WebRTC react native

我将使用 React native iOS 通过 webRTC 创建视频聊天。为此,我为 iOS 编写了 React 本机代码。它要求我访问相机,但之后它无法加载视频并抛出一条警告消息,

Failed to bind EAGLDrawable: <CAEAGLLayer: 0x16d50e30> to GL_RENDERBUFFER 1
Failed to make complete framebuffer object 8cd6

我知道上面的警告是由于没有获取相机视图以渲染视频帧。但是我不知道我的反应代码有什么问题,它没有给它框架,我的代码如下,

import React, {
  AppRegistry,
  Component,
  StyleSheet,
  Text,
  View
} from 'react-native';

var WebRTC = require('react-native-webrtc');
var {
  RTCPeerConnection,
  RTCMediaStream,
  RTCIceCandidate,
  RTCSessionDescription,
  RTCView
} = WebRTC;


var container;
var configuration = {"iceServers": [{"url": "stun:stun.l.google.com:19302"}]};
  var pc = new RTCPeerConnection(configuration);
  navigator.getUserMedia({ "audio": true, "video": true }, function (stream) {
    pc.addStream(stream);
  });
  pc.createOffer(function(desc) {
    pc.setLocalDescription(desc, function () {
    // Send pc.localDescription to peer
  }, function(e) {});
  }, function(e) {});
  pc.onicecandidate = function (event) {
  // send event.candidate to peer
};

var RCTWebRTCDemo = React.createClass({
  getInitialState: function() {
    return {videoURL: null};
  },
  componentDidMount: function() {
    container = this;
  },
  render: function() {
    return (
      <View style={styles.container}>
        <RTCView streamURL={this.state.videoURL}/>
      </View>
    );
  }
});

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

AppRegistry.registerComponent('RCTWebRTCDemo', () => RCTWebRTCDemo);

我很想知道我哪里错了?

我在

之前设置了框架
<View style={styles.container}>
        <RTCView streamURL={this.state.videoURL}/>
 </View>

但这是错误的。 RTCView 的创建略有不同,因此我们在 RTCView 语法中设置框架。正确的方法是,

       <View>
        <RTCView streamURL={this.state.videoURL} style={styles.container}/>
      </View>