react-native - 使用 Janus-gateway 的远程视频流不显示在 react-native 中

标签 react-native janus-gateway

我正在尝试在我的 React Native 项目中使用 janus 网关显示远程流视频。 我正在使用这个包:https://github.com/oney/react-native-webrtc在我的组件和 janus 库(janus.mobile.js 文件)中显示流媒体视频 https://github.com/atyenoria/react-native-webrtc-janus-gateway/blob/master/src/janus.mobile.js

我的 onremotestream 功能被触发但我一直收到黑屏而不是我的流媒体视频。(android 和 ios)

我正在使用 react-native-webrtc v : 1.75.3 react native :0.60.5

我在我的组件中这样调用 Janus: 这是我的代码:

`export default class VideoExample extends Component { componentDidMount() { containerStreaming = this;

    Janus.init({debug: "all", callback: function() {
            if(started)
                return;
            started = true;
        }});

    this.janusStart();
}

janusStart = () => {
    containerStreaming.setState({ visible: true });
            let janus = new Janus({
                server: containerStreaming.props.server,
                iceServers: containerStreaming.props.iceServers,
                token: containerStreaming.props.token,

                success: function() {
                    janus.attach({
                        plugin: "janus.plugin.streaming",

                        success: function(pluginHandle) {
                            streaming = pluginHandle;
                            Janus.log(`Janus Plugin Attached : ${pluginHandle.getId()}`);
                            streaming.send({ "message": {"request": "watch", id: containerStreaming.props.id } });
                        },
                        error: function(error) {
                            Janus.error(`Error Attaching Janus Plugin ${error}`)
                        },
                        mediaState: function(medium, on) {
                            containerStreaming.setState({status: 'stopped', info: 'Stopped'});
                            Janus.log("Janus " + (on ? "started" : "stopped") + " receiving our " + medium);
                        },
                        webrtcState: function(on) {
                            console.log("Janus says our WebRTC PeerConnection is " + (on ? "up" : "down") + " now");
                            // $("#videolocal").parent().parent().unblock();
                        },
                        onmessage: function(msg, jsep) {
                            console.log("jsep" ,jsep.sdp);
                            Janus.log(`Janus Message received : ${JSON.stringify(msg)} and jsep ${jsep}`);
                            var result = msg['result'];
                            if (!!result && result['status'] == 'stopped') {
                                janus.destroy();
                                return;
                            }
                            if (jsep !== null && jsep !== undefined) {
                                Janus.log(`JANUS : Handling SDP as well : ${jsep}`);
                                streaming.createAnswer({
                                    jsep: jsep,
                                    media: { audioSend: false, videoSend: false }, // recvonly
                                    success: function(jsep){
                                        Janus.debug(`Janus Got SDP : ${jsep}`);
                                        streaming.send({ message: { request: 'start' }, jsep: jsep });
                                    },
                                    error: function(error) {
                                        Janus.error(`Janus WebRTC error : ${error}`)
                                    }
                                });
                            }
                        },
                        onremotestream: function(stream) {
                            Janus.log('Janus Remote stream detected');
                            Janus.log(stream);
                            containerStreaming.setState({status: 'streaming', info: 'Streaming'});
                            containerStreaming.setState({selfViewSrc: stream.toURL()});
                        },
                        oncleanup: function() {
                            Janus.log('Janus clean up notification')
                        }
                    })
                },
                error: function(error) {
                    Janus.error('Janus  -- ' + error);
                    Janus.error('Destroying Janus');
                    janus.destroy();
                },
                destroyed: function() {
                    window.location.reload();
                },

            });
};

`

render() { return ( <RTCView zOrder={0} streamURL={this.state.selfViewSrc} style={styles.streamingStyle} /> );}; }

最佳答案

使用 cefsharp.Net 的桌面 Chromium 应用程序也是如此

关于react-native - 使用 Janus-gateway 的远程视频流不显示在 react-native 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60415418/

相关文章:

javascript - 交换视频标签会使整个 div 变空

FFMPEG 将 rtp 流转换为 rtmp - 绑定(bind)失败的地址已在使用中

reactjs - {React Native} 提交后重置 Formik 表单

android - 如何修复 "BUILD FAILED"android react native 说错误 : package android. support.annotation 不存在

java - 如何使用 Android Studio 调试原生 React 原生库?

webrtc - 如何将 webRTC 内容提供商连接到 Janus-Gateway 流媒体插件

ios - 连接到 janus 服务器总是挂起,并显示来自 janus 的挂断消息

typescript - 无法将 babel-plugin-module-resolver 与 expo 和 react-native 一起使用

react-native - 您为我们提供了节点类型 "ForAwaitStatement"的访问者,但它不是有效类型

webrtc - Ant Media、Jitsi 和 Janus 哪一个最适合在移动应用程序中开始一对多的实时语音流?