winlin

refine code for bug #66

... ... @@ -34,18 +34,26 @@ gcc srs_h264_raw_publish.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_h
int main(int argc, char** argv)
{
srs_rtmp_t rtmp;
// packet data
int type, size;
u_int32_t timestamp = 0;
char* data;
srs_trace("publish raw h.264 as rtmp stream to server like FMLE/FFMPEG/Encoder");
srs_trace("srs(simple-rtmp-server) client librtmp library.");
srs_trace("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
srs_trace("version: %d.%d.%d", srs_version_major(), srs_version_minor(), srs_version_revision());
if (argc <= 2) {
srs_trace("Usage: %s <h264_raw_file> <rtmp_publish_url>", argv[0]);
srs_trace(" h264_raw_file: the raw h264 steam file.");
srs_trace(" rtmp_publish_url: the rtmp publish url.");
srs_trace("For example:");
srs_trace(" %s ./720p.h264.raw rtmp://127.0.0.1:1935/live/livestream", argv[0]);
srs_trace("Where the file: http://winlinvip.github.io/srs.release/3rdparty/720p.h264.raw");
srs_trace("See: https://github.com/winlinvip/simple-rtmp-server/issues/66");
exit(-1);
}
const char* raw_file = argv[1];
const char* rtmp_url = argv[2];
srs_trace("raw_file=%s, rtmp_url=%s", raw_file, rtmp_url);
rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream");
srs_rtmp_t rtmp = srs_rtmp_create(rtmp_url);
if (srs_simple_handshake(rtmp) != 0) {
srs_trace("simple handshake failed.");
... ... @@ -65,11 +73,12 @@ int main(int argc, char** argv)
}
srs_trace("publish stream success");
u_int32_t timestamp = 0;
for (;;) {
type = SRS_RTMP_TYPE_VIDEO;
int type = SRS_RTMP_TYPE_VIDEO;
timestamp += 40;
size = 4096;
data = (char*)malloc(4096);
int size = 4096;
char* data = (char*)malloc(4096);
if (srs_write_packet(rtmp, type, timestamp, data, size) != 0) {
goto rtmp_destroy;
... ...