mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine librtmp, unify all tools format and usage.
This commit is contained in:
parent
6de83db76e
commit
cf5c24af4a
8 changed files with 96 additions and 98 deletions
|
@ -58,9 +58,13 @@ int main(int argc, char** argv)
|
||||||
const char* rtmp_url = NULL;
|
const char* rtmp_url = NULL;
|
||||||
int duration = 0;
|
int duration = 0;
|
||||||
int timeout = 0;
|
int timeout = 0;
|
||||||
|
|
||||||
|
printf("detect rtmp stream\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());
|
||||||
|
|
||||||
if (argc <= 3) {
|
if (argc <= 3) {
|
||||||
printf("detect stream on RTMP server\n"
|
printf("detect stream on RTMP server, print result to stderr.\n"
|
||||||
"Usage: %s <rtmp_url> <duration> <timeout>\n"
|
"Usage: %s <rtmp_url> <duration> <timeout>\n"
|
||||||
" rtmp_url RTMP stream url to play\n"
|
" rtmp_url RTMP stream url to play\n"
|
||||||
" duration how long to play, in seconds, stream time.\n"
|
" duration how long to play, in seconds, stream time.\n"
|
||||||
|
@ -68,69 +72,63 @@ int main(int argc, char** argv)
|
||||||
"For example:\n"
|
"For example:\n"
|
||||||
" %s rtmp://127.0.0.1:1935/live/livestream 3 10\n",
|
" %s rtmp://127.0.0.1:1935/live/livestream 3 10\n",
|
||||||
argv[0], argv[0]);
|
argv[0], argv[0]);
|
||||||
ret = 1;
|
exit(-1);
|
||||||
exit(ret);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rtmp_url = argv[1];
|
rtmp_url = argv[1];
|
||||||
duration = atoi(argv[2]);
|
duration = atoi(argv[2]);
|
||||||
timeout = atoi(argv[3]);
|
timeout = atoi(argv[3]);
|
||||||
|
|
||||||
printf("detect rtmp stream\n");
|
srs_trace("rtmp url: %s", rtmp_url);
|
||||||
printf("srs(simple-rtmp-server) client librtmp library.\n");
|
srs_trace("duration: %ds, timeout:%ds", duration, timeout);
|
||||||
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
|
|
||||||
printf("rtmp url: %s\n", rtmp_url);
|
|
||||||
printf("duration: %ds, timeout:%ds\n", duration, timeout);
|
|
||||||
|
|
||||||
if (duration <= 0 || timeout <= 0) {
|
if (duration <= 0 || timeout <= 0) {
|
||||||
ret = 1;
|
srs_trace("duration and timeout must be positive.");
|
||||||
fprintf(stderr, "duration and timeout must be positive. ret=%d\n", ret);
|
exit(-1);
|
||||||
exit(ret);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rtmp = srs_rtmp_create(rtmp_url);
|
rtmp = srs_rtmp_create(rtmp_url);
|
||||||
|
|
||||||
if ((ret = __srs_dns_resolve(rtmp)) != 0) {
|
if ((ret = __srs_dns_resolve(rtmp)) != 0) {
|
||||||
fprintf(stderr, "dns resolve failed. ret=%d\n", ret);
|
srs_trace("dns resolve failed. ret=%d", ret);
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
printf("dns resolve success\n");
|
srs_trace("dns resolve success");
|
||||||
time_dns_resolve = srs_get_time_ms();
|
time_dns_resolve = srs_get_time_ms();
|
||||||
|
|
||||||
if ((ret = __srs_connect_server(rtmp)) != 0) {
|
if ((ret = __srs_connect_server(rtmp)) != 0) {
|
||||||
fprintf(stderr, "socket connect failed. ret=%d\n", ret);
|
srs_trace("socket connect failed. ret=%d", ret);
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
printf("socket connect success\n");
|
srs_trace("socket connect success");
|
||||||
time_socket_connect = srs_get_time_ms();
|
time_socket_connect = srs_get_time_ms();
|
||||||
|
|
||||||
if ((ret = __srs_do_simple_handshake(rtmp)) != 0) {
|
if ((ret = __srs_do_simple_handshake(rtmp)) != 0) {
|
||||||
fprintf(stderr, "do simple handshake failed. ret=%d\n", ret);
|
srs_trace("do simple handshake failed. ret=%d", ret);
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
printf("do simple handshake success\n");
|
srs_trace("do simple handshake success");
|
||||||
|
|
||||||
if ((ret = srs_connect_app(rtmp)) != 0) {
|
if ((ret = srs_connect_app(rtmp)) != 0) {
|
||||||
fprintf(stderr, "connect vhost/app failed. ret=%d\n", ret);
|
srs_trace("connect vhost/app failed. ret=%d", ret);
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
printf("connect vhost/app success\n");
|
srs_trace("connect vhost/app success");
|
||||||
|
|
||||||
if ((ret = srs_play_stream(rtmp)) != 0) {
|
if ((ret = srs_play_stream(rtmp)) != 0) {
|
||||||
fprintf(stderr, "play stream failed. ret=%d\n", ret);
|
srs_trace("play stream failed. ret=%d", ret);
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
printf("play stream success\n");
|
srs_trace("play stream success");
|
||||||
time_play_stream = srs_get_time_ms();
|
time_play_stream = srs_get_time_ms();
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if ((ret = srs_read_packet(rtmp, &type, ×tamp, &data, &size)) != 0) {
|
if ((ret = srs_read_packet(rtmp, &type, ×tamp, &data, &size)) != 0) {
|
||||||
fprintf(stderr, "read packet failed. ret=%d\n", ret);
|
srs_trace("read packet failed. ret=%d", ret);
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
printf("got packet: type=%s, time=%d, size=%d\n", srs_type2string(type), timestamp, size);
|
srs_trace("got packet: type=%s, time=%d, size=%d",
|
||||||
|
srs_type2string(type), timestamp, size);
|
||||||
|
|
||||||
if (SRS_RTMP_TYPE_VIDEO == type || SRS_RTMP_TYPE_AUDIO == type) {
|
if (SRS_RTMP_TYPE_VIDEO == type || SRS_RTMP_TYPE_AUDIO == type) {
|
||||||
if (time_first_packet <= 0) {
|
if (time_first_packet <= 0) {
|
||||||
|
@ -144,12 +142,12 @@ int main(int argc, char** argv)
|
||||||
free(data);
|
free(data);
|
||||||
|
|
||||||
if (srs_get_time_ms() - time_startup > timeout * 1000) {
|
if (srs_get_time_ms() - time_startup > timeout * 1000) {
|
||||||
printf("timeout, terminate.\n");
|
srs_trace("timeout, terminate.");
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((timestamp - basetime) > duration * 1000) {
|
if ((timestamp - basetime) > duration * 1000) {
|
||||||
printf("duration exceed, terminate.\n");
|
srs_trace("duration exceed, terminate.");
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,7 +195,9 @@ rtmp_destroy:
|
||||||
"\"remark1\": \"delay = stream - (time_cleanup - time_first_packet)\"",
|
"\"remark1\": \"delay = stream - (time_cleanup - time_first_packet)\"",
|
||||||
"\"remark2\": \"if code is not 0, user must ignore all data\""
|
"\"remark2\": \"if code is not 0, user must ignore all data\""
|
||||||
);
|
);
|
||||||
printf("\n");
|
|
||||||
|
srs_trace("");
|
||||||
|
srs_trace("completed");
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,10 @@ int main(int argc, char** argv)
|
||||||
// temp variables.
|
// temp variables.
|
||||||
int tmp_file_size = 0;
|
int tmp_file_size = 0;
|
||||||
char* tmp_file;
|
char* tmp_file;
|
||||||
|
|
||||||
|
printf("inject flv file keyframes to metadata.\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());
|
||||||
|
|
||||||
if (argc <= 2) {
|
if (argc <= 2) {
|
||||||
printf("inject flv file keyframes to metadata\n"
|
printf("inject flv file keyframes to metadata\n"
|
||||||
|
@ -59,11 +63,10 @@ int main(int argc, char** argv)
|
||||||
" in_flv_file input flv file to inject.\n"
|
" in_flv_file input flv file to inject.\n"
|
||||||
" out_flv_file the inject output file, can be in_flv_file.\n"
|
" out_flv_file the inject output file, can be in_flv_file.\n"
|
||||||
"For example:\n"
|
"For example:\n"
|
||||||
|
" %s doc/source.200kbps.768x320.flv injected.flv\n"
|
||||||
" %s ../../doc/source.200kbps.768x320.flv injected.flv\n",
|
" %s ../../doc/source.200kbps.768x320.flv injected.flv\n",
|
||||||
argv[0], argv[0]);
|
argv[0], argv[0], argv[0]);
|
||||||
ret = 1;
|
exit(-1);
|
||||||
exit(ret);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
in_flv_file = argv[1];
|
in_flv_file = argv[1];
|
||||||
|
@ -73,9 +76,6 @@ int main(int argc, char** argv)
|
||||||
tmp_file = (char*)malloc(tmp_file_size);
|
tmp_file = (char*)malloc(tmp_file_size);
|
||||||
snprintf(tmp_file, tmp_file_size, "%s.tmp", out_flv_file);
|
snprintf(tmp_file, tmp_file_size, "%s.tmp", out_flv_file);
|
||||||
|
|
||||||
srs_trace("inject flv file keyframes to metadata.");
|
|
||||||
srs_trace("srs(simple-rtmp-server) client librtmp library.");
|
|
||||||
srs_trace("version: %d.%d.%d", srs_version_major(), srs_version_minor(), srs_version_revision());
|
|
||||||
srs_trace("input: %s", in_flv_file);
|
srs_trace("input: %s", in_flv_file);
|
||||||
srs_trace("output: %s", out_flv_file);
|
srs_trace("output: %s", out_flv_file);
|
||||||
srs_trace("tmp_file: %s", tmp_file);
|
srs_trace("tmp_file: %s", tmp_file);
|
||||||
|
|
|
@ -45,23 +45,22 @@ int main(int argc, char** argv)
|
||||||
// flv handler
|
// flv handler
|
||||||
srs_flv_t flv;
|
srs_flv_t flv;
|
||||||
|
|
||||||
|
printf("parse and show flv file detail.\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());
|
||||||
|
|
||||||
if (argc <= 1) {
|
if (argc <= 1) {
|
||||||
printf("parse and show flv file detail\n"
|
printf("parse and show flv file detail\n"
|
||||||
"Usage: %s in_flv_file\n"
|
"Usage: %s in_flv_file\n"
|
||||||
" in_flv_file flv file to parse and show.\n"
|
" in_flv_file flv file to parse and show.\n"
|
||||||
"For example:\n"
|
"For example:\n"
|
||||||
|
" %s doc/source.200kbps.768x320.flv\n"
|
||||||
" %s ../../doc/source.200kbps.768x320.flv\n",
|
" %s ../../doc/source.200kbps.768x320.flv\n",
|
||||||
argv[0], argv[0]);
|
argv[0], argv[0], argv[0]);
|
||||||
ret = 1;
|
exit(-1);
|
||||||
exit(ret);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
in_flv_file = argv[1];
|
in_flv_file = argv[1];
|
||||||
|
|
||||||
srs_trace("parse and show flv file detail.");
|
|
||||||
srs_trace("srs(simple-rtmp-server) client librtmp library.");
|
|
||||||
srs_trace("version: %d.%d.%d", srs_version_major(), srs_version_minor(), srs_version_revision());
|
|
||||||
srs_trace("input: %s", in_flv_file);
|
srs_trace("input: %s", in_flv_file);
|
||||||
|
|
||||||
if ((flv = srs_flv_open_read(in_flv_file)) == NULL) {
|
if ((flv = srs_flv_open_read(in_flv_file)) == NULL) {
|
||||||
|
|
|
@ -59,17 +59,20 @@ int main(int argc, char** argv)
|
||||||
// flv handler
|
// flv handler
|
||||||
srs_flv_t flv;
|
srs_flv_t flv;
|
||||||
|
|
||||||
|
printf("ingest flv file and publish to RTMP server like FFMPEG.\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());
|
||||||
|
|
||||||
if (argc <= 2) {
|
if (argc <= 2) {
|
||||||
printf("ingest flv file and publish to RTMP server\n"
|
printf("ingest flv file and publish to RTMP server\n"
|
||||||
"Usage: %s <-i in_flv_file> <-y out_rtmp_url>\n"
|
"Usage: %s <-i in_flv_file> <-y out_rtmp_url>\n"
|
||||||
" in_flv_file input flv file, ingest from this file.\n"
|
" in_flv_file input flv file, ingest from this file.\n"
|
||||||
" out_rtmp_url output rtmp url, publish to this url.\n"
|
" out_rtmp_url output rtmp url, publish to this url.\n"
|
||||||
"For example:\n"
|
"For example:\n"
|
||||||
" %s -i ../../doc/source.200kbps.768x320.flv -y rtmp://127.0.0.1/live/demo\n",
|
" %s -i doc/source.200kbps.768x320.flv -y rtmp://127.0.0.1/live/livestream\n"
|
||||||
argv[0], argv[0]);
|
" %s -i ../../doc/source.200kbps.768x320.flv -y rtmp://127.0.0.1/live/livestream\n",
|
||||||
ret = 1;
|
argv[0], argv[0], argv[0]);
|
||||||
exit(ret);
|
exit(-1);
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse options in FFMPEG format.
|
// parse options in FFMPEG format.
|
||||||
|
@ -86,9 +89,6 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_trace("ingest flv file and publish to RTMP server like FFMPEG.");
|
|
||||||
srs_trace("srs(simple-rtmp-server) client librtmp library.");
|
|
||||||
srs_trace("version: %d.%d.%d", srs_version_major(), srs_version_minor(), srs_version_revision());
|
|
||||||
srs_trace("input: %s", in_flv_file);
|
srs_trace("input: %s", in_flv_file);
|
||||||
srs_trace("output: %s", out_rtmp_url);
|
srs_trace("output: %s", out_rtmp_url);
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,10 @@ int main(int argc, char** argv)
|
||||||
// rtmp handler
|
// rtmp handler
|
||||||
srs_rtmp_t irtmp, ortmp;
|
srs_rtmp_t irtmp, ortmp;
|
||||||
|
|
||||||
|
printf("ingest RTMP and publish to RTMP server like edge.\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());
|
||||||
|
|
||||||
if (argc <= 2) {
|
if (argc <= 2) {
|
||||||
printf("ingest RTMP and publish to RTMP server\n"
|
printf("ingest RTMP and publish to RTMP server\n"
|
||||||
"Usage: %s <-i in_rtmp_url> <-y out_rtmp_url>\n"
|
"Usage: %s <-i in_rtmp_url> <-y out_rtmp_url>\n"
|
||||||
|
@ -53,9 +57,7 @@ int main(int argc, char** argv)
|
||||||
"For example:\n"
|
"For example:\n"
|
||||||
" %s -i rtmp://127.0.0.1/live/livestream -y rtmp://127.0.0.1/live/demo\n",
|
" %s -i rtmp://127.0.0.1/live/livestream -y rtmp://127.0.0.1/live/demo\n",
|
||||||
argv[0], argv[0]);
|
argv[0], argv[0]);
|
||||||
ret = 1;
|
exit(-1);
|
||||||
exit(ret);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse options in FFMPEG format.
|
// parse options in FFMPEG format.
|
||||||
|
@ -72,9 +74,6 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
srs_trace("ingest RTMP and publish to RTMP server like edge.");
|
|
||||||
srs_trace("srs(simple-rtmp-server) client librtmp library.");
|
|
||||||
srs_trace("version: %d.%d.%d", srs_version_major(), srs_version_minor(), srs_version_revision());
|
|
||||||
srs_trace("input: %s", in_rtmp_url);
|
srs_trace("input: %s", in_rtmp_url);
|
||||||
srs_trace("output: %s", out_rtmp_url);
|
srs_trace("output: %s", out_rtmp_url);
|
||||||
|
|
||||||
|
|
|
@ -31,31 +31,21 @@ gcc srs_play.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_play
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
srs_rtmp_t rtmp;
|
printf("suck rtmp stream like rtmpdump\n");
|
||||||
|
printf("srs(simple-rtmp-server) client librtmp library.\n");
|
||||||
// packet data
|
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
|
||||||
int type, size;
|
|
||||||
u_int32_t timestamp = 0;
|
|
||||||
char* data;
|
|
||||||
|
|
||||||
if (argc <= 1) {
|
if (argc <= 1) {
|
||||||
printf("play stream on RTMP server\n"
|
printf("Usage: %s <rtmp_url>\n"
|
||||||
"Usage: %s <rtmp_url>\n"
|
|
||||||
" rtmp_url RTMP stream url to play\n"
|
" rtmp_url RTMP stream url to play\n"
|
||||||
"For example:\n"
|
"For example:\n"
|
||||||
" %s rtmp://127.0.0.1:1935/live/livestream\n",
|
" %s rtmp://127.0.0.1:1935/live/livestream\n",
|
||||||
argv[0], argv[0]);
|
argv[0], argv[0]);
|
||||||
int ret = 1;
|
exit(-1);
|
||||||
exit(ret);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rtmp = srs_rtmp_create(argv[1]);
|
|
||||||
|
|
||||||
srs_trace("suck rtmp stream like rtmpdump");
|
|
||||||
srs_trace("srs(simple-rtmp-server) client librtmp library.");
|
|
||||||
srs_trace("version: %d.%d.%d", srs_version_major(), srs_version_minor(), srs_version_revision());
|
|
||||||
srs_trace("rtmp url: %s", argv[1]);
|
srs_trace("rtmp url: %s", argv[1]);
|
||||||
|
srs_rtmp_t rtmp = srs_rtmp_create(argv[1]);
|
||||||
|
|
||||||
if (srs_simple_handshake(rtmp) != 0) {
|
if (srs_simple_handshake(rtmp) != 0) {
|
||||||
srs_trace("simple handshake failed.");
|
srs_trace("simple handshake failed.");
|
||||||
|
@ -76,6 +66,10 @@ int main(int argc, char** argv)
|
||||||
srs_trace("play stream success");
|
srs_trace("play stream success");
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
int type, size;
|
||||||
|
u_int32_t timestamp = 0;
|
||||||
|
char* data;
|
||||||
|
|
||||||
if (srs_read_packet(rtmp, &type, ×tamp, &data, &size) != 0) {
|
if (srs_read_packet(rtmp, &type, ×tamp, &data, &size) != 0) {
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,54 +32,60 @@ gcc srs_publish.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_publish
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
srs_rtmp_t rtmp;
|
|
||||||
|
|
||||||
// packet data
|
|
||||||
int type, size;
|
|
||||||
u_int32_t timestamp = 0;
|
|
||||||
char* data;
|
|
||||||
|
|
||||||
printf("publish rtmp stream to server like FMLE/FFMPEG/Encoder\n");
|
printf("publish rtmp stream to server like FMLE/FFMPEG/Encoder\n");
|
||||||
printf("srs(simple-rtmp-server) client librtmp library.\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());
|
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
|
||||||
|
|
||||||
|
if (argc <= 1) {
|
||||||
|
printf("Usage: %s <rtmp_url>\n"
|
||||||
|
" rtmp_url RTMP stream url to publish\n"
|
||||||
|
"For example:\n"
|
||||||
|
" %s rtmp://127.0.0.1:1935/live/livestream\n",
|
||||||
|
argv[0], argv[0]);
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
// warn it .
|
// warn it .
|
||||||
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/126
|
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/126
|
||||||
printf("\033[33m%s\033[0m",
|
srs_trace("\033[33m%s\033[0m",
|
||||||
"[warning] it's only a sample to use librtmp. "
|
"[warning] it's only a sample to use librtmp. "
|
||||||
"please never use it to publish and test forward/transcode/edge/HLS whatever. "
|
"please never use it to publish and test forward/transcode/edge/HLS whatever. "
|
||||||
"you should refer to this tool to use the srs-librtmp to publish the real media stream.");
|
"you should refer to this tool to use the srs-librtmp to publish the real media stream."
|
||||||
printf("\n");
|
"read about: https://github.com/winlinvip/simple-rtmp-server/issues/126");
|
||||||
|
srs_trace("rtmp url: %s", argv[1]);
|
||||||
rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream");
|
srs_rtmp_t rtmp = srs_rtmp_create(argv[1]);
|
||||||
|
|
||||||
if (srs_simple_handshake(rtmp) != 0) {
|
if (srs_simple_handshake(rtmp) != 0) {
|
||||||
printf("simple handshake failed.\n");
|
srs_trace("simple handshake failed.");
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
printf("simple handshake success\n");
|
srs_trace("simple handshake success");
|
||||||
|
|
||||||
if (srs_connect_app(rtmp) != 0) {
|
if (srs_connect_app(rtmp) != 0) {
|
||||||
printf("connect vhost/app failed.\n");
|
srs_trace("connect vhost/app failed.");
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
printf("connect vhost/app success\n");
|
srs_trace("connect vhost/app success");
|
||||||
|
|
||||||
if (srs_publish_stream(rtmp) != 0) {
|
if (srs_publish_stream(rtmp) != 0) {
|
||||||
printf("publish stream failed.\n");
|
srs_trace("publish stream failed.");
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
printf("publish stream success\n");
|
srs_trace("publish stream success");
|
||||||
|
|
||||||
|
u_int32_t timestamp = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
type = SRS_RTMP_TYPE_VIDEO;
|
int type = SRS_RTMP_TYPE_VIDEO;
|
||||||
|
int size = 4096;
|
||||||
|
char* data = (char*)malloc(4096);
|
||||||
|
|
||||||
timestamp += 40;
|
timestamp += 40;
|
||||||
size = 4096;
|
|
||||||
data = (char*)malloc(4096);
|
|
||||||
|
|
||||||
if (srs_write_packet(rtmp, type, timestamp, data, size) != 0) {
|
if (srs_write_packet(rtmp, type, timestamp, data, size) != 0) {
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
printf("sent packet: type=%s, time=%d, size=%d\n", srs_type2string(type), timestamp, size);
|
srs_trace("sent packet: type=%s, time=%d, size=%d",
|
||||||
|
srs_type2string(type), timestamp, size);
|
||||||
|
|
||||||
usleep(40 * 1000);
|
usleep(40 * 1000);
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,8 +237,8 @@ extern int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp);
|
||||||
|
|
||||||
// log to console, for use srs-librtmp application.
|
// log to console, for use srs-librtmp application.
|
||||||
extern const char* srs_format_time();
|
extern const char* srs_format_time();
|
||||||
#define srs_trace(msg, ...) printf("[%s]", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n")
|
#define srs_trace(msg, ...) printf("[%s] ", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n")
|
||||||
#define srs_verbose(msg, ...) printf("[%s]", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n")
|
#define srs_verbose(msg, ...) printf("[%s] ", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n")
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
**************************************************************
|
**************************************************************
|
||||||
|
@ -338,7 +338,7 @@ extern void srs_amf0_strict_array_append(srs_amf0_t amf0, srs_amf0_t value);
|
||||||
/**
|
/**
|
||||||
* human readable print
|
* human readable print
|
||||||
* @param pdata, output the heap data, NULL to ignore.
|
* @param pdata, output the heap data, NULL to ignore.
|
||||||
* user must use srs_amf0_free_bytes to free it.
|
* user must use srs_amf0_free_bytes to free it.
|
||||||
* @return return the *pdata for print. NULL to ignore.
|
* @return return the *pdata for print. NULL to ignore.
|
||||||
*/
|
*/
|
||||||
extern char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize);
|
extern char* srs_amf0_human_print(srs_amf0_t amf0, char** pdata, int* psize);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue