rtp_file_reader.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #ifndef TEST_RTP_FILE_READER_H_
  11. #define TEST_RTP_FILE_READER_H_
  12. #include <set>
  13. #include <string>
  14. namespace webrtc {
  15. namespace test {
  16. struct RtpPacket {
  17. // Accommodate for 50 ms packets of 32 kHz PCM16 samples (3200 bytes) plus
  18. // some overhead.
  19. static const size_t kMaxPacketBufferSize = 3500;
  20. uint8_t data[kMaxPacketBufferSize];
  21. size_t length;
  22. // The length the packet had on wire. Will be different from |length| when
  23. // reading a header-only RTP dump.
  24. size_t original_length;
  25. uint32_t time_ms;
  26. };
  27. class RtpFileReader {
  28. public:
  29. enum FileFormat { kPcap, kRtpDump, kLengthPacketInterleaved };
  30. virtual ~RtpFileReader() {}
  31. static RtpFileReader* Create(FileFormat format,
  32. const uint8_t* data,
  33. size_t size,
  34. const std::set<uint32_t>& ssrc_filter);
  35. static RtpFileReader* Create(FileFormat format, const std::string& filename);
  36. static RtpFileReader* Create(FileFormat format,
  37. const std::string& filename,
  38. const std::set<uint32_t>& ssrc_filter);
  39. virtual bool NextPacket(RtpPacket* packet) = 0;
  40. };
  41. } // namespace test
  42. } // namespace webrtc
  43. #endif // TEST_RTP_FILE_READER_H_