Browse code

b/f:b2b: remember 'receiving' in AudioStreamData, to restore after re-init

also removed dsm sbc mute/unmute functions, as they need to use other proper functions

Stefan Sayer authored on 17/12/2013 13:18:37
Showing 1 changed files
... ...
@@ -314,6 +314,11 @@ protected:
314 314
 
315 315
 public:
316 316
 
317
+  /**
318
+   * Set whether RTP stream will receive RTP packets internally (received packets will be dropped or not).
319
+   */
320
+  void setReceiving(bool r);
321
+
317 322
   /**
318 323
    * Stops RTP stream receiving RTP packets internally (received packets will be dropped).
319 324
    */
Browse code

core: only use setter for AmRtpStream::receiving

Stefan Sayer authored on 17/12/2013 15:04:03
Showing 1 changed files
... ...
@@ -252,6 +252,9 @@ protected:
252 252
   RtpEventQueue   rtp_ev_qu;
253 253
   AmMutex         receive_mut;
254 254
 
255
+  /** should we receive packets? if not -> drop */
256
+  bool receiving;
257
+
255 258
   /** if relay_stream is initialized, received RTP is relayed there */
256 259
   bool            relay_enabled;
257 260
   /** if true, packets are note parsed or checked */
... ...
@@ -324,9 +327,6 @@ public:
324 327
   /** Mute */
325 328
   bool mute;
326 329
 
327
-  /** should we receive packets? if not -> drop */
328
-  bool receiving;
329
-
330 330
   /** should we receive RFC-2833-style DTMF even when receiving is disabled? */
331 331
   bool force_receive_dtmf;
332 332
 
Browse code

Merge remote-tracking branch 'private/master-ccdsm' into b2b_oa_fixes

Conflicts:
apps/sbc/CallLeg.cpp
apps/sbc/CallLeg.h

Václav Kubart authored on 25/11/2013 14:39:31
Showing 0 changed files
Browse code

core: AmRtpStream: added method for debugging

Václav Kubart authored on 22/11/2013 08:04:37
Showing 1 changed files
... ...
@@ -499,6 +499,8 @@ public:
499 499
 
500 500
   /** set destination for logging all received/sent RTP and RTCP packets */
501 501
   void setLogger(msg_logger *_logger);
502
+
503
+  void debug();
502 504
 };
503 505
 
504 506
 #endif
Browse code

core:doc:small comment fix

Stefan Sayer authored on 13/11/2013 23:07:16
Showing 1 changed files
... ...
@@ -453,10 +453,10 @@ public:
453 453
    */
454 454
   virtual int init(const AmSdp& local, const AmSdp& remote, bool force_passive_mode = false);
455 455
 
456
-  /** set the RTP stream on hold (mute && port = 0) */
456
+  /** set the RTP stream on hold */
457 457
   void setOnHold(bool on_hold);
458 458
   
459
-  /** get the RTP stream on hold  */
459
+  /** get whether RTP stream is on hold  */
460 460
   bool getOnHold();
461 461
 
462 462
   /** setter for monitor_rtp_timeout */
Browse code

core: b2b: rtp relay: split up enableRtpRelay and setting relay streams/mask

Stefan Sayer authored on 13/11/2013 16:20:47
Showing 1 changed files
... ...
@@ -472,9 +472,11 @@ public:
472 472
   /** set relay stream for  RTP relaying */
473 473
   void setRelayStream(AmRtpStream* stream);
474 474
 
475
+  /** set relay payloads for  RTP relaying */
476
+  void setRelayPayloads(const PayloadMask &_relay_payloads);
477
+
475 478
   /** ensable RTP relaying through relay stream */
476 479
   void enableRtpRelay();
477
-  void enableRtpRelay(const PayloadMask &_relay_payloads, AmRtpStream *_relay_stream);
478 480
 
479 481
   /** disable RTP relaying through relay stream */
480 482
   void disableRtpRelay();
Browse code

core: rtp stream: clarify stream pause/resume doc, dbg log

Stefan Sayer authored on 10/11/2013 16:47:50
Showing 1 changed files
... ...
@@ -312,12 +312,12 @@ protected:
312 312
 public:
313 313
 
314 314
   /**
315
-   * Stops RTP stream.
315
+   * Stops RTP stream receiving RTP packets internally (received packets will be dropped).
316 316
    */
317 317
   void pause();
318 318
 
319 319
   /**
320
-   * Resume a paused RTP stream.
320
+   * Resume a paused RTP stream internally (received packets will be processed).
321 321
    */
322 322
   void resume();
323 323
 
Browse code

core: rtp stream: make pause() and resume() public

Stefan Sayer authored on 10/11/2013 16:32:38
Showing 1 changed files
... ...
@@ -309,6 +309,8 @@ protected:
309 309
    */
310 310
   int getDefaultPT();
311 311
 
312
+public:
313
+
312 314
   /**
313 315
    * Stops RTP stream.
314 316
    */
... ...
@@ -319,8 +321,6 @@ protected:
319 321
    */
320 322
   void resume();
321 323
 
322
-public:
323
-
324 324
   /** Mute */
325 325
   bool mute;
326 326
 
Browse code

core:AmRtpStream:relay_filter_dtmf option, receive relayed 2833/4733 DTMF if force_dtmf_receiving set

Stefan Sayer authored on 05/11/2013 23:47:28
Showing 1 changed files
... ...
@@ -264,6 +264,8 @@ protected:
264 264
   bool            relay_transparent_seqno;
265 265
   /** control transparency for RTP ssrc in RTP relay mode */
266 266
   bool            relay_transparent_ssrc;
267
+  /** filter RTP DTMF (2833 / 4733) in relaying */
268
+  bool            relay_filter_dtmf;
267 269
 
268 270
   /** Session owning this stream */
269 271
   AmSession*         session;
... ...
@@ -273,6 +275,9 @@ protected:
273 275
   /** Payload provider */
274 276
   AmPayloadProvider* payload_provider;
275 277
 
278
+  /** insert packet in DTMF queue if correct payload */
279
+  void recvDtmfPacket(AmRtpPacket* p);
280
+
276 281
   /** Insert an RTP packet to the buffer queue */
277 282
   void bufferPacket(AmRtpPacket* p);
278 283
   /* Get next packet from the buffer queue */
... ...
@@ -486,6 +491,9 @@ public:
486 491
   /** enable or disable transparent SSRC seqno for relay */
487 492
   void setRtpRelayTransparentSSRC(bool transparent);
488 493
 
494
+  /** enable or disable filtering of RTP DTMF for relay */
495
+  void setRtpRelayFilterRtpDtmf(bool filter);
496
+
489 497
   /** remove from RTP receiver */
490 498
   void stopReceiving();
491 499
 
Browse code

Revert "RTP/RTCP: receive multiple packets at once"

This reverts commit ba9ca84593fdb7795fe1c84a4497acee24288579.

Václav Kubart authored on 15/10/2013 10:04:18
Showing 1 changed files
... ...
@@ -344,11 +344,9 @@ public:
344 344
   int receive( unsigned char* buffer, unsigned int size,
345 345
 	       unsigned int& ts, int& payload );
346 346
 
347
-  /** receive packet; returns false if there was no data to be received */
348
-  bool recvPacket(int fd);
347
+  void recvPacket(int fd);
349 348
 
350
-  /** receive RTCP packet; returns false if there was no data to be received */
351
-  bool recvRtcpPacket();
349
+  void recvRtcpPacket();
352 350
 
353 351
   /** ping the remote side, to open NATs and enable symmetric RTP */
354 352
   int ping();
Browse code

RTP/RTCP: receive multiple packets at once

... could improve performance under heavy traffic - if there are more
packets waiting for receiving on one RTP/RTCP socket
... on the other hand adds additional system call if there are no
waiting packets

Václav Kubart authored on 14/10/2013 07:22:03
Showing 1 changed files
... ...
@@ -344,9 +344,11 @@ public:
344 344
   int receive( unsigned char* buffer, unsigned int size,
345 345
 	       unsigned int& ts, int& payload );
346 346
 
347
-  void recvPacket(int fd);
347
+  /** receive packet; returns false if there was no data to be received */
348
+  bool recvPacket(int fd);
348 349
 
349
-  void recvRtcpPacket();
350
+  /** receive RTCP packet; returns false if there was no data to be received */
351
+  bool recvRtcpPacket();
350 352
 
351 353
   /** ping the remote side, to open NATs and enable symmetric RTP */
352 354
   int ping();
Browse code

rtp stream q/f: attempt to fix dropped fax packets

... do not use uninitialised AmRtpPacket members

Václav Kubart authored on 01/08/2013 14:37:09
Showing 1 changed files
... ...
@@ -119,7 +119,7 @@ class PayloadMask
119 119
     void invert();
120 120
 
121 121
     // get given flag
122
-    bool get(unsigned char payload_id) { if (payload_id > 127) return false; return (bits[payload_id / 8] & (1 << (payload_id % 8))); }
122
+    bool get(unsigned char payload_id) { if (payload_id > 127) { ERROR("BUG: payload_id out of range\n"); return false; } return (bits[payload_id / 8] & (1 << (payload_id % 8))); }
123 123
     
124 124
     PayloadMask() { clear(); }
125 125
     PayloadMask(bool _set_all) { if (_set_all) set_all(); else clear(); }
Browse code

b2b calls q/f: replace "rtcp" attribute value with our RTCP IP/port

Václav Kubart authored on 03/07/2013 14:27:40 • Raphael Coeffic committed on 04/07/2013 10:21:40
Showing 1 changed files
... ...
@@ -376,6 +376,12 @@ public:
376 376
    */
377 377
   int getLocalPort();
378 378
 
379
+  /** 
380
+   * Gets RTCP port number. If no RTP/RTCP port in assigned, assigns a new one.
381
+   * @return local RTCP port. 
382
+   */
383
+  int getLocalRtcpPort();
384
+
379 385
   /** 
380 386
    * Gets remote RTP port.
381 387
    * @return remote RTP port.
Browse code

b2b relay streams b/f: propagate session options for non-audio streams

following flags are propagated from session to non-audio streams:
- passive mode
- transparent SSRC
- transparent seq. number

Václav Kubart authored on 28/06/2013 13:28:40
Showing 1 changed files
... ...
@@ -122,6 +122,7 @@ class PayloadMask
122 122
     bool get(unsigned char payload_id) { if (payload_id > 127) return false; return (bits[payload_id / 8] & (1 << (payload_id % 8))); }
123 123
     
124 124
     PayloadMask() { clear(); }
125
+    PayloadMask(bool _set_all) { if (_set_all) set_all(); else clear(); }
125 126
     PayloadMask(const PayloadMask &src);
126 127
 };
127 128
 
Browse code

rtp b/f: reuse oldest buffered packet if there are no more free packets available

Václav Kubart authored on 27/06/2013 17:01:50
Showing 1 changed files
... ...
@@ -277,6 +277,9 @@ protected:
277 277
   /* Get next packet from the buffer queue */
278 278
   int nextPacket(AmRtpPacket*& p);
279 279
   
280
+  /** Try to reuse oldest buffered packet for newly coming packet */
281
+  AmRtpPacket *reuseBufferedPacket();
282
+
280 283
   /** handle symmetric RTP/RTCP - if in passive mode, update raddr from rp */
281 284
   void handleSymmetricRtp(struct sockaddr_storage* recv_addr, bool rtcp);
282 285
 
Browse code

b/f: fixes RTP packet double free issue on resume()

If the receive buffer is not cleared at the same time, the packets contained will caused a double-free when processed.

Raphael Coeffic authored on 23/05/2013 15:22:40
Showing 1 changed files
... ...
@@ -300,6 +300,16 @@ protected:
300 300
    */
301 301
   int getDefaultPT();
302 302
 
303
+  /**
304
+   * Stops RTP stream.
305
+   */
306
+  void pause();
307
+
308
+  /**
309
+   * Resume a paused RTP stream.
310
+   */
311
+  void resume();
312
+
303 313
 public:
304 314
 
305 315
   /** Mute */
... ...
@@ -428,16 +438,6 @@ public:
428 438
    */
429 439
   virtual int init(const AmSdp& local, const AmSdp& remote, bool force_passive_mode = false);
430 440
 
431
-  /**
432
-   * Stops RTP stream.
433
-   */
434
-  void pause();
435
-
436
-  /**
437
-   * Resume a paused RTP stream.
438
-   */
439
-  void resume();
440
-
441 441
   /** set the RTP stream on hold (mute && port = 0) */
442 442
   void setOnHold(bool on_hold);
443 443
   
Browse code

rtp: allow to init RTP stream with preset port number

Raphael Coeffic authored on 20/05/2013 11:53:43
Showing 1 changed files
... ...
@@ -350,8 +350,11 @@ public:
350 350
    */
351 351
   void setLocalIP(const string& ip);
352 352
 	    
353
-  /** Initializes a new random local port, and sets own attributes properly. */
354
-  void setLocalPort();
353
+  /** 
354
+   * Initializes with a new random local port if 'p' is 0,
355
+   * else binds the given port, and sets own attributes properly. 
356
+   */
357
+  void setLocalPort(unsigned short p = 0);
355 358
 
356 359
   /** 
357 360
    * Gets RTP port number. If no RTP port in assigned, assigns a new one.
Browse code

sbc: support for RTP/RTCP packet logging

Václav Kubart authored on 22/04/2013 10:12:45 • Raphael Coeffic committed on 22/05/2013 19:50:18
Showing 1 changed files
... ...
@@ -63,6 +63,7 @@ class  AmAudio;
63 63
 class  AmSession;
64 64
 struct SdpPayload;
65 65
 struct amci_payload_t;
66
+class msg_logger;
66 67
 
67 68
 /**
68 69
  * This provides the memory for the receive buffer.
... ...
@@ -200,6 +201,7 @@ protected:
200 201
    */
201 202
   struct sockaddr_storage r_saddr;
202 203
   struct sockaddr_storage l_saddr;
204
+  struct sockaddr_storage l_rtcp_saddr;
203 205
 
204 206
   /** Local port */
205 207
   unsigned short     l_port;
... ...
@@ -265,6 +267,8 @@ protected:
265 267
   /** Session owning this stream */
266 268
   AmSession*         session;
267 269
 
270
+  msg_logger *logger;
271
+
268 272
   /** Payload provider */
269 273
   AmPayloadProvider* payload_provider;
270 274
 
... ...
@@ -479,6 +483,9 @@ public:
479 483
    * not be reinitialised implicitly (it might be used for media traffic
480 484
    * already). */
481 485
   void changeSession(AmSession *_s) { session = _s; }
486
+
487
+  /** set destination for logging all received/sent RTP and RTCP packets */
488
+  void setLogger(msg_logger *_logger);
482 489
 };
483 490
 
484 491
 #endif
Browse code

b/f: fixes RTCP relay and symmetric RTCP

Raphael Coeffic authored on 25/01/2013 13:08:57
Showing 1 changed files
... ...
@@ -187,6 +187,7 @@ protected:
187 187
   /** Remote host information */
188 188
   string             r_host;
189 189
   unsigned short     r_port;
190
+  unsigned short     r_rtcp_port;
190 191
 
191 192
   /** 
192 193
    * Local interface used for this stream
... ...
@@ -220,8 +221,9 @@ protected:
220 221
   unsigned int   r_ssrc;
221 222
   bool           r_ssrc_i;
222 223
 
223
-  /** symmetric RTP */
224
-  bool           passive;      // passive mode ?
224
+  /** symmetric RTP & RTCP */
225
+  bool           passive;
226
+  bool           passive_rtcp;
225 227
 
226 228
   /** mute && port == 0 */
227 229
   bool           hold;
... ...
@@ -271,8 +273,8 @@ protected:
271 273
   /* Get next packet from the buffer queue */
272 274
   int nextPacket(AmRtpPacket*& p);
273 275
   
274
-  /** handle symmetric RTP - if in passive mode, update raddr from rp */
275
-  void handleSymmetricRtp(AmRtpPacket* rp);
276
+  /** handle symmetric RTP/RTCP - if in passive mode, update raddr from rp */
277
+  void handleSymmetricRtp(struct sockaddr_storage* recv_addr, bool rtcp);
276 278
 
277 279
   void relay(AmRtpPacket* p);
278 280
 
... ...
@@ -368,11 +370,12 @@ public:
368 370
   /**
369 371
    * Set remote IP & port.
370 372
    */
371
-  void setRAddr(const string& addr, unsigned short port);
373
+  void setRAddr(const string& addr, unsigned short port,
374
+		unsigned short rtcp_port = 0);
372 375
 
373
-  /** Symmetric RTP: passive mode ? */
376
+  /** Symmetric RTP & RTCP: passive mode ? */
374 377
   void setPassiveMode(bool p);
375
-  bool getPassiveMode() { return passive; }
378
+  bool getPassiveMode() { return passive || passive_rtcp; }
376 379
 
377 380
   unsigned int get_ssrc() { return l_ssrc; }
378 381
 
Browse code

Merge branch 'pbx/base' into pbx/master_subnot

Conflicts:
apps/sbc/SBC.cpp
apps/sbc/SBC.h
apps/sbc/SDPFilter.cpp
core/AmB2BMedia.cpp
core/AmB2BMedia.h
core/AmB2BSession.cpp
core/AmRtpStream.cpp
core/AmRtpStream.h
core/AmSipDialog.h
core/sip/defs.h

Work in progress - compilable but not working correctly.

Václav Kubart authored on 31/12/2012 15:51:24
Showing 0 changed files
Browse code

adds support for raw UDP relay.

Raphael Coeffic authored on 26/11/2012 12:08:36
Showing 1 changed files
... ...
@@ -249,6 +249,8 @@ protected:
249 249
 
250 250
   /** if relay_stream is initialized, received RTP is relayed there */
251 251
   bool            relay_enabled;
252
+  /** if true, packets are note parsed or checked */
253
+  bool            relay_raw;
252 254
   /** pointer to relay stream.
253 255
       NOTE: This may only be accessed in initialization
254 256
       or by the AmRtpReceiver thread while relaying!  */
... ...
@@ -452,11 +454,23 @@ public:
452 454
   /** disable RTP relaying through relay stream */
453 455
   void disableRtpRelay();
454 456
 
457
+  /** enable raw UDP relaying through relay stream */
458
+  void enableRawRelay();
459
+
460
+  /** disable raw UDP relaying through relay stream */
461
+  void disableRawRelay();
462
+
455 463
   /** enable or disable transparent RTP seqno for relay */
456 464
   void setRtpRelayTransparentSeqno(bool transparent);
457 465
 
458 466
   /** enable or disable transparent SSRC seqno for relay */
459 467
   void setRtpRelayTransparentSSRC(bool transparent);
468
+
469
+  /** remove from RTP receiver */
470
+  void stopReceiving();
471
+
472
+  /** (re-)insert into RTP receiver */
473
+  void resumeReceiving();
460 474
 };
461 475
 
462 476
 #endif
Browse code

additional PayloadMask operations

adds set_all() and invert().

Raphael Coeffic authored on 26/11/2012 12:02:47
Showing 1 changed files
... ...
@@ -111,6 +111,12 @@ class PayloadMask
111 111
     // set given flag (TODO: once it shows to be working, change / and % to >> and &)
112 112
     void set(unsigned char payload_id) { if (payload_id < 128) bits[payload_id / 8] |= 1 << (payload_id % 8); }
113 113
 
114
+    // set all flags to 'true'
115
+    void set_all();
116
+
117
+    // invert all flags
118
+    void invert();
119
+
114 120
     // get given flag
115 121
     bool get(unsigned char payload_id) { if (payload_id > 127) return false; return (bits[payload_id / 8] & (1 << (payload_id % 8))); }
116 122
     
Browse code

fixed IPv6 support

limitations: IPv6 DNS lookups are not supported yet.

Raphael Coeffic authored on 19/11/2012 16:23:06
Showing 1 changed files
... ...
@@ -191,13 +191,8 @@ protected:
191 191
   /**
192 192
    * Local and remote host addresses
193 193
    */
194
-#ifdef SUPPORT_IPV6
195 194
   struct sockaddr_storage r_saddr;
196 195
   struct sockaddr_storage l_saddr;
197
-#else
198
-  struct sockaddr_in r_saddr;
199
-  struct sockaddr_in l_saddr;
200
-#endif
201 196
 
202 197
   /** Local port */
203 198
   unsigned short     l_port;
Browse code

rtcp relay draft (WIP)

Raphael Coeffic authored on 11/09/2012 08:42:04
Showing 1 changed files
... ...
@@ -205,6 +205,12 @@ protected:
205 205
   /** Local socket */
206 206
   int                l_sd;
207 207
 
208
+  /** Local RTCP port */
209
+  unsigned int l_rtcp_port;
210
+
211
+  /** Local RTCP socket */
212
+  int          l_rtcp_sd;
213
+
208 214
   /** Timestamp of the last received RTP packet */
209 215
   struct timeval last_recv_time;
210 216
 
... ...
@@ -257,9 +263,6 @@ protected:
257 263
   /** Payload provider */
258 264
   AmPayloadProvider* payload_provider;
259 265
 
260
-  // get the next available port within configured range
261
-  static int getNextPort();
262
-
263 266
   /** Insert an RTP packet to the buffer queue */
264 267
   void bufferPacket(AmRtpPacket* p);
265 268
   /* Get next packet from the buffer queue */
... ...
@@ -318,7 +321,9 @@ public:
318 321
   int receive( unsigned char* buffer, unsigned int size,
319 322
 	       unsigned int& ts, int& payload );
320 323
 
321
-  void recvPacket();
324
+  void recvPacket(int fd);
325
+
326
+  void recvRtcpPacket();
322 327
 
323 328
   /** ping the remote side, to open NATs and enable symmetric RTP */
324 329
   int ping();
Browse code

rtp: speed up packet cache

Raphael Coeffic authored on 10/09/2012 15:25:21
Showing 1 changed files
... ...
@@ -68,7 +68,9 @@ struct amci_payload_t;
68 68
  * This provides the memory for the receive buffer.
69 69
  */
70 70
 struct PacketMem {
71
-#define MAX_PACKETS 32
71
+#define MAX_PACKETS_BITS 5
72
+#define MAX_PACKETS (1<<MAX_PACKETS_BITS)
73
+#define MAX_PACKETS_MASK (MAX_PACKETS-1)
72 74
 
73 75
   AmRtpPacket packets[MAX_PACKETS];
74 76
   bool        used[MAX_PACKETS];
... ...
@@ -78,6 +80,10 @@ struct PacketMem {
78 80
   inline AmRtpPacket* newPacket();
79 81
   inline void freePacket(AmRtpPacket* p);
80 82
   inline void clear();
83
+
84
+private:
85
+  unsigned int cur_idx;
86
+  unsigned int n_used;
81 87
 };
82 88
 
83 89
 /** \brief event fired on RTP timeout */
Browse code

symmetrical B2B legs: AmB2BMedia accepts NULL session

Still work in progress (not tested).

Václav Kubart authored on 30/07/2012 08:33:09
Showing 1 changed files
... ...
@@ -445,6 +445,11 @@ public:
445 445
 
446 446
   /** enable or disable transparent SSRC seqno for relay */
447 447
   void setRtpRelayTransparentSSRC(bool transparent);
448
+
449
+  /** Quick hack to assign existing stream to another session. The stream should
450
+   * not be reinitialised implicitly (it might be used for media traffic
451
+   * already). */
452
+  void changeSession(AmSession *_s) { session = _s; }
448 453
 };
449 454
 
450 455
 #endif
Browse code

b/f: relay RTP DTMF packets iff audio is currently relayed as well.

Raphael Coeffic authored on 24/04/2012 09:09:31
Showing 1 changed files
... ...
@@ -362,6 +362,7 @@ public:
362 362
 
363 363
   unsigned int get_ssrc() { return l_ssrc; }
364 364
 
365
+  int getLocalTelephoneEventPT();
365 366
   int getLocalTelephoneEventRate();
366 367
 
367 368
   void setPayloadProvider(AmPayloadProvider* pl_prov);
Browse code

b/f: AmB2BMedia: possible to force symmetric RTP

The SBC profile parameter rtp_relay_force_symmetric_rtp was ignored.

Thanks to Peter Loeppky for report.

Václav Kubart authored on 04/05/2012 12:03:26
Showing 1 changed files
... ...
@@ -401,7 +401,7 @@ public:
401 401
    * @warning It is necessary to call getSdpOffer/getSdpAnswer prior to init(...)
402 402
    * @warning so that the internal SDP media line index is set properly.
403 403
    */
404
-  virtual int init(const AmSdp& local, const AmSdp& remote);
404
+  virtual int init(const AmSdp& local, const AmSdp& remote, bool force_passive_mode = false);
405 405
 
406 406
   /**
407 407
    * Stops RTP stream.
Browse code

transcoder: statistics about input codec usage

Václav Kubart authored on 25/04/2012 10:00:07
Showing 1 changed files
... ...
@@ -369,7 +369,8 @@ public:
369 369
   int getSdpMediaIndex() { return sdp_media_index; }
370 370
   void forceSdpMediaIndex(int idx) { sdp_media_index = idx; offer_answer_used = false; }
371 371
   int getPayloadType() { return payload; }
372
-  string getPayloadName();
372
+  int getLastPayload() { return last_payload; }
373
+  string getPayloadName(int payload_type);
373 374
 
374 375
   /**
375 376
    * send a DTMF as RTP payload (RFC4733)
Browse code

transcoder: statistics about output codec usage

Václav Kubart authored on 25/04/2012 08:50:33
Showing 1 changed files
... ...
@@ -369,6 +369,7 @@ public:
369 369
   int getSdpMediaIndex() { return sdp_media_index; }
370 370
   void forceSdpMediaIndex(int idx) { sdp_media_index = idx; offer_answer_used = false; }
371 371
   int getPayloadType() { return payload; }
372
+  string getPayloadName();
372 373
 
373 374
   /**
374 375
    * send a DTMF as RTP payload (RFC4733)
Browse code

Merge branch 'transcoding'

Development of the transcoding feature has been sponsored by ng-voice GmbH / fibernetics.ca.

Raphael Coeffic authored on 18/04/2012 15:53:34
Showing 1 changed files
... ...
@@ -48,11 +48,12 @@ using std::pair;
48 48
 
49 49
 // return values of AmRtpStream::receive
50 50
 #define RTP_EMPTY        0 // no rtp packet available
51
-#define RTP_PARSE_ERROR -1 // error while parsing rtp packet
52
-#define RTP_TIMEOUT     -2 // last received packet is too old
53
-#define RTP_DTMF        -3 // dtmf packet has been received
54
-#define RTP_BUFFER_SIZE -4 // buffer overrun
55
-#define RTP_UNKNOWN_PL  -5 // unknown payload
51
+#define RTP_ERROR       -1 // generic error
52
+#define RTP_PARSE_ERROR -2 // error while parsing rtp packet
53
+#define RTP_TIMEOUT     -3 // last received packet is too old
54
+#define RTP_DTMF        -4 // dtmf packet has been received
55
+#define RTP_BUFFER_SIZE -5 // buffer overrun
56
+#define RTP_UNKNOWN_PL  -6 // unknown payload
56 57
 
57 58
 
58 59
 /**
... ...
@@ -90,6 +91,26 @@ public:
90 91
   ~AmRtpTimeoutEvent() { }
91 92
 };
92 93
 
94
+/** helper class for assigning boolean floag to a payload ID
95
+ * it is used to check if the payload should be relayed or not */
96
+class PayloadMask
97
+{
98
+  private:
99
+    unsigned char bits[16];
100
+
101
+  public:
102
+    // clear flag for all payloads
103
+    void clear();
104
+
105
+    // set given flag (TODO: once it shows to be working, change / and % to >> and &)
106
+    void set(unsigned char payload_id) { if (payload_id < 128) bits[payload_id / 8] |= 1 << (payload_id % 8); }
107
+
108
+    // get given flag
109
+    bool get(unsigned char payload_id) { if (payload_id > 127) return false; return (bits[payload_id / 8] & (1 << (payload_id % 8))); }
110
+    
111
+    PayloadMask() { clear(); }
112
+    PayloadMask(const PayloadMask &src);
113
+};
93 114
 
94 115
 /**
95 116
  * \brief represents one admissible payload type
... ...
@@ -249,6 +270,12 @@ protected:
249 270
   /** Clear RTP timeout at time recv_time */
250 271
   void clearRTPTimeout(struct timeval* recv_time);
251 272
 
273
+  PayloadMask relay_payloads;
274
+  bool offer_answer_used;
275
+
276
+  /** set to true if any data received */
277
+  bool active;
278
+
252 279
   /** 
253 280
    * Select a compatible default payload 
254 281
    * @return -1 if none available.
... ...
@@ -340,6 +367,7 @@ public:
340 367
   void setPayloadProvider(AmPayloadProvider* pl_prov);
341 368
 
342 369
   int getSdpMediaIndex() { return sdp_media_index; }
370
+  void forceSdpMediaIndex(int idx) { sdp_media_index = idx; offer_answer_used = false; }
343 371
   int getPayloadType() { return payload; }
344 372
 
345 373
   /**
... ...
@@ -404,6 +432,7 @@ public:
404 432
 
405 433
   /** ensable RTP relaying through relay stream */
406 434
   void enableRtpRelay();
435
+  void enableRtpRelay(const PayloadMask &_relay_payloads, AmRtpStream *_relay_stream);
407 436
 
408 437
   /** disable RTP relaying through relay stream */
409 438
   void disableRtpRelay();
Browse code

b/f: default codec selection fixed.

Raphael Coeffic authored on 02/03/2012 18:41:33
Showing 1 changed files
... ...
@@ -249,6 +249,12 @@ protected:
249 249
   /** Clear RTP timeout at time recv_time */
250 250
   void clearRTPTimeout(struct timeval* recv_time);
251 251
 
252
+  /** 
253
+   * Select a compatible default payload 
254
+   * @return -1 if none available.
255
+   */
256
+  int getDefaultPT();
257
+
252 258
 public:
253 259
 
254 260
   /** Mute */
Browse code

adds support for wideband audio

Raphael Coeffic authored on 21/02/2012 17:26:22
Showing 1 changed files
... ...
@@ -91,6 +91,19 @@ public:
91 91
 };
92 92
 
93 93
 
94
+/**
95
+ * \brief represents one admissible payload type
96
+ *
97
+ *
98
+ */
99
+struct Payload {
100
+  unsigned char pt;
101
+  string        name;
102
+  unsigned int  clock_rate;
103
+  unsigned int  advertised_clock_rate; // differs for G722
104
+  int           codec_id;
105
+};
106
+
94 107
 /**
95 108
  * \brief RTP implementation
96 109
  *
... ...
@@ -102,12 +115,13 @@ class AmRtpStream
102 115
 protected:
103 116
 
104 117
   // payload collection
105
-  struct Payload {
106
-    unsigned char pt;
107
-    string        name;
108
-    unsigned int  clock_rate;
109
-    int           codec_id;
110
-  };
118
+  typedef std::vector<Payload> PayloadCollection;
119
+  
120
+  // list of locally supported payloads
121
+  PayloadCollection payloads;
122
+
123
+  // current payload (index into @payloads)
124
+  int payload;
111 125
 
112 126
   struct PayloadMapping {
113 127
     // remote payload type
... ...
@@ -119,15 +133,8 @@ protected:
119 133
 
120 134
   typedef std::map<unsigned int, AmRtpPacket*, ts_less> ReceiveBuffer;
121 135
   typedef std::queue<AmRtpPacket*>                      RtpEventQueue;
122
-  typedef std::vector<Payload>                          PayloadCollection;
123 136
   typedef std::map<unsigned char, PayloadMapping>       PayloadMappingTable;
124 137
   
125
-  // list of locally supported payloads
126
-  PayloadCollection payloads;
127
-
128
-  // current payload (index into @payloads)
129
-  int payload;
130
-
131 138
   // mapping from local payload type to PayloadMapping
132 139
   PayloadMappingTable pl_map;
133 140
 
Browse code

support for receiving RTP DTMF while not processing RTP

based on a patch by Robert Szokovacs

Stefan Sayer authored on 24/02/2012 21:27:34
Showing 1 changed files
... ...
@@ -250,6 +250,9 @@ public:
250 250
   /** should we receive packets? if not -> drop */
251 251
   bool receiving;
252 252
 
253
+  /** should we receive RFC-2833-style DTMF even when receiving is disabled? */
254
+  bool force_receive_dtmf;
255
+
253 256
   /** Allocates resources for future use of RTP. */
254 257
   AmRtpStream(AmSession* _s, int _if);
255 258
 
Browse code

added configurable transparency for seqno/ssrc in RTP relay

Conflicts:

apps/sbc/SBCCallProfile.h
core/AmB2BSession.h
core/AmRtpStream.cpp

Stefan Sayer authored on 31/01/2012 20:17:49
Showing 1 changed files
... ...
@@ -212,6 +212,10 @@ protected:
212 212
       NOTE: This may only be accessed in initialization
213 213
       or by the AmRtpReceiver thread while relaying!  */
214 214
   AmRtpStream*    relay_stream;
215
+  /** control transparency for RTP seqno in RTP relay mode */
216
+  bool            relay_transparent_seqno;
217
+  /** control transparency for RTP ssrc in RTP relay mode */
218
+  bool            relay_transparent_ssrc;
215 219
 
216 220
   /** Session owning this stream */
217 221
   AmSession*         session;
... ...
@@ -388,6 +392,11 @@ public:
388 392
   /** disable RTP relaying through relay stream */
389 393
   void disableRtpRelay();
390 394
 
395
+  /** enable or disable transparent RTP seqno for relay */
396
+  void setRtpRelayTransparentSeqno(bool transparent);
397
+
398
+  /** enable or disable transparent SSRC seqno for relay */
399
+  void setRtpRelayTransparentSSRC(bool transparent);
391 400
 };
392 401
 
393 402
 #endif
Browse code

b/f: fix MT RTP receiver with RTP relay

- reversed the introduction of the rtp receiver thread index.
- simplest hashing (modulo) on socket descriptor seems to be sufficient.

Stefan Sayer authored on 21/01/2012 23:10:40 • Raphael Coeffic committed on 23/01/2012 11:41:27
Showing 1 changed files
... ...
@@ -171,9 +171,6 @@ protected:
171 171
   /** Local socket */
172 172
   int                l_sd;
173 173
 
174
-  /** Receiver thread index */
175
-  unsigned int       recver_index;
176
-
177 174
   /** Timestamp of the last received RTP packet */
178 175
   struct timeval last_recv_time;
179 176
 
... ...
@@ -279,9 +276,6 @@ public:
279 276
   /** initializes and gets the socket descriptor for local socket */
280 277
   int getLocalSocket();
281 278
 
282
-  /** returns the receiver thread index */
283
-  unsigned int getReceiverIndex() { return recver_index; }
284
-
285 279
   /**
286 280
    * This function must be called before setLocalPort, because
287 281
    * setLocalPort will bind the socket and it will be not
Browse code

added thread-pool support for the RTP receiver

- new config parameter: rtp_receiver_threads

Raphael Coeffic authored on 20/01/2012 15:49:22
Showing 1 changed files
... ...
@@ -171,6 +171,9 @@ protected:
171 171
   /** Local socket */
172 172
   int                l_sd;
173 173
 
174
+  /** Receiver thread index */
175
+  unsigned int       recver_index;
176
+
174 177
   /** Timestamp of the last received RTP packet */
175 178
   struct timeval last_recv_time;
176 179
 
... ...
@@ -276,6 +279,9 @@ public:
276 279
   /** initializes and gets the socket descriptor for local socket */
277 280
   int getLocalSocket();
278 281
 
282
+  /** returns the receiver thread index */
283
+  unsigned int getReceiverIndex() { return recver_index; }
284
+
279 285
   /**
280 286
    * This function must be called before setLocalPort, because
281 287
    * setLocalPort will bind the socket and it will be not
Browse code

some clean up in AmRtpStream

- moved packet receiving logic to the receiver to the stream.
- removed unnecessary attributes from the public interface.

Raphael Coeffic authored on 14/12/2011 17:42:25
Showing 1 changed files
... ...
@@ -182,6 +182,15 @@ protected:
182 182
   /** symmetric RTP */
183 183
   bool           passive;      // passive mode ?
184 184
 
185
+  /** mute && port == 0 */
186
+  bool           hold;
187
+
188
+  /** marker flag */
189
+  bool           begin_talk;
190
+
191
+  /** do check rtp timeout */
192
+  bool           monitor_rtp_timeout;
193
+
185 194
   /** Payload type for telephone event */
186 195
   auto_ptr<const SdpPayload> remote_telephone_event_pt;
187 196
   auto_ptr<const SdpPayload> local_telephone_event_pt;
... ...
@@ -210,7 +219,12 @@ protected:
210 219
   /** Payload provider */
211 220
   AmPayloadProvider* payload_provider;
212 221
 
213
-  /* get next packet in buffer */
222
+  // get the next available port within configured range
223
+  static int getNextPort();
224
+
225
+  /** Insert an RTP packet to the buffer queue */
226
+  void bufferPacket(AmRtpPacket* p);
227
+  /* Get next packet from the buffer queue */
214 228
   int nextPacket(AmRtpPacket*& p);
215 229
   
216 230
   /** handle symmetric RTP - if in passive mode, update raddr from rp */
... ...
@@ -221,28 +235,20 @@ protected:
221 235
   /** Sets generic parameters on SDP media */
222 236
   void getSdp(SdpMedia& m);
223 237
 
224
-  // get the next available port within configured range
225
-  static int getNextPort();
238
+  /** Clear RTP timeout at time recv_time */
239
+  void clearRTPTimeout(struct timeval* recv_time);
226 240
 
227 241
 public:
228 242
 
229
-  AmRtpPacket* newPacket();
230
-  void freePacket(AmRtpPacket* p);
231
-  
232 243
   /** Mute */
233 244
   bool mute;
234
-  /** mute && port == 0 */
235
-  bool hold;
236
-  /** marker flag */
237
-  bool begin_talk;
238
-  /** do check rtp timeout */
239
-  bool monitor_rtp_timeout;
240 245
 
241 246
   /** should we receive packets? if not -> drop */
242 247
   bool receiving;
243 248
 
244 249
   /** Allocates resources for future use of RTP. */
245 250
   AmRtpStream(AmSession* _s, int _if);
251
+
246 252
   /** Stops the stream and frees all resources. */
247 253
   virtual ~AmRtpStream();
248 254
 
... ...
@@ -259,6 +265,8 @@ public:
259 265
   int receive( unsigned char* buffer, unsigned int size,
260 266
 	       unsigned int& ts, int& payload );
261 267
 
268
+  void recvPacket();
269
+
262 270
   /** ping the remote side, to open NATs and enable symmetric RTP */
263 271
   int ping();
264 272
 
... ...
@@ -343,8 +351,7 @@ public:
343 351
    * @warning It is necessary to call getSdpOffer/getSdpAnswer prior to init(...)
344 352
    * @warning so that the internal SDP media line index is set properly.
345 353
    */
346
-  virtual int init(const AmSdp& local,
347
-		   const AmSdp& remote);
354
+  virtual int init(const AmSdp& local, const AmSdp& remote);
348 355
 
349 356
   /**
350 357
    * Stops RTP stream.
... ...
@@ -367,24 +374,11 @@ public:
367 374
   /** getter for monitor_rtp_timeout */
368 375
   bool getMonitorRTPTimeout() { return monitor_rtp_timeout; }
369 376
 
370
-  /**
371
-   * Insert an RTP packet to the buffer.
372
-   * Note: memory is owned by this instance.
373
-   */
374
-  void bufferPacket(AmRtpPacket* p);
375
-
376
-  /*
377
-   * clear RTP timeout at time recv_time 
378
-   */
379
-  void clearRTPTimeout(struct timeval* recv_time);
380
-
381 377
   /*
382 378
    * clear RTP timeout to current time
383 379
    */
384 380
   void clearRTPTimeout();
385 381
 
386
-  virtual unsigned int bytes2samples(unsigned int) const;
387
-
388 382
   /** set relay stream for  RTP relaying */
389 383
   void setRelayStream(AmRtpStream* stream);
390 384
 
Browse code

better support for multiple SDP media + small fixes in related use cases.

Raphael Coeffic authored on 14/12/2011 15:31:00
Showing 1 changed files
... ...
@@ -131,6 +131,10 @@ protected:
131 131
   // mapping from local payload type to PayloadMapping
132 132
   PayloadMappingTable pl_map;
133 133
 
134
+  /** SDP media slot number (n-th media line) */
135
+  int sdp_media_index;
136
+
137
+  /** RTP sequence number */
134 138
   unsigned int sequence;
135 139
 
136 140
   /**
... ...
@@ -307,6 +311,9 @@ public:
307 311
 
308 312
   void setPayloadProvider(AmPayloadProvider* pl_prov);
309 313
 
314
+  int getSdpMediaIndex() { return sdp_media_index; }
315
+  int getPayloadType() { return payload; }
316
+
310 317
   /**
311 318
    * send a DTMF as RTP payload (RFC4733)
312 319
    * @param event event ID (e.g. key press), see rfc
... ...
@@ -316,26 +323,27 @@ public:
316 323
 
317 324
   /**
318 325
    * Generate an SDP offer based on the stream capabilities.
326
+   * @param index index of the SDP media within the SDP.
319 327
    * @param offer the local offer to be filled/completed.
320 328
    */
321
-  virtual void getSdpOffer(SdpMedia& offer);
329
+  virtual void getSdpOffer(unsigned int index, SdpMedia& offer);
322 330
 
323 331
   /**
324 332
    * Generate an answer for the given SDP media based on the stream capabilities.
333
+   * @param index index of the SDP media within the SDP.
325 334
    * @param offer the remote offer.
326 335
    * @param answer the local answer to be filled/completed.
327 336
    */
328
-  virtual void getSdpAnswer(const SdpMedia& offer, SdpMedia& answer);
337
+  virtual void getSdpAnswer(unsigned int index, const SdpMedia& offer, SdpMedia& answer);
329 338
 
330 339
   /**
331 340
    * Enables RTP stream.
332
-   * @param sdp_payload payload from the SDP message.
333
-   * @warning start() must have been called so that play and record work.
334
-   * @warning It should be called only if the stream has been completly initialized,
335
-   * @warning and only once per session. Use resume() then.
341
+   * @param local the SDP message generated by the local UA.
342
+   * @param remote the SDP message generated by the remote UA.
343
+   * @warning It is necessary to call getSdpOffer/getSdpAnswer prior to init(...)
344
+   * @warning so that the internal SDP media line index is set properly.
336 345
    */
337
-  virtual int init(unsigned char media_i, 
338
-		   const AmSdp& local,
346
+  virtual int init(const AmSdp& local,
339 347
 		   const AmSdp& remote);
340 348
 
341 349
   /**
Browse code

moved DTMF sending support into AmDtmfSender.

Raphael Coeffic authored on 14/12/2011 11:41:17
Showing 1 changed files
... ...
@@ -34,6 +34,7 @@
34 34
 #include "SampleArray.h"
35 35
 #include "AmRtpPacket.h"
36 36
 #include "AmEvent.h"
37
+#include "AmDtmfSender.h"
37 38
 
38 39
 #include <netinet/in.h>
39 40
 
... ...
@@ -54,13 +55,13 @@ using std::pair;
54 55
 #define RTP_UNKNOWN_PL  -5 // unknown payload
55