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

srs-librtmp: finish the simple publish and play sample.

This commit is contained in:
winlin 2014-03-02 18:33:32 +08:00
parent efa09102cf
commit c1086f8a9d
6 changed files with 110 additions and 10 deletions

View file

@ -25,12 +25,20 @@ gcc srs_publish.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_publish
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "../../objs/include/srs_librtmp.h"
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("srs(simple-rtmp-server) client librtmp library.\n");
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
@ -55,6 +63,20 @@ int main(int argc, char** argv)
}
printf("publish stream success\n");
for (;;) {
type = SRS_RTMP_TYPE_VIDEO;
timestamp += 40;
size = 4096;
data = (char*)malloc(4096);
if (srs_write_packet(rtmp, type, timestamp, data, size) != 0) {
goto rtmp_destroy;
}
printf("sent packet: type=%s, time=%d, size=%d\n", srs_type2string(type), timestamp, size);
usleep(40 * 1000);
}
rtmp_destroy:
srs_rtmp_destroy(rtmp);