INET Framework for OMNeT++/OMNEST
inet::VoIPStreamSender::Buffer Class Reference

#include <VoIPStreamSender.h>

Public Types

enum  { BUFSIZE = 48000*2*2 }
 

Public Member Functions

 Buffer ()
 
 ~Buffer ()
 
void clear (int framesize)
 
int length () const
 
bool empty () const
 
char * readPtr ()
 
char * writePtr ()
 
int availableSpace () const
 
void notifyRead (int length)
 
void notifyWrote (int length)
 
void align ()
 

Protected Attributes

char * samples
 
int bufferSize
 
int readOffset
 
int writeOffset
 

Member Enumeration Documentation

anonymous enum
Enumerator
BUFSIZE 
78 { BUFSIZE = 48000*2*2 }; // 1 second of two channel 48kHz 16bit audio
Definition: VoIPStreamSender.h:78

Constructor & Destructor Documentation

inet::VoIPStreamSender::Buffer::Buffer ( )
49  :
50  samples(nullptr),
51  bufferSize(0),
52  readOffset(0),
53  writeOffset(0)
54 {
55 }
char * samples
Definition: VoIPStreamSender.h:81
int writeOffset
Definition: VoIPStreamSender.h:84
int bufferSize
Definition: VoIPStreamSender.h:82
int readOffset
Definition: VoIPStreamSender.h:83
inet::VoIPStreamSender::Buffer::~Buffer ( )
58 {
59  delete[] samples;
60 }
char * samples
Definition: VoIPStreamSender.h:81

Member Function Documentation

void inet::VoIPStreamSender::Buffer::align ( )

Referenced by inet::VoIPStreamSender::readFrame().

423 {
424  if (readOffset) {
425  if (length())
426  memcpy(samples, samples + readOffset, length());
428  readOffset = 0;
429  }
430 }
char * samples
Definition: VoIPStreamSender.h:81
int length() const
Definition: VoIPStreamSender.h:90
int writeOffset
Definition: VoIPStreamSender.h:84
int readOffset
Definition: VoIPStreamSender.h:83
int inet::VoIPStreamSender::Buffer::availableSpace ( ) const
inline

Referenced by inet::VoIPStreamSender::readFrame().

94 { return bufferSize - writeOffset; }
int writeOffset
Definition: VoIPStreamSender.h:84
int bufferSize
Definition: VoIPStreamSender.h:82
void inet::VoIPStreamSender::Buffer::clear ( int  framesize)

Referenced by inet::VoIPStreamSender::initialize(), and inet::VoIPStreamSender::openSoundFile().

63 {
64  int newsize = BUFSIZE + framesize;
65  if (bufferSize != newsize) {
66  delete [] samples;
67  bufferSize = newsize;
68  samples = new char[bufferSize];
69  }
70  readOffset = 0;
71  writeOffset = 0;
72 }
char * samples
Definition: VoIPStreamSender.h:81
Definition: VoIPStreamSender.h:78
int writeOffset
Definition: VoIPStreamSender.h:84
int bufferSize
Definition: VoIPStreamSender.h:82
int readOffset
Definition: VoIPStreamSender.h:83
bool inet::VoIPStreamSender::Buffer::empty ( ) const
inline

Referenced by inet::VoIPStreamSender::generatePacket().

91 { return writeOffset <= readOffset; }
int writeOffset
Definition: VoIPStreamSender.h:84
int readOffset
Definition: VoIPStreamSender.h:83
int inet::VoIPStreamSender::Buffer::length ( ) const
inline

Referenced by align(), inet::VoIPStreamSender::generatePacket(), and inet::VoIPStreamSender::readFrame().

90 { return writeOffset - readOffset; }
int writeOffset
Definition: VoIPStreamSender.h:84
int readOffset
Definition: VoIPStreamSender.h:83
void inet::VoIPStreamSender::Buffer::notifyRead ( int  length)
inline

Referenced by inet::VoIPStreamSender::generatePacket().

95 { readOffset += length; ASSERT(readOffset <= writeOffset); }
int length() const
Definition: VoIPStreamSender.h:90
int writeOffset
Definition: VoIPStreamSender.h:84
int readOffset
Definition: VoIPStreamSender.h:83
void inet::VoIPStreamSender::Buffer::notifyWrote ( int  length)
inline

Referenced by inet::VoIPStreamSender::readFrame().

96 { writeOffset += length; ASSERT(writeOffset <= bufferSize); }
int length() const
Definition: VoIPStreamSender.h:90
int writeOffset
Definition: VoIPStreamSender.h:84
int bufferSize
Definition: VoIPStreamSender.h:82
char* inet::VoIPStreamSender::Buffer::readPtr ( )
inline

Referenced by inet::VoIPStreamSender::generatePacket().

92 { return samples + readOffset; }
char * samples
Definition: VoIPStreamSender.h:81
int readOffset
Definition: VoIPStreamSender.h:83
char* inet::VoIPStreamSender::Buffer::writePtr ( )
inline

Referenced by inet::VoIPStreamSender::readFrame().

93 { return samples + writeOffset; }
char * samples
Definition: VoIPStreamSender.h:81
int writeOffset
Definition: VoIPStreamSender.h:84

Member Data Documentation

int inet::VoIPStreamSender::Buffer::bufferSize
protected

Referenced by clear().

int inet::VoIPStreamSender::Buffer::readOffset
protected

Referenced by align(), and clear().

char* inet::VoIPStreamSender::Buffer::samples
protected
int inet::VoIPStreamSender::Buffer::writeOffset
protected

Referenced by align(), and clear().


The documentation for this class was generated from the following files: