提交 cc6cc6e4 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

test-rtp.cpp: code cleanup.

上级 d065ad7a
...@@ -11,24 +11,23 @@ using namespace RTC; ...@@ -11,24 +11,23 @@ using namespace RTC;
FCTMF_SUITE_BGN(test_rtp) FCTMF_SUITE_BGN(test_rtp)
{ {
FCT_TEST_BGN(parse_packet) FCT_TEST_BGN(parse_rtp_packet)
{ {
// DOC: http://insanecoding.blogspot.com.es/2011/11/how-to-read-in-file-in-c.html // DOC: http://insanecoding.blogspot.com.es/2011/11/how-to-read-in-file-in-c.html
uint8_t buffer[65536]; uint8_t buffer[65536];
std::ifstream in("worker/test/data/packet1.raw", std::ios::in | std::ios::binary); std::ifstream in("worker/test/data/packet1.raw", std::ios::ate | std::ios::binary);
if (in) if (in)
{ {
in.seekg(0, std::ios::end); size_t file_size = (size_t)in.tellg() - 1;
size_t file_size = in.tellg();
in.seekg(0, std::ios::beg); in.seekg(0, std::ios::beg);
in.read((char*)buffer, file_size); in.read((char*)buffer, file_size);
in.close(); in.close();
// TODO: Why -1??? It fails without it! RtpPacket* packet = RtpPacket::Parse(buffer, file_size);
RtpPacket* packet = RtpPacket::Parse(buffer, file_size - 1);
if (!packet) if (!packet)
{ {
...@@ -38,12 +37,7 @@ FCTMF_SUITE_BGN(test_rtp) ...@@ -38,12 +37,7 @@ FCTMF_SUITE_BGN(test_rtp)
return; return;
} }
packet->Dump(); // packet->Dump();
// MS_ERROR("-- payload type: %" PRIu8, packet->GetPayloadType());
// auto pt = packet->GetPayloadType();
// uint8_t pt = 11;
// fct_chk_eq_int(pt, 112);
fct_chk(packet->HasMarker() == false); fct_chk(packet->HasMarker() == false);
fct_chk(packet->HasExtensionHeader() == true); fct_chk(packet->HasExtensionHeader() == true);
...@@ -54,11 +48,11 @@ FCTMF_SUITE_BGN(test_rtp) ...@@ -54,11 +48,11 @@ FCTMF_SUITE_BGN(test_rtp)
fct_chk_eq_int(packet->GetTimestamp(), 1660241882); fct_chk_eq_int(packet->GetTimestamp(), 1660241882);
fct_chk_eq_int(packet->GetSsrc(), 2674985186); fct_chk_eq_int(packet->GetSsrc(), 2674985186);
// delete packet; delete packet;
} }
else else
{ {
// TODO: What here? how to fial the test? // TODO: What here? how to fail the test?
MS_ERROR("file not found"); MS_ERROR("file not found");
} }
} }
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论