tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Channel.h (3299B)


      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 
     11 #ifndef MODULES_AUDIO_CODING_TEST_CHANNEL_H_
     12 #define MODULES_AUDIO_CODING_TEST_CHANNEL_H_
     13 
     14 #include <stdio.h>
     15 
     16 #include <cstdint>
     17 
     18 #include "api/neteq/neteq.h"
     19 #include "modules/audio_coding/include/audio_coding_module.h"
     20 #include "modules/audio_coding/include/audio_coding_module_typedefs.h"
     21 #include "rtc_base/synchronization/mutex.h"
     22 
     23 namespace webrtc {
     24 
     25 #define MAX_NUM_PAYLOADS 50
     26 #define MAX_NUM_FRAMESIZES 6
     27 
     28 // TODO(turajs): Write constructor for this structure.
     29 struct ACMTestFrameSizeStats {
     30  uint16_t frameSizeSample;
     31  size_t maxPayloadLen;
     32  uint32_t numPackets;
     33  uint64_t totalPayloadLenByte;
     34  uint64_t totalEncodedSamples;
     35  double rateBitPerSec;
     36  double usageLenSec;
     37 };
     38 
     39 // TODO(turajs): Write constructor for this structure.
     40 struct ACMTestPayloadStats {
     41  bool newPacket;
     42  int16_t payloadType;
     43  size_t lastPayloadLenByte;
     44  uint32_t lastTimestamp;
     45  ACMTestFrameSizeStats frameSizeStats[MAX_NUM_FRAMESIZES];
     46 };
     47 
     48 class Channel : public AudioPacketizationCallback {
     49 public:
     50  Channel(int16_t chID = -1);
     51  ~Channel() override;
     52 
     53  int32_t SendData(AudioFrameType frameType,
     54                   uint8_t payloadType,
     55                   uint32_t timeStamp,
     56                   const uint8_t* payloadData,
     57                   size_t payloadSize,
     58                   int64_t absolute_capture_timestamp_ms) override;
     59 
     60  void RegisterReceiverNetEq(NetEq* neteq);
     61 
     62  void ResetStats();
     63 
     64  void SetIsStereo(bool isStereo) { _isStereo = isStereo; }
     65 
     66  uint32_t LastInTimestamp();
     67 
     68  void SetFECTestWithPacketLoss(bool usePacketLoss) {
     69    _useFECTestWithPacketLoss = usePacketLoss;
     70  }
     71 
     72  double BitRate();
     73 
     74  void set_send_timestamp(uint32_t new_send_ts) {
     75    external_send_timestamp_ = new_send_ts;
     76  }
     77 
     78  void set_sequence_number(uint16_t new_sequence_number) {
     79    external_sequence_number_ = new_sequence_number;
     80  }
     81 
     82  void set_num_packets_to_drop(int new_num_packets_to_drop) {
     83    num_packets_to_drop_ = new_num_packets_to_drop;
     84  }
     85 
     86 private:
     87  void CalcStatistics(const RTPHeader& rtp_header, size_t payloadSize);
     88 
     89  NetEq* _neteq;
     90  uint16_t _seqNo;
     91  // 60msec * 32 sample(max)/msec * 2 description (maybe) * 2 bytes/sample
     92  uint8_t _payloadData[60 * 32 * 2 * 2];
     93 
     94  Mutex _channelCritSect;
     95  FILE* _bitStreamFile;
     96  bool _saveBitStream;
     97  int16_t _lastPayloadType;
     98  ACMTestPayloadStats _payloadStats[MAX_NUM_PAYLOADS];
     99  bool _isStereo;
    100  RTPHeader _rtp_header;
    101  bool _leftChannel;
    102  uint32_t _lastInTimestamp;
    103  bool _useLastFrameSize;
    104  uint32_t _lastFrameSizeSample;
    105  // FEC Test variables
    106  int16_t _packetLoss;
    107  bool _useFECTestWithPacketLoss;
    108  uint64_t _beginTime;
    109  uint64_t _totalBytes;
    110 
    111  // External timing info, defaulted to -1. Only used if they are
    112  // non-negative.
    113  int64_t external_send_timestamp_;
    114  int32_t external_sequence_number_;
    115  int num_packets_to_drop_;
    116 };
    117 
    118 }  // namespace webrtc
    119 
    120 #endif  // MODULES_AUDIO_CODING_TEST_CHANNEL_H_