Удаленное потоковое видео с использованием Janus-шлюза, не отображаемого в реагирующем - PullRequest
0 голосов
/ 26 февраля 2020

Я пытаюсь отобразить удаленное потоковое видео с помощью шлюза 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)

Я использую реагировать-native-webrt c v: 1.75.3 Reaction-native: 0.60.5

Я вызываю Януса таким образом в моем компоненте: Вот мой код:

`класс экспорта по умолчанию 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} /> );}; }

...