You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.1 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
  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. #ifndef MODULES_AUDIO_CODING_TEST_CHANNEL_H_
  11. #define MODULES_AUDIO_CODING_TEST_CHANNEL_H_
  12. #include <stdio.h>
  13. #include "modules/audio_coding/include/audio_coding_module.h"
  14. #include "modules/include/module_common_types.h"
  15. #include "rtc_base/critical_section.h"
  16. namespace webrtc {
  17. #define MAX_NUM_PAYLOADS 50
  18. #define MAX_NUM_FRAMESIZES 6
  19. // TODO(turajs): Write constructor for this structure.
  20. struct ACMTestFrameSizeStats {
  21. uint16_t frameSizeSample;
  22. size_t maxPayloadLen;
  23. uint32_t numPackets;
  24. uint64_t totalPayloadLenByte;
  25. uint64_t totalEncodedSamples;
  26. double rateBitPerSec;
  27. double usageLenSec;
  28. };
  29. // TODO(turajs): Write constructor for this structure.
  30. struct ACMTestPayloadStats {
  31. bool newPacket;
  32. int16_t payloadType;
  33. size_t lastPayloadLenByte;
  34. uint32_t lastTimestamp;
  35. ACMTestFrameSizeStats frameSizeStats[MAX_NUM_FRAMESIZES];
  36. };
  37. class Channel : public AudioPacketizationCallback {
  38. public:
  39. Channel(int16_t chID = -1);
  40. ~Channel() override;
  41. int32_t SendData(AudioFrameType frameType,
  42. uint8_t payloadType,
  43. uint32_t timeStamp,
  44. const uint8_t* payloadData,
  45. size_t payloadSize) override;
  46. void RegisterReceiverACM(AudioCodingModule* acm);
  47. void ResetStats();
  48. void SetIsStereo(bool isStereo) { _isStereo = isStereo; }
  49. uint32_t LastInTimestamp();
  50. void SetFECTestWithPacketLoss(bool usePacketLoss) {
  51. _useFECTestWithPacketLoss = usePacketLoss;
  52. }
  53. double BitRate();
  54. void set_send_timestamp(uint32_t new_send_ts) {
  55. external_send_timestamp_ = new_send_ts;
  56. }
  57. void set_sequence_number(uint16_t new_sequence_number) {
  58. external_sequence_number_ = new_sequence_number;
  59. }
  60. void set_num_packets_to_drop(int new_num_packets_to_drop) {
  61. num_packets_to_drop_ = new_num_packets_to_drop;
  62. }
  63. private:
  64. void CalcStatistics(const RTPHeader& rtp_header, size_t payloadSize);
  65. AudioCodingModule* _receiverACM;
  66. uint16_t _seqNo;
  67. // 60msec * 32 sample(max)/msec * 2 description (maybe) * 2 bytes/sample
  68. uint8_t _payloadData[60 * 32 * 2 * 2];
  69. rtc::CriticalSection _channelCritSect;
  70. FILE* _bitStreamFile;
  71. bool _saveBitStream;
  72. int16_t _lastPayloadType;
  73. ACMTestPayloadStats _payloadStats[MAX_NUM_PAYLOADS];
  74. bool _isStereo;
  75. RTPHeader _rtp_header;
  76. bool _leftChannel;
  77. uint32_t _lastInTimestamp;
  78. bool _useLastFrameSize;
  79. uint32_t _lastFrameSizeSample;
  80. // FEC Test variables
  81. int16_t _packetLoss;
  82. bool _useFECTestWithPacketLoss;
  83. uint64_t _beginTime;
  84. uint64_t _totalBytes;
  85. // External timing info, defaulted to -1. Only used if they are
  86. // non-negative.
  87. int64_t external_send_timestamp_;
  88. int32_t external_sequence_number_;
  89. int num_packets_to_drop_;
  90. };
  91. } // namespace webrtc
  92. #endif // MODULES_AUDIO_CODING_TEST_CHANNEL_H_