Changeset 1839 for pjproject/trunk
- Timestamp:
- Mar 3, 2008 1:25:17 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/conference.c
r1833 r1839 180 180 unsigned tx_buf_count; /**< # of samples in the buffer. */ 181 181 182 /* When the port is not receiving signal from any other ports (e.g. when 183 * no other ports is transmitting to this port), the bridge periodically 184 * transmit NULL frame to the port to keep the port "alive" (for example, 185 * a stream port needs this heart-beat to periodically transmit silence 186 * frame to keep NAT binding alive). 187 * 188 * This NULL frame should be sent to the port at the port's ptime rate. 189 * So if the port's ptime is greater than the bridge's ptime, the bridge 190 * needs to delay the NULL frame until it's the right time to do so. 191 * 192 * This variable keeps track of how many pending NULL samples are being 193 * "held" for this port. Once this value reaches samples_per_frame 194 * value of the port, a NULL frame is sent. The samples value on this 195 * variable is clocked at the port's clock rate. 196 */ 197 unsigned tx_heart_beat; 198 182 199 /* Delay buffer is a special buffer for sound device port (port 0, master 183 200 * port) and other passive ports (sound device port is also passive port). … … 1389 1406 pjmedia_frame frame; 1390 1407 1391 /* Adjust the timestamp */ 1408 /* Clear left-over samples in tx_buffer, if any, so that it won't 1409 * be transmitted next time we have audio signal. 1410 */ 1411 cport->tx_buf_count = 0; 1412 1413 /* Add sample counts to heart-beat samples */ 1414 cport->tx_heart_beat += conf->samples_per_frame * cport->clock_rate / 1415 conf->clock_rate; 1416 1417 /* Set frame timestamp */ 1392 1418 frame.timestamp.u64 = timestamp->u64 * cport->clock_rate / 1393 1419 conf->clock_rate; … … 1396 1422 frame.size = 0; 1397 1423 1424 /* Transmit heart-beat frames (may transmit more than one NULL frame 1425 * if port's ptime is less than bridge's ptime. 1426 */ 1398 1427 if (cport->port && cport->port->put_frame) { 1399 pjmedia_port_put_frame(cport->port, &frame); 1428 while (cport->tx_heart_beat >= cport->samples_per_frame) { 1429 1430 pjmedia_port_put_frame(cport->port, &frame); 1431 1432 cport->tx_heart_beat -= cport->samples_per_frame; 1433 frame.timestamp.u64 += cport->samples_per_frame; 1434 } 1400 1435 } 1401 1436 … … 1409 1444 return PJ_SUCCESS; 1410 1445 } 1446 1447 /* Reset heart-beat sample count */ 1448 cport->tx_heart_beat = 0; 1411 1449 1412 1450 buf = (pj_int16_t*) cport->mix_buf;
Note: See TracChangeset
for help on using the changeset viewer.