| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 } else { | 614 } else { |
| 615 // tone has ended | 615 // tone has ended |
| 616 makeRTPheader(rtp_data, NETEQ_CODEC_AVT_PT, seqNo, DTMFtimestamp, ssrc); | 616 makeRTPheader(rtp_data, NETEQ_CODEC_AVT_PT, seqNo, DTMFtimestamp, ssrc); |
| 617 enc_len = makeDTMFpayload(&rtp_data[12], NTone % 12, 1, 4, | 617 enc_len = makeDTMFpayload(&rtp_data[12], NTone % 12, 1, 4, |
| 618 DTMF_DURATION * (fs / 1000)); | 618 DTMF_DURATION * (fs / 1000)); |
| 619 NTone++; | 619 NTone++; |
| 620 DTMFfirst = 1; | 620 DTMFfirst = 1; |
| 621 } | 621 } |
| 622 | 622 |
| 623 /* write RTP packet to file */ | 623 /* write RTP packet to file */ |
| 624 length = htons(12 + enc_len + 8); | 624 length = htons(static_cast<unsigned short>(12 + enc_len + 8)); |
| 625 plen = htons(12 + enc_len); | 625 plen = htons(static_cast<unsigned short>(12 + enc_len)); |
| 626 offset = (uint32_t)sendtime; //(timestamp/(fs/1000)); | 626 offset = (uint32_t)sendtime; //(timestamp/(fs/1000)); |
| 627 offset = htonl(offset); | 627 offset = htonl(offset); |
| 628 if (fwrite(&length, 2, 1, out_file) != 1) { | 628 if (fwrite(&length, 2, 1, out_file) != 1) { |
| 629 return -1; | 629 return -1; |
| 630 } | 630 } |
| 631 if (fwrite(&plen, 2, 1, out_file) != 1) { | 631 if (fwrite(&plen, 2, 1, out_file) != 1) { |
| 632 return -1; | 632 return -1; |
| 633 } | 633 } |
| 634 if (fwrite(&offset, 4, 1, out_file) != 1) { | 634 if (fwrite(&offset, 4, 1, out_file) != 1) { |
| 635 return -1; | 635 return -1; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 666 } | 666 } |
| 667 #endif | 667 #endif |
| 668 | 668 |
| 669 if (enc_len > 0 && | 669 if (enc_len > 0 && |
| 670 (sendtime <= STOPSENDTIME || sendtime > RESTARTSENDTIME)) { | 670 (sendtime <= STOPSENDTIME || sendtime > RESTARTSENDTIME)) { |
| 671 if (useRed) { | 671 if (useRed) { |
| 672 if (red_len[0] > 0) { | 672 if (red_len[0] > 0) { |
| 673 memmove(&rtp_data[RTPheaderLen + red_len[0]], &rtp_data[12], enc_len); | 673 memmove(&rtp_data[RTPheaderLen + red_len[0]], &rtp_data[12], enc_len); |
| 674 memcpy(&rtp_data[RTPheaderLen], red_data, red_len[0]); | 674 memcpy(&rtp_data[RTPheaderLen], red_data, red_len[0]); |
| 675 | 675 |
| 676 red_len[1] = enc_len; | 676 red_len[1] = static_cast<uint16_t>(enc_len); |
| 677 red_TS[1] = timestamp; | 677 red_TS[1] = timestamp; |
| 678 if (vad) | 678 if (vad) |
| 679 red_PT[1] = payloadType; | 679 red_PT[1] = payloadType; |
| 680 else | 680 else |
| 681 red_PT[1] = NETEQ_CODEC_CN_PT; | 681 red_PT[1] = NETEQ_CODEC_CN_PT; |
| 682 | 682 |
| 683 makeRedundantHeader(rtp_data, red_PT, 2, red_TS, red_len, seqNo++, | 683 makeRedundantHeader(rtp_data, red_PT, 2, red_TS, red_len, seqNo++, |
| 684 ssrc); | 684 ssrc); |
| 685 | 685 |
| 686 enc_len += red_len[0] + RTPheaderLen - 12; | 686 enc_len += red_len[0] + RTPheaderLen - 12; |
| 687 } else { // do not use redundancy payload for this packet, i.e., only | 687 } else { // do not use redundancy payload for this packet, i.e., only |
| 688 // last payload | 688 // last payload |
| 689 memmove(&rtp_data[RTPheaderLen - 4], &rtp_data[12], enc_len); | 689 memmove(&rtp_data[RTPheaderLen - 4], &rtp_data[12], enc_len); |
| 690 // memcpy(&rtp_data[RTPheaderLen], red_data, red_len[0]); | 690 // memcpy(&rtp_data[RTPheaderLen], red_data, red_len[0]); |
| 691 | 691 |
| 692 red_len[1] = enc_len; | 692 red_len[1] = static_cast<uint16_t>(enc_len); |
| 693 red_TS[1] = timestamp; | 693 red_TS[1] = timestamp; |
| 694 if (vad) | 694 if (vad) |
| 695 red_PT[1] = payloadType; | 695 red_PT[1] = payloadType; |
| 696 else | 696 else |
| 697 red_PT[1] = NETEQ_CODEC_CN_PT; | 697 red_PT[1] = NETEQ_CODEC_CN_PT; |
| 698 | 698 |
| 699 makeRedundantHeader(rtp_data, red_PT, 2, red_TS, red_len, seqNo++, | 699 makeRedundantHeader(rtp_data, red_PT, 2, red_TS, red_len, seqNo++, |
| 700 ssrc); | 700 ssrc); |
| 701 | 701 |
| 702 enc_len += red_len[0] + RTPheaderLen - 4 - | 702 enc_len += red_len[0] + RTPheaderLen - 4 - |
| 703 12; // 4 is length of redundancy header (not used) | 703 12; // 4 is length of redundancy header (not used) |
| 704 } | 704 } |
| 705 } else { | 705 } else { |
| 706 /* make RTP header */ | 706 /* make RTP header */ |
| 707 if (vad) // regular speech data | 707 if (vad) // regular speech data |
| 708 makeRTPheader(rtp_data, payloadType, seqNo++, timestamp, ssrc); | 708 makeRTPheader(rtp_data, payloadType, seqNo++, timestamp, ssrc); |
| 709 else // CNG data | 709 else // CNG data |
| 710 makeRTPheader(rtp_data, NETEQ_CODEC_CN_PT, seqNo++, timestamp, ssrc); | 710 makeRTPheader(rtp_data, NETEQ_CODEC_CN_PT, seqNo++, timestamp, ssrc); |
| 711 } | 711 } |
| 712 #ifdef MULTIPLE_SAME_TIMESTAMP | 712 #ifdef MULTIPLE_SAME_TIMESTAMP |
| 713 int mult_pack = 0; | 713 int mult_pack = 0; |
| 714 do { | 714 do { |
| 715 #endif // MULTIPLE_SAME_TIMESTAMP | 715 #endif // MULTIPLE_SAME_TIMESTAMP |
| 716 /* write RTP packet to file */ | 716 /* write RTP packet to file */ |
| 717 length = htons(12 + enc_len + 8); | 717 length = htons(static_cast<unsigned short>(12 + enc_len + 8)); |
| 718 plen = htons(12 + enc_len); | 718 plen = htons(static_cast<unsigned short>(12 + enc_len)); |
| 719 offset = (uint32_t)sendtime; | 719 offset = (uint32_t)sendtime; |
| 720 //(timestamp/(fs/1000)); | 720 //(timestamp/(fs/1000)); |
| 721 offset = htonl(offset); | 721 offset = htonl(offset); |
| 722 if (fwrite(&length, 2, 1, out_file) != 1) { | 722 if (fwrite(&length, 2, 1, out_file) != 1) { |
| 723 return -1; | 723 return -1; |
| 724 } | 724 } |
| 725 if (fwrite(&plen, 2, 1, out_file) != 1) { | 725 if (fwrite(&plen, 2, 1, out_file) != 1) { |
| 726 return -1; | 726 return -1; |
| 727 } | 727 } |
| 728 if (fwrite(&offset, 4, 1, out_file) != 1) { | 728 if (fwrite(&offset, 4, 1, out_file) != 1) { |
| (...skipping 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1832 memmove(ptrL + stride, ptrL, ptrR - ptrL); | 1832 memmove(ptrL + stride, ptrL, ptrR - ptrL); |
| 1833 | 1833 |
| 1834 // copy from temp to left pointer | 1834 // copy from temp to left pointer |
| 1835 memcpy(ptrL, temp, stride); | 1835 memcpy(ptrL, temp, stride); |
| 1836 | 1836 |
| 1837 // advance pointers | 1837 // advance pointers |
| 1838 ptrL += stride * 2; | 1838 ptrL += stride * 2; |
| 1839 ptrR += stride; | 1839 ptrR += stride; |
| 1840 } | 1840 } |
| 1841 } | 1841 } |
| OLD | NEW |