Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
00d8956c
Commit
00d8956c
authored
Jan 20, 2012
by
Alexandre Savard
Browse files
Revert "Merge branch 'master' of
git+ssh://git.sflphone.org/var/repos/sflphone/git/sflphone
"
This reverts commit
a4256fcb
, reversing changes made to
aa2dd717
.
parent
a4256fcb
Changes
51
Expand all
Hide whitespace changes
Inline
Side-by-side
daemon/src/audio/audiolayer.h
View file @
00d8956c
...
...
@@ -64,10 +64,6 @@ class AudioLayer {
AudioLayer
();
virtual
~
AudioLayer
();
/**
* Function that returns the list of available audio device provided the stream
* type: AUDIO_STREAM_CAPTURE, AUDIO_STREAM_PLAYBACK.
*/
virtual
std
::
vector
<
std
::
string
>
getAudioDeviceList
(
AudioStreamDirection
dir
)
const
=
0
;
/**
...
...
daemon/src/audio/audiorecord.cpp
View file @
00d8956c
...
...
@@ -29,7 +29,7 @@
*/
#include
"audiorecord.h"
#include
<
cstring>
// for strstr
#include
<
unistd.h>
#include
<sstream>
// for stringstream
// structure for the wave header
...
...
@@ -50,7 +50,6 @@ struct wavhdr {
SINT32
data_length
;
// in bytes
};
AudioRecord
::
AudioRecord
()
:
fileHandle_
(
NULL
)
,
fileType_
(
FILE_INVALID
)
,
channels_
(
1
)
...
...
@@ -63,6 +62,7 @@ AudioRecord::AudioRecord() : fileHandle_(NULL)
,
mixBuffer_
(
new
SFLDataFormat
[
nbSamplesMax_
])
,
micBuffer_
(
new
SFLDataFormat
[
nbSamplesMax_
])
,
spkBuffer_
(
new
SFLDataFormat
[
nbSamplesMax_
])
,
filename_
()
,
savePath_
()
{
createFilename
();
...
...
@@ -93,21 +93,19 @@ void AudioRecord::setRecordingOption(FILE_TYPE type, int sndSmplRate, const std:
savePath_
=
path
+
"/"
;
}
void
AudioRecord
::
initFileName
(
std
::
string
peerNumber
)
void
AudioRecord
::
initFilename
(
const
std
::
string
&
peerNumber
)
{
std
::
string
fName
=
file
N
ame_
;
std
::
string
fName
(
file
n
ame_
)
;
fName
.
append
(
"-"
+
peerNumber
);
if
(
fileType_
==
FILE_RAW
)
{
if
(
strstr
(
file
N
ame_
,
".raw"
)
==
NULL
)
{
DEBUG
(
"AudioRecord: concatenate .raw file extension: name : %s"
,
file
N
ame_
);
if
(
file
n
ame_
.
find
(
".raw"
)
==
std
::
string
::
npos
)
{
DEBUG
(
"AudioRecord: concatenate .raw file extension: name : %s"
,
file
n
ame_
.
c_str
()
);
fName
.
append
(
".raw"
);
}
}
else
if
(
fileType_
==
FILE_WAV
)
{
if
(
strstr
(
file
N
ame_
,
".wav"
)
==
NULL
)
{
DEBUG
(
"AudioRecord: concatenate .wav file extension: name : %s"
,
file
N
ame_
);
if
(
file
n
ame_
.
find
(
".wav"
)
==
std
::
string
::
npos
)
{
DEBUG
(
"AudioRecord: concatenate .wav file extension: name : %s"
,
file
n
ame_
.
c_str
()
);
fName
.
append
(
".wav"
);
}
}
...
...
@@ -115,7 +113,7 @@ void AudioRecord::initFileName(std::string peerNumber)
savePath_
.
append
(
fName
);
}
std
::
string
AudioRecord
::
getFile
N
ame
()
std
::
string
AudioRecord
::
getFile
n
ame
()
const
{
return
savePath_
;
}
...
...
@@ -145,7 +143,6 @@ bool AudioRecord::openFile()
return
result
;
}
void
AudioRecord
::
closeFile
()
{
if
(
fileHandle_
==
0
)
return
;
...
...
@@ -153,20 +150,17 @@ void AudioRecord::closeFile()
if
(
fileType_
==
FILE_RAW
)
fclose
(
fileHandle_
);
else
if
(
fileType_
==
FILE_WAV
)
this
->
closeWavFile
();
closeWavFile
();
}
bool
AudioRecord
::
isOpenFile
()
bool
AudioRecord
::
isOpenFile
()
const
{
return
fileHandle_
!=
0
;
}
bool
AudioRecord
::
fileExists
()
bool
AudioRecord
::
fileExists
()
const
{
DEBUG
(
"AudioRecord: Trying to open %s "
,
fileName_
);
return
fopen
(
fileName_
,
"rb"
)
!=
0
;
return
access
(
savePath_
.
c_str
(),
F_OK
)
!=
-
1
;
}
bool
AudioRecord
::
isRecording
()
const
...
...
@@ -174,7 +168,6 @@ bool AudioRecord::isRecording() const
return
recordingEnabled_
;
}
bool
AudioRecord
::
setRecording
()
{
if
(
isOpenFile
())
{
...
...
@@ -201,7 +194,6 @@ void AudioRecord::stopRecording()
recordingEnabled_
=
false
;
}
void
AudioRecord
::
createFilename
()
{
time_t
rawtime
;
...
...
@@ -214,7 +206,7 @@ void AudioRecord::createFilename()
std
::
stringstream
out
;
// DATE
out
<<
timeinfo
->
tm_year
+
1900
;
out
<<
timeinfo
->
tm_year
+
1900
;
if
(
timeinfo
->
tm_mon
<
9
)
// january is 01, not 1
out
<<
0
;
...
...
@@ -247,11 +239,9 @@ void AudioRecord::createFilename()
out
<<
0
;
out
<<
timeinfo
->
tm_sec
;
filename_
=
out
.
str
();
// fileName_ = out.str();
strncpy
(
fileName_
,
out
.
str
().
c_str
(),
8192
);
DEBUG
(
"AudioRecord: create filename for this call %s "
,
fileName_
);
DEBUG
(
"AudioRecord: create filename for this call %s "
,
filename_
.
c_str
());
}
bool
AudioRecord
::
setRawFile
()
...
...
@@ -268,7 +258,6 @@ bool AudioRecord::setRawFile()
return
true
;
}
bool
AudioRecord
::
setWavFile
()
{
DEBUG
(
"AudioRecord: Create new wave file %s, sampling rate: %d"
,
savePath_
.
c_str
(),
sndSmplRate_
);
...
...
@@ -311,10 +300,9 @@ bool AudioRecord::setWavFile()
return
true
;
}
bool
AudioRecord
::
openExistingRawFile
()
{
fileHandle_
=
fopen
(
file
N
ame_
,
"ab+"
);
fileHandle_
=
fopen
(
file
n
ame_
.
c_str
()
,
"ab+"
);
if
(
!
fileHandle_
)
{
WARN
(
"AudioRecord: could not create RAW file!"
);
...
...
@@ -324,12 +312,11 @@ bool AudioRecord::openExistingRawFile()
return
true
;
}
bool
AudioRecord
::
openExistingWavFile
()
{
DEBUG
(
"%s(%s)
\n
"
,
__PRETTY_FUNCTION__
,
file
N
ame_
);
DEBUG
(
"%s(%s)
\n
"
,
__PRETTY_FUNCTION__
,
file
n
ame_
.
c_str
()
);
fileHandle_
=
fopen
(
file
N
ame_
,
"rb+"
);
fileHandle_
=
fopen
(
file
n
ame_
.
c_str
()
,
"rb+"
);
if
(
!
fileHandle_
)
{
WARN
(
"AudioRecord: Error: could not open WAV file!"
);
...
...
@@ -349,7 +336,7 @@ bool AudioRecord::openExistingWavFile()
if
(
fclose
(
fileHandle_
)
!=
0
)
WARN
(
"AudioRecord: Error: Can't close file r+ "
);
fileHandle_
=
fopen
(
file
N
ame_
,
"ab+"
);
fileHandle_
=
fopen
(
file
n
ame_
.
c_str
()
,
"ab+"
);
if
(
!
fileHandle_
)
{
WARN
(
"AudioRecord: Error: Could not createopen WAV file ab+!"
);
...
...
@@ -410,7 +397,6 @@ void AudioRecord::recSpkrData(SFLDataFormat* buffer, int nSamples)
}
}
void
AudioRecord
::
recMicData
(
SFLDataFormat
*
buffer
,
int
nSamples
)
{
if
(
recordingEnabled_
)
{
...
...
@@ -422,7 +408,6 @@ void AudioRecord::recMicData(SFLDataFormat* buffer, int nSamples)
}
}
void
AudioRecord
::
recData
(
SFLDataFormat
*
buffer
,
int
nSamples
)
{
if
(
recordingEnabled_
)
{
...
...
@@ -440,7 +425,6 @@ void AudioRecord::recData(SFLDataFormat* buffer, int nSamples)
}
}
void
AudioRecord
::
recData
(
SFLDataFormat
*
buffer_1
,
SFLDataFormat
*
buffer_2
,
int
nSamples_1
,
int
/*nSamples_2*/
)
{
...
...
daemon/src/audio/audiorecord.h
View file @
00d8956c
...
...
@@ -57,16 +57,16 @@ class AudioRecord {
/**
* Init recording file path
*/
void
initFile
N
ame
(
std
::
string
peerNumber
);
void
initFile
n
ame
(
const
std
::
string
&
peerNumber
);
/**
* Return the filepath of the recording
*/
std
::
string
getFile
N
ame
();
std
::
string
getFile
n
ame
()
const
;
/**
* Check if no otehr file is opened, then create a new one
* @param file
N
ame A string containing teh file (with/without extension)
* @param file
n
ame A string containing teh file (with/without extension)
* @param type The sound file format (FILE_RAW, FILE_WAVE)
* @param format Internal sound format (INT16 / INT32)
* @return bool True if file was opened
...
...
@@ -81,12 +81,12 @@ class AudioRecord {
/**
* Check if a file is already opened
*/
bool
isOpenFile
();
bool
isOpenFile
()
const
;
/**
* Check if a file already exists
*/
bool
fileExists
();
bool
fileExists
()
const
;
/**
* Check recording state
...
...
@@ -231,7 +231,7 @@ class AudioRecord {
/**
* Filename for this recording
*/
char
file
N
ame_
[
8192
]
;
std
::
string
file
n
ame_
;
/**
* Path for this recording
...
...
daemon/src/audio/pulseaudio/pulselayer.cpp
View file @
00d8956c
...
...
@@ -189,16 +189,12 @@ bool PulseLayer::inSourceList(const std::string &deviceName) const
std
::
vector
<
std
::
string
>
PulseLayer
::
getAudioDeviceList
(
AudioStreamDirection
dir
)
const
{
std
::
vector
<
std
::
string
>
emptyVector
;
if
(
AUDIO_STREAM_CAPTURE
==
dir
)
{
return
sinkList_
;
}
else
if
(
AUDIO_STREAM_PLAYBACK
==
dir
)
{
if
(
AUDIO_STREAM_PLAYBACK
)
{
return
sourceList_
;
}
return
emptyVector
;
}
void
PulseLayer
::
createStreams
(
pa_context
*
c
)
...
...
daemon/src/audio/recordable.cpp
View file @
00d8956c
...
...
@@ -30,33 +30,33 @@
#include
"recordable.h"
#include
"manager.h"
Recordable
::
Recordable
()
:
recAudio
(),
recorder
(
&
recAudio
,
Manager
::
instance
().
getMainBuffer
())
Recordable
::
Recordable
()
:
recAudio
_
(),
recorder
_
(
&
recAudio
_
,
Manager
::
instance
().
getMainBuffer
())
{
recAudio
.
setRecordingOption
(
AudioRecord
::
FILE_WAV
,
8000
,
Manager
::
instance
().
audioPreference
.
getRecordpath
());
recAudio
_
.
setRecordingOption
(
AudioRecord
::
FILE_WAV
,
8000
,
Manager
::
instance
().
audioPreference
.
getRecordpath
());
}
Recordable
::~
Recordable
()
{
if
(
recAudio
.
isOpenFile
())
recAudio
.
closeFile
();
if
(
recAudio
_
.
isOpenFile
())
recAudio
_
.
closeFile
();
}
void
Recordable
::
initRecFile
N
ame
(
std
::
string
filename
)
void
Recordable
::
initRecFile
n
ame
(
const
std
::
string
&
filename
)
{
recAudio
.
initFile
N
ame
(
filename
);
recAudio
_
.
initFile
n
ame
(
filename
);
}
std
::
string
Recordable
::
getFile
N
ame
()
std
::
string
Recordable
::
getFile
n
ame
()
const
{
return
recAudio
.
getFile
N
ame
();
return
recAudio
_
.
getFile
n
ame
();
}
void
Recordable
::
setRecordingSmplRate
(
int
smplRate
)
{
recAudio
.
setSndSamplingRate
(
smplRate
);
recAudio
_
.
setSndSamplingRate
(
smplRate
);
}
int
Recordable
::
getRecordingSmplRate
()
const
{
return
recAudio
.
getSndSamplingRate
();
return
recAudio
_
.
getSndSamplingRate
();
}
daemon/src/audio/recordable.h
View file @
00d8956c
...
...
@@ -43,8 +43,8 @@ class Recordable {
/**
* Return recording state (true/false)
*/
bool
isRecording
()
{
return
recAudio
.
isRecording
();
bool
isRecording
()
const
{
return
recAudio
_
.
isRecording
();
}
/**
...
...
@@ -57,18 +57,18 @@ class Recordable {
* Stop recording
*/
void
stopRecording
()
{
recAudio
.
stopRecording
();
recAudio
_
.
stopRecording
();
}
/**
* Init the recording file name according to path specified in configuration
*/
void
initRecFile
N
ame
(
std
::
string
filename
);
void
initRecFile
n
ame
(
const
std
::
string
&
filename
);
/**
* Return the file path for this recording
*/
std
::
string
getFile
N
ame
();
virtual
std
::
string
getFile
n
ame
()
const
;
/**
* Set recording sampling rate.
...
...
@@ -82,16 +82,13 @@ class Recordable {
/**
* Virtual method to be implemented in order to the main
* buffer to retr
e
ive the recorded id.
* buffer to retri
e
ve the recorded id.
*/
virtual
std
::
string
getRecFileId
()
const
=
0
;
/**
* An instance of audio recorder
*/
AudioRecord
recAudio
;
AudioRecorder
recorder
;
protected:
AudioRecord
recAudio_
;
AudioRecorder
recorder_
;
};
#endif
daemon/src/call.cpp
View file @
00d8956c
...
...
@@ -31,6 +31,7 @@
#include
"call.h"
#include
"manager.h"
#include
"audio/mainbuffer.h"
#include
"history/historyitem.h"
const
char
*
const
Call
::
DEFAULT_ID
=
"audiolayer_id"
;
...
...
@@ -41,13 +42,16 @@ Call::Call(const std::string& id, Call::CallType type)
,
id_
(
id
)
,
confID_
()
,
type_
(
type
)
,
connectionState_
(
Call
::
Disconnected
)
,
callState_
(
Call
::
Inactive
)
,
callConfig_
(
Call
::
Classic
)
,
peerName_
()
,
connectionState_
(
Call
::
DISCONNECTED
)
,
callState_
(
Call
::
INACTIVE
)
,
isIPToIP_
(
false
)
,
peerNumber_
()
,
displayName_
()
{}
,
timestamp_start_
(
0
)
,
timestamp_stop_
(
0
)
{
time
(
&
timestamp_start_
);
}
Call
::~
Call
()
{}
...
...
@@ -66,7 +70,6 @@ Call::getConnectionState()
return
connectionState_
;
}
void
Call
::
setState
(
CallState
state
)
{
...
...
@@ -85,34 +88,34 @@ std::string
Call
::
getStateStr
()
{
switch
(
getState
())
{
case
A
ctive
:
case
A
CTIVE
:
switch
(
getConnectionState
())
{
case
R
inging
:
case
R
INGING
:
return
isIncoming
()
?
"INCOMING"
:
"RINGING"
;
case
C
onnected
:
case
C
ONNECTED
:
default:
return
isRecording
()
?
"RECORD"
:
"CURRENT"
;
}
case
H
old
:
case
H
OLD
:
return
"HOLD"
;
case
B
usy
:
case
B
USY
:
return
"BUSY"
;
case
I
nactive
:
case
I
NACTIVE
:
switch
(
getConnectionState
())
{
case
R
inging
:
case
R
INGING
:
return
isIncoming
()
?
"INCOMING"
:
"RINGING"
;
case
C
onnected
:
case
C
ONNECTED
:
return
"CURRENT"
;
default:
return
"INACTIVE"
;
}
case
C
onferencing
:
case
C
ONFERENCING
:
return
"CONFERENCING"
;
case
R
efused
:
case
E
rror
:
case
R
EFUSED
:
case
E
RROR
:
default:
return
"FAILURE"
;
}
...
...
@@ -136,17 +139,17 @@ Call::getLocalAudioPort()
bool
Call
::
setRecording
()
{
bool
recordStatus
=
Recordable
::
recAudio
.
isRecording
();
bool
recordStatus
=
Recordable
::
recAudio
_
.
isRecording
();
Recordable
::
recAudio
.
setRecording
();
Recordable
::
recAudio
_
.
setRecording
();
MainBuffer
*
mbuffer
=
Manager
::
instance
().
getMainBuffer
();
std
::
string
process_id
=
Recordable
::
recorder
.
getRecorderID
();
std
::
string
process_id
=
Recordable
::
recorder
_
.
getRecorderID
();
if
(
!
recordStatus
)
{
mbuffer
->
bindHalfDuplexOut
(
process_id
,
id_
);
mbuffer
->
bindHalfDuplexOut
(
process_id
);
Recordable
::
recorder
.
start
();
Recordable
::
recorder
_
.
start
();
}
else
{
mbuffer
->
unBindHalfDuplexOut
(
process_id
,
id_
);
mbuffer
->
unBindHalfDuplexOut
(
process_id
);
...
...
@@ -156,3 +159,44 @@ Call::setRecording()
return
recordStatus
;
}
void
Call
::
time_stop
()
{
time
(
&
timestamp_stop_
);
}
std
::
string
Call
::
getTypeStr
()
const
{
switch
(
type_
)
{
case
INCOMING
:
return
"incoming"
;
case
OUTGOING
:
return
"outgoing"
;
case
MISSED
:
return
"missed"
;
default:
return
""
;
}
}
std
::
map
<
std
::
string
,
std
::
string
>
Call
::
createHistoryEntry
()
const
{
std
::
map
<
std
::
string
,
std
::
string
>
result
;
result
[
HistoryItem
::
ACCOUNT_ID_KEY
]
=
Manager
::
instance
().
getAccountFromCall
(
id_
);
result
[
HistoryItem
::
CONFID_KEY
]
=
confID_
;
result
[
HistoryItem
::
CALLID_KEY
]
=
id_
;
result
[
HistoryItem
::
DISPLAY_NAME_KEY
]
=
displayName_
;
result
[
HistoryItem
::
PEER_NUMBER_KEY
]
=
peerNumber_
;
result
[
HistoryItem
::
RECORDING_PATH_KEY
]
=
recAudio_
.
fileExists
()
?
getFilename
()
:
""
;
std
::
stringstream
time_str
;
time_str
<<
timestamp_start_
;
result
[
HistoryItem
::
TIMESTAMP_START_KEY
]
=
time_str
.
str
();
time_str
.
str
(
""
);
time_str
<<
timestamp_stop_
;
result
[
HistoryItem
::
TIMESTAMP_STOP_KEY
]
=
time_str
.
str
();
if
(
connectionState_
==
RINGING
)
result
[
HistoryItem
::
STATE_KEY
]
=
HistoryItem
::
MISSED_STRING
;
else
result
[
HistoryItem
::
STATE_KEY
]
=
getTypeStr
();
return
result
;
}
daemon/src/call.h
View file @
00d8956c
...
...
@@ -47,15 +47,10 @@ class Call : public Recordable {
static
const
char
*
const
DEFAULT_ID
;
/**
* This determines if the call is a direct IP-to-IP call or a classic call, made with an existing account
* This determines if the call originated from the local user (OUTGOING)
* or from some remote peer (INCOMING, MISSED).
*/
enum
CallConfiguration
{
Classic
,
IPtoIP
};
/**
* This determines if the call originated from the local user (Outgoing)
* or from some remote peer (Incoming).
*/
enum
CallType
{
Incoming
,
Outgoing
};
enum
CallType
{
INCOMING
,
OUTGOING
,
MISSED
};
/**
* Tell where we're at with the call. The call gets Connected when we know
...
...
@@ -65,12 +60,12 @@ class Call : public Recordable {
* Audio should be transmitted when ConnectionState = Connected AND
* CallState = Active.
*/
enum
ConnectionState
{
D
isconnected
,
Trying
,
Progressing
,
Ringing
,
Connected
};
enum
ConnectionState
{
D
ISCONNECTED
,
TRYING
,
PROGRESSING
,
RINGING
,
CONNECTED
};
/**
* The Call State.
*/
enum
CallState
{
I
nactive
,
Active
,
Hold
,
Busy
,
Conferencing
,
Refused
,
Error
};
enum
CallState
{
I
NACTIVE
,
ACTIVE
,
HOLD
,
BUSY
,
CONFERENCING
,
REFUSED
,
ERROR
};
/**
* Constructor of a call
...
...
@@ -122,24 +117,6 @@ class Call : public Recordable {
return
peerNumber_
;
}
/**
* Set the peer name (caller in ingoing)
* not protected by mutex (when created)
* @param name The peer name
*/
void
setPeerName
(
const
std
::
string
&
name
)
{
peerName_
=
name
;
}
/**
* Get the peer name (caller in ingoing)
* not protected by mutex (when created)
* @return std::string The peer name
*/
std
::
string
getPeerName
()
const
{
return
peerName_
;
}
/**
* Set the display name (caller in ingoing)
* not protected by mutex (when created)
...
...
@@ -163,8 +140,8 @@ class Call : public Recordable {
* @return true if yes
* false otherwise
*/
bool
isIncoming
()
{
return
type_
==
I
ncoming
;
bool
isIncoming
()
const
{
return
type_
==
I
NCOMING
;
}
/**
...
...
@@ -193,12 +170,8 @@ class Call : public Recordable {
std
::
string
getStateStr
();
void
setCallConfiguration
(
Call
::
CallConfiguration
callConfig
)
{
callConfig_
=
callConfig
;
}
Call
::
CallConfiguration
getCallConfiguration
()
const
{
return
callConfig_
;
void
setIPToIP
(
bool
IPToIP
)
{
isIPToIP_
=
IPToIP
;
}
/**
...
...
@@ -230,16 +203,15 @@ class Call : public Recordable {
unsigned
int
getLocalAudioPort
();
std
::
string
getRecFileId
()
const
{
return
getPeerName
();
}
std
::
string
getFileName
()
const
{
return
peerNumber_
;
return
getDisplayName
();
}
void
time_stop
();
std
::
map
<
std
::
string
,
std
::
string
>
createHistoryEntry
()
const
;
virtual
bool
setRecording
();
private:
std
::
string
getTypeStr
()
const
;
/** Protect every attribute that can be changed by two threads */
ost
::
Mutex
callMutex_
;
...
...
@@ -267,16 +239,16 @@ class Call : public Recordable {
CallState
callState_
;
/** Direct IP-to-IP or classic call */
CallConfiguration
callConfig_
;
/** Name of the peer */
std
::
string
peerName_
;
bool
isIPToIP_
;