Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
d893a4dd
Commit
d893a4dd
authored
16 years ago
by
Alexandre Savard
Browse files
Options
Downloads
Patches
Plain Diff
Recording while leaving a message with IAX works fine now!
parent
7f852128
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/plug-in/audiorecorder/audiorecord.cpp
+47
-66
47 additions, 66 deletions
src/plug-in/audiorecorder/audiorecord.cpp
src/plug-in/audiorecorder/audiorecord.h
+47
-5
47 additions, 5 deletions
src/plug-in/audiorecorder/audiorecord.h
with
94 additions
and
71 deletions
src/plug-in/audiorecorder/audiorecord.cpp
+
47
−
66
View file @
d893a4dd
...
@@ -44,9 +44,19 @@ AudioRecord::AudioRecord(){
...
@@ -44,9 +44,19 @@ AudioRecord::AudioRecord(){
byteCounter_
=
0
;
byteCounter_
=
0
;
recordingEnabled_
=
false
;
recordingEnabled_
=
false
;
fp
=
0
;
fp
=
0
;
nbSamplesMax_
=
3000
;
createFilename
();
createFilename
();
mixBuffer_
=
new
SFLDataFormat
[
nbSamplesMax_
];
micBuffer_
=
new
SFLDataFormat
[
nbSamplesMax_
];
spkBuffer_
=
new
SFLDataFormat
[
nbSamplesMax_
];
}
AudioRecord
::~
AudioRecord
()
{
delete
[]
mixBuffer_
;
delete
[]
micBuffer_
;
delete
[]
spkBuffer_
;
}
}
...
@@ -56,7 +66,6 @@ void AudioRecord::setSndSamplingRate(int smplRate){
...
@@ -56,7 +66,6 @@ void AudioRecord::setSndSamplingRate(int smplRate){
void
AudioRecord
::
setRecordingOption
(
FILE_TYPE
type
,
SOUND_FORMAT
format
,
int
sndSmplRate
,
std
::
string
path
,
std
::
string
id
){
void
AudioRecord
::
setRecordingOption
(
FILE_TYPE
type
,
SOUND_FORMAT
format
,
int
sndSmplRate
,
std
::
string
path
,
std
::
string
id
){
// std::string fName;
fileType_
=
type
;
fileType_
=
type
;
sndFormat_
=
format
;
sndFormat_
=
format
;
...
@@ -64,26 +73,8 @@ void AudioRecord::setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sn
...
@@ -64,26 +73,8 @@ void AudioRecord::setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sn
sndSmplRate_
=
sndSmplRate
;
sndSmplRate_
=
sndSmplRate
;
call_id_
=
id
;
call_id_
=
id
;
// fName = fileName_;
// fName.append("-"+call_id_);
/*
if (fileType_ == FILE_RAW){
if ( strstr(fileName_, ".raw") == NULL){
printf("AudioRecord::openFile::concatenate .raw file extension: name : %s \n", fileName_);
fName.append(".raw");
}
}
else if (fileType_ == FILE_WAV){
if ( strstr(fileName_, ".wav") == NULL){
printf("AudioRecord::openFile::concatenate .wav file extension: name : %s \n", fileName_);
fName.append(".wav");
}
}
*/
savePath_
=
path
+
"/"
;
savePath_
=
path
+
"/"
;
// savePath_.append(fName);
}
}
...
@@ -362,22 +353,10 @@ void AudioRecord::closeWavFile()
...
@@ -362,22 +353,10 @@ void AudioRecord::closeWavFile()
_debug
(
"AudioRecord:: Can't closeWavFile, a file has not yet been opened!
\n
"
);
_debug
(
"AudioRecord:: Can't closeWavFile, a file has not yet been opened!
\n
"
);
return
;
return
;
}
}
/*
_debug("AudioRecord::closeWavFile() \n");
if ( fclose( fp ) != 0)
_debug("AudioRecord::closeWavFile()::ERROR: can't close file ab \n");
fp = fopen(fileName_, "rb+");
if ( !fp ) {
_debug("AudioRecord::closeWavFile() : could not open WAV file rb+!\n");
return;
}
*/
SINT32
bytes
=
byteCounter_
*
channels_
;
SINT32
bytes
=
byteCounter_
*
channels_
;
fseek
(
fp
,
40
,
SEEK_SET
);
// jump to data length
fseek
(
fp
,
40
,
SEEK_SET
);
// jump to data length
if
(
ferror
(
fp
))
perror
(
"AudioRecord::closeWavFile()::ERROR: can't reach offset 40
\n
"
);
if
(
ferror
(
fp
))
perror
(
"AudioRecord::closeWavFile()::ERROR: can't reach offset 40
\n
"
);
...
@@ -397,11 +376,37 @@ void AudioRecord::closeWavFile()
...
@@ -397,11 +376,37 @@ void AudioRecord::closeWavFile()
if
(
fclose
(
fp
)
!=
0
)
if
(
fclose
(
fp
)
!=
0
)
_debug
(
"AudioRecord::closeWavFile()::ERROR: can't close file
\n
"
);
_debug
(
"AudioRecord::closeWavFile()::ERROR: can't close file
\n
"
);
// i = fclose(fp);
// printf("AudioRecord::closeWavFile : indicator i : %i \n",i);
}
}
void
AudioRecord
::
recSpkrData
(
SFLDataFormat
*
buffer
,
int
nSamples
)
{
if
(
recordingEnabled_
)
{
nbSamplesMic_
=
nSamples
;
for
(
int
i
=
0
;
i
<
nbSamplesMic_
;
i
++
)
micBuffer_
[
i
]
=
buffer
[
i
];
}
return
;
}
void
AudioRecord
::
recMicData
(
SFLDataFormat
*
buffer
,
int
nSamples
)
{
if
(
recordingEnabled_
)
{
nbSamplesSpk_
=
nSamples
;
for
(
int
i
=
0
;
i
<
nbSamplesSpk_
;
i
++
)
spkBuffer_
[
i
]
=
buffer
[
i
];
}
return
;
}
void
AudioRecord
::
recData
(
SFLDataFormat
*
buffer
,
int
nSamples
)
{
void
AudioRecord
::
recData
(
SFLDataFormat
*
buffer
,
int
nSamples
)
{
...
@@ -412,22 +417,13 @@ void AudioRecord::recData(SFLDataFormat* buffer, int nSamples) {
...
@@ -412,22 +417,13 @@ void AudioRecord::recData(SFLDataFormat* buffer, int nSamples) {
return
;
return
;
}
}
// int size = nSamples * (sizeof(SFLDataFormat));
// int size = sizeof(buffer);
// int count = sizeof(buffer) / sizeof(SFLDataFormat);
// printf("AudioRecord : sizeof(buffer) : %d \n",size);
// printf("AudioRecord : sizeof(buffer) / sizeof(SFLDataFormat) : %d \n",count);
// printf("AudioRecord : nSamples : %d \n",nSamples);
// printf("AudioRecord : buffer: %x : ", buffer);
if
(
sndFormat_
==
INT16
)
{
// TODO change INT16 to SINT16
if
(
sndFormat_
==
INT16
)
{
// TODO change INT16 to SINT16
if
(
fwrite
(
buffer
,
sizeof
(
SFLDataFormat
),
nSamples
,
fp
)
!=
nSamples
)
if
(
fwrite
(
buffer
,
sizeof
(
SFLDataFormat
),
nSamples
,
fp
)
!=
nSamples
)
_debug
(
"AudioRecord: Could not record data!
\n
"
);
_debug
(
"AudioRecord: Could not record data!
\n
"
);
else
{
else
{
// printf("Buffer : %x \n",*buffer);
fflush
(
fp
);
fflush
(
fp
);
// _debug("Flushing!\n");
byteCounter_
+=
(
unsigned
long
)(
nSamples
*
sizeof
(
SFLDataFormat
));
byteCounter_
+=
(
unsigned
long
)(
nSamples
*
sizeof
(
SFLDataFormat
));
}
}
}
}
...
@@ -446,40 +442,25 @@ void AudioRecord::recData(SFLDataFormat* buffer_1, SFLDataFormat* buffer_2, int
...
@@ -446,40 +442,25 @@ void AudioRecord::recData(SFLDataFormat* buffer_1, SFLDataFormat* buffer_2, int
return
;
return
;
}
}
mixBuffer_
=
new
SFLDataFormat
[
nSamples_1
];
// int size = nSamples * (sizeof(SFLDataFormat));
// int size = sizeof(buffer);
// int count = sizeof(buffer) / sizeof(SFLDataFormat);
// printf("AudioRecord : sizeof(buffer) : %d \n",size);
// printf("AudioRecord : sizeof(buffer) / sizeof(SFLDataFormat) : %d \n",count);
// printf("AudioRecord : nSamples : %d \n",nSamples);
// printf("AudioRecord : buffer: %x : ", buffer);
if
(
sndFormat_
==
INT16
)
{
// TODO change INT16 to SINT16
if
(
sndFormat_
==
INT16
)
{
// TODO change INT16 to SINT16
for
(
int
k
=
0
;
k
<
nSamples_1
;
k
++
){
for
(
int
k
=
0
;
k
<
nSamples_1
;
k
++
){
// mixBuffer_[k] = ((buffer_1[k]+buffer_2[k])/2)/32767;
mixBuffer_
[
k
]
=
(
buffer_1
[
k
]
+
buffer_2
[
k
]);
mixBuffer_
[
k
]
=
(
buffer_1
[
k
]
+
buffer_2
[
k
]);
// dsp.getRMS(mixBuffer_[k]);
if
(
fwrite
(
&
buffer_1
[
k
],
2
,
1
,
fp
)
!=
1
)
if
(
fwrite
(
&
mixBuffer_
[
k
],
2
,
1
,
fp
)
!=
1
)
_debug
(
"AudioRecord: Could not record data!
\n
"
);
_debug
(
"AudioRecord: Could not record data!
\n
"
);
else
{
else
{
// printf("Buffer : %x \n",*buffer);
fflush
(
fp
);
fflush
(
fp
);
// _debug("Flushing!\n");
}
}
}
}
}
}
byteCounter_
+=
(
unsigned
long
)(
nSamples_1
*
sizeof
(
SFLDataFormat
));
byteCounter_
+=
(
unsigned
long
)(
nSamples_1
*
sizeof
(
SFLDataFormat
));
//printf("AudioRecord::recData():: byteCounter_ : %i \n",(int)byteCounter_ );
delete
[]
mixBuffer_
;
}
}
return
;
return
;
}
}
This diff is collapsed.
Click to expand it.
src/plug-in/audiorecorder/audiorecord.h
+
47
−
5
View file @
d893a4dd
...
@@ -41,6 +41,8 @@ public:
...
@@ -41,6 +41,8 @@ public:
AudioRecord
();
AudioRecord
();
~
AudioRecord
();
void
setSndSamplingRate
(
int
smplRate
);
void
setSndSamplingRate
(
int
smplRate
);
void
setRecordingOption
(
FILE_TYPE
type
,
SOUND_FORMAT
format
,
int
sndSmplRate
,
std
::
string
path
,
std
::
string
id
);
void
setRecordingOption
(
FILE_TYPE
type
,
SOUND_FORMAT
format
,
int
sndSmplRate
,
std
::
string
path
,
std
::
string
id
);
...
@@ -85,6 +87,21 @@ public:
...
@@ -85,6 +87,21 @@ public:
*/
*/
void
stopRecording
();
void
stopRecording
();
/**
* Record a chunk of data in an internal buffer
* @param buffer The data chunk to be recorded
* @param nSamples Number of samples (number of bytes) to be recorded
*/
void
recSpkrData
(
SFLDataFormat
*
buffer
,
int
nSamples
);
/**
* Record a chunk of data in an internal buffer
* @param buffer The data chunk to be recorded
* @param nSamples Number of samples (number of bytes) to be recorded
*/
void
recMicData
(
SFLDataFormat
*
buffer
,
int
nSamples
);
/**
/**
* Record a chunk of data in an openend file
* Record a chunk of data in an openend file
* @param buffer The data chunk to be recorded
* @param buffer The data chunk to be recorded
...
@@ -101,6 +118,7 @@ public:
...
@@ -101,6 +118,7 @@ public:
*/
*/
void
recData
(
SFLDataFormat
*
buffer_1
,
SFLDataFormat
*
buffer_2
,
int
nSamples_1
,
int
nSamples_2
);
void
recData
(
SFLDataFormat
*
buffer_1
,
SFLDataFormat
*
buffer_2
,
int
nSamples_1
,
int
nSamples_2
);
protected:
protected:
/**
/**
...
@@ -133,10 +151,6 @@ protected:
...
@@ -133,10 +151,6 @@ protected:
*/
*/
void
closeWavFile
();
void
closeWavFile
();
/**
* Given two buffers, return one mixed audio buffer
*/
void
mixBuffers
(
SFLDataFormat
*
buffer_1
,
SFLDataFormat
*
buffer_2
,
int
nSamples_1
,
int
nSamples_2
);
/**
/**
* Pointer to the recorded file
* Pointer to the recorded file
...
@@ -168,6 +182,21 @@ protected:
...
@@ -168,6 +182,21 @@ protected:
*/
*/
int
sndSmplRate_
;
int
sndSmplRate_
;
/**
* number of samples recorded for mic buffer
*/
int
nbSamplesMic_
;
/**
* number of samples recorded for speaker buffer
*/
int
nbSamplesSpk_
;
/**
* Maximum number of samples
*/
int
nbSamplesMax_
;
/**
/**
* Recording flage
* Recording flage
*/
*/
...
@@ -178,6 +207,16 @@ protected:
...
@@ -178,6 +207,16 @@ protected:
*/
*/
SFLDataFormat
*
mixBuffer_
;
SFLDataFormat
*
mixBuffer_
;
/**
* Buffer used to copy mic info
*/
SFLDataFormat
*
micBuffer_
;
/**
* Buffer used to copy spkr info
*/
SFLDataFormat
*
spkBuffer_
;
/**
/**
* Filename for this recording
* Filename for this recording
*/
*/
...
@@ -188,6 +227,9 @@ protected:
...
@@ -188,6 +227,9 @@ protected:
*/
*/
std
::
string
savePath_
;
std
::
string
savePath_
;
/**
* Path for this recordingId for this call
*/
std
::
string
call_id_
;
std
::
string
call_id_
;
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment