Commit 29369410 authored by jcaceres's avatar jcaceres
Browse files

Added branch with QT4 wroking with backwards compatibity qt3 classes

parent e4c93bcd
# Doxyfile 1.5.1-KDevelop
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
PROJECT_NAME = jacktrip
PROJECT_NUMBER = 1
OUTPUT_DIRECTORY =
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
USE_WINDOWS_ENCODING = NO
BRIEF_MEMBER_DESC = YES
REPEAT_BRIEF = YES
ABBREVIATE_BRIEF = "The $name class" \
"The $name widget" \
"The $name file" \
is \
provides \
specifies \
contains \
represents \
a \
an \
the
ALWAYS_DETAILED_SEC = NO
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = YES
STRIP_FROM_PATH = /user/j/jcaceres/
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = NO
MULTILINE_CPP_IS_BRIEF = NO
DETAILS_AT_TOP = NO
INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
BUILTIN_STL_SUPPORT = NO
DISTRIBUTE_GROUP_DOC = NO
SUBGROUPING = YES
#---------------------------------------------------------------------------
# Build related configuration options
#---------------------------------------------------------------------------
EXTRACT_ALL = NO
EXTRACT_PRIVATE = NO
EXTRACT_STATIC = NO
EXTRACT_LOCAL_CLASSES = YES
EXTRACT_LOCAL_METHODS = NO
HIDE_UNDOC_MEMBERS = NO
HIDE_UNDOC_CLASSES = NO
HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = NO
INTERNAL_DOCS = NO
CASE_SENSE_NAMES = YES
HIDE_SCOPE_NAMES = NO
SHOW_INCLUDE_FILES = YES
INLINE_INFO = YES
SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
GENERATE_TODOLIST = YES
GENERATE_TESTLIST = YES
GENERATE_BUGLIST = YES
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
MAX_INITIALIZER_LINES = 30
SHOW_USED_FILES = YES
SHOW_DIRECTORIES = NO
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
QUIET = NO
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = /user/j/jcaceres/svn-jacktrip/trunk/jacktrip
FILE_PATTERNS = *.c \
*.cc \
*.cxx \
*.cpp \
*.c++ \
*.d \
*.java \
*.ii \
*.ixx \
*.ipp \
*.i++ \
*.inl \
*.h \
*.hh \
*.hxx \
*.hpp \
*.h++ \
*.idl \
*.odl \
*.cs \
*.php \
*.php3 \
*.inc \
*.m \
*.mm \
*.dox \
*.py \
*.C \
*.CC \
*.C++ \
*.II \
*.I++ \
*.H \
*.HH \
*.H++ \
*.CS \
*.PHP \
*.PHP3 \
*.M \
*.MM \
*.PY \
*.C \
*.H \
*.tlh \
*.diff \
*.patch \
*.moc \
*.xpm \
*.dox
RECURSIVE = yes
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
IMAGE_PATH =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
#---------------------------------------------------------------------------
SOURCE_BROWSER = NO
INLINE_SOURCES = NO
STRIP_CODE_COMMENTS = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION = YES
REFERENCES_LINK_SOURCE = YES
USE_HTAGS = NO
VERBATIM_HEADERS = YES
#---------------------------------------------------------------------------
# configuration options related to the alphabetical class index
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
GENERATE_HTML = YES
HTML_OUTPUT = html
HTML_FILE_EXTENSION = .html
HTML_HEADER =
HTML_FOOTER =
HTML_STYLESHEET =
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = NO
DISABLE_INDEX = NO
ENUM_VALUES_PER_LINE = 4
GENERATE_TREEVIEW = NO
TREEVIEW_WIDTH = 250
#---------------------------------------------------------------------------
# configuration options related to the LaTeX output
#---------------------------------------------------------------------------
GENERATE_LATEX = YES
LATEX_OUTPUT = latex
LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
LATEX_HIDE_INDICES = NO
#---------------------------------------------------------------------------
# configuration options related to the RTF output
#---------------------------------------------------------------------------
GENERATE_RTF = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
GENERATE_MAN = NO
MAN_OUTPUT = man
MAN_EXTENSION = .3
MAN_LINKS = NO
#---------------------------------------------------------------------------
# configuration options related to the XML output
#---------------------------------------------------------------------------
GENERATE_XML = yes
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
#---------------------------------------------------------------------------
GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
# configuration options related to the Perl module output
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = NO
EXPAND_ONLY_PREDEF = NO
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
PREDEFINED =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES =
GENERATE_TAGFILE = jacktrip.tag
ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = YES
HAVE_DOT = NO
CLASS_GRAPH = YES
COLLABORATION_GRAPH = YES
GROUP_GRAPHS = YES
UML_LOOK = NO
TEMPLATE_RELATIONS = NO
INCLUDE_GRAPH = YES
INCLUDED_BY_GRAPH = YES
CALL_GRAPH = NO
CALLER_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_WIDTH = 1024
MAX_DOT_GRAPH_HEIGHT = 1024
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = NO
GENERATE_LEGEND = YES
DOT_CLEANUP = YES
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO
#include "udp_input.h"
#include "networkInfo.h"
#include "stream.h"
#include "unistd.h"
#include <stdlib.h>
#include <stdio.h>
#include <iostream.h>
#include <QHostInfo>//***JPC Port to qt4*****************
extern QString *IPv4Addr (char *namebuf);
extern int set_fifo_priority (bool half);
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
UDPInput::UDPInput (NetworkInfoT netInfo, AudioInfoT audInfo):
InputPlugin ("UDP Input"), netInfo (netInfo), audInfo (audInfo)
{
bpp = netInfo->getDataBytesPerPacket ();
cout << "bpp = " << bpp << endl;
char localhostbuf[100];
has_peer = false;
_rcvr = NULL;
//sock = new Q3SocketDevice (Q3SocketDevice::Datagram); // for an unreliable UDP socket//***JPC Port to qt4*****************
//sock->setAddressReusable(true);//***JPC Port to qt4*****************
sock = new QUdpSocket;//***JPC Port to qt4*****************
peerAddress = new QHostAddress;
if (gethostname (localhostbuf, 99))
{
perror ("gethostname");
exit ();
}
cout <<"Local Host Name: " << QString(QHostInfo::localHostName ()).latin1() << endl;//***JPC Port to qt4*****************
//cout << "Rx buff = " << sock->receiveBufferSize () << endl;//***JPC Port to qt4*****************
QHostAddress *ha = new QHostAddress ();//***JPC Port to qt4*****************
QString *s = IPv4Addr (localhostbuf); // dotted integer from name//***JPC Port to qt4*****************
ha->setAddress (*s);//***JPC Port to qt4*****************
cout << "INPUT PORT: " << netInfo->getInPort () << endl;
//if (!(sock->bind (*ha, netInfo->getInPort ())))//***JPC Port to qt4*****************
if (!(sock->bind (*ha, netInfo->getInPort (), QUdpSocket::ShareAddress ) ) )//***JPC Port to qt4*****************
{
perror ("bind\n");
exit ();
}
if (!sock->isValid ())
{
cout << "socket creation error " << endl;
}
packetIndex = 0;
wholeSize = sizeof (nsHeader) + (netInfo->getChunksPerPacket () * bpp) + 1;
packetData = new char[wholeSize];
memset (packetData, 0, wholeSize);
numRedundantBuffers = netInfo->getChunksPerPacket() - 1;
maxPacketIndex = netInfo->getMaxSeq();
cout << endl << "UDPInput binding to " << localhostbuf
<< " port " << netInfo->getInPort () << endl;
}
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
UDPInput::~UDPInput()
{
//delete sock;
//delete peerAddress;
}
//-------------------------------------------------------------------------------
/*! cout that the UDPInput thread has started
*
*/
//-------------------------------------------------------------------------------
void
UDPInput::Initial ()
{
cout << "Started UDPInput thread" << endl;
}
//-------------------------------------------------------------------------------
/* Receive a buffer from the UDPSocket.
* @param buf is the location at which to store the buffer.
* @param le is the size of the buffer to be received.
*/
//-------------------------------------------------------------------------------
int
UDPInput::rcv (char *buf)
{
//int rv = sock->readBlock (packetData, wholeSize);//***JPC Port to qt4*****************
//cout << "###############################################" << endl;
int rv = sock->readDatagram (packetData, wholeSize, peerAddress);//***JPC Port to qt4*****************
//cout << "###############################################" << rv << endl;
//cout << "***Packet Size***: " << rv << endl;//***JPC Port to qt4*****************
char *datapart;
packetIndex = ((nsHeader *) packetData)->i_seq;
datapart = packetData + sizeof (nsHeader) +
((packetIndex % ((nsHeader *) packetData)->i_copies) * bpp);
memcpy (buf, datapart, bpp);
/*
((nsHeader *) packetData)->i_type = 0;
((nsHeader *) packetData)->i_nframes = 1;
((nsHeader *) packetData)->i_nchans = 2;
((nsHeader *) packetData)->i_copies = n;
((nsHeader *) packetData)->i_cksum = 4;
((nsHeader *) packetData)->i_seq = packetIndex;
((nsHeader *) packetData)->i_rtnseq = 6;
((nsHeader *) packetData)->i_rtt = 7;
*/
if (rv < 0)
{
cerr << "bad read..." << endl;
}
return packetIndex;
}
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
int
UDPInput::rcvz1 (char *bufz1, int z)
{
char *datapart;
packetIndex = ((nsHeader *) packetData)->i_seq-z;
if (packetIndex < 0)
{
packetIndex += maxPacketIndex;
// cout << "backed below 0 (a good thing)" << endl;
}
datapart = packetData + sizeof (nsHeader) +
((packetIndex % ((nsHeader *) packetData)->i_copies) * bpp);
memcpy (bufz1, datapart, bpp);
return packetIndex;
}
//-------------------------------------------------------------------------------
/* The main run loop. Calls waitForConnection(). Once connected,
* while running is true, it checks if the socket has a new buffer.
* If it does, it writes the buffer to the stream.
*/
//-------------------------------------------------------------------------------
void
UDPInput::stop ()
{
_running = false;
}
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
void
UDPInput::run ()
{
_running = true;
int seq;
char *buf = (char *) new char[bpp];
char *bufz1 = (char *) new char[bpp];
cout << "UDP Input waiting for peer." << endl;
while (has_peer == false)
{
//cout << "pendingDatagramSize!!!!!!" << sock->pendingDatagramSize () << endl;//***JPC Port to qt4*****************
//cout << "hasPendingDatagrams!!!!!!" << sock->hasPendingDatagrams () << endl;//***JPC Port to qt4*****************
//}
//if (sock->bytesAvailable () >= wholeSize) // not an error//***JPC Port to qt4*****************
if (sock->pendingDatagramSize () >= wholeSize) // not an error//***JPC Port to qt4*****************
{
//cout <<"wholeSize = " << wholeSize << " " <<sock->bytesAvailable ()<< endl;// not an error//***JPC Port to qt4*****************
cout <<"wholeSize = " << wholeSize << " " <<sock->pendingDatagramSize ()<< endl;// not an error//***JPC Port to qt4*****************
//sock->readBlock (buf, wholeSize);
this->rcv (buf);
has_peer = true; // really rcvd something
cout << "UDP Input Connected!" << endl;
} else
msleep (100);
}
msleep (10);
cout << "Started UDP Input Run" << endl;
set_fifo_priority (false);
bool timeout;
int ret;
unsigned long now = 0;
unsigned long lastTickTime = usecTime ();
int ctr = 0;
double max = 0.0;
int gap;
double gapAvg = 0.0;
while (_running)
{
// If timeout is non-null and no error occurred
// (i.e. it does not return -1): this function sets *timeout to TRUE,
// if the reason for returning was that the timeout was reached;
// otherwise it sets *timeout to FALSE. This is useful to find out
// if the peer closed the connection.
//ret = (sock->waitForMore (30, &timeout));//***JPC Port to qt4*****************
//***********************************************************
//###########################################################
// THE SEGMENTATION FAAULT BUG IS IN THE FOLLOWING LINE
// IT SEEMS THAT QT4 IS MESSING UP SOMETHING
//###########################################################
//***********************************************************
cout << "BEFORE SEGFAULT LINE" << endl;
timeout = sock->waitForReadyRead(30);//***JPC Port to qt4*****************
cout << "AFTER SEGFAULT LINE" << endl;
//***********************************************************
//##########################################################
//***********************************************************
//if (ret == -1)//***JPC Port to qt4*****************
//cerr << "udp in sock problems..." << endl;//***JPC Port to qt4*****************
//else if (timeout)//***JPC Port to qt4*****************
if (!timeout)//***JPC Port to qt4*****************
cerr << "udp in waited too long (more than 30ms)..." << endl;
else
{
seq = this->rcv (buf);
if (stream == NULL)
{
cerr << "ERROR: UDPInput has no sream to write to!" << endl;
}
int z = numRedundantBuffers;
while (z)
{
int zseq = this->rcvz1 (bufz1, z);
stream->writeRedundant (bufz1, key, z, zseq);
z--;
}
gap = stream->writeRedundant (buf, key, 0, seq);
// cout << "writePosition " << gap <<"\t\t";
/*
now = usecTime ();
ctr++;
if (ctr == 40)
{
ctr = 0;
gapAvg = gapAvg / 40.0;
// plotVal (gapAvg);
// plotVal (max);
gapAvg = 0.0;
max = 0.0;
} else {
double xxx = (((double)now - (double)lastTickTime)/1000000.0);
// if (xxx>max) max = xxx;
max += xxx;
gapAvg += ((double)gap);
}
lastTickTime = now;
*/
// stream->write (buf, key);
}
}
cout << "UDP Input stop" << endl;
}
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
void UDPInput::plotVal (double v)
{
if(_rcvr!=NULL)
{
ThreadCommEvent *e = new ThreadCommEvent (-1.0, v, 0.0);
QApplication::postEvent (_rcvr, e); // to app event loop
}
}
//-------------------------------------------------------------------------------
//-------------------------------------------------------------------------------
bool UDPInput::hasPeer ()
{
return has_peer;
}
//-------------------------------------------------------------------------------
/* Returns the address of the peer to which the socket is connected
*
*/
//-------------------------------------------------------------------------------
QHostAddress UDPInput::peer ()
{
cout << "#################RETURNING PEEEEERRRRRRRRR#############################" << endl;
sock->readDatagram (packetData, wholeSize, peerAddress);//***JPC Port to qt4*****************
cout << (*peerAddress).toString().latin1() << endl;
//cout << sock->state() << endl;
//cout << sock->peerName().latin1() << endl;
//cout << "RETURNING 23232323**************** *********" << endl;
//return sock->peerAddress ();
return (*peerAddress);
}
#ifndef _UDP_INPUT_H
#define _UDP_INPUT_H
#include "input_plugin.h"
#include "udp.h"
#include "networkInfo.h"
#include "audioInfo.h"
//#include <q3socketdevice.h> //***JPC Port to qt4*****************
#include <QUdpSocket> //***JPC Port to qt4*****************
#include <qobject.h>
/**
* @brief Sends buffers received from a UDP input stream into
* a Stream.
*/
class UDPInput:public InputPlugin
{
private:
NetworkInfoT netInfo;
AudioInfoT audInfo;
//Q3SocketDevice *sock;//***JPC Port to qt4*****************
QUdpSocket *sock;//***JPC Port to qt4*****************
bool _running;
bool has_peer;
int packetIndex; //used for netdebug, checking order of incoming packets
int maxPacketIndex;
char *packetData;
void setPacketSize (int size);
QHostAddress *peerAddress;//***JPC Port to qt4*****************
public:
UDPInput (NetworkInfoT netInfo, AudioInfoT audInfo);
virtual ~UDPInput();
int rcvz1 (char *bufz1, int z);
int rcv (char *buf);
bool hasPeer ();
QHostAddress peer ();
void Initial ();
void run ();
void stop ();
int bpp;
int wholeSize;
int numRedundantBuffers;
void plotVal (double v);