2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
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.
11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_RTP_FILE_SOURCE_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_RTP_FILE_SOURCE_H_
17 #include "webrtc/base/constructormagic.h"
18 #include "webrtc/common_types.h"
19 #include "webrtc/modules/audio_coding/neteq/tools/packet_source.h"
20 #include "webrtc/modules/rtp_rtcp/interface/rtp_rtcp_defines.h"
21 #include "webrtc/system_wrappers/interface/scoped_ptr.h"
25 class RtpHeaderParser;
29 class RtpFileSource : public PacketSource {
31 // Creates an RtpFileSource reading from |file_name|. If the file cannot be
32 // opened, or has the wrong format, NULL will be returned.
33 static RtpFileSource* Create(const std::string& file_name);
35 virtual ~RtpFileSource();
37 // Registers an RTP header extension and binds it to |id|.
38 virtual bool RegisterRtpHeaderExtension(RTPExtensionType type, uint8_t id);
40 // Returns a pointer to the next packet. Returns NULL if end of file was
41 // reached, or if a the data was corrupt.
42 virtual Packet* NextPacket();
44 // Returns true if the end of file has been reached.
45 virtual bool EndOfFile() const;
48 static const int kFirstLineLength = 40;
49 static const int kRtpFileHeaderSize = 4 + 4 + 4 + 2 + 2;
50 static const size_t kPacketHeaderSize = 8;
54 bool OpenFile(const std::string& file_name);
56 bool SkipFileHeader();
60 scoped_ptr<RtpHeaderParser> parser_;
62 DISALLOW_COPY_AND_ASSIGN(RtpFileSource);
67 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_RTP_FILE_SOURCE_H_