1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-14 20:31:56 +00:00

Cover all kernel flv.

This commit is contained in:
winlin 2019-05-23 07:53:03 +08:00
parent 32b53de46d
commit bb3e8a41d1

View file

@ -935,6 +935,87 @@ VOID TEST(KernelFLVTest, CoverVodStreamErrorCase)
}
}
VOID TEST(KernelFLVTest, CoverFLVVodSHCase)
{
srs_error_t err;
if (true) {
uint8_t buf[] = {
0x12, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0x09, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0x08, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00
};
MockSrsFileReader r((const char*)buf, sizeof(buf));
HELPER_EXPECT_SUCCESS(r.open(""));
SrsFlvVodStreamDecoder d;
HELPER_EXPECT_SUCCESS(d.initialize(&r));
int64_t start = -1; int size = 0;
HELPER_EXPECT_SUCCESS(d.read_sequence_header_summary(&start, &size));
EXPECT_EQ(15, start);
EXPECT_EQ(30, size);
}
if (true) {
uint8_t buf[] = {
0x12, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0x09, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0x09, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00
};
MockSrsFileReader r((const char*)buf, sizeof(buf));
HELPER_EXPECT_SUCCESS(r.open(""));
SrsFlvVodStreamDecoder d;
HELPER_EXPECT_SUCCESS(d.initialize(&r));
int64_t start = -1; int size = 0;
HELPER_EXPECT_SUCCESS(d.read_sequence_header_summary(&start, &size));
EXPECT_EQ(15, start);
EXPECT_EQ(15, size);
}
if (true) {
uint8_t buf[] = {
0x12, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0x08, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0x08, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00
};
MockSrsFileReader r((const char*)buf, sizeof(buf));
HELPER_EXPECT_SUCCESS(r.open(""));
SrsFlvVodStreamDecoder d;
HELPER_EXPECT_SUCCESS(d.initialize(&r));
int64_t start = -1; int size = 0;
HELPER_EXPECT_SUCCESS(d.read_sequence_header_summary(&start, &size));
EXPECT_EQ(15, start);
EXPECT_EQ(15, size);
}
if (true) {
uint8_t buf[] = {
0x12, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0x12, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00,
0x12, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00, 0x00,0x00,0x00,0x00
};
MockSrsFileReader r((const char*)buf, sizeof(buf));
HELPER_EXPECT_SUCCESS(r.open(""));
SrsFlvVodStreamDecoder d;
HELPER_EXPECT_SUCCESS(d.initialize(&r));
int64_t start = -1; int size = 0;
HELPER_EXPECT_FAILED(d.read_sequence_header_summary(&start, &size));
EXPECT_EQ(-1, start);
EXPECT_EQ(0, size);
}
}
/**
* test the flv decoder,
* exception: file stream not open.