Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
TPF
jacktrip
Commits
932a109d
Commit
932a109d
authored
Apr 22, 2008
by
jcaceres
Browse files
more advances in binary header
parent
4445737e
Changes
5
Show whitespace changes
Inline
Side-by-side
src/jamlink.h
0 → 100644
View file @
932a109d
// Written by Juan-Pablo Caceres
// Soundwire Group, 2008
//JamLink UDP Header:
/************************************************************************/
/* values for the UDP stream type */
/* streamType is a 16-bit value at the head of each UDP stream */
/* Its bit map is as follows: (b15-msb) */
/* B15:reserved, B14:extended header, B13 Stereo, B12 not 16-bit */
/* B11-B9: 0-48 Khz, 1-44 Khz, 2-32 Khz, 3-24 Khz, */
/* 4-22 Khz, 5-16 Khz, 6-11 Khz, 7-8 Khz */
/* B8-0: Samples in packet */
/************************************************************************/
#define ETX_RSVD (0<<15)
#define ETX_XTND (1<<14)
#define ETX_STEREO (1<<13)
#define ETX_MONO (0<<13)
#define ETX_16BIT (0<<12)
#define ETX_RATE_MASK(a) (a&(0x7<<9))
#define ETX_48KHZ (0<<9)
#define ETX_44KHZ (1<<9)
#define ETX_32KHZ (2<<9)
#define ETX_24KHZ (3<<9)
#define ETX_22KHZ (4<<9)
#define ETX_16KHZ (5<<9)
#define ETX_11KHZ (6<<9)
#define ETX_8KHZ (7<<9)
#define ETX_SPP(a) (a&0x01FF)
/* able to express up to 512 SPP */
/* Note that the extended header is likely to have 6 more bytes: */
/* 2 for the sequence number, and 4 for a timestamp */
//Instpired on Thinking in C++
//http://www.linuxtopia.org/online_books/programming_books/thinking_in_c++/Chapter03_045.html
// Display a unsigned short (2 bytes) in binary
void
printBinary
(
const
unsigned
short
val
);
#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"
;
}
src/networkInfo.h
View file @
932a109d
...
...
@@ -48,9 +48,11 @@ typedef struct _nshdr
//char i_copies;//JPC JLink***********************************
//unsigned short i_nframes;//JPC JLink***********************************
//unsigned short i_cksum;//JPC JLink***********************************
unsigned
short
i_seq
;
//
unsigned short i_seq;
//unsigned short i_rtnseq;//JPC JLink***********************************
//unsigned short i_rtt;//JPC JLink***********************************
unsigned
short
i_head
;
//JPC JLink***********************************
}
nsHeader
;
...
...
src/udp_input.cpp
View file @
932a109d
...
...
@@ -5,6 +5,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
);
...
...
@@ -38,6 +39,7 @@ InputPlugin ("UDP Input"), netInfo (netInfo), audInfo (audInfo)
}
packetIndex
=
0
;
//wholeSize = sizeof (nsHeader) + (netInfo->getChunksPerPacket () * bpp) + 1;//JPC JLink***********************************
wholeSize
=
sizeof
(
nsHeader
)
+
(
netInfo
->
getChunksPerPacket
()
*
bpp
);
//JPC JLink***********************************
packetData
=
new
char
[
wholeSize
];
...
...
@@ -69,12 +71,19 @@ UDPInput::rcv (char *buf)
int
rv
=
sock
->
readBlock
(
packetData
,
wholeSize
);
char
*
datapart
;
packetIndex
=
((
nsHeader
*
)
packetData
)
->
i_seq
;
//packetIndex = ((nsHeader *) packetData)->i_seq;//JPC JLink***********************************
packetHeader
=
((
nsHeader
*
)
packetData
)
->
i_head
;
//JPC JLink***********************************
datapart
=
packetData
+
sizeof
(
nsHeader
);
//cout << sizeof (nsHeader) << endl;
//datapart = packetData + sizeof (nsHeader) + //JPC JLink***********************************
// ((packetIndex % ((nsHeader *) packetData)->i_copies) * bpp);//JPC JLink***********************************
memcpy
(
buf
,
datapart
,
bpp
);
//JPC JLink***********************************
//JPC JLink***********************************
// Binary print function
unsigned
short
caca
=
0xFFFF
;
PR
(
"header in binary: "
,
ETX_STEREO
);
//JPC JLink***********************************
/*
((nsHeader *) packetData)->i_type = 0;
((nsHeader *) packetData)->i_nframes = 1;
...
...
@@ -96,7 +105,8 @@ int
UDPInput
::
rcvz1
(
char
*
bufz1
,
int
z
)
{
char
*
datapart
;
packetIndex
=
((
nsHeader
*
)
packetData
)
->
i_seq
-
z
;
//packetIndex = ((nsHeader *) packetData)->i_seq-z;//JPC JLink***********************************
packetIndex
=
((
nsHeader
*
)
packetData
)
->
i_head
-
z
;
//JPC JLink***********************************
if
(
packetIndex
<
0
)
{
packetIndex
+=
maxPacketIndex
;
...
...
src/udp_input.h
View file @
932a109d
...
...
@@ -25,6 +25,7 @@ class UDPInput:public InputPlugin
bool
has_peer
;
int
packetIndex
;
//used for netdebug, checking order of incoming packets
unsigned
short
packetHeader
;
//JPC JLink***********************************
int
maxPacketIndex
;
char
*
packetData
;
...
...
src/udp_output.cpp
View file @
932a109d
...
...
@@ -81,8 +81,9 @@ int
UDPOutput
::
send
(
char
*
buf
)
{
packetIndex
=
(
packetIndex
+
1
)
%
maxPacketIndex
;
((
nsHeader
*
)
packetData
)
->
i_head
=
packetIndex
;
//JPC JLink***********************************
//((nsHeader *) packetData)->i_cksum = 4;//JPC JLink***********************************
((
nsHeader
*
)
packetData
)
->
i_seq
=
packetIndex
;
//
((nsHeader *) packetData)->i_seq = packetIndex;
//JPC JLink***********************************
//((nsHeader *) packetData)->i_rtnseq = 6;//JPC JLink***********************************
//((nsHeader *) packetData)->i_rtt = 7;//JPC JLink***********************************
char
*
datapart
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment