DataProtocol.cpp 2.75 KB
Newer Older
jcaceres's avatar
jcaceres committed
1
2
//*****************************************************************
/*
jcaceres's avatar
jcaceres committed
3
  JackTrip: A System for High-Quality Audio Network Performance
jcaceres's avatar
jcaceres committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  over the Internet

  Copyright (c) 2008 Juan-Pablo Caceres, Chris Chafe.
  SoundWIRE group at CCRMA, Stanford University.
  
  Permission is hereby granted, free of charge, to any person
  obtaining a copy of this software and associated documentation
  files (the "Software"), to deal in the Software without
  restriction, including without limitation the rights to use,
  copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the
  Software is furnished to do so, subject to the following
  conditions:
  
  The above copyright notice and this permission notice shall be
  included in all copies or substantial portions of the Software.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  OTHER DEALINGS IN THE SOFTWARE.
*/
//*****************************************************************

/**
 * \file DataProtocol.cpp
 * \author Juan-Pablo Caceres
 * \date June 2008
 */

#include "DataProtocol.h"
#include "globals.h"
40
#include "JackAudioInterface.h"
41
#include "PacketHeader.h"
jcaceres's avatar
jcaceres committed
42

43
44
45
46
47
#include <iostream>
#include <cstdlib>

#include <QHostInfo>
#include <QHostAddress>
jcaceres's avatar
jcaceres committed
48

jcaceres's avatar
jcaceres committed
49
using std::cout; using std::endl;
jcaceres's avatar
jcaceres committed
50

51

jcaceres's avatar
jcaceres committed
52
//*******************************************************************************
jcacerec's avatar
jcacerec committed
53
54
DataProtocol::DataProtocol(JackTrip* jacktrip,
			   const runModeT runmode,
55
			   const packetHeaderTypeT headertype) : 
jcacerec's avatar
jcacerec committed
56
57
  mStopped(false), mHasPacketsToReceive(false), mRunMode(runmode), mHeader(NULL),
  mJackTrip(jacktrip)
jcaceres's avatar
jcaceres committed
58
{
jcaceres's avatar
jcaceres committed
59
60
61
62
63
  switch (headertype) {
  case DEFAULT :
    mHeader = new DefaultHeader;
    break;
  case JAMLINK :
64
    //mHeader = new JamLinkHeader;
jcaceres's avatar
jcaceres committed
65
66
67
68
69
70
71
    break;
  default:
    std::cerr << "ERROR: Undefined Header Type" << endl;
    std::cerr << "Exiting Program..." << endl;
    std::exit(1);
    break;
  }
jcacerec's avatar
jcacerec committed
72
73
74
75

  /////////////////////////////////////////////////
  //mJackTrip->createHeader(headertype);
  /////////////////////////////////////////////////
76
77
78
79
80
81
82
83
84
85
86
87
88
89
}


//*******************************************************************************
DataProtocol::~DataProtocol()
{
  delete mHeader;
}


//*******************************************************************************
void DataProtocol::fillHeaderCommonFromJack(const JackAudioInterface& jackaudio)
{
  mHeader->fillHeaderCommonFromJack(jackaudio);
jcaceres's avatar
jcaceres committed
90
}