~ubuntu-branches/ubuntu/saucy/sflphone/saucy

« back to all changes in this revision

Viewing changes to sflphone-common/src/plug-in/audiorecorder/audiorecord.h

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2010-12-24 16:33:55 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20101224163355-tkvvikqxbrbav6up
Tags: 0.9.11-1
* New upstream release
* Add new build dependencies on libwebkit-dev and libyaml-dev

* Bump Standards-Version up to 3.9.1
* Bump debhelper compatibility to 8
* Patch another typo in the upstream code (lintian notice)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *  Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc.
3
 
 *  Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
4
 
 *
5
 
 *  This program is free software; you can redistribute it and/or modify
6
 
 *  it under the terms of the GNU General Public License as published by
7
 
 *  the Free Software Foundation; either version 3 of the License, or
8
 
 *  (at your option) any later version.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
 
 *
19
 
 *  Additional permission under GNU GPL version 3 section 7:
20
 
 *
21
 
 *  If you modify this program, or any covered work, by linking or
22
 
 *  combining it with the OpenSSL project's OpenSSL library (or a
23
 
 *  modified version of that library), containing parts covered by the
24
 
 *  terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
25
 
 *  grants you additional permission to convey the resulting work.
26
 
 *  Corresponding Source for a non-source form of such a combination
27
 
 *  shall include the source code for the parts of OpenSSL used as well
28
 
 *  as that of the covered work.
29
 
 */
30
 
 
31
 
#ifndef _AUDIO_RECORD_H
32
 
#define _AUDIO_RECORD_H
33
 
 
34
 
#include <iostream>
35
 
#include <string.h>
36
 
#include <stdlib.h>
37
 
#include <sstream>
38
 
 
39
 
#include "plug-in/plugin.h"
40
 
// #include "audiodsp.h"
41
 
 
42
 
// class AudioDSP;
43
 
 
44
 
using namespace std;
45
 
 
46
 
typedef std::string CallID;
47
 
 
48
 
class AudioRecord
49
 
{
50
 
 
51
 
public:
52
 
 
53
 
  AudioRecord();
54
 
 
55
 
  ~AudioRecord();
56
 
  
57
 
  void setSndSamplingRate(int smplRate);
58
 
 
59
 
  void setRecordingOption(FILE_TYPE type, SOUND_FORMAT format, int sndSmplRate, std::string path);
60
 
 
61
 
  void initFileName( std::string peerNumber );
62
 
 
63
 
  /** 
64
 
   * Check if no otehr file is opened, then create a new one
65
 
   * @param fileName A string containing teh file (with/without extension)
66
 
   * @param type     The sound file format (FILE_RAW, FILE_WAVE)
67
 
   * @param format   Internal sound format (INT16 / INT32)
68
 
   */
69
 
  void openFile();
70
 
 
71
 
  /**
72
 
   * Close the opend recording file. If wave: cout the number of byte
73
 
   */
74
 
  void closeFile();
75
 
 
76
 
  /**
77
 
   * Check if a file is already opened
78
 
   */
79
 
  bool isOpenFile();
80
 
 
81
 
  /** 
82
 
   * Check if a file already exist
83
 
   */
84
 
  bool isFileExist();
85
 
 
86
 
  /**
87
 
   * Check recording state 
88
 
   */ 
89
 
  bool isRecording();
90
 
 
91
 
  /**
92
 
   * Set recording flag
93
 
   */
94
 
  bool setRecording();
95
 
 
96
 
  /**
97
 
   * Stop recording flag
98
 
   */
99
 
  void stopRecording();
100
 
 
101
 
 
102
 
  /**
103
 
   * Record a chunk of data in an internal buffer
104
 
   * @param buffer  The data chunk to be recorded
105
 
   * @param nSamples Number of samples (number of bytes) to be recorded 
106
 
   */
107
 
  void recSpkrData(SFLDataFormat* buffer, int nSamples);
108
 
 
109
 
  /**
110
 
   * Record a chunk of data in an internal buffer
111
 
   * @param buffer  The data chunk to be recorded
112
 
   * @param nSamples Number of samples (number of bytes) to be recorded 
113
 
   */
114
 
  void recMicData(SFLDataFormat* buffer, int nSamples);
115
 
 
116
 
  /**
117
 
   * Record a chunk of data in an openend file
118
 
   * @param buffer  The data chunk to be recorded
119
 
   * @param nSamples Number of samples (number of bytes) to be recorded 
120
 
   */
121
 
  void recData(SFLDataFormat* buffer, int nSamples);
122
 
 
123
 
  /**
124
 
   * Record a chunk of data in an openend file, Mix two differnet buffer
125
 
   * @param buffer_1  The first data chunk to be recorded
126
 
   * @param buffer_2  The second data chunk to be recorded
127
 
   * @param nSamples_1 Number of samples (number of bytes) of buffer_1
128
 
   * @param nSamples_2 Number of samples (number of bytes) of buffer_2
129
 
   */
130
 
  void recData(SFLDataFormat* buffer_1, SFLDataFormat* buffer_2, int nSamples_1, int nSamples_2);
131
 
 
132
 
 
133
 
protected:
134
 
 
135
 
  /**
136
 
   * Create name file according to current date
137
 
   */
138
 
  void createFilename();
139
 
  
140
 
  /**
141
 
   * Set the header for raw files
142
 
   */
143
 
  bool setRawFile();
144
 
 
145
 
  /**
146
 
   * Set the header for wave files
147
 
   */
148
 
  bool setWavFile();
149
 
 
150
 
  /**
151
 
   * Open an existing raw file, used when the call is set on hold    
152
 
   */
153
 
  bool openExistingRawFile();
154
 
 
155
 
  /**
156
 
   * Open an existing wav file, used when the call is set on hold
157
 
   */
158
 
  bool openExistingWavFile();
159
 
 
160
 
  /**
161
 
   * Compute the number of byte recorded and close the file
162
 
   */
163
 
  void closeWavFile();
164
 
 
165
 
 
166
 
  /**
167
 
   * Pointer to the recorded file
168
 
   */
169
 
  FILE *fp;                      //file pointer
170
 
 
171
 
  /**
172
 
   * File format (RAW / WAVE)
173
 
   */
174
 
  FILE_TYPE fileType_;
175
 
 
176
 
  /**
177
 
   * Sound format (SINT16/SINT32)
178
 
   */
179
 
  SOUND_FORMAT sndFormat_;
180
 
 
181
 
  /**
182
 
   * Number of channels
183
 
   */
184
 
  int channels_;
185
 
 
186
 
  /**
187
 
   * Number of byte recorded
188
 
   */
189
 
  unsigned long byteCounter_;
190
 
 
191
 
  /**
192
 
   * Sampling rate
193
 
   */
194
 
  int sndSmplRate_;
195
 
  
196
 
  /**
197
 
   * number of samples recorded for mic buffer
198
 
   */
199
 
  int nbSamplesMic_;
200
 
 
201
 
  /**
202
 
   * number of samples recorded for speaker buffer
203
 
   */
204
 
  int nbSamplesSpk_;
205
 
 
206
 
  /**
207
 
   * Maximum number of samples
208
 
   */
209
 
  int nbSamplesMax_;
210
 
 
211
 
  /**
212
 
   * Recording flage
213
 
   */
214
 
  bool recordingEnabled_;
215
 
 
216
 
  /**
217
 
   * Buffer used for mixing two channels
218
 
   */
219
 
  SFLDataFormat* mixBuffer_;
220
 
 
221
 
  /**
222
 
   * Buffer used to copy mic info
223
 
   */
224
 
  SFLDataFormat* micBuffer_;
225
 
  
226
 
  /**
227
 
   * Buffer used to copy spkr info
228
 
   */
229
 
  SFLDataFormat* spkBuffer_;
230
 
  
231
 
  /**
232
 
   * Filename for this recording
233
 
   */
234
 
  char fileName_[8192];
235
 
 
236
 
  /**
237
 
   * Path for this recording
238
 
   */
239
 
  std::string savePath_;
240
 
 
241
 
};
242
 
 
243
 
#endif // _AUDIO_RECORD_H