sipxmedialib  Version 3.3
MpAudioAbstract.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2006-2010 SIPez LLC. All rights reserved.
3 // Licensed to SIPfoundry under a Contributor Agreement.
4 //
5 // Copyright (C) 2004-2006 SIPfoundry Inc.
6 // Licensed by SIPfoundry under the LGPL license.
7 //
8 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
9 // Licensed to SIPfoundry under a Contributor Agreement.
10 //
11 // $$
13 
14 #ifndef MP_AUDIO_ABSTRACT_H
15 #define MP_AUDIO_ABSTRACT_H
16 
17 #include <mp/MpTypes.h>
18 #include <os/iostream>
19 #include <stdio.h>
20 
21 typedef short AudioSample;
22 typedef unsigned char AudioByte;
23 
24 
25 //formats we support
26 #define AUDIO_FORMAT_UNKNOWN 0
27 #define AUDIO_FORMAT_WAV 1
28 #define AUDIO_FORMAT_AU 2
29 
31 
32 public:
33 
34 /* ============================ CREATORS ================================== */
36 
37 
39  MpAudioAbstract(void);
40 
43 
45  virtual ~MpAudioAbstract();
46 
48 
49 public:
51 
52 
54  virtual size_t getSamples(AudioSample *, size_t) = 0;
55 
57  virtual size_t readBytes(AudioByte * buff, size_t length);
58 
60  virtual size_t getBytesSize();
61 
63  virtual int getDecompressionType();
64 
66 
67 public:
69 
70 
73 
76 
79 
82 
84 
85 public:
87 
88 
90  virtual void setSamplingRate(long s);
91 
93  virtual void setSamplingRateRecursive(long s);
94 
96  virtual void minMaxSamplingRate(long *min, long *max, long *prefer);
97 
99  virtual void negotiateSamplingRate(void);
100 
102  virtual long getSamplingRate(void);
103 
105 
106 public:
108 
109 
111  virtual void setChannels(int ch);
112 
114  virtual void setChannelsRecursive(int s);
115 
117  virtual void minMaxChannels(int *min, int *max, int *preferred) ;
118 
120  virtual void negotiateChannels(void);
121 
123  virtual int getChannels(void);
124 
126  virtual void setAudioFormat(int type) { mDetectedFormat = type;}
127 
129  virtual int getAudioFormat() { return mDetectedFormat;}
130 
132  bool isOk() {return mbIsOk;}
133 
135 
136 /* ============================ PRIVATE ================================== */
137 private:
138  // pointers to MpAudioAbstract itself then
141 
142 private: // sampling Rate related stuff
145 
146 private: // channel related stuff
147  long mChannels;
149 
151 
152 protected:
153  bool mbIsOk;
154 };
155 
156 #endif
Definition: MpAudioAbstract.h:30
virtual void setAudioFormat(int type)
Set audio object format.
Definition: MpAudioAbstract.h:126
virtual size_t getSamples(AudioSample *, size_t)=0
Returns number of samples actually read, 0 on error.
virtual void negotiateSamplingRate(void)
negotiate the sampling rate
Definition: MpAudioAbstract.cpp:114
bool mSamplingRateFrozen
Definition: MpAudioAbstract.h:144
virtual size_t getBytesSize()
get bytes size of the audio file
Definition: MpAudioAbstract.cpp:51
virtual int getAudioFormat()
Get audio object format.
Definition: MpAudioAbstract.h:129
virtual void setChannelsRecursive(int s)
Set channel recusively.
Definition: MpAudioAbstract.cpp:146
virtual void minMaxChannels(int *min, int *max, int *preferred)
Get prefered channel.
Definition: MpAudioAbstract.cpp:154
int mDetectedFormat
Definition: MpAudioAbstract.h:150
MpAudioAbstract(void)
Default Constructor.
Definition: MpAudioAbstract.cpp:19
virtual ~MpAudioAbstract()
Destructor.
Definition: MpAudioAbstract.cpp:38
bool isOk()
Return true if file loaded ok.
Definition: MpAudioAbstract.h:132
virtual int getDecompressionType()
get decompression type of the audio file
Definition: MpAudioAbstract.cpp:56
void setNextAudio(MpAudioAbstract *a)
set next audio to a
Definition: MpAudioAbstract.cpp:81
virtual void minMaxSamplingRate(long *min, long *max, long *prefer)
TODO: the meaning of this function, get the prefered Sampling rate.
Definition: MpAudioAbstract.cpp:105
long mSamplingRate
Definition: MpAudioAbstract.h:143
virtual void setChannels(int ch)
Set channel to ch.
Definition: MpAudioAbstract.cpp:137
virtual void negotiateChannels(void)
negotiate channel
Definition: MpAudioAbstract.cpp:163
virtual size_t readBytes(AudioByte *buff, size_t length)
read length of bytes
Definition: MpAudioAbstract.cpp:46
MpAudioAbstract * getNextAudio(void)
get next audio
Definition: MpAudioAbstract.cpp:75
long mChannels
Definition: MpAudioAbstract.h:147
bool mbIsOk
If file loaded ok.
Definition: MpAudioAbstract.h:153
virtual void setSamplingRate(long s)
Set the sampling rate to s.
Definition: MpAudioAbstract.cpp:88
unsigned char AudioByte
Definition: MpAudioAbstract.h:22
MpAudioAbstract * getPreviousAudio(void)
get previous audio
Definition: MpAudioAbstract.cpp:63
short AudioSample
Definition: MpAudioAbstract.h:21
MpAudioAbstract * mNext
object pulling data from us
Definition: MpAudioAbstract.h:140
MpAudioAbstract * mPrevious
object to get data from
Definition: MpAudioAbstract.h:139
virtual void setSamplingRateRecursive(long s)
Set sampling rate recursively.
Definition: MpAudioAbstract.cpp:97
bool mChannelsFrozen
Definition: MpAudioAbstract.h:148
virtual long getSamplingRate(void)
Return the sampling rate.
Definition: MpAudioAbstract.cpp:128
virtual int getChannels(void)
Return the channels.
Definition: MpAudioAbstract.cpp:178
void setPreviousAudio(MpAudioAbstract *a)
set previous audio to a
Definition: MpAudioAbstract.cpp:69