Here is the code snippet
import { RTCView } from 'react-native-webrtc';
class VideoComponent extends Component{
constructor(props){
super(props)
this.state={
connectionSide: null,
connectionTop: null,
}
this.iceServers = null;
const { viewStreamAccount, viewStreamId1, viewStreamId2 } = this.props.streamData;
this.side = sideStreamConfig(viewStreamAccount, viewStreamId1);
this.top = topStreamConfig(viewStreamAccount, viewStreamId2);
this.millicastClientSide = createMillicastClient(this.side);
this.millicastClientTop = createMillicastClient(this.top);
}
async componentDidMount() {
try {
const connectionSide = await this.connectToVideoStream(this.millicastClientSide, this.side);
const connectionTop = await this.connectToVideoStream(this.millicastClientTop, this.top);
this.setState({
connectionSide,
connectionTop,
});
} catch (error) {
this.handleError();
}
await this.updateQueueInfo();
}
connectToVideoStream = async (client, clientConfig) => {
if (!this.iceServers) {
this.iceServers = await client.getIceServers();
}
const { viewerStreamAccountId, viewerStreamId } = streamConfig;
const wsUrl = await client.viewDirector(viewerStreamAccountId, viewerStreamId);
const connection = await client.viewStream(wsUrl, viewerStreamId, this.iceServers);
return connection;
};
render(){
return(
<View>
<RTCView streamURL={connectionSide.stream.toURL()} objectFit="cover" />
<RTCView streamURL={connectionTop.stream.toURL()} objectFit="cover" />
</View>
)
}
}