1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

add complex handshake utest

This commit is contained in:
winlin 2014-03-19 17:14:42 +08:00
parent 491ea4b630
commit da93b6fe99
6 changed files with 1083 additions and 1078 deletions

View file

@ -31,46 +31,46 @@ gcc srs_play.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_play
int main(int argc, char** argv)
{
srs_rtmp_t rtmp;
// packet data
int type, size;
u_int32_t timestamp = 0;
char* data;
srs_rtmp_t rtmp;
// packet data
int type, size;
u_int32_t timestamp = 0;
char* data;
printf("suck rtmp stream like rtmpdump\n");
printf("srs(simple-rtmp-server) client librtmp library.\n");
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream");
if (srs_simple_handshake(rtmp) != 0) {
printf("simple handshake failed.\n");
goto rtmp_destroy;
}
printf("simple handshake success\n");
if (srs_simple_handshake(rtmp) != 0) {
printf("simple handshake failed.\n");
goto rtmp_destroy;
}
printf("simple handshake success\n");
if (srs_connect_app(rtmp) != 0) {
printf("connect vhost/app failed.\n");
goto rtmp_destroy;
}
printf("connect vhost/app success\n");
if (srs_connect_app(rtmp) != 0) {
printf("connect vhost/app failed.\n");
goto rtmp_destroy;
}
printf("connect vhost/app success\n");
if (srs_play_stream(rtmp) != 0) {
printf("play stream failed.\n");
goto rtmp_destroy;
}
printf("play stream success\n");
for (;;) {
if (srs_read_packet(rtmp, &type, &timestamp, &data, &size) != 0) {
goto rtmp_destroy;
}
printf("got packet: type=%s, time=%d, size=%d\n", srs_type2string(type), timestamp, size);
free(data);
}
if (srs_play_stream(rtmp) != 0) {
printf("play stream failed.\n");
goto rtmp_destroy;
}
printf("play stream success\n");
for (;;) {
if (srs_read_packet(rtmp, &type, &timestamp, &data, &size) != 0) {
goto rtmp_destroy;
}
printf("got packet: type=%s, time=%d, size=%d\n", srs_type2string(type), timestamp, size);
free(data);
}
rtmp_destroy:
srs_rtmp_destroy(rtmp);