tor-browser

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

rtp_file_source.h (2313B)


      1 /*
      2 *  Copyright (c) 2014 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_NETEQ_TOOLS_RTP_FILE_SOURCE_H_
     12 #define MODULES_AUDIO_CODING_NETEQ_TOOLS_RTP_FILE_SOURCE_H_
     13 
     14 #include <stdio.h>
     15 
     16 #include <cstdint>
     17 #include <memory>
     18 #include <optional>
     19 
     20 #include "absl/strings/string_view.h"
     21 #include "modules/audio_coding/neteq/tools/packet_source.h"
     22 #include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
     23 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
     24 #include "modules/rtp_rtcp/source/rtp_packet_received.h"
     25 
     26 namespace webrtc {
     27 
     28 namespace test {
     29 
     30 class RtpFileReader;
     31 
     32 class RtpFileSource : public PacketSource {
     33 public:
     34  // Creates an RtpFileSource reading from `file_name`. If the file cannot be
     35  // opened, or has the wrong format, NULL will be returned.
     36  static RtpFileSource* Create(
     37      absl::string_view file_name,
     38      std::optional<uint32_t> ssrc_filter = std::nullopt);
     39 
     40  // Checks whether a files is a valid RTP dump or PCAP (Wireshark) file.
     41  static bool ValidRtpDump(absl::string_view file_name);
     42  static bool ValidPcap(absl::string_view file_name);
     43 
     44  ~RtpFileSource() override;
     45 
     46  RtpFileSource(const RtpFileSource&) = delete;
     47  RtpFileSource& operator=(const RtpFileSource&) = delete;
     48 
     49  // Registers an RTP header extension and binds it to `id`.
     50  virtual bool RegisterRtpHeaderExtension(RTPExtensionType type, uint8_t id);
     51 
     52  std::unique_ptr<RtpPacketReceived> NextPacket() override;
     53 
     54 private:
     55  static const int kFirstLineLength = 40;
     56  static const int kRtpFileHeaderSize = 4 + 4 + 4 + 2 + 2;
     57  static const size_t kPacketHeaderSize = 8;
     58 
     59  explicit RtpFileSource(std::optional<uint32_t> ssrc_filter);
     60 
     61  bool OpenFile(absl::string_view file_name);
     62 
     63  std::unique_ptr<RtpFileReader> rtp_reader_;
     64  const std::optional<uint32_t> ssrc_filter_;
     65  RtpHeaderExtensionMap rtp_header_extension_map_;
     66 };
     67 
     68 }  // namespace test
     69 }  // namespace webrtc
     70 #endif  // MODULES_AUDIO_CODING_NETEQ_TOOLS_RTP_FILE_SOURCE_H_