1
2
3
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/*
* Oreka -- A media capture and retrieval platform
*
* Copyright (C) 2005, orecx LLC
*
* http://www.orecx.com
*
* This program is free software, distributed under the terms of
* the GNU General Public License.
* Please refer to http://www.gnu.org/copyleft/gpl.html
*
*/
#ifndef __AUDIOCAPTURE_H__
#define __AUDIOCAPTURE_H__
#include "time.h"
#include "StdString.h"
#include "OrkBase.h"
#include "boost/shared_ptr.hpp"
/** This class represents a piece of audio.
*/
class DLL_IMPORT_EXPORT AudioChunk
{
public:
typedef enum
{
UnknownAudio = 0,
PcmAudio = 1,
AlawAudio = 2,
UlawAudio = 3,
InvalidAudio = 4
} AudioEncodingEnum;
AudioChunk();
~AudioChunk();
/** Copy external buffer to internal buffer. Create internal buffer if necessary */
void SetBuffer(void* pBuffer, size_t numBytes, AudioEncodingEnum, unsigned int timestamp = 0, unsigned int sequenceNumber = 0);
/** Computes the Root-Mean-Square power value of the buffer */
double ComputeRms();
/** Compute the RMS decibel value of the buffer with a 0 dB reference being the maximum theoretical RMS power of the buffer (2^15) */
double ComputeRmsDb();
int GetNumSamples();
double GetDurationSec();
AudioEncodingEnum m_encoding;
unsigned int m_numBytes;
void * m_pBuffer;
unsigned int m_timestamp; // usually: relative timestamp measured in samples
unsigned int m_sequenceNumber;
unsigned int m_sampleRate;
};
typedef boost::shared_ptr<AudioChunk> AudioChunkRef;
class DLL_IMPORT_EXPORT CaptureEvent
{
public:
CaptureEvent();
#define DIR_IN "in"
#define DIR_OUT "out"
#define DIR_UNKN "unkn"
typedef enum {
DirIn = 0,
DirOut = 1,
DirUnkn = 2
} DirectionEnum;
static CStdString DirectionToString(int);
static int DirectionToEnum(CStdString& dir);
#define ET_UNKNOWN "unknown"
#define ET_START "start"
#define ET_STOP "stop"
#define ET_DIRECTION "direction"
#define ET_REMOTEPARTY "remoteparty"
#define ET_LOCALPARTY "localparty"
#define ET_LOCALENTRYPOINT "localentrypoint"
#define ET_KEYVALUE "keyvalue"
#define ET_INVALID "invalid"
typedef enum
{
EtUnknown = 0,
EtStart = 1,
EtStop = 2,
EtDirection = 3,
EtRemoteParty = 4,
EtLocalParty = 5,
EtLocalEntryPoint = 6,
EtKeyValue = 7,
EtInvalid = 8
} EventTypeEnum;
static CStdString EventTypeToString(int eventTypeEnum);
static int EventTypeToEnum(CStdString&);
time_t m_timestamp;
EventTypeEnum m_type;
CStdString m_key;
CStdString m_value;
};
typedef boost::shared_ptr<CaptureEvent> CaptureEventRef;
#endif
|