//
// RemoteSource.js
//
// Copyright (c) 2019 2020 Andrea Bondavalli. All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
//
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import RestAPI from './Services';
import Loader from './Loader';
import SourceInfo from './SourceInfo';
require('./styles.css');
class RemoteSourceEntry extends Component {
static propTypes = {
source: PropTypes.string.isRequired,
id: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
domain: PropTypes.string.isRequired,
address: PropTypes.string.isRequired,
sdp: PropTypes.string.isRequired,
last_seen: PropTypes.number.isRequired,
period: PropTypes.number.isRequired,
onInfoClick: PropTypes.func.isRequired,
};
constructor(props) {
super(props);
this.state = {
rtp_address: 'n/a',
port: 'n/a'
};
}
handleInfoClick = () => {
this.props.onInfoClick(this.props.id);
};
componentDidMount() {
var rtp_address = this.props.sdp.match(/(c=IN IP4 )([0-9.]+)/g);
var port = this.props.sdp.match(/(m=audio )([0-9]+)/g);
if (rtp_address && port) {
this.setState({ rtp_address: rtp_address[0].substr(9), port: port[0].substr(8) });
}
}
render() {
return (