call.cpp 3.34 KB
Newer Older
yanmorin's avatar
   
yanmorin committed
1
2
/*
 *  Copyright (C) 2004-2006 Savoir-Faire Linux inc.
jpbl's avatar
jpbl committed
3
 *  Author: Yan Morin <yan.morin@savoirfairelinux.com>
yanmorin's avatar
   
yanmorin committed
4
5
 *  Author : Laurielle Lea <laurielle.lea@savoirfairelinux.com>
 *
jpbl's avatar
jpbl committed
6
7
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; either version 3 of the License, or
jpbl's avatar
jpbl committed
9
 *  (at your option) any later version.
yanmorin's avatar
   
yanmorin committed
10
 *
jpbl's avatar
jpbl committed
11
12
13
14
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
yanmorin's avatar
   
yanmorin committed
15
 *
jpbl's avatar
jpbl committed
16
17
18
19
20
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
#include "call.h"
21
#include "manager.h"
jpbl's avatar
jpbl committed
22

Yun Liu's avatar
Yun Liu committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Call::Call(const CallID& id, Call::CallType type)
           : _callMutex()
           , _codecMap()
           , _audioCodec()
           , _audioStarted(false)    
           , _localIPAddress("") 
           , _localAudioPort(0)
           , _localExternalAudioPort(0)
           , _remoteIPAddress("")
           , _remoteAudioPort(0)
           , _id(id) 
           , _type(type) 
           , _connectionState(Call::Disconnected)
           , _callState(Call::Inactive)
           , _peerName()
           , _peerNumber()
jpbl's avatar
jpbl committed
39
{
40
41
42
 
    FILE_TYPE fileType = FILE_WAV;
    SOUND_FORMAT soundFormat = INT16;
43

Alexandre Savard's avatar
Alexandre Savard committed
44
    recAudio.setRecordingOption(fileType,soundFormat,44100, Manager::instance().getConfigString (AUDIO, RECORD_PATH),id);
45
    // _debug("CALL::Constructor for this clss is called \n");    
jpbl's avatar
jpbl committed
46
47
48
}


yanmorin's avatar
   
yanmorin committed
49
Call::~Call()
jpbl's avatar
jpbl committed
50
{
51
   // _debug("CALL::~Call(): Destructor for this clss is called \n");
52
53
   
   if(recAudio.isOpenFile()) {
54
     // _debug("CALL::~Call(): A recording file is open, close it \n");
55
56
     recAudio.closeFile();
   }
jpbl's avatar
jpbl committed
57
58
59
}

void 
yanmorin's avatar
   
yanmorin committed
60
Call::setConnectionState(ConnectionState state) 
jpbl's avatar
jpbl committed
61
{
yanmorin's avatar
   
yanmorin committed
62
63
  ost::MutexLock m(_callMutex);
  _connectionState = state;
jpbl's avatar
jpbl committed
64
65
}

yanmorin's avatar
   
yanmorin committed
66
67
Call::ConnectionState
Call::getConnectionState() 
jpbl's avatar
jpbl committed
68
{
yanmorin's avatar
   
yanmorin committed
69
70
  ost::MutexLock m(_callMutex);
  return _connectionState;
jpbl's avatar
jpbl committed
71
72
73
74
}


void 
yanmorin's avatar
   
yanmorin committed
75
Call::setState(CallState state) 
jpbl's avatar
jpbl committed
76
{
yanmorin's avatar
   
yanmorin committed
77
78
  ost::MutexLock m(_callMutex);
  _callState = state;
jpbl's avatar
jpbl committed
79
80
81
}

Call::CallState
yanmorin's avatar
   
yanmorin committed
82
Call::getState() 
jpbl's avatar
jpbl committed
83
{
yanmorin's avatar
   
yanmorin committed
84
85
  ost::MutexLock m(_callMutex);
  return _callState;
jpbl's avatar
jpbl committed
86
87
}

88
CodecDescriptor& 
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
Call::getCodecMap()
{
  return _codecMap;
}

const std::string& 
Call::getLocalIp()
{
  ost::MutexLock m(_callMutex);  
  return _localIPAddress;
}

unsigned int 
Call::getLocalAudioPort()
{
  ost::MutexLock m(_callMutex);  
  return _localAudioPort;
}

unsigned int 
Call::getRemoteAudioPort()
{
  ost::MutexLock m(_callMutex);  
  return _remoteAudioPort;
}

const std::string& 
Call::getRemoteIp()
{
  ost::MutexLock m(_callMutex);  
  return _remoteIPAddress;
}

122
AudioCodecType 
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
Call::getAudioCodec()
{
  ost::MutexLock m(_callMutex);  
  return _audioCodec;  
}

void 
Call::setAudioStart(bool start)
{
  ost::MutexLock m(_callMutex);  
  _audioStarted = start;  
}

bool 
Call::isAudioStarted()
{
  ost::MutexLock m(_callMutex);  
  return _audioStarted;
}

143
144
145
146
147
void
Call::setRecording()
{
  recAudio.setRecording();
}
alexandresavard's avatar
alexandresavard committed
148

149
150
151
152
153
void 
Call::initRecFileName() {
  recAudio.initFileName(_peerNumber);
}

154
155
156
157
158
159
void
Call::stopRecording()
{
  recAudio.stopRecording();
}

alexandresavard's avatar
alexandresavard committed
160
161
162
163
164
165
bool
Call::isRecording()
{
  return recAudio.isRecording();
}