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:
parent
efa09102cf
commit
c1086f8a9d
6 changed files with 110 additions and 10 deletions
|
@ -25,6 +25,8 @@ gcc srs_play.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_play
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../../objs/include/srs_librtmp.h"
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
@ -33,14 +35,14 @@ int main(int argc, char** argv)
|
|||
|
||||
// packet data
|
||||
int type, size;
|
||||
u_int32_t timestamp;
|
||||
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?vhost=__defaultVhost__/livestream");
|
||||
rtmp = srs_rtmp_create("rtmp://127.0.0.1:1935/live/livestream");
|
||||
|
||||
if (srs_simple_handshake(rtmp) != 0) {
|
||||
printf("simple handshake failed.\n");
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue