niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_CODING_TEST_CHANNEL_H_ |
| 12 | #define MODULES_AUDIO_CODING_TEST_CHANNEL_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
| 14 | #include <stdio.h> |
| 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "modules/audio_coding/include/audio_coding_module.h" |
| 17 | #include "modules/include/module_common_types.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame^] | 18 | #include "rtc_base/critical_section.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | |
tina.legrand@webrtc.org | 554ae1a | 2011-12-16 10:09:04 +0000 | [diff] [blame] | 20 | namespace webrtc { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 22 | #define MAX_NUM_PAYLOADS 50 |
| 23 | #define MAX_NUM_FRAMESIZES 6 |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 24 | |
turaj@webrtc.org | c2d69d3 | 2014-02-19 20:31:17 +0000 | [diff] [blame] | 25 | // TODO(turajs): Write constructor for this structure. |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 26 | struct ACMTestFrameSizeStats { |
| 27 | uint16_t frameSizeSample; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 28 | size_t maxPayloadLen; |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 29 | uint32_t numPackets; |
| 30 | uint64_t totalPayloadLenByte; |
| 31 | uint64_t totalEncodedSamples; |
| 32 | double rateBitPerSec; |
| 33 | double usageLenSec; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 34 | }; |
| 35 | |
turaj@webrtc.org | c2d69d3 | 2014-02-19 20:31:17 +0000 | [diff] [blame] | 36 | // TODO(turajs): Write constructor for this structure. |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 37 | struct ACMTestPayloadStats { |
| 38 | bool newPacket; |
| 39 | int16_t payloadType; |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 40 | size_t lastPayloadLenByte; |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 41 | uint32_t lastTimestamp; |
| 42 | ACMTestFrameSizeStats frameSizeStats[MAX_NUM_FRAMESIZES]; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 45 | class Channel : public AudioPacketizationCallback { |
| 46 | public: |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 47 | Channel(int16_t chID = -1); |
kwiberg | 65fc8b9 | 2016-08-29 10:05:24 -0700 | [diff] [blame] | 48 | ~Channel() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 49 | |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 50 | int32_t SendData(FrameType frameType, |
| 51 | uint8_t payloadType, |
| 52 | uint32_t timeStamp, |
| 53 | const uint8_t* payloadData, |
| 54 | size_t payloadSize, |
| 55 | const RTPFragmentationHeader* fragmentation) override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 56 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 57 | void RegisterReceiverACM(AudioCodingModule* acm); |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 58 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 59 | void ResetStats(); |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 60 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 61 | void SetIsStereo(bool isStereo) { _isStereo = isStereo; } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 62 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 63 | uint32_t LastInTimestamp(); |
andrew@webrtc.org | d7a71d0 | 2012-08-01 01:40:02 +0000 | [diff] [blame] | 64 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 65 | void SetFECTestWithPacketLoss(bool usePacketLoss) { |
| 66 | _useFECTestWithPacketLoss = usePacketLoss; |
| 67 | } |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 68 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 69 | double BitRate(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 70 | |
turaj@webrtc.org | a305e96 | 2013-06-06 19:00:09 +0000 | [diff] [blame] | 71 | void set_send_timestamp(uint32_t new_send_ts) { |
| 72 | external_send_timestamp_ = new_send_ts; |
| 73 | } |
| 74 | |
| 75 | void set_sequence_number(uint16_t new_sequence_number) { |
| 76 | external_sequence_number_ = new_sequence_number; |
| 77 | } |
| 78 | |
| 79 | void set_num_packets_to_drop(int new_num_packets_to_drop) { |
| 80 | num_packets_to_drop_ = new_num_packets_to_drop; |
| 81 | } |
| 82 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 83 | private: |
pkasting@chromium.org | 4591fbd | 2014-11-20 22:28:14 +0000 | [diff] [blame] | 84 | void CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 85 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 86 | AudioCodingModule* _receiverACM; |
| 87 | uint16_t _seqNo; |
| 88 | // 60msec * 32 sample(max)/msec * 2 description (maybe) * 2 bytes/sample |
| 89 | uint8_t _payloadData[60 * 32 * 2 * 2]; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 90 | |
pbos | 5ad935c | 2016-01-25 03:52:44 -0800 | [diff] [blame] | 91 | rtc::CriticalSection _channelCritSect; |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 92 | FILE* _bitStreamFile; |
| 93 | bool _saveBitStream; |
| 94 | int16_t _lastPayloadType; |
| 95 | ACMTestPayloadStats _payloadStats[MAX_NUM_PAYLOADS]; |
| 96 | bool _isStereo; |
| 97 | WebRtcRTPHeader _rtpInfo; |
| 98 | bool _leftChannel; |
| 99 | uint32_t _lastInTimestamp; |
minyue@webrtc.org | 0561716 | 2015-03-03 12:02:30 +0000 | [diff] [blame] | 100 | bool _useLastFrameSize; |
| 101 | uint32_t _lastFrameSizeSample; |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 102 | // FEC Test variables |
| 103 | int16_t _packetLoss; |
| 104 | bool _useFECTestWithPacketLoss; |
| 105 | uint64_t _beginTime; |
| 106 | uint64_t _totalBytes; |
turaj@webrtc.org | a305e96 | 2013-06-06 19:00:09 +0000 | [diff] [blame] | 107 | |
| 108 | // External timing info, defaulted to -1. Only used if they are |
| 109 | // non-negative. |
| 110 | int64_t external_send_timestamp_; |
| 111 | int32_t external_sequence_number_; |
| 112 | int num_packets_to_drop_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 113 | }; |
| 114 | |
tina.legrand@webrtc.org | d5726a1 | 2013-05-03 07:34:12 +0000 | [diff] [blame] | 115 | } // namespace webrtc |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 116 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 117 | #endif // MODULES_AUDIO_CODING_TEST_CHANNEL_H_ |