Skip to content

Commit

Permalink
change: update test file
Browse files Browse the repository at this point in the history
  • Loading branch information
ireader committed Jan 19, 2025
1 parent e3186d5 commit a745b95
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 24 deletions.
6 changes: 5 additions & 1 deletion libmpeg/source/mpeg-pmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,14 @@ static int pmt_read_descriptor(struct pes_t* stream, const uint8_t* data, uint16
assert(PSI_STREAM_PRIVATE_DATA == stream->codecid);
stream->codecid = PSI_STREAM_AV1;
}
else if (len >= 4 && 'A' == data[2] && 'V' == data[3] && 'S' == data[4] && '3' == data[5])
else if (len >= 4 && 'A' == data[2] && 'V' == data[3] && 'S' == data[4] && ('3' == data[5] || 'V' == data[5]))
{
stream->codecid = PSI_STREAM_VIDEO_AVS3;
}
else if (len >= 4 && 'A' == data[2] && 'V' == data[3] && 'S' == data[4] && 'A' == data[5])
{
stream->codecid = PSI_STREAM_AUDIO_AVS3;
}
break;

case 0x7f: // DVB-Service Information: 6.1 Descriptor identification and location (p38)
Expand Down
2 changes: 1 addition & 1 deletion libmpeg/test/mpeg-ts-dec-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static int on_ts_packet(void* /*param*/, int program, int stream, int avtype, in
{
static char s_pts[64], s_dts[64];

if (PSI_STREAM_AAC == avtype || PSI_STREAM_AUDIO_OPUS == avtype)
if (PSI_STREAM_AAC == avtype || PSI_STREAM_AUDIO_OPUS == avtype || PSI_STREAM_AUDIO_AVS3 == avtype)
{
static int64_t a_pts = 0, a_dts = 0;
if (PTS_NO_VALUE == dts)
Expand Down
31 changes: 14 additions & 17 deletions librtp/test/rtp-payload-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ struct rtp_payload_test_t
const char* encoding;

FILE* frtp;
FILE* fsource;
FILE* frtp2;
FILE* fsource2;
FILE* fout2;

void* encoder;
void* decoder;
Expand Down Expand Up @@ -55,7 +54,7 @@ static int rtp_encode_packet(void* param, const void *packet, int bytes, uint32_

static int mpeg_ps_demuxer_onpacket(void* param, int stream, int codecid, int flags, int64_t pts, int64_t dts, const void* data, size_t bytes)
{
printf("[%d] codec: %d, pts: %" PRId64 ", dts: %" PRId64 ", bytes: %d, flags: 0x%x\n", stream, codecid, pts, dts, (int)bytes, flags);
printf("[%d] codec: %d, pts: %" PRId64 ", dts: %" PRId64 ", bytes: %d, flags: 0x%x\n", stream, codecid, pts/90, dts/90, (int)bytes, flags);
return 0;
}

Expand Down Expand Up @@ -107,22 +106,21 @@ static int rtp_decode_packet(void* param, const void *packet, int bytes, uint32_

// TODO:
// check media file
fwrite(buffer, 1, size, ctx->fsource2);
fwrite(buffer, 1, size, ctx->fout2);

return rtp_payload_encode_input(ctx->encoder, buffer, size, timestamp);
}

void rtp_payload_test(int payload, const char* encoding, uint16_t seq, uint32_t ssrc, const char* rtpfile, const char* sourcefile)
static void rtp_payload_test(int payload, const char* encoding, uint16_t seq, uint32_t ssrc, const char* rtpfile, const char* deprecated)
{
struct rtp_payload_test_t ctx;
memset(&ctx, 0, sizeof(ctx));
ctx.payload = payload;
ctx.encoding = encoding;

ctx.frtp = fopen(rtpfile, "rb");
ctx.fsource = fopen(sourcefile, "rb");
ctx.frtp2 = fopen("out.rtp", "wb");
ctx.fsource2 = fopen("out.media", "wb");
ctx.fout2 = fopen("out.media", "wb");

rtp_packet_setsize(1456); // 1456(live555)

Expand All @@ -138,7 +136,7 @@ void rtp_payload_test(int payload, const char* encoding, uint16_t seq, uint32_t
handler1.packet = rtp_decode_packet;
ctx.decoder = rtp_payload_decode_create(payload, encoding, &handler1, &ctx);

while (1)
for(int i = 0; ;i++)
{
uint8_t s2[2];
if (2 != fread(s2, 1, 2, ctx.frtp))
Expand All @@ -153,20 +151,19 @@ void rtp_payload_test(int payload, const char* encoding, uint16_t seq, uint32_t
rtp_payload_decode_input(ctx.decoder, ctx.packet, ctx.size);
}

fclose(ctx.frtp2);
fclose(ctx.fsource2);
fclose(ctx.frtp);
fclose(ctx.fsource);
fclose(ctx.frtp2);
fclose(ctx.fout2);
rtp_payload_decode_destroy(ctx.decoder);
rtp_payload_encode_destroy(ctx.encoder);
}

void binary_diff(const char* f1, const char* f2);
// todo: binary_diff(rtpfile£¬ deprecated)
}

// http://www.live555.com/liveMedia/public/
void rtp_payload_test()
void rtp_payload_test(const char* file, int payload, const char* encoding)
{
//rtp_payload_test(33, "MP2T", 24470, 1726408532, "E:\\video\\rtp\\bipbop-gear1-all.ts.rtp", "E:\\video\\rtp\\bipbop-gear1-all.ts");
//rtp_payload_test(33, "MP2T", 24470, 1726408532, "E:\\video\\rtp\\bipbop-gear1-all.ts.rtp");
//binary_diff("E:\\video\\rtp\\bipbop-gear1-all.ts.rtp", "out.rtp");
//binary_diff("E:\\video\\rtp\\bipbop-gear1-all.ts", "out.media");

Expand Down Expand Up @@ -207,6 +204,6 @@ void rtp_payload_test()
//binary_diff("E:\\work\\media-server\\rtmp2hls\\192.168.31.132.6974.96.VP8", "out.media");

//rtp_payload_test(96, "AV1", 12686, 1957754144, "C:\\Users\\Administrator\\Downloads\\1688.rtp", "1.h264");
//rtp_payload_test(96, "PS", 12686, 1957754144, "C:\\Users\\Administrator\\Downloads\\talk.bin", "1.ps");
rtp_payload_test(100, "PS", 12686, 0x615658d, "C:\\Users\\Administrator\\Downloads\\rtp.tcp", "1.ps");
//rtp_payload_test(96, "PS", 12686, 1957754144, "C:\\Users\\Administrator\\Downloads\\1.rtp", "1.ps");
rtp_payload_test(payload, encoding, 0, 0, file, "");
}
34 changes: 31 additions & 3 deletions librtsp/test/sdp-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ static const char* sdp_read(const char* file)
return s_sdp;
}

void sdp_test(const char* file)
void sdp_test1(const char* file)
{
const char* txt = sdp_read(file);
sdp_t* sdp = sdp_parse(txt, strlen(txt));
sdp_destroy(sdp);
}

void sdp_test2()
static void sdp_test2()
{
const char* txt = "v=0\n\
o=- 0 0 IN IP4 192.168.3.118\n\
Expand All @@ -35,9 +35,37 @@ a=sendrecv";
sdp_destroy(sdp);
}

void sdp_test3()
static void sdp_test3()
{
const char txt[] = { 0x76, 0x3d, 0x30, 0x0d, 0x0a, 0x6f, 0x3d, 0x2d, 0x20, 0x31, 0x33, 0x37, 0x34, 0x38, 0x31, 0x31, 0x31, 0x20, 0x31, 0x20, 0x49, 0x4e, 0x20, 0x49, 0x50, 0x34, 0x20, 0x31, 0x32, 0x37, 0x2e, 0x30, 0x2e, 0x31, 0x2e, 0x31, 0x0d, 0x0a, 0x73, 0x3d, 0x72, 0x74, 0x73, 0x70, 0x20, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x20, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x0d, 0x0a, 0x69, 0x3d, 0x54, 0x68, 0x75, 0x20, 0x4a, 0x61, 0x6e, 0x20, 0x20, 0x31, 0x20, 0x30, 0x38, 0x3a, 0x30, 0x30, 0x3a, 0x31, 0x33, 0x20, 0x31, 0x39, 0x37, 0x30, 0x0a, 0x0d, 0x0a, 0x74, 0x3d, 0x30, 0x20, 0x30, 0x0d, 0x0a, 0x61, 0x3d, 0x74, 0x6f, 0x6f, 0x6c, 0x3a, 0x4c, 0x49, 0x56, 0x45, 0x35, 0x35, 0x35, 0x20, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x69, 0x6e, 0x67, 0x20, 0x4d, 0x65, 0x64, 0x69, 0x61, 0x20, 0x76 };
sdp_t* sdp = sdp_parse(txt, strlen(txt));
sdp_destroy(sdp);
}

static void sdp_test4()
{
const char* txt = "v=0\n\
o=- 1001 1 IN\n\
s=VCP IPC Realtime stream\n\
m=video 0 RTP/AVP 105\n\
c=IN\n\
a=control:rtsp://192.168.1.98/media/video1/video\n\
a=rtpmap:105 H264/90000\n\
a=fmtp:105 profile-level-id=4d001f; packetization-mode=1; sprop-parameter-sets=Z00AH541wKALdNwEBAUAAAMD6AAAw1CE,aO4xsg==\n\
a=recvonly\n\
m=application 0 RTP/AVP 107\n\
c=IN\n\
a=control:rtsp://192.168.1.98/media/video1/metadata\n\
a=rtpmap:107 vnd.onvif.metadata/90000\n\
a=fmtp:107 DecoderTag=h3c-v3 RTCP=0\n\
a=recvonly";
sdp_t* sdp = sdp_parse(txt, strlen(txt));
sdp_destroy(sdp);
}

void sdp_test()
{
sdp_test2();
sdp_test3();
sdp_test4();
}
6 changes: 4 additions & 2 deletions test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ DEF_FUN_2PCHAR(rtsp_client_push_test, const char* host, const char* file);
DEF_FUN_PCHAR(rtsp_client_input_test, const char* file);
DEF_FUN_PCHAR(rtp_dump_test, const char* file);
//DEF_FUN_PCHAR(rtp_header_ext_test, const char* rtpfile);
DEF_FUN_VOID(rtp_payload_test);
DEF_FUN_PCHAR_INT_PCHAR(rtp_payload_test, const char* file, int payload, const char* encoding);

DEF_FUN_PCHAR(flv_parser_test, const char* flv);
DEF_FUN_PCHAR(flv_read_write_test, const char* flv);
Expand Down Expand Up @@ -229,7 +229,8 @@ DEF_FUN_VOID(sip_uas_test);
DEF_FUN_VOID(sip_uac_test2);
DEF_FUN_VOID(sip_uas_test2);

DEF_FUN_PCHAR(sdp_test, const char* file);
DEF_FUN_VOID(sdp_test);
DEF_FUN_PCHAR(sdp_test1, const char* file);

int binnary_diff(const char* file1, const char* file2);

Expand All @@ -255,6 +256,7 @@ int main(int argc, const char* argv[])
RE_RUN_REG("opus_head_test", argc, argv);
RE_RUN_REG("flac_streaminfo_test", argc, argv);
RE_RUN_REG("h264_mp4toannexb_test", argc, argv);
RE_RUN_REG("sdp_test", argc, argv);
RE_RUN_REG("sdp_a_fmtp_test", argc, argv);
RE_RUN_REG("sdp_a_rtpmap_test", argc, argv);
RE_RUN_REG("sdp_a_webrtc_test", argc, argv);
Expand Down

0 comments on commit a745b95

Please sign in to comment.