Commit ee4389e6 authored by jcaceres's avatar jcaceres
Browse files

more advances in jamlink communication

parent 94061367
#include "jamlink.h"
void printBinary(const unsigned short val) {
for(int i = 15; i >= 0; i--)
if(val & (1 << i))
std::cout << "1";
else
std::cout << "0";
}
// Written by Juan-Pablo Caceres
// Soundwire Group, 2008
#ifndef _JAMLINK_H
#define _JAMLINK_H
#include <iostream>
//JamLink UDP Header:
/************************************************************************/
/* values for the UDP stream type */
......@@ -35,16 +40,18 @@
// Display a unsigned short (2 bytes) in binary
void printBinary(const unsigned short val);
#include <iostream>
//#include <iostream>
#define PR(STR, EXPR) \
cout << STR; printBinary(EXPR); cout << endl;
/*
void printBinary(const unsigned short val) {
for(int i = 15; i >= 0; i--)
if(val & (1 << i))
std::cout << "1";
else
std::cout << "0";
std::cout << "0";
}
*/
#endif
......@@ -24,6 +24,7 @@ UDPInput::UDPInput (NetworkInfoT netInfo, AudioInfoT audInfo):
packetIndex = 0;
//wholeSize = sizeof (nsHeader) + (netInfo->getChunksPerPacket () * bpp) + 1;//JPC JLink***********************************
wholeSize = sizeof (nsHeader) + (netInfo->getChunksPerPacket () * bpp);//JPC JLink***********************************
packetData = new char[wholeSize];
memset (packetData, 0, wholeSize);
//numRedundantBuffers = netInfo->getChunksPerPacket() - 1;//JPC JLink***********************************
......@@ -73,13 +74,31 @@ UDPInput::rcv (char *buf)
packetHeader = ((nsHeader *) packetData)->i_head;//JPC JLink***********************************
//datapart = packetData + sizeof (nsHeader) + //JPC JLink***********************************
// ((packetIndex % ((nsHeader *) packetData)->i_copies) * bpp);//JPC JLink***********************************
//##############################################
//Something is wrong here
//##############################################
datapart = packetData + sizeof (nsHeader);//JPC JLink***********************************
memcpy (buf, datapart, bpp);
//cout << "sizeof (packetHeader) INPUT: " << packetData << endl;//this is showing the wrong size
//cout << "sizeof(datapart) INPUT: " << sizeof(datapart) << endl;//This seems to be correct
//cout << "sizeof (nsHeader)INPUT: " << sizeof (nsHeader) << endl;
//int n;
//for (n=0;buf[n];n++)
// ;
//cout << "n SIIIIIIIIIIIIIIIIIIIIIIIIIIZE: " << n << endl;
//cout << "BUFFFFFFFFFFFFFFFFFFFFFFFFFFF " << buf[12] << endl;
//###############JPC JLink#######################
// Binary print function
//unsigned short caca = 0xFFFF;
//PR("header in binary: ", ETX_STEREO);
//PR("header in binary:", packetHeader);
//PR("Binary Tests: ", ETX_XTND | ETX_STEREO | ETX_44KHZ);
//PR("ETX_8KHZ: ", ETX_XTND | ETX_STEREO | ETX_8KHZ)
//###############################################
/*
......
......@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <iostream.h>
#include "jamlink.h"
extern QString *IPv4Addr (char *namebuf);
extern int set_fifo_priority (bool half);
......@@ -42,7 +43,7 @@ UDPOutput::UDPOutput (NetworkInfoT netInfo, AudioInfoT audInfo):
packetIndex = 0;
//wholeSize = sizeof (nsHeader) + (netInfo->getChunksPerPacket () * bpp) + 1;//JPC JLink***********************************
wholeSize = sizeof (nsHeader) + (netInfo->getChunksPerPacket () * bpp)-1;//JPC JLink***********************************
wholeSize = sizeof (nsHeader) + (netInfo->getChunksPerPacket () * bpp);//JPC JLink***********************************
packetData = new char[wholeSize];
memset (packetData, 0, wholeSize);
......@@ -95,7 +96,14 @@ int
UDPOutput::send (char *buf)
{
packetIndex = (packetIndex + 1) % maxPacketIndex;
((nsHeader *) packetData)->i_head = packetIndex;//JPC JLink***********************************
//###################################
//Add here the header info
//###################################
//((nsHeader *) packetData)->i_head = packetIndex;//JPC JLink***********************************
((nsHeader *) packetData)->i_head = ETX_XTND;//JPC JLink***********************************
//PR("header in binary:", packetHeader);
//((nsHeader *) packetData)->i_cksum = 4;//JPC JLink***********************************
//((nsHeader *) packetData)->i_seq = packetIndex;//JPC JLink***********************************
//((nsHeader *) packetData)->i_rtnseq = 6;//JPC JLink***********************************
......@@ -109,6 +117,13 @@ UDPOutput::send (char *buf)
memcpy (datapart, buf, bpp);
//cout << "sizeof(packetData): " << sizeof(packetData) << endl;
//cout << "numBuffers: " << numBuffers << endl;
//cout << "bpp: " << bpp << endl;
//cout << "datapart OUTPUT: " << sizeof(datapart) << endl;
//cout << "wholeSize:" << wholeSize << endl;
//int rv = sock->writeBlock (packetData, wholeSize,//***JPC Port to qt4*****************
// sock->peerAddress (),//***JPC Port to qt4*****************
// sock->peerPort ());//***JPC Port to qt4*****************
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment