Merge branch 'match'

pull/3/head
Tom Early 2 years ago
commit 381268fb0b

@ -1,7 +1,7 @@
<?php <?php
class xReflector { class xReflector {
public $Nodes = null; public $Nodes = null;
public $Stations = null; public $Stations = null;
public $Peers = null; public $Peers = null;
@ -27,7 +27,7 @@ class xReflector {
public $Interlinks = null; public $Interlinks = null;
private $InterlinkXML = null; private $InterlinkXML = null;
private $ReflectorXML = null; private $ReflectorXML = null;
public function __construct() { public function __construct() {
$this->Nodes = array(); $this->Nodes = array();
$this->Stations = array(); $this->Stations = array();
@ -35,61 +35,61 @@ class xReflector {
$this->Interlinks = array(); $this->Interlinks = array();
$this->Transferinterlink = false; $this->Transferinterlink = false;
} }
public function LoadXML() { public function LoadXML() {
if ($this->XMLFile != null) { if ($this->XMLFile != null) {
$handle = fopen($this->XMLFile, 'r'); $handle = fopen($this->XMLFile, 'r');
$this->XMLContent = fread($handle, filesize($this->XMLFile)); $this->XMLContent = fread($handle, filesize($this->XMLFile));
fclose($handle); fclose($handle);
$this->ServiceName = substr($this->XMLContent, strpos($this->XMLContent, "<XLX")+4, 3); $this->ServiceName = substr($this->XMLContent, strpos($this->XMLContent, "<XLX")+4, 3);
if (!is_numeric($this->ServiceName)) { if (preg_match('/[^a-zA-Z0-9]/', $this->ServiceName) == 1) {
$this->ServiceName = null; $this->ServiceName = null;
return false; return false;
} }
$this->ReflectorName = "XLX".$this->ServiceName; $this->ReflectorName = "XLX".$this->ServiceName;
$LinkedPeersName = "XLX".$this->ServiceName." linked peers"; $LinkedPeersName = "XLX".$this->ServiceName." linked peers";
$LinkedNodesName = "XLX".$this->ServiceName." linked nodes"; $LinkedNodesName = "XLX".$this->ServiceName." linked nodes";
$LinkedUsersName = "XLX".$this->ServiceName." heard users"; $LinkedUsersName = "XLX".$this->ServiceName." heard users";
$XML = new ParseXML(); $XML = new ParseXML();
$AllNodesString = $XML->GetElement($this->XMLContent, $LinkedNodesName); $AllNodesString = $XML->GetElement($this->XMLContent, $LinkedNodesName);
$tmpNodes = $XML->GetAllElements($AllNodesString, "NODE"); $tmpNodes = $XML->GetAllElements($AllNodesString, "NODE");
for ($i=0;$i<count($tmpNodes);$i++) { for ($i=0;$i<count($tmpNodes);$i++) {
$Node = new Node($XML->GetElement($tmpNodes[$i], 'Callsign'), $XML->GetElement($tmpNodes[$i], 'IP'), $XML->GetElement($tmpNodes[$i], 'LinkedModule'), $XML->GetElement($tmpNodes[$i], 'Protocol'), $XML->GetElement($tmpNodes[$i], 'ConnectTime'), $XML->GetElement($tmpNodes[$i], 'LastHeardTime'), CreateCode(16)); $Node = new Node($XML->GetElement($tmpNodes[$i], 'Callsign'), $XML->GetElement($tmpNodes[$i], 'IP'), $XML->GetElement($tmpNodes[$i], 'LinkedModule'), $XML->GetElement($tmpNodes[$i], 'Protocol'), $XML->GetElement($tmpNodes[$i], 'ConnectTime'), $XML->GetElement($tmpNodes[$i], 'LastHeardTime'), CreateCode(16));
$this->AddNode($Node); $this->AddNode($Node);
} }
$AllStationsString = $XML->GetElement($this->XMLContent, $LinkedUsersName); $AllStationsString = $XML->GetElement($this->XMLContent, $LinkedUsersName);
$tmpStations = $XML->GetAllElements($AllStationsString, "STATION"); $tmpStations = $XML->GetAllElements($AllStationsString, "STATION");
for ($i=0;$i<count($tmpStations);$i++) { for ($i=0;$i<count($tmpStations);$i++) {
$Station = new Station($XML->GetElement($tmpStations[$i], 'Callsign'), $XML->GetElement($tmpStations[$i], 'Via node'), $XML->GetElement($tmpStations[$i], 'Via peer'), $XML->GetElement($tmpStations[$i], 'LastHeardTime'), $XML->GetElement($tmpStations[$i], 'On module')); $Station = new Station($XML->GetElement($tmpStations[$i], 'Callsign'), $XML->GetElement($tmpStations[$i], 'Via node'), $XML->GetElement($tmpStations[$i], 'Via peer'), $XML->GetElement($tmpStations[$i], 'LastHeardTime'), $XML->GetElement($tmpStations[$i], 'On module'));
$this->AddStation($Station, false); $this->AddStation($Station, false);
} }
$AllPeersString = $XML->GetElement($this->XMLContent, $LinkedPeersName); $AllPeersString = $XML->GetElement($this->XMLContent, $LinkedPeersName);
$tmpPeers = $XML->GetAllElements($AllPeersString, "PEER"); $tmpPeers = $XML->GetAllElements($AllPeersString, "PEER");
for ($i=0;$i<count($tmpPeers);$i++) { for ($i=0;$i<count($tmpPeers);$i++) {
$Peer = new Peer($XML->GetElement($tmpPeers[$i], 'Callsign'), $XML->GetElement($tmpPeers[$i], 'IP'), $XML->GetElement($tmpPeers[$i], 'LinkedModule'), $XML->GetElement($tmpPeers[$i], 'Protocol'), $XML->GetElement($tmpPeers[$i], 'ConnectTime'), $XML->GetElement($tmpPeers[$i], 'LastHeardTime')); $Peer = new Peer($XML->GetElement($tmpPeers[$i], 'Callsign'), $XML->GetElement($tmpPeers[$i], 'IP'), $XML->GetElement($tmpPeers[$i], 'LinkedModule'), $XML->GetElement($tmpPeers[$i], 'Protocol'), $XML->GetElement($tmpPeers[$i], 'ConnectTime'), $XML->GetElement($tmpPeers[$i], 'LastHeardTime'));
$this->AddPeer($Peer, false); $this->AddPeer($Peer, false);
} }
$this->Version = $XML->GetElement($this->XMLContent, "Version"); $this->Version = $XML->GetElement($this->XMLContent, "Version");
} }
} }
public function GetVersion() { public function GetVersion() {
return $this->Version; return $this->Version;
} }
public function GetReflectorName() { public function GetReflectorName() {
return $this->ReflectorName; return $this->ReflectorName;
} }
public function SetXMLFile($XMLFile) { public function SetXMLFile($XMLFile) {
if (file_exists($XMLFile) && (is_readable($XMLFile))) { if (file_exists($XMLFile) && (is_readable($XMLFile))) {
$this->XMLFile = $XMLFile; $this->XMLFile = $XMLFile;
@ -99,7 +99,7 @@ class xReflector {
$this->XMLContent = null; $this->XMLContent = null;
} }
} }
public function SetPIDFile($ProcessIDFile) { public function SetPIDFile($ProcessIDFile) {
if (file_exists($ProcessIDFile)) { if (file_exists($ProcessIDFile)) {
$this->ProcessIDFile = $ProcessIDFile; $this->ProcessIDFile = $ProcessIDFile;
@ -110,11 +110,11 @@ class xReflector {
$this->ServiceUptime = null; $this->ServiceUptime = null;
} }
} }
public function GetServiceUptime() { public function GetServiceUptime() {
return $this->ServiceUptime; return $this->ServiceUptime;
} }
public function SetFlagFile($Flagfile) { public function SetFlagFile($Flagfile) {
if (file_exists($Flagfile) && (is_readable($Flagfile))) { if (file_exists($Flagfile) && (is_readable($Flagfile))) {
$this->Flagfile = $Flagfile; $this->Flagfile = $Flagfile;
@ -122,7 +122,7 @@ class xReflector {
} }
return false; return false;
} }
public function LoadFlags() { public function LoadFlags() {
if ($this->Flagfile != null) { if ($this->Flagfile != null) {
$this->Flagarray = array(); $this->Flagarray = array();
@ -133,18 +133,18 @@ class xReflector {
while(!feof($handle)) { while(!feof($handle)) {
$row = fgets($handle,1024); $row = fgets($handle,1024);
$tmp = explode(";", $row); $tmp = explode(";", $row);
if (isset($tmp[0])) { $this->Flagarray[$i]['Country'] = $tmp[0]; } else { $this->Flagarray[$i]['Country'] = 'Undefined'; } if (isset($tmp[0])) { $this->Flagarray[$i]['Country'] = $tmp[0]; } else { $this->Flagarray[$i]['Country'] = 'Undefined'; }
if (isset($tmp[1])) { $this->Flagarray[$i]['ISO'] = $tmp[1]; } else { $this->Flagarray[$i]['ISO'] = "Undefined"; } if (isset($tmp[1])) { $this->Flagarray[$i]['ISO'] = $tmp[1]; } else { $this->Flagarray[$i]['ISO'] = "Undefined"; }
//$this->Flagarray[$i]['DXCC'] = array(); //$this->Flagarray[$i]['DXCC'] = array();
if (isset($tmp[2])) { if (isset($tmp[2])) {
$tmp2 = explode("-", $tmp[2]); $tmp2 = explode("-", $tmp[2]);
for ($j=0;$j<count($tmp2);$j++) { for ($j=0;$j<count($tmp2);$j++) {
//$this->Flagarray[$i]['DXCC'][] = $tmp2[$j]; //$this->Flagarray[$i]['DXCC'][] = $tmp2[$j];
$this->Flagarray_DXCC[ trim($tmp2[$j]) ] = $i; $this->Flagarray_DXCC[ trim($tmp2[$j]) ] = $i;
} }
} }
$i++; $i++;
} }
fclose($handle); fclose($handle);
} }
@ -152,17 +152,17 @@ class xReflector {
} }
return false; return false;
} }
public function AddNode($NodeObject) { public function AddNode($NodeObject) {
if (is_object($NodeObject)) { if (is_object($NodeObject)) {
$this->Nodes[] = $NodeObject; $this->Nodes[] = $NodeObject;
} }
} }
public function NodeCount() { public function NodeCount() {
return count($this->Nodes); return count($this->Nodes);
} }
public function GetNode($ArrayIndex) { public function GetNode($ArrayIndex) {
if (isset($this->Nodes[$ArrayIndex])) { if (isset($this->Nodes[$ArrayIndex])) {
return $this->Nodes[$ArrayIndex]; return $this->Nodes[$ArrayIndex];
@ -175,11 +175,11 @@ class xReflector {
$this->Peers[] = $PeerObject; $this->Peers[] = $PeerObject;
} }
} }
public function PeerCount() { public function PeerCount() {
return count($this->Peers); return count($this->Peers);
} }
public function GetPeer($ArrayIndex) { public function GetPeer($ArrayIndex) {
if (isset($this->Peer[$ArrayIndex])) { if (isset($this->Peer[$ArrayIndex])) {
return $this->Peer[$ArrayIndex]; return $this->Peer[$ArrayIndex];
@ -189,34 +189,34 @@ class xReflector {
public function AddStation($StationObject, $AllowDouble = false) { public function AddStation($StationObject, $AllowDouble = false) {
if (is_object($StationObject)) { if (is_object($StationObject)) {
if ($AllowDouble) { if ($AllowDouble) {
$this->Stations[] = $StationObject; $this->Stations[] = $StationObject;
} }
else { else {
$FoundStationInList = false; $FoundStationInList = false;
$i = 0; $i = 0;
$tmp = explode(" ", $StationObject->GetCallsign()); $tmp = explode(" ", $StationObject->GetCallsign());
$RealCallsign = trim($tmp[0]); $RealCallsign = trim($tmp[0]);
while (!$FoundStationInList && $i<$this->StationCount()) { while (!$FoundStationInList && $i<$this->StationCount()) {
if ($this->Stations[$i]->GetCallsignOnly() == $RealCallsign) { if ($this->Stations[$i]->GetCallsignOnly() == $RealCallsign) {
$FoundStationInList = true; $FoundStationInList = true;
} }
$i++; $i++;
} }
if (!$FoundStationInList) { if (!$FoundStationInList) {
if (strlen(trim($RealCallsign)) > 3) { if (strlen(trim($RealCallsign)) > 3) {
$this->Stations[] = $StationObject; $this->Stations[] = $StationObject;
} }
} }
} }
} }
} }
public function GetSuffixOfRepeater($Repeater, $LinkedModul, $StartWithIndex = 0) { public function GetSuffixOfRepeater($Repeater, $LinkedModul, $StartWithIndex = 0) {
$suffix = ""; $suffix = "";
$found = false; $found = false;
@ -232,7 +232,7 @@ class xReflector {
} }
return $suffix; return $suffix;
} }
public function GetCallsignAndSuffixByID($RandomId) { public function GetCallsignAndSuffixByID($RandomId) {
$suffix = ""; $suffix = "";
$callsign = ""; $callsign = "";
@ -250,18 +250,18 @@ class xReflector {
} }
return 'N/A'; return 'N/A';
} }
public function StationCount() { public function StationCount() {
return count($this->Stations); return count($this->Stations);
} }
public function GetStation($ArrayIndex) { public function GetStation($ArrayIndex) {
if (isset($this->Stations[$ArrayIndex])) { if (isset($this->Stations[$ArrayIndex])) {
return $this->Stations[$ArrayIndex]; return $this->Stations[$ArrayIndex];
} }
return false; return false;
} }
public function GetFlag($Callsign) { public function GetFlag($Callsign) {
$Image = ""; $Image = "";
$Letters = 4; $Letters = 4;
@ -277,7 +277,7 @@ class xReflector {
} }
return array(strtolower($Image), $Name); return array(strtolower($Image), $Name);
} }
public function GetModules() { public function GetModules() {
$out = array(); $out = array();
for ($i=0;$i<$this->NodeCount();$i++) { for ($i=0;$i<$this->NodeCount();$i++) {
@ -295,7 +295,7 @@ class xReflector {
} }
return $out; return $out;
} }
public function GetModuleOfNode($Node) { public function GetModuleOfNode($Node) {
die("FUNCTION DEPRECATED..."); die("FUNCTION DEPRECATED...");
$Node = trim(str_replace(" ", "-", $Node)); $Node = trim(str_replace(" ", "-", $Node));
@ -305,38 +305,38 @@ class xReflector {
$i = 0; $i = 0;
$Module = ""; $Module = "";
while (!$found && $i<$this->NodeCount()) { while (!$found && $i<$this->NodeCount()) {
if (strpos($Node, $this->Nodes[$i]->GetFullCallsign()) !== false) { if (strpos($Node, $this->Nodes[$i]->GetFullCallsign()) !== false) {
$Module = $this->Nodes[$i]->GetLinkedModule(); $Module = $this->Nodes[$i]->GetLinkedModule();
$found = true; $found = true;
} }
$i++; $i++;
} }
return $Module; return $Module;
} }
public function GetCallSignsInModules($Module) { public function GetCallSignsInModules($Module) {
$out = array(); $out = array();
for ($i=0;$i<$this->NodeCount();$i++) { for ($i=0;$i<$this->NodeCount();$i++) {
if ($this->Nodes[$i]->GetLinkedModule() == $Module) { if ($this->Nodes[$i]->GetLinkedModule() == $Module) {
$out[] = $this->Nodes[$i]->GetCallsign(); $out[] = $this->Nodes[$i]->GetCallsign();
} }
} }
return $out; return $out;
} }
public function GetNodesInModulesById($Module) { public function GetNodesInModulesById($Module) {
$out = array(); $out = array();
for ($i=0;$i<$this->NodeCount();$i++) { for ($i=0;$i<$this->NodeCount();$i++) {
if ($this->Nodes[$i]->GetLinkedModule() == $Module) { if ($this->Nodes[$i]->GetLinkedModule() == $Module) {
$out[] = $this->Nodes[$i]->GetRandomID(); $out[] = $this->Nodes[$i]->GetRandomID();
} }
} }
return $out; return $out;
} }
public function SetCallingHome($CallingHomeVariables, $Hash) { public function SetCallingHome($CallingHomeVariables, $Hash) {
if (!isset($CallingHomeVariables['Active'])) { $CallingHomeVariables['Active'] = false; } if (!isset($CallingHomeVariables['Active'])) { $CallingHomeVariables['Active'] = false; }
if (!isset($CallingHomeVariables['MyDashBoardURL'])) { $CallingHomeVariables['MyDashBoardURL'] = ''; } if (!isset($CallingHomeVariables['MyDashBoardURL'])) { $CallingHomeVariables['MyDashBoardURL'] = ''; }
if (!isset($CallingHomeVariables['ServerURL'])) { $CallingHomeVariables['ServerURL'] = ''; } if (!isset($CallingHomeVariables['ServerURL'])) { $CallingHomeVariables['ServerURL'] = ''; }
@ -344,16 +344,16 @@ class xReflector {
if (!isset($CallingHomeVariables['Comment'])) { $CallingHomeVariables['Comment'] = ''; } if (!isset($CallingHomeVariables['Comment'])) { $CallingHomeVariables['Comment'] = ''; }
if (!isset($CallingHomeVariables['OverrideIPAddress'])) { $CallingHomeVariables['OverrideIPAddress'] = false; } if (!isset($CallingHomeVariables['OverrideIPAddress'])) { $CallingHomeVariables['OverrideIPAddress'] = false; }
if (!isset($CallingHomeVariables['InterlinkFile'])) { $CallingHomeVariables['InterlinkFile'] = ''; } if (!isset($CallingHomeVariables['InterlinkFile'])) { $CallingHomeVariables['InterlinkFile'] = ''; }
if (!file_exists($CallingHomeVariables['InterlinkFile'])) { if (!file_exists($CallingHomeVariables['InterlinkFile'])) {
$this->Interlinkfile = ''; $this->Interlinkfile = '';
$this->Transferinterlink = false; $this->Transferinterlink = false;
} }
else { else {
$this->Transferinterlink = true; $this->Transferinterlink = true;
$this->Interlinkfile = $CallingHomeVariables['InterlinkFile']; $this->Interlinkfile = $CallingHomeVariables['InterlinkFile'];
} }
$this->CallingHomeActive = ($CallingHomeVariables['Active'] === true); $this->CallingHomeActive = ($CallingHomeVariables['Active'] === true);
$this->CallingHomeHash = $Hash; $this->CallingHomeHash = $Hash;
$this->CallingHomeDashboardURL = $CallingHomeVariables['MyDashBoardURL']; $this->CallingHomeDashboardURL = $CallingHomeVariables['MyDashBoardURL'];
@ -361,13 +361,13 @@ class xReflector {
$this->CallingHomeCountry = $CallingHomeVariables['Country']; $this->CallingHomeCountry = $CallingHomeVariables['Country'];
$this->CallingHomeComment = $CallingHomeVariables['Comment']; $this->CallingHomeComment = $CallingHomeVariables['Comment'];
$this->CallingHomeOverrideIP = $CallingHomeVariables['OverrideIPAddress']; $this->CallingHomeOverrideIP = $CallingHomeVariables['OverrideIPAddress'];
} }
public function PushCallingHome() { public function PushCallingHome() {
$CallingHome = @fopen($this->CallingHomeServerURL."?ReflectorName=".$this->ReflectorName."&ReflectorUptime=".$this->ServiceUptime."&ReflectorHash=".$this->CallingHomeHash."&DashboardURL=".$this->CallingHomeDashboardURL."&Country=".urlencode($this->CallingHomeCountry)."&Comment=".urlencode($this->CallingHomeComment)."&OverrideIP=".$this->CallingHomeOverrideIP, "r"); $CallingHome = @fopen($this->CallingHomeServerURL."?ReflectorName=".$this->ReflectorName."&ReflectorUptime=".$this->ServiceUptime."&ReflectorHash=".$this->CallingHomeHash."&DashboardURL=".$this->CallingHomeDashboardURL."&Country=".urlencode($this->CallingHomeCountry)."&Comment=".urlencode($this->CallingHomeComment)."&OverrideIP=".$this->CallingHomeOverrideIP, "r");
} }
public function ReadInterlinkFile() { public function ReadInterlinkFile() {
if (file_exists($this->Interlinkfile) && (is_readable($this->Interlinkfile))) { if (file_exists($this->Interlinkfile) && (is_readable($this->Interlinkfile))) {
$this->Interlinks = array(); $this->Interlinks = array();
@ -379,7 +379,7 @@ class xReflector {
$this->Interlinks[] = new Interlink(); $this->Interlinks[] = new Interlink();
if (isset($Interlink[0])) { $this->Interlinks[count($this->Interlinks)-1]->SetName(trim($Interlink[0])); } if (isset($Interlink[0])) { $this->Interlinks[count($this->Interlinks)-1]->SetName(trim($Interlink[0])); }
if (isset($Interlink[1])) { $this->Interlinks[count($this->Interlinks)-1]->SetAddress(trim($Interlink[1])); } if (isset($Interlink[1])) { $this->Interlinks[count($this->Interlinks)-1]->SetAddress(trim($Interlink[1])); }
if (isset($Interlink[2])) { if (isset($Interlink[2])) {
$Modules = str_split(trim($Interlink[2]), 1); $Modules = str_split(trim($Interlink[2]), 1);
for ($j=0;$j<count($Modules);$j++) { for ($j=0;$j<count($Modules);$j++) {
$this->Interlinks[count($this->Interlinks)-1]->AddModule($Modules[$j]); $this->Interlinks[count($this->Interlinks)-1]->AddModule($Modules[$j]);
@ -391,7 +391,7 @@ class xReflector {
} }
return false; return false;
} }
public function PrepareInterlinkXML() { public function PrepareInterlinkXML() {
$xml = ' $xml = '
<interlinks>'; <interlinks>';
@ -407,7 +407,7 @@ class xReflector {
</interlinks>'; </interlinks>';
$this->InterlinkXML = $xml; $this->InterlinkXML = $xml;
} }
public function PrepareReflectorXML() { public function PrepareReflectorXML() {
$this->ReflectorXML = ' $this->ReflectorXML = '
<reflector> <reflector>
@ -421,28 +421,28 @@ class xReflector {
<reflectorversion>'.$this->Version.'</reflectorversion> <reflectorversion>'.$this->Version.'</reflectorversion>
</reflector>'; </reflector>';
} }
public function CallHome() { public function CallHome() {
$xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?> $xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<query>CallingHome</query>'.$this->ReflectorXML.$this->InterlinkXML; <query>CallingHome</query>'.$this->ReflectorXML.$this->InterlinkXML;
$p = @stream_context_create(array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n", $p = @stream_context_create(array('http' => array('header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST', 'method' => 'POST',
'content' => http_build_query(array('xml' => $xml)) ))); 'content' => http_build_query(array('xml' => $xml)) )));
$result = @file_get_contents($this->CallingHomeServerURL, false, $p); $result = @file_get_contents($this->CallingHomeServerURL, false, $p);
if ($result === false) { if ($result === false) {
die("CONNECTION FAILED!"); die("CONNECTION FAILED!");
} }
} }
public function InterlinkCount() { public function InterlinkCount() {
return count($this->Interlinks); return count($this->Interlinks);
} }
public function GetInterlink($Index) { public function GetInterlink($Index) {
if (isset($this->Interlinks[$Index])) return $this->Interlinks[$Index]; if (isset($this->Interlinks[$Index])) return $this->Interlinks[$Index];
return array(); return array();
} }
public function IsInterlinked($Reflectorname) { public function IsInterlinked($Reflectorname) {
$i = -1; $i = -1;
$f = false; $f = false;
@ -457,7 +457,7 @@ class xReflector {
} }
return -1; return -1;
} }
} }
?> ?>

@ -143,30 +143,36 @@ void CCodecStream::Task(void)
{ {
// pop the original packet // pop the original packet
auto Packet = m_LocalQueue.Pop(); auto Packet = m_LocalQueue.Pop();
auto Frame = (CDvFramePacket *)Packet.get(); auto Frame = static_cast<CDvFramePacket *>(Packet.get());
// do things look okay? // make sure this is the correct packet
if (pack.module != m_CSModule) if ((pack.streamid == Frame->GetCodecPacket()->streamid) && (pack.sequence == Frame->GetCodecPacket()->sequence))
std::cerr << "CodecStream '" << m_CSModule << "' received a transcoded packet from module '" << pack.module << "'" << std::dec << std::noshowbase << std::endl;
if (pack.sequence != Frame->GetCodecPacket()->sequence)
std::cerr << "Sequence mismatch: this voice frame=" << Frame->GetCodecPacket()->sequence << " returned transcoder packet=" << pack.sequence << std::endl;
if (pack.streamid != Frame->GetCodecPacket()->streamid)
std::cerr << std::hex << std::showbase << "StreamID mismatch: this voice frame=" << ntohs(Frame->GetCodecPacket()->streamid) << " returned transcoder packet=" << ntohs(pack.streamid) << std::dec << std::noshowbase << std::endl;
// update content with transcoded data
Frame->SetCodecData(&pack);
// mark the DStar sync frames if the source isn't dstar
if (ECodecType::dstar!=Frame->GetCodecIn() && 0==Frame->GetPacketId()%21)
{ {
const uint8_t DStarSync[] = { 0x55, 0x2D, 0x16 }; // update content with transcoded data
Frame->SetDvData(DStarSync); Frame->SetCodecData(&pack);
// mark the DStar sync frames if the source isn't dstar
if (ECodecType::dstar!=Frame->GetCodecIn() && 0==Frame->GetPacketId()%21)
{
const uint8_t DStarSync[] = { 0x55, 0x2D, 0x16 };
Frame->SetDvData(DStarSync);
}
// and push it back to client
m_PacketStream->ReturnPacket(std::move(Packet));
}
else
{
// Not the correct packet! It will be ignored
// Report it
if (pack.streamid != Frame->GetCodecPacket()->streamid)
std::cerr << std::hex << std::showbase << "StreamID mismatch: this voice frame=" << ntohs(Frame->GetCodecPacket()->streamid) << " returned transcoder packet=" << ntohs(pack.streamid) << std::dec << std::noshowbase << std::endl;
if (pack.sequence != Frame->GetCodecPacket()->sequence)
std::cerr << "Sequence mismatch: this voice frame=" << Frame->GetCodecPacket()->sequence << " returned transcoder packet=" << pack.sequence << std::endl;
} }
// and push it back to client
m_PacketStream->ReturnPacket(std::move(Packet));
} }
else else
{ {
// Likewise, this packet will be ignored
std::cout << "Transcoder packet received but CodecStream[" << m_CSModule << "] is closed: Module='" << pack.module << "' StreamID=" << std::hex << std::showbase << ntohs(pack.streamid) << std::endl; std::cout << "Transcoder packet received but CodecStream[" << m_CSModule << "] is closed: Module='" << pack.module << "' StreamID=" << std::hex << std::showbase << ntohs(pack.streamid) << std::endl;
} }
} }

@ -90,17 +90,6 @@ CDvHeaderPacket::CDvHeaderPacket(const struct dstar_header *buffer, uint16_t sid
m_uiFlag2 = buffer->Flag2; m_uiFlag2 = buffer->Flag2;
m_uiFlag3 = buffer->Flag3; m_uiFlag3 = buffer->Flag3;
m_csUR.SetCallsign(buffer->UR, CALLSIGN_LEN); m_csUR.SetCallsign(buffer->UR, CALLSIGN_LEN);
if((buffer->RPT1)[7] == 0x20){
char rptr1[8];
memcpy(rptr1, buffer->RPT1, 8);
rptr1[7] = DPLUS_DEFAULT_RPTR1_SUFFIX;
m_csRPT1.SetCallsign(rptr1, CALLSIGN_LEN);
}
else{
m_csRPT1.SetCallsign(buffer->RPT1, CALLSIGN_LEN);
}
m_csRPT1.SetCallsign(buffer->RPT1, CALLSIGN_LEN); m_csRPT1.SetCallsign(buffer->RPT1, CALLSIGN_LEN);
m_csRPT2.SetCallsign(buffer->RPT2, CALLSIGN_LEN); m_csRPT2.SetCallsign(buffer->RPT2, CALLSIGN_LEN);
m_csMY.SetCallsign(buffer->MY, CALLSIGN_LEN); m_csMY.SetCallsign(buffer->MY, CALLSIGN_LEN);

@ -28,7 +28,7 @@ SJsonKeys g_Keys;
CReflector g_Reflector; CReflector g_Reflector;
CGateKeeper g_GateKeeper; CGateKeeper g_GateKeeper;
CConfigure g_Configure; CConfigure g_Configure;
CVersion g_Version(3,1,1); // The major byte should only change if the interlink packet changes! CVersion g_Version(3,1,2); // The major byte should only change if the interlink packet changes!
CLookupDmr g_LDid; CLookupDmr g_LDid;
CLookupNxdn g_LNid; CLookupNxdn g_LNid;
CLookupYsf g_LYtr; CLookupYsf g_LYtr;

@ -60,7 +60,7 @@ bool CReflector::Start(void)
#ifndef NO_DHT #ifndef NO_DHT
// start the dht instance // start the dht instance
refhash = dht::InfoHash::get(cs); refhash = dht::InfoHash::get(cs);
node.run(17171, dht::crypto::generateIdentity(cs), true); node.run(17171, dht::crypto::generateIdentity(cs), true, 59973);
node.bootstrap(g_Configure.GetString(g_Keys.names.bootstrap), "17171"); node.bootstrap(g_Configure.GetString(g_Keys.names.bootstrap), "17171");
#endif #endif
@ -595,7 +595,7 @@ void CReflector::PutDHTClients()
#else #else
[](bool success){ if (! success) std::cout << "PutDHTClients() unsuccessful" << std::endl; }, [](bool success){ if (! success) std::cout << "PutDHTClients() unsuccessful" << std::endl; },
#endif #endif
true // permanent! false // not permanent!
); );
} }
@ -624,7 +624,7 @@ void CReflector::PutDHTUsers()
#else #else
[](bool success){ if (! success) std::cout << "PutDHTUsers() unsuccessful" << std::endl; }, [](bool success){ if (! success) std::cout << "PutDHTUsers() unsuccessful" << std::endl; },
#endif #endif
true // permanent! false // not permanent
); );
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.