INET Framework for OMNeT++/OMNEST
inet::VoipStreamSender Class Reference

#include <VoipStreamSender.h>

Inheritance diagram for inet::VoipStreamSender:
inet::LifecycleUnsupported inet::ILifecycle

Classes

class  Buffer
 

Public Member Functions

 VoipStreamSender ()
 
 ~VoipStreamSender ()
 
- Public Member Functions inherited from inet::LifecycleUnsupported
virtual bool handleOperationStage (LifecycleOperation *operation, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual int numInitStages () const override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void finish () override
 
virtual void openSoundFile (const char *name)
 
virtual PacketgeneratePacket ()
 
virtual bool checkSilence (AVSampleFormat sampleFormat, void *_buf, int samples)
 
virtual void readFrame ()
 

Protected Attributes

int localPort = -1
 
int destPort = -1
 
L3Address destAddress
 
int voipHeaderSize = 0
 
int voipSilenceThreshold = 0
 
int voipSilencePacketSize = 0
 
int sampleRate = 0
 
const char * codec = nullptr
 
int compressedBitRate = 0
 
simtime_t packetTimeLength
 
const char * soundFile = nullptr
 
int repeatCount = 0
 
const char * traceFileName = nullptr
 
AudioOutFile outFile
 
AVFormatContext * pFormatCtx = nullptr
 
AVCodecContext * pCodecCtx = nullptr
 
AVCodec * pCodec = nullptr
 
AVAudioResampleContext * pReSampleCtx = nullptr
 
AVCodecContext * pEncoderCtx = nullptr
 
AVCodec * pCodecEncoder = nullptr
 
UdpSocket socket
 
int streamIndex = -1
 
uint32_t pktID = 0
 
int samplesPerPacket = 0
 
AVPacket packet {}
 
Buffer sampleBuffer
 
cMessage * timer = nullptr
 

Constructor & Destructor Documentation

◆ VoipStreamSender()

inet::VoipStreamSender::VoipStreamSender ( )
29 {
30 }

◆ ~VoipStreamSender()

inet::VoipStreamSender::~VoipStreamSender ( )
33 {
34  if (pEncoderCtx) {
35  avcodec_close(pEncoderCtx);
36  avcodec_free_context(&pEncoderCtx);
37  }
38  cancelAndDelete(timer);
39  av_free_packet(&packet);
40 }

Member Function Documentation

◆ checkSilence()

bool inet::VoipStreamSender::checkSilence ( AVSampleFormat  sampleFormat,
void *  _buf,
int  samples 
)
protectedvirtual
364 {
365  int max = 0;
366  int i;
367 
368  switch (sampleFormat) {
369  case AV_SAMPLE_FMT_U8: {
370  uint8_t *buf = (uint8_t *)_buf;
371  for (i = 0; i < samples; ++i) {
372  int s = abs(int(buf[i]) - 0x80);
373  if (s > max)
374  max = s;
375  }
376  }
377  break;
378 
379  case AV_SAMPLE_FMT_S16: {
380  int16_t *buf = (int16_t *)_buf;
381  for (i = 0; i < samples; ++i) {
382  int s = abs(buf[i]);
383  if (s > max)
384  max = s;
385  }
386  }
387  break;
388 
389  case AV_SAMPLE_FMT_S32: {
390  int32_t *buf = (int32_t *)_buf;
391 
392  for (i = 0; i < samples; ++i) {
393  int s = abs(buf[i]);
394 
395  if (s > max)
396  max = s;
397  }
398  }
399  break;
400 
401  default:
402  throw cRuntimeError("Invalid sampleFormat: %d", sampleFormat);
403  }
404 
405  return max < voipSilenceThreshold;
406 }

Referenced by generatePacket().

◆ finish()

void inet::VoipStreamSender::finish ( )
overrideprotectedvirtual
181 {
182  av_free_packet(&packet);
183  outFile.close();
184 
185  if (pCodecCtx) {
186  avcodec_close(pCodecCtx);
187  }
188  if (pReSampleCtx) {
189  avresample_close(pReSampleCtx);
190  avresample_free(&pReSampleCtx);
191  pReSampleCtx = nullptr;
192  }
193 
194  if (pFormatCtx) {
195  avformat_close_input(&pFormatCtx);
196  }
197 }

◆ generatePacket()

Packet * inet::VoipStreamSender::generatePacket ( )
protectedvirtual
292 {
293  readFrame();
294 
295  if (sampleBuffer.empty())
296  return nullptr;
297 
298  short int bytesPerInSample = av_get_bytes_per_sample(pEncoderCtx->sample_fmt);
299  int samples = std::min(sampleBuffer.length() / (bytesPerInSample), samplesPerPacket);
300  int inBytes = samples * bytesPerInSample;
301  bool isSilent = checkSilence(pEncoderCtx->sample_fmt, sampleBuffer.readPtr(), samples);
302  const auto& vp = makeShared<VoipStreamPacket>();
303 
304  AVPacket opacket;
305  av_init_packet(&opacket);
306  opacket.data = nullptr;
307  opacket.size = 0;
308  AVFrame *frame = av_frame_alloc();
309 
310  frame->nb_samples = samples;
311 
312  frame->channel_layout = AV_CH_LAYOUT_MONO;
313  frame->sample_rate = pEncoderCtx->sample_rate;
314 
315  int ret = avcodec_fill_audio_frame(frame, /*channels*/ 1, pEncoderCtx->sample_fmt, (const uint8_t *)(sampleBuffer.readPtr()), inBytes, 1);
316  if (ret < 0)
317  throw cRuntimeError("Error in avcodec_fill_audio_frame(): err=%d", ret);
318 
319  // The bitsPerOutSample is not 0 when codec is PCM.
320  int gotPacket;
321  ret = avcodec_encode_audio2(pEncoderCtx, &opacket, frame, &gotPacket);
322  if (ret < 0 || gotPacket != 1)
323  throw cRuntimeError("avcodec_encode_audio() error: %d gotPacket: %d", ret, gotPacket);
324 
325  if (outFile.isOpen())
326  outFile.write(sampleBuffer.readPtr(), inBytes);
327  sampleBuffer.notifyRead(inBytes);
328 
329  Packet *pk = new Packet();
330  if (isSilent) {
331  pk->setName("SILENCE");
332  vp->setType(SILENCE);
333  vp->setChunkLength(B(voipSilencePacketSize));
334  vp->setHeaderLength(voipSilencePacketSize);
335  vp->setDataLength(0);
336  }
337  else {
338  pk->setName("VOICE");
339  vp->setType(VOICE);
340  vp->setDataLength(opacket.size);
341  vp->setChunkLength(B(voipHeaderSize));
342  vp->setHeaderLength(voipHeaderSize);
343  const auto& voice = makeShared<BytesChunk>(opacket.data, opacket.size);
344  pk->insertAtFront(voice);
345  }
346 
347  vp->setTimeStamp(pktID);
348  vp->setSeqNo(pktID);
349  vp->setCodec(pEncoderCtx->codec_id);
350  vp->setSampleRate(sampleRate);
351  vp->setSampleBits(pEncoderCtx->bits_per_coded_sample);
352  vp->setSamplesPerPacket(samplesPerPacket);
353  vp->setTransmitBitrate(compressedBitRate);
354  pk->insertAtFront(vp);
355 
356  pktID++;
357 
358  av_free_packet(&opacket);
359  av_frame_free(&frame);
360  return pk;
361 }

Referenced by handleMessage().

◆ handleMessage()

void inet::VoipStreamSender::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
149 {
150  if (msg->isSelfMessage()) {
151  Packet *packet;
152 
153  if (msg == timer) {
155 
156  if (!packet) {
157  if (repeatCount > 1) {
158  repeatCount--;
159  av_seek_frame(pFormatCtx, streamIndex, 0, 0);
161  }
162  }
163 
164  if (packet) {
165  // reschedule trigger message
166  scheduleAfter(packetTimeLength, packet);
167  scheduleAfter(packetTimeLength, msg);
168  }
169  }
170  else {
171  packet = check_and_cast<Packet *>(msg);
172  emit(packetSentSignal, packet);
174  }
175  }
176  else
177  delete msg;
178 }

◆ initialize()

void inet::VoipStreamSender::initialize ( int  stage)
overrideprotectedvirtual
68 {
69  if (stage == INITSTAGE_LOCAL) {
70  voipHeaderSize = par("voipHeaderSize");
71  voipSilenceThreshold = par("voipSilenceThreshold");
72  sampleRate = par("sampleRate");
73  codec = par("codec");
74  compressedBitRate = par("compressedBitRate");
75  packetTimeLength = par("packetTimeLength");
76 
77  samplesPerPacket = (int)round(sampleRate * SIMTIME_DBL(packetTimeLength));
78  if (samplesPerPacket & 1)
80  EV_INFO << "The packetTimeLength parameter is " << packetTimeLength * 1000.0 << "ms, ";
82  EV_INFO << "adjusted to " << packetTimeLength * 1000.0 << "ms" << endl;
83 
84  soundFile = par("soundFile");
85  repeatCount = par("repeatCount");
86  traceFileName = par("traceFileName");
87 
88  pReSampleCtx = nullptr;
89  localPort = par("localPort");
90  destPort = par("destPort");
91  EV_DEBUG << "libavcodec: " << LIBAVCODEC_VERSION_MAJOR << "." << LIBAVCODEC_VERSION_MINOR << "." << LIBAVCODEC_VERSION_MICRO << endl;
92  EV_DEBUG << "libavformat: " << LIBAVFORMAT_VERSION_MAJOR << "." << LIBAVFORMAT_VERSION_MINOR << "." << LIBAVFORMAT_VERSION_MICRO << endl;
93  EV_DEBUG << "libavutil: " << LIBAVUTIL_VERSION_MAJOR << "." << LIBAVUTIL_VERSION_MINOR << "." << LIBAVUTIL_VERSION_MICRO << endl;
94  EV_DEBUG << "libavresample: " << LIBAVRESAMPLE_VERSION_MAJOR << "." << LIBAVRESAMPLE_VERSION_MINOR << "." << LIBAVRESAMPLE_VERSION_MICRO << endl;
95  }
96  else if (stage == INITSTAGE_APPLICATION_LAYER) {
97  cModule *node = findContainingNode(this);
98  NodeStatus *nodeStatus = node ? check_and_cast_nullable<NodeStatus *>(node->getSubmodule("status")) : nullptr;
99  bool isOperational = (!nodeStatus) || nodeStatus->getState() == NodeStatus::UP;
100  if (!isOperational)
101  throw cRuntimeError("This module doesn't support starting in node DOWN state");
102 
103  // say HELLO to the world
104  EV_TRACE << "VoIPSourceApp -> initialize(" << stage << ")" << endl;
105 
106  // KLUDGE hack to create results folder (doesn't work when record-scalars = false)
107  recordScalar("hackForCreateResultsFolder", 0);
108 
109  destAddress = L3AddressResolver().resolve(par("destAddress"));
110  socket.setOutputGate(gate("socketOut"));
111 
113 
114  int timeToLive = par("timeToLive");
115  if (timeToLive != -1)
116  socket.setTimeToLive(timeToLive);
117 
118  int dscp = par("dscp");
119  if (dscp != -1)
120  socket.setDscp(dscp);
121 
122  int tos = par("tos");
123  if (tos != -1)
124  socket.setTos(tos);
125 
126  simtime_t startTime = par("startTime");
127 
128  sampleBuffer.clear(0);
129 
130  // initialize avcodec library
131  av_register_all();
132  avcodec_register_all();
133 
134  av_init_packet(&packet);
135 
137 
138  timer = new cMessage("sendVoIP");
139  scheduleAt(startTime, timer);
140 
142 
143  // initialize the sequence number
144  pktID = 1;
145  }
146 }

◆ numInitStages()

virtual int inet::VoipStreamSender::numInitStages ( ) const
inlineoverrideprotectedvirtual
49 { return NUM_INIT_STAGES; }

◆ openSoundFile()

void inet::VoipStreamSender::openSoundFile ( const char *  name)
protectedvirtual
200 {
201  int ret;
202 
203  ret = avformat_open_input(&pFormatCtx, name, nullptr, nullptr);
204  if (ret < 0)
205  throw cRuntimeError("Audiofile '%s' open error: %d", name, ret);
206 
207  ret = avformat_find_stream_info(pFormatCtx, nullptr);
208  if (ret < 0)
209  throw cRuntimeError("Audiofile '%s' avformat_find_stream_info() error: %d", name, ret);
210 
211  // get stream number
212  streamIndex = -1;
213  for (unsigned int j = 0; j < pFormatCtx->nb_streams; j++) {
214  if (pFormatCtx->streams[j]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
215  streamIndex = j;
216  break;
217  }
218  }
219 
220  if (streamIndex == -1)
221  throw cRuntimeError("The file '%s' not contains any audio stream.", name);
222 
223  pCodecCtx = pFormatCtx->streams[streamIndex]->codec;
224 
225  // find decoder and open the correct codec
226  pCodec = avcodec_find_decoder(pCodecCtx->codec_id);
227  if (!pCodec)
228  throw cRuntimeError("Audiofile '%s' avcodec_find_decoder() error: decoder not found", name);
229 
230  ret = avcodec_open2(pCodecCtx, pCodec, nullptr);
231  if (ret < 0)
232  throw cRuntimeError("avcodec_open() error on file '%s': %d", name, ret);
233 
234  // allocate encoder
235  pEncoderCtx = avcodec_alloc_context3(nullptr);
236  if (!pEncoderCtx)
237  throw cRuntimeError("error occured in avcodec_alloc_context3()");
238  // set bitrate:
239  pEncoderCtx->bit_rate = compressedBitRate;
240 
241  pEncoderCtx->sample_rate = sampleRate;
242  pEncoderCtx->channels = 1;
243 
244  pCodecEncoder = avcodec_find_encoder_by_name(codec);
245  if (!pCodecEncoder)
246  throw cRuntimeError("Codec '%s' not found!", codec);
247 
248  pEncoderCtx->sample_fmt = pCodecEncoder->sample_fmts[0];
249 
250  if (avcodec_open2(pEncoderCtx, pCodecEncoder, nullptr) < 0)
251  throw cRuntimeError("could not open %s encoding codec!", codec);
252 
253  if (pCodecCtx->sample_rate == sampleRate
254  && pCodecCtx->sample_fmt == pEncoderCtx->sample_fmt
255  && pCodecCtx->channels == 1)
256  {
257  pReSampleCtx = nullptr;
258  }
259  else {
260  pReSampleCtx = avresample_alloc_context();
261  if (!pReSampleCtx)
262  throw cRuntimeError("error in av_audio_resample_init()");
263 
264  int inChannelLayout = pCodecCtx->channel_layout == 0 ? av_get_default_channel_layout(pCodecCtx->channels) : pCodecCtx->channel_layout;
265  if (av_opt_set_int(pReSampleCtx, "in_channel_layout", inChannelLayout, 0))
266  throw cRuntimeError("error in option setting of 'in_channel_layout'");
267  if (av_opt_set_int(pReSampleCtx, "in_sample_fmt", pCodecCtx->sample_fmt, 0))
268  throw cRuntimeError("error in option setting of 'in_sample_fmt'");
269  if (av_opt_set_int(pReSampleCtx, "in_sample_rate", pCodecCtx->sample_rate, 0))
270  throw cRuntimeError("error in option setting of 'in_sample_rate'");
271  if (av_opt_set_int(pReSampleCtx, "out_channel_layout", AV_CH_LAYOUT_MONO, 0))
272  throw cRuntimeError("error in option setting of 'out_channel_layout'");
273  if (av_opt_set_int(pReSampleCtx, "out_sample_fmt", pEncoderCtx->sample_fmt, 0))
274  throw cRuntimeError("error in option setting of 'out_sample_fmt'");
275  if (av_opt_set_int(pReSampleCtx, "out_sample_rate", sampleRate, 0))
276  throw cRuntimeError("error in option setting of 'out_sample_rate'");
277  if (av_opt_set_int(pReSampleCtx, "internal_sample_fmt", AV_SAMPLE_FMT_FLTP, 0))
278  throw cRuntimeError("error in option setting of 'internal_sample_fmt'");
279 
280  ret = avresample_open(pReSampleCtx);
281  if (ret < 0)
282  throw cRuntimeError("Error opening context");
283  }
284 
286  outFile.open(traceFileName, sampleRate, 8 * av_get_bytes_per_sample(pEncoderCtx->sample_fmt));
287 
288  sampleBuffer.clear(samplesPerPacket * av_get_bytes_per_sample(pEncoderCtx->sample_fmt));
289 }

Referenced by initialize().

◆ readFrame()

void inet::VoipStreamSender::readFrame ( )
protectedvirtual
419 {
420  short int inBytesPerSample = av_get_bytes_per_sample(pCodecCtx->sample_fmt);
421  short int outBytesPerSample = av_get_bytes_per_sample(pEncoderCtx->sample_fmt);
422  if (sampleBuffer.length() >= samplesPerPacket * inBytesPerSample)
423  return;
424 
426 
427  while (sampleBuffer.length() < samplesPerPacket * inBytesPerSample) {
428  // read one frame
429  int err = av_read_frame(pFormatCtx, &packet);
430  if (err < 0)
431  break;
432 
433  // if the frame doesn't belong to our audiostream, continue... is not supposed to happen,
434  // since .wav contain only one media stream
435  if (packet.stream_index != streamIndex)
436  continue;
437 
438  // packet length == 0 ? read next packet
439  if (packet.size == 0)
440  continue;
441 
442  AVPacket avpkt;
443  avpkt.data = nullptr;
444  avpkt.size = 0;
445  av_init_packet(&avpkt);
446  ASSERT(avpkt.data == nullptr && avpkt.size == 0);
447  avpkt.data = packet.data;
448  avpkt.size = packet.size;
449 
450  while (avpkt.size > 0) {
451  // decode audio and save the decoded samples in our buffer
452  AVFrame *frame = av_frame_alloc();
453  int gotFrame;
454  int decoded = avcodec_decode_audio4(pCodecCtx, frame, &gotFrame, &avpkt);
455  if (decoded < 0)
456  throw cRuntimeError("Error in avcodec_decode_audio4(), err=%d, gotFrame=%d", decoded, gotFrame);
457 
458  avpkt.data += decoded;
459  avpkt.size -= decoded;
460 
461  if (gotFrame) {
462  if (!pReSampleCtx) {
463  // copy frame to sampleBuffer
464  int dataSize = av_samples_get_buffer_size(nullptr, pCodecCtx->channels, frame->nb_samples, pCodecCtx->sample_fmt, 1);
465  memcpy(sampleBuffer.writePtr(), frame->data[0], dataSize);
466  sampleBuffer.notifyWrote(dataSize);
467  }
468  else {
469  uint8_t *tmpSamples = new uint8_t[Buffer::BUFSIZE];
470 
471  uint8_t **in_data = frame->extended_data;
472  int in_linesize = frame->linesize[0];
473  int in_nb_samples = frame->nb_samples;
474 
475  uint8_t *out_data[AVRESAMPLE_MAX_CHANNELS] = {
476  nullptr
477  };
478  int maxOutSamples = sampleBuffer.availableSpace() / outBytesPerSample;
479  int out_linesize;
480  int ret;
481  ret = av_samples_fill_arrays(out_data, &out_linesize, tmpSamples, 1, maxOutSamples, pEncoderCtx->sample_fmt, 0);
482  if (ret < 0)
483  throw cRuntimeError("failed out_data fill arrays");
484 
485  decoded = avresample_convert(pReSampleCtx, out_data, out_linesize, decoded, in_data, in_linesize, in_nb_samples);
486  if (decoded <= 0 && avresample_get_delay(pReSampleCtx) == 0) {
487  throw cRuntimeError("audio_resample() returns error");
488  }
489 // if (avresample_get_delay(pReSampleCtx) > 0)
490 // throw cRuntimeError("%d delay samples not converted\n", avresample_get_delay(pReSampleCtx));
491 // if (avresample_available(pReSampleCtx) > 0)
492 // throw cRuntimeError("%d samples available for output\n", avresample_available(pReSampleCtx));
493  if (decoded > 0) {
494  memcpy(sampleBuffer.writePtr(), out_data[0], decoded * outBytesPerSample);
495  sampleBuffer.notifyWrote(decoded * outBytesPerSample);
496  }
497  delete[] tmpSamples;
498  }
499  }
500  av_frame_free(&frame);
501  av_free_packet(&avpkt);
502  }
503  av_free_packet(&packet);
504  }
505 }

Referenced by generatePacket().

Member Data Documentation

◆ codec

const char* inet::VoipStreamSender::codec = nullptr
protected

Referenced by initialize(), and openSoundFile().

◆ compressedBitRate

int inet::VoipStreamSender::compressedBitRate = 0
protected

◆ destAddress

L3Address inet::VoipStreamSender::destAddress
protected

Referenced by handleMessage(), and initialize().

◆ destPort

int inet::VoipStreamSender::destPort = -1
protected

Referenced by handleMessage(), and initialize().

◆ localPort

int inet::VoipStreamSender::localPort = -1
protected

Referenced by initialize().

◆ outFile

AudioOutFile inet::VoipStreamSender::outFile
protected

◆ packet

AVPacket inet::VoipStreamSender::packet {}
protected

◆ packetTimeLength

simtime_t inet::VoipStreamSender::packetTimeLength
protected

Referenced by handleMessage(), and initialize().

◆ pCodec

AVCodec* inet::VoipStreamSender::pCodec = nullptr
protected

Referenced by openSoundFile().

◆ pCodecCtx

AVCodecContext* inet::VoipStreamSender::pCodecCtx = nullptr
protected

Referenced by finish(), openSoundFile(), and readFrame().

◆ pCodecEncoder

AVCodec* inet::VoipStreamSender::pCodecEncoder = nullptr
protected

Referenced by openSoundFile().

◆ pEncoderCtx

AVCodecContext* inet::VoipStreamSender::pEncoderCtx = nullptr
protected

◆ pFormatCtx

AVFormatContext* inet::VoipStreamSender::pFormatCtx = nullptr
protected

◆ pktID

uint32_t inet::VoipStreamSender::pktID = 0
protected

Referenced by generatePacket(), and initialize().

◆ pReSampleCtx

AVAudioResampleContext* inet::VoipStreamSender::pReSampleCtx = nullptr
protected

◆ repeatCount

int inet::VoipStreamSender::repeatCount = 0
protected

Referenced by handleMessage(), and initialize().

◆ sampleBuffer

Buffer inet::VoipStreamSender::sampleBuffer
protected

◆ sampleRate

int inet::VoipStreamSender::sampleRate = 0
protected

◆ samplesPerPacket

int inet::VoipStreamSender::samplesPerPacket = 0
protected

◆ socket

UdpSocket inet::VoipStreamSender::socket
protected

Referenced by handleMessage(), and initialize().

◆ soundFile

const char* inet::VoipStreamSender::soundFile = nullptr
protected

Referenced by initialize().

◆ streamIndex

int inet::VoipStreamSender::streamIndex = -1
protected

◆ timer

cMessage* inet::VoipStreamSender::timer = nullptr
protected

◆ traceFileName

const char* inet::VoipStreamSender::traceFileName = nullptr
protected

Referenced by initialize(), and openSoundFile().

◆ voipHeaderSize

int inet::VoipStreamSender::voipHeaderSize = 0
protected

Referenced by generatePacket(), and initialize().

◆ voipSilencePacketSize

int inet::VoipStreamSender::voipSilencePacketSize = 0
protected

Referenced by generatePacket(), and initialize().

◆ voipSilenceThreshold

int inet::VoipStreamSender::voipSilenceThreshold = 0
protected

Referenced by checkSilence(), and initialize().


The documentation for this class was generated from the following files:
inet::UdpSocket::setOutputGate
void setOutputGate(cGate *toUdp)
Sets the gate on which to send to UDP.
Definition: UdpSocket.h:117
inet::findContainingNode
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:31
inet::UdpSocket::setDscp
void setDscp(short dscp)
Sets the Ipv4 / Ipv6 dscp fields of packets sent from the UDP socket.
Definition: UdpSocket.cc:121
inet::UdpSocket::setTimeToLive
void setTimeToLive(int ttl)
Set the TTL (Ipv6: Hop Limit) field on sent packets.
Definition: UdpSocket.cc:112
inet::VoipStreamSender::Buffer::notifyRead
void notifyRead(int length)
Definition: VoipStreamSender.h:78
inet::VoipStreamSender::pReSampleCtx
AVAudioResampleContext * pReSampleCtx
Definition: VoipStreamSender.h:106
inet::UdpSocket::bind
void bind(int localPort)
Bind the socket to a local port number.
Definition: UdpSocket.cc:34
inet::VoipStreamSender::sampleBuffer
Buffer sampleBuffer
Definition: VoipStreamSender.h:116
inet::UdpSocket::sendTo
void sendTo(Packet *msg, L3Address destAddr, int destPort)
Sends a data packet to the given address and port.
Definition: UdpSocket.cc:69
inet::VoipStreamSender::Buffer::readPtr
char * readPtr()
Definition: VoipStreamSender.h:75
inet::VoipStreamSender::samplesPerPacket
int samplesPerPacket
Definition: VoipStreamSender.h:114
inet::VoipStreamSender::readFrame
virtual void readFrame()
Definition: VoipStreamSender.cc:418
inet::VoipStreamSender::pFormatCtx
AVFormatContext * pFormatCtx
Definition: VoipStreamSender.h:103
inet::VoipStreamSender::localPort
int localPort
Definition: VoipStreamSender.h:85
inet::VoipStreamSender::voipHeaderSize
int voipHeaderSize
Definition: VoipStreamSender.h:89
inet::VoipStreamSender::voipSilenceThreshold
int voipSilenceThreshold
Definition: VoipStreamSender.h:90
inet::VoipStreamSender::Buffer::clear
void clear(int framesize)
Definition: VoipStreamSender.cc:55
inet::sctp::min
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SctpAssociation.h:261
inet::AudioOutFile::open
void open(const char *resultFile, int sampleRate, short int sampleBits)
Definition: AudioOutFile.cc:43
inet::VoipStreamSender::pCodecEncoder
AVCodec * pCodecEncoder
Definition: VoipStreamSender.h:108
inet::VoipStreamSender::Buffer::length
int length() const
Definition: VoipStreamSender.h:73
inet::packetSentSignal
simsignal_t packetSentSignal
Definition: Simsignals.cc:96
inet::VoipStreamSender::destAddress
L3Address destAddress
Definition: VoipStreamSender.h:87
inet::VoipStreamSender::packetTimeLength
simtime_t packetTimeLength
Definition: VoipStreamSender.h:95
inet::AudioOutFile::isOpen
bool isOpen() const
Definition: AudioOutFile.h:35
inet::VoipStreamSender::outFile
AudioOutFile outFile
Definition: VoipStreamSender.h:100
inet::VoipStreamSender::Buffer::writePtr
char * writePtr()
Definition: VoipStreamSender.h:76
inet::units::values::s
value< double, units::s > s
Definition: Units.h:1235
inet::units::units::B
intscale< b, 1, 8 > B
Definition: Units.h:1168
inet::VoipStreamSender::Buffer::empty
bool empty() const
Definition: VoipStreamSender.h:74
inet::VoipStreamSender::voipSilencePacketSize
int voipSilencePacketSize
Definition: VoipStreamSender.h:91
inet::VoipStreamSender::Buffer::BUFSIZE
@ BUFSIZE
Definition: VoipStreamSender.h:61
inet::VoipStreamSender::pCodec
AVCodec * pCodec
Definition: VoipStreamSender.h:105
inet::VoipStreamSender::sampleRate
int sampleRate
Definition: VoipStreamSender.h:92
inet::VoipStreamSender::socket
UdpSocket socket
Definition: VoipStreamSender.h:111
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::VoipStreamSender::pCodecCtx
AVCodecContext * pCodecCtx
Definition: VoipStreamSender.h:104
inet::AudioOutFile::write
void write(void *inbuf, int inbytes)
Definition: AudioOutFile.cc:101
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::math::round
int round(double d)
Returns an integer that corresponds to rounded double parameter.
Definition: INETMath.h:143
inet::VoipStreamSender::Buffer::availableSpace
int availableSpace() const
Definition: VoipStreamSender.h:77
inet::sctp::max
double max(const double a, const double b)
Returns the maximum of a and b.
Definition: SctpAssociation.h:266
inet::AudioOutFile::close
bool close()
Definition: AudioOutFile.cc:139
inet::VoipStreamSender::pktID
uint32_t pktID
Definition: VoipStreamSender.h:113
inet::INITSTAGE_APPLICATION_LAYER
INET_API InitStage INITSTAGE_APPLICATION_LAYER
Initialization of applications.
inet::VoipStreamSender::Buffer::align
void align()
Definition: VoipStreamSender.cc:408
inet::NodeStatus::UP
@ UP
Definition: NodeStatus.h:28
inet::VoipStreamSender::openSoundFile
virtual void openSoundFile(const char *name)
Definition: VoipStreamSender.cc:199
inet::VoipStreamSender::soundFile
const char * soundFile
Definition: VoipStreamSender.h:96
inet::VoipStreamSender::traceFileName
const char * traceFileName
Definition: VoipStreamSender.h:99
inet::VoipStreamSender::streamIndex
int streamIndex
Definition: VoipStreamSender.h:112
inet::VoipStreamSender::Buffer::notifyWrote
void notifyWrote(int length)
Definition: VoipStreamSender.h:79
inet::VoipStreamSender::timer
cMessage * timer
Definition: VoipStreamSender.h:118
inet::VoipStreamSender::packet
AVPacket packet
Definition: VoipStreamSender.h:115
inet::VoipStreamSender::pEncoderCtx
AVCodecContext * pEncoderCtx
Definition: VoipStreamSender.h:107
inet::UdpSocket::setTos
void setTos(short tos)
Sets the Ipv4 Type of Service / Ipv6 Traffic Class fields of packets sent from the UDP socket.
Definition: UdpSocket.cc:130
inet::VoipStreamSender::destPort
int destPort
Definition: VoipStreamSender.h:86
inet::VoipStreamSender::generatePacket
virtual Packet * generatePacket()
Definition: VoipStreamSender.cc:291
inet::VoipStreamSender::repeatCount
int repeatCount
Definition: VoipStreamSender.h:97
inet::VoipStreamSender::checkSilence
virtual bool checkSilence(AVSampleFormat sampleFormat, void *_buf, int samples)
Definition: VoipStreamSender.cc:363
inet::VoipStreamSender::codec
const char * codec
Definition: VoipStreamSender.h:93
inet::VoipStreamSender::compressedBitRate
int compressedBitRate
Definition: VoipStreamSender.h:94