使用Janus网关的远程视频流未在本机显示
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用Janus网关的远程视频流未在本机显示相关的知识,希望对你有一定的参考价值。
我正在尝试在我的本机项目中使用janus网关显示远程流式视频。我正在使用此软件包:https://github.com/oney/react-native-webrtc从此处https://github.com/atyenoria/react-native-webrtc-janus-gateway/blob/master/src/janus.mobile.js
在我的组件和janus库(janus.mobile.js文件)中显示流式视频。我的onremotestream函数已触发,但是我一直收到黑屏,而不是流视频。(包括android和ios)
我正在使用react-native-webrtc v:1.75.3反应本机:0.60.5
我在组件中这样称呼Janus:这是我的代码:
`导出默认类VideoExample扩展了组件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 />
);;
我有同样的问题。您解决了这个问题吗?如是。您能帮我解决这个问题吗?>
以上是关于使用Janus网关的远程视频流未在本机显示的主要内容,如果未能解决你的问题,请参考以下文章