2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_CHANNEL_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_CHANNEL_H_
16 #include "webrtc/modules/audio_coding/main/interface/audio_coding_module.h"
17 #include "webrtc/modules/interface/module_common_types.h"
18 #include "webrtc/typedefs.h"
22 class CriticalSectionWrapper;
24 #define MAX_NUM_PAYLOADS 50
25 #define MAX_NUM_FRAMESIZES 6
27 // TODO(turajs): Write constructor for this structure.
28 struct ACMTestFrameSizeStats {
29 uint16_t frameSizeSample;
30 int16_t maxPayloadLen;
32 uint64_t totalPayloadLenByte;
33 uint64_t totalEncodedSamples;
38 // TODO(turajs): Write constructor for this structure.
39 struct ACMTestPayloadStats {
42 int16_t lastPayloadLenByte;
43 uint32_t lastTimestamp;
44 ACMTestFrameSizeStats frameSizeStats[MAX_NUM_FRAMESIZES];
47 class Channel : public AudioPacketizationCallback {
50 Channel(int16_t chID = -1);
53 virtual int32_t SendData(
54 const FrameType frameType, const uint8_t payloadType,
55 const uint32_t timeStamp, const uint8_t* payloadData,
56 const uint16_t payloadSize,
57 const RTPFragmentationHeader* fragmentation) OVERRIDE;
59 void RegisterReceiverACM(AudioCodingModule *acm);
63 int16_t Stats(CodecInst& codecInst, ACMTestPayloadStats& payloadStats);
65 void Stats(uint32_t* numPackets);
67 void Stats(uint8_t* payloadLenByte, uint32_t* payloadType);
69 void PrintStats(CodecInst& codecInst);
71 void SetIsStereo(bool isStereo) {
75 uint32_t LastInTimestamp();
77 void SetFECTestWithPacketLoss(bool usePacketLoss) {
78 _useFECTestWithPacketLoss = usePacketLoss;
83 void set_send_timestamp(uint32_t new_send_ts) {
84 external_send_timestamp_ = new_send_ts;
87 void set_sequence_number(uint16_t new_sequence_number) {
88 external_sequence_number_ = new_sequence_number;
91 void set_num_packets_to_drop(int new_num_packets_to_drop) {
92 num_packets_to_drop_ = new_num_packets_to_drop;
96 void CalcStatistics(WebRtcRTPHeader& rtpInfo, uint16_t payloadSize);
98 AudioCodingModule* _receiverACM;
100 // 60msec * 32 sample(max)/msec * 2 description (maybe) * 2 bytes/sample
101 uint8_t _payloadData[60 * 32 * 2 * 2];
103 CriticalSectionWrapper* _channelCritSect;
104 FILE* _bitStreamFile;
106 int16_t _lastPayloadType;
107 ACMTestPayloadStats _payloadStats[MAX_NUM_PAYLOADS];
109 WebRtcRTPHeader _rtpInfo;
111 uint32_t _lastInTimestamp;
112 // FEC Test variables
114 bool _useFECTestWithPacketLoss;
116 uint64_t _totalBytes;
118 // External timing info, defaulted to -1. Only used if they are
120 int64_t external_send_timestamp_;
121 int32_t external_sequence_number_;
122 int num_packets_to_drop_;
125 } // namespace webrtc
127 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_TEST_CHANNEL_H_