Rename RtpFileReader::Packet to RtpPacket and move out of RtpFileReader
This is in preparation for creating a new class RtpFileWriter which will use the same RtpPacket struct. R=pbos@webrtc.org Review URL: https://webrtc-codereview.appspot.com/33429004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7749 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -43,7 +43,7 @@ bool RtpFileSource::RegisterRtpHeaderExtension(RTPExtensionType type,
|
|||||||
|
|
||||||
Packet* RtpFileSource::NextPacket() {
|
Packet* RtpFileSource::NextPacket() {
|
||||||
while (true) {
|
while (true) {
|
||||||
RtpFileReader::Packet temp_packet;
|
RtpPacket temp_packet;
|
||||||
if (!rtp_reader_->NextPacket(&temp_packet)) {
|
if (!rtp_reader_->NextPacket(&temp_packet)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ int main(int argc, char** argv) {
|
|||||||
int non_zero_ts_offsets = 0;
|
int non_zero_ts_offsets = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (next_rtp_time_ms <= clock.TimeInMilliseconds()) {
|
if (next_rtp_time_ms <= clock.TimeInMilliseconds()) {
|
||||||
webrtc::test::RtpFileReader::Packet packet;
|
webrtc::test::RtpPacket packet;
|
||||||
if (!rtp_reader->NextPacket(&packet)) {
|
if (!rtp_reader->NextPacket(&packet)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ int main(int argc, char** argv) {
|
|||||||
int packet_counter = 0;
|
int packet_counter = 0;
|
||||||
int non_zero_abs_send_time = 0;
|
int non_zero_abs_send_time = 0;
|
||||||
int non_zero_ts_offsets = 0;
|
int non_zero_ts_offsets = 0;
|
||||||
webrtc::test::RtpFileReader::Packet packet;
|
webrtc::test::RtpPacket packet;
|
||||||
while (rtp_reader->NextPacket(&packet)) {
|
while (rtp_reader->NextPacket(&packet)) {
|
||||||
webrtc::RTPHeader header;
|
webrtc::RTPHeader header;
|
||||||
parser->Parse(packet.data, packet.length, &header);
|
parser->Parse(packet.data, packet.length, &header);
|
||||||
|
|||||||
@@ -450,7 +450,7 @@ class RtpPlayerImpl : public RtpPlayerInterface {
|
|||||||
SsrcHandlers ssrc_handlers_;
|
SsrcHandlers ssrc_handlers_;
|
||||||
Clock* clock_;
|
Clock* clock_;
|
||||||
scoped_ptr<test::RtpFileReader> packet_source_;
|
scoped_ptr<test::RtpFileReader> packet_source_;
|
||||||
test::RtpFileReader::Packet next_packet_;
|
test::RtpPacket next_packet_;
|
||||||
uint32_t next_rtp_time_;
|
uint32_t next_rtp_time_;
|
||||||
bool first_packet_;
|
bool first_packet_;
|
||||||
int64_t first_packet_rtp_time_;
|
int64_t first_packet_rtp_time_;
|
||||||
|
|||||||
@@ -100,9 +100,9 @@ class RtpDumpReader : public RtpFileReaderImpl {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool NextPacket(Packet* packet) OVERRIDE {
|
virtual bool NextPacket(RtpPacket* packet) OVERRIDE {
|
||||||
uint8_t* rtp_data = packet->data;
|
uint8_t* rtp_data = packet->data;
|
||||||
packet->length = Packet::kMaxPacketBufferSize;
|
packet->length = RtpPacket::kMaxPacketBufferSize;
|
||||||
|
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
uint16_t plen;
|
uint16_t plen;
|
||||||
@@ -290,8 +290,8 @@ class PcapReader : public RtpFileReaderImpl {
|
|||||||
return kResultSuccess;
|
return kResultSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool NextPacket(Packet* packet) OVERRIDE {
|
virtual bool NextPacket(RtpPacket* packet) OVERRIDE {
|
||||||
uint32_t length = Packet::kMaxPacketBufferSize;
|
uint32_t length = RtpPacket::kMaxPacketBufferSize;
|
||||||
if (NextPcap(packet->data, &length, &packet->time_ms) != kResultSuccess)
|
if (NextPcap(packet->data, &length, &packet->time_ms) != kResultSuccess)
|
||||||
return false;
|
return false;
|
||||||
packet->length = static_cast<size_t>(length);
|
packet->length = static_cast<size_t>(length);
|
||||||
|
|||||||
@@ -16,6 +16,20 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
|
struct RtpPacket {
|
||||||
|
// Accommodate for 50 ms packets of 32 kHz PCM16 samples (3200 bytes) plus
|
||||||
|
// some overhead.
|
||||||
|
static const size_t kMaxPacketBufferSize = 3500;
|
||||||
|
uint8_t data[kMaxPacketBufferSize];
|
||||||
|
size_t length;
|
||||||
|
// The length the packet had on wire. Will be different from |length| when
|
||||||
|
// reading a header-only RTP dump.
|
||||||
|
size_t original_length;
|
||||||
|
|
||||||
|
uint32_t time_ms;
|
||||||
|
};
|
||||||
|
|
||||||
class RtpFileReader {
|
class RtpFileReader {
|
||||||
public:
|
public:
|
||||||
enum FileFormat {
|
enum FileFormat {
|
||||||
@@ -23,24 +37,11 @@ class RtpFileReader {
|
|||||||
kRtpDump,
|
kRtpDump,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Packet {
|
|
||||||
// Accommodate for 50 ms packets of 32 kHz PCM16 samples (3200 bytes) plus
|
|
||||||
// some overhead.
|
|
||||||
static const size_t kMaxPacketBufferSize = 3500;
|
|
||||||
uint8_t data[kMaxPacketBufferSize];
|
|
||||||
size_t length;
|
|
||||||
// The length the packet had on wire. Will be different from |length| when
|
|
||||||
// reading a header-only RTP dump.
|
|
||||||
size_t original_length;
|
|
||||||
|
|
||||||
uint32_t time_ms;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual ~RtpFileReader() {}
|
virtual ~RtpFileReader() {}
|
||||||
static RtpFileReader* Create(FileFormat format,
|
static RtpFileReader* Create(FileFormat format,
|
||||||
const std::string& filename);
|
const std::string& filename);
|
||||||
|
|
||||||
virtual bool NextPacket(Packet* packet) = 0;
|
virtual bool NextPacket(RtpPacket* packet) = 0;
|
||||||
};
|
};
|
||||||
} // namespace test
|
} // namespace test
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class TestRtpFileReader : public ::testing::Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int CountRtpPackets() {
|
int CountRtpPackets() {
|
||||||
test::RtpFileReader::Packet packet;
|
test::RtpPacket packet;
|
||||||
int c = 0;
|
int c = 0;
|
||||||
while (rtp_packet_source_->NextPacket(&packet)) {
|
while (rtp_packet_source_->NextPacket(&packet)) {
|
||||||
if (headers_only_file_)
|
if (headers_only_file_)
|
||||||
@@ -71,7 +71,7 @@ class TestPcapFileReader : public ::testing::Test {
|
|||||||
|
|
||||||
int CountRtpPackets() {
|
int CountRtpPackets() {
|
||||||
int c = 0;
|
int c = 0;
|
||||||
test::RtpFileReader::Packet packet;
|
test::RtpPacket packet;
|
||||||
while (rtp_packet_source_->NextPacket(&packet)) {
|
while (rtp_packet_source_->NextPacket(&packet)) {
|
||||||
EXPECT_EQ(packet.length, packet.original_length);
|
EXPECT_EQ(packet.length, packet.original_length);
|
||||||
c++;
|
c++;
|
||||||
@@ -81,7 +81,7 @@ class TestPcapFileReader : public ::testing::Test {
|
|||||||
|
|
||||||
PacketsPerSsrc CountRtpPacketsPerSsrc() {
|
PacketsPerSsrc CountRtpPacketsPerSsrc() {
|
||||||
PacketsPerSsrc pps;
|
PacketsPerSsrc pps;
|
||||||
test::RtpFileReader::Packet packet;
|
test::RtpPacket packet;
|
||||||
while (rtp_packet_source_->NextPacket(&packet)) {
|
while (rtp_packet_source_->NextPacket(&packet)) {
|
||||||
RtpUtility::RtpHeaderParser rtp_header_parser(packet.data, packet.length);
|
RtpUtility::RtpHeaderParser rtp_header_parser(packet.data, packet.length);
|
||||||
webrtc::RTPHeader header;
|
webrtc::RTPHeader header;
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ void RtpReplay() {
|
|||||||
int num_packets = 0;
|
int num_packets = 0;
|
||||||
std::map<uint32_t, int> unknown_packets;
|
std::map<uint32_t, int> unknown_packets;
|
||||||
while (true) {
|
while (true) {
|
||||||
test::RtpFileReader::Packet packet;
|
test::RtpPacket packet;
|
||||||
if (!rtp_reader->NextPacket(&packet))
|
if (!rtp_reader->NextPacket(&packet))
|
||||||
break;
|
break;
|
||||||
++num_packets;
|
++num_packets;
|
||||||
|
|||||||
Reference in New Issue
Block a user