blob: ebf4461d161af887fbd5557fa44b61d9a6379447 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:251/*
andrew@webrtc.orgd7a71d02012-08-01 01:40:022 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:253 *
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 Bonadei92ea95e2017-09-15 04:47:3111#ifndef MODULES_AUDIO_CODING_TEST_CHANNEL_H_
12#define MODULES_AUDIO_CODING_TEST_CHANNEL_H_
niklase@google.com470e71d2011-07-07 08:21:2513
14#include <stdio.h>
15
Henrik Lundin84f75692023-02-01 12:07:1016#include "modules/audio_coding/acm2/acm_receiver.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3117#include "modules/audio_coding/include/audio_coding_module.h"
18#include "modules/include/module_common_types.h"
Markus Handell0df0fae2020-07-07 13:53:3419#include "rtc_base/synchronization/mutex.h"
niklase@google.com470e71d2011-07-07 08:21:2520
tina.legrand@webrtc.org554ae1a2011-12-16 10:09:0421namespace webrtc {
niklase@google.com470e71d2011-07-07 08:21:2522
Yves Gerey665174f2018-06-19 13:03:0523#define MAX_NUM_PAYLOADS 50
24#define MAX_NUM_FRAMESIZES 6
niklase@google.com470e71d2011-07-07 08:21:2525
turaj@webrtc.orgc2d69d32014-02-19 20:31:1726// TODO(turajs): Write constructor for this structure.
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:1227struct ACMTestFrameSizeStats {
28 uint16_t frameSizeSample;
pkasting@chromium.org4591fbd2014-11-20 22:28:1429 size_t maxPayloadLen;
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:1230 uint32_t numPackets;
31 uint64_t totalPayloadLenByte;
32 uint64_t totalEncodedSamples;
33 double rateBitPerSec;
34 double usageLenSec;
niklase@google.com470e71d2011-07-07 08:21:2535};
36
turaj@webrtc.orgc2d69d32014-02-19 20:31:1737// TODO(turajs): Write constructor for this structure.
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:1238struct ACMTestPayloadStats {
39 bool newPacket;
40 int16_t payloadType;
pkasting@chromium.org4591fbd2014-11-20 22:28:1441 size_t lastPayloadLenByte;
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:1242 uint32_t lastTimestamp;
43 ACMTestFrameSizeStats frameSizeStats[MAX_NUM_FRAMESIZES];
niklase@google.com470e71d2011-07-07 08:21:2544};
45
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:1246class Channel : public AudioPacketizationCallback {
47 public:
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:1248 Channel(int16_t chID = -1);
kwiberg65fc8b92016-08-29 17:05:2449 ~Channel() override;
niklase@google.com470e71d2011-07-07 08:21:2550
Niels Möller87e2d782019-03-07 09:18:2351 int32_t SendData(AudioFrameType frameType,
kjellander@webrtc.org14665ff2015-03-04 12:58:3552 uint8_t payloadType,
53 uint32_t timeStamp,
54 const uint8_t* payloadData,
Minyue Liff0e4db2020-01-23 12:45:5055 size_t payloadSize,
56 int64_t absolute_capture_timestamp_ms) override;
niklase@google.com470e71d2011-07-07 08:21:2557
Henrik Lundin84f75692023-02-01 12:07:1058 void RegisterReceiverACM(acm2::AcmReceiver* acm_receiver);
andrew@webrtc.orgd7a71d02012-08-01 01:40:0259
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:1260 void ResetStats();
andrew@webrtc.orgd7a71d02012-08-01 01:40:0261
Yves Gerey665174f2018-06-19 13:03:0562 void SetIsStereo(bool isStereo) { _isStereo = isStereo; }
niklase@google.com470e71d2011-07-07 08:21:2563
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:1264 uint32_t LastInTimestamp();
andrew@webrtc.orgd7a71d02012-08-01 01:40:0265
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:1266 void SetFECTestWithPacketLoss(bool usePacketLoss) {
67 _useFECTestWithPacketLoss = usePacketLoss;
68 }
niklase@google.com470e71d2011-07-07 08:21:2569
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:1270 double BitRate();
niklase@google.com470e71d2011-07-07 08:21:2571
turaj@webrtc.orga305e962013-06-06 19:00:0972 void set_send_timestamp(uint32_t new_send_ts) {
73 external_send_timestamp_ = new_send_ts;
74 }
75
76 void set_sequence_number(uint16_t new_sequence_number) {
77 external_sequence_number_ = new_sequence_number;
78 }
79
80 void set_num_packets_to_drop(int new_num_packets_to_drop) {
81 num_packets_to_drop_ = new_num_packets_to_drop;
82 }
83
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:1284 private:
Niels Möllerbf474952019-02-18 11:00:0685 void CalcStatistics(const RTPHeader& rtp_header, size_t payloadSize);
niklase@google.com470e71d2011-07-07 08:21:2586
Henrik Lundin84f75692023-02-01 12:07:1087 acm2::AcmReceiver* _receiverACM;
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:1288 uint16_t _seqNo;
89 // 60msec * 32 sample(max)/msec * 2 description (maybe) * 2 bytes/sample
90 uint8_t _payloadData[60 * 32 * 2 * 2];
niklase@google.com470e71d2011-07-07 08:21:2591
Markus Handell0df0fae2020-07-07 13:53:3492 Mutex _channelCritSect;
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:1293 FILE* _bitStreamFile;
94 bool _saveBitStream;
95 int16_t _lastPayloadType;
96 ACMTestPayloadStats _payloadStats[MAX_NUM_PAYLOADS];
97 bool _isStereo;
Niels Möllerbf474952019-02-18 11:00:0698 RTPHeader _rtp_header;
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:1299 bool _leftChannel;
100 uint32_t _lastInTimestamp;
minyue@webrtc.org05617162015-03-03 12:02:30101 bool _useLastFrameSize;
102 uint32_t _lastFrameSizeSample;
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:12103 // FEC Test variables
104 int16_t _packetLoss;
105 bool _useFECTestWithPacketLoss;
106 uint64_t _beginTime;
107 uint64_t _totalBytes;
turaj@webrtc.orga305e962013-06-06 19:00:09108
109 // External timing info, defaulted to -1. Only used if they are
110 // non-negative.
111 int64_t external_send_timestamp_;
112 int32_t external_sequence_number_;
113 int num_packets_to_drop_;
niklase@google.com470e71d2011-07-07 08:21:25114};
115
tina.legrand@webrtc.orgd5726a122013-05-03 07:34:12116} // namespace webrtc
niklase@google.com470e71d2011-07-07 08:21:25117
Mirko Bonadei92ea95e2017-09-15 04:47:31118#endif // MODULES_AUDIO_CODING_TEST_CHANNEL_H_