mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #299, refine code.
This commit is contained in:
parent
62b7204514
commit
f32aab3d92
175 changed files with 15529 additions and 15935 deletions
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
# see: https://github.com/ossrs/srs/issues/190
|
||||
# see: https://github.com/ossrs/srs/wiki/v1_CN_SrsLinuxArm
|
||||
g++ -g -O0 -o jmp_sp jmp_sp.cpp
|
||||
arm-linux-gnueabi-g++ -g -o jmp_sp jmp_sp.cpp -static
|
||||
arm-linux-gnueabi-strip jmp_sp
|
||||
*/
|
||||
# see: https://github.com/ossrs/srs/issues/190
|
||||
# see: https://github.com/ossrs/srs/wiki/v1_CN_SrsLinuxArm
|
||||
g++ -g -O0 -o jmp_sp jmp_sp.cpp
|
||||
arm-linux-gnueabi-g++ -g -o jmp_sp jmp_sp.cpp -static
|
||||
arm-linux-gnueabi-strip jmp_sp
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
|
@ -14,14 +14,14 @@ jmp_buf context;
|
|||
void do_longjmp()
|
||||
{
|
||||
/**
|
||||
the definition of jmp_buf:
|
||||
typedef struct __jmp_buf_tag jmp_buf[1];
|
||||
struct __jmp_buf_tag {
|
||||
__jmp_buf __jmpbuf;
|
||||
int __mask_was_saved;
|
||||
__sigset_t __saved_mask;
|
||||
};
|
||||
*/
|
||||
the definition of jmp_buf:
|
||||
typedef struct __jmp_buf_tag jmp_buf[1];
|
||||
struct __jmp_buf_tag {
|
||||
__jmp_buf __jmpbuf;
|
||||
int __mask_was_saved;
|
||||
__sigset_t __saved_mask;
|
||||
};
|
||||
*/
|
||||
#if defined(__amd64__) || defined(__x86_64__)
|
||||
// http://ftp.gnu.org/gnu/glibc/glibc-2.12.2.tar.xz
|
||||
// http://ftp.gnu.org/gnu/glibc/glibc-2.12.1.tar.gz
|
||||
|
@ -38,21 +38,21 @@ void do_longjmp()
|
|||
*/
|
||||
// for glibc 2.4+, it's not possible to get and set the sp in jmp_buf
|
||||
/**
|
||||
for example, the following is show the jmp_buf when setjmp:
|
||||
(gdb) x /64xb context[0].__jmpbuf
|
||||
0x600ca0 <context>: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||
0x600ca8 <context+8>: 0xf8 0xc1 0x71 0xe5 0xa8 0x88 0xb4 0x15
|
||||
0x600cb0 <context+16>: 0xa0 0x05 0x40 0x00 0x00 0x00 0x00 0x00
|
||||
0x600cb8 <context+24>: 0x90 0xe4 0xff 0xff 0xff 0x7f 0x00 0x00
|
||||
0x600cc0 <context+32>: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||
0x600cc8 <context+40>: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||
0x600cd0 <context+48>: 0xf8 0xc1 0x51 0xe5 0xa8 0x88 0xb4 0x15
|
||||
0x600cd8 <context+56>: 0xf8 0xc1 0xd9 0x2f 0xd7 0x77 0x4b 0xea
|
||||
(gdb) p /x $sp
|
||||
$4 = 0x7fffffffe380
|
||||
we cannot finger the sp out.
|
||||
where the glibc is 2.12.
|
||||
*/
|
||||
for example, the following is show the jmp_buf when setjmp:
|
||||
(gdb) x /64xb context[0].__jmpbuf
|
||||
0x600ca0 <context>: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||
0x600ca8 <context+8>: 0xf8 0xc1 0x71 0xe5 0xa8 0x88 0xb4 0x15
|
||||
0x600cb0 <context+16>: 0xa0 0x05 0x40 0x00 0x00 0x00 0x00 0x00
|
||||
0x600cb8 <context+24>: 0x90 0xe4 0xff 0xff 0xff 0x7f 0x00 0x00
|
||||
0x600cc0 <context+32>: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||
0x600cc8 <context+40>: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
|
||||
0x600cd0 <context+48>: 0xf8 0xc1 0x51 0xe5 0xa8 0x88 0xb4 0x15
|
||||
0x600cd8 <context+56>: 0xf8 0xc1 0xd9 0x2f 0xd7 0x77 0x4b 0xea
|
||||
(gdb) p /x $sp
|
||||
$4 = 0x7fffffffe380
|
||||
we cannot finger the sp out.
|
||||
where the glibc is 2.12.
|
||||
*/
|
||||
register long int rsp0 asm("rsp");
|
||||
|
||||
int ret = setjmp(context);
|
||||
|
@ -64,46 +64,46 @@ void do_longjmp()
|
|||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(__arm__)
|
||||
/**
|
||||
/usr/arm-linux-gnueabi/include/bits/setjmp.h
|
||||
#ifndef _ASM
|
||||
The exact set of registers saved may depend on the particular core
|
||||
in use, as some coprocessor registers may need to be saved. The C
|
||||
Library ABI requires that the buffer be 8-byte aligned, and
|
||||
recommends that the buffer contain 64 words. The first 28 words
|
||||
are occupied by v1-v6, sl, fp, sp, pc, d8-d15, and fpscr. (Note
|
||||
that d8-15 require 17 words, due to the use of fstmx.)
|
||||
typedef int __jmp_buf[64] __attribute__((__aligned__ (8)));
|
||||
|
||||
the layout of setjmp for arm:
|
||||
0-5: v1-v6
|
||||
6: sl
|
||||
7: fp
|
||||
8: sp
|
||||
9: pc
|
||||
10-26: d8-d15 17words
|
||||
27: fpscr
|
||||
*/
|
||||
/usr/arm-linux-gnueabi/include/bits/setjmp.h
|
||||
#ifndef _ASM
|
||||
The exact set of registers saved may depend on the particular core
|
||||
in use, as some coprocessor registers may need to be saved. The C
|
||||
Library ABI requires that the buffer be 8-byte aligned, and
|
||||
recommends that the buffer contain 64 words. The first 28 words
|
||||
are occupied by v1-v6, sl, fp, sp, pc, d8-d15, and fpscr. (Note
|
||||
that d8-15 require 17 words, due to the use of fstmx.)
|
||||
typedef int __jmp_buf[64] __attribute__((__aligned__ (8)));
|
||||
|
||||
the layout of setjmp for arm:
|
||||
0-5: v1-v6
|
||||
6: sl
|
||||
7: fp
|
||||
8: sp
|
||||
9: pc
|
||||
10-26: d8-d15 17words
|
||||
27: fpscr
|
||||
*/
|
||||
/**
|
||||
For example, on raspberry-pi, armv6 cpu:
|
||||
(gdb) x /64xb (char*)context[0].__jmpbuf
|
||||
v1, 0: 0x00 0x00 0x00 0x00
|
||||
v2, 1: 0x00 0x00 0x00 0x00
|
||||
v3, 2: 0x2c 0x84 0x00 0x00
|
||||
v4, 3: 0x00 0x00 0x00 0x00
|
||||
v5, 4: 0x00 0x00 0x00 0x00
|
||||
v6, 5: 0x00 0x00 0x00 0x00
|
||||
sl, 6: 0x00 0xf0 0xff 0xb6
|
||||
fp, 7: 0x9c 0xfb 0xff 0xbe
|
||||
sp, 8: 0x88 0xfb 0xff 0xbe
|
||||
pc, 9: 0x08 0x85 0x00 0x00
|
||||
(gdb) p /x $sp
|
||||
$5 = 0xbefffb88
|
||||
(gdb) p /x $pc
|
||||
$4 = 0x850c
|
||||
*/
|
||||
For example, on raspberry-pi, armv6 cpu:
|
||||
(gdb) x /64xb (char*)context[0].__jmpbuf
|
||||
v1, 0: 0x00 0x00 0x00 0x00
|
||||
v2, 1: 0x00 0x00 0x00 0x00
|
||||
v3, 2: 0x2c 0x84 0x00 0x00
|
||||
v4, 3: 0x00 0x00 0x00 0x00
|
||||
v5, 4: 0x00 0x00 0x00 0x00
|
||||
v6, 5: 0x00 0x00 0x00 0x00
|
||||
sl, 6: 0x00 0xf0 0xff 0xb6
|
||||
fp, 7: 0x9c 0xfb 0xff 0xbe
|
||||
sp, 8: 0x88 0xfb 0xff 0xbe
|
||||
pc, 9: 0x08 0x85 0x00 0x00
|
||||
(gdb) p /x $sp
|
||||
$5 = 0xbefffb88
|
||||
(gdb) p /x $pc
|
||||
$4 = 0x850c
|
||||
*/
|
||||
int ret = setjmp(context);
|
||||
printf("setjmp func1 ret=%d\n", ret);
|
||||
|
||||
|
@ -116,23 +116,23 @@ void do_longjmp()
|
|||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
#if defined(__amd64__) || defined(__x86_64__)
|
||||
printf("x86_64 sizeof(long int)=%d, sizeof(long)=%d, "
|
||||
"sizeof(int)=%d, __WORDSIZE=%d, __GLIBC__=%d, __GLIBC_MINOR__=%d\n",
|
||||
(int)sizeof(long int), (int)sizeof(long), (int)sizeof(int),
|
||||
(int)__WORDSIZE, (int)__GLIBC__, (int)__GLIBC_MINOR__);
|
||||
"sizeof(int)=%d, __WORDSIZE=%d, __GLIBC__=%d, __GLIBC_MINOR__=%d\n",
|
||||
(int)sizeof(long int), (int)sizeof(long), (int)sizeof(int),
|
||||
(int)__WORDSIZE, (int)__GLIBC__, (int)__GLIBC_MINOR__);
|
||||
#else
|
||||
printf("arm sizeof(long int)=%d, sizeof(long)=%d, "
|
||||
"sizeof(int)=%d, __GLIBC__=%d,__GLIBC_MINOR__=%d\n",
|
||||
(int)sizeof(long int), (int)sizeof(long), (int)sizeof(int),
|
||||
(int)__GLIBC__, (int)__GLIBC_MINOR__);
|
||||
"sizeof(int)=%d, __GLIBC__=%d,__GLIBC_MINOR__=%d\n",
|
||||
(int)sizeof(long int), (int)sizeof(long), (int)sizeof(int),
|
||||
(int)__GLIBC__, (int)__GLIBC_MINOR__);
|
||||
#endif
|
||||
|
||||
|
||||
do_longjmp();
|
||||
|
||||
printf("terminated\n");
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
g++ memory.error.notcmalloc.cpp -g -O0 -o memory.error.notcmalloc
|
||||
*/
|
||||
g++ memory.error.notcmalloc.cpp -g -O0 -o memory.error.notcmalloc
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
g++ memory.error.notcmalloc.cpp -g -O0 -o memory.error.notcmalloc
|
||||
*/
|
||||
g++ memory.error.notcmalloc.cpp -g -O0 -o memory.error.notcmalloc
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -29,11 +29,11 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
#include "../../objs/include/srs_librtmp.h"
|
||||
|
||||
// https://github.com/ossrs/srs/issues/212#issuecomment-64145910
|
||||
int read_audio_frame(char* data, int size, char** pp, char** frame, int* frame_size)
|
||||
int read_audio_frame(char* data, int size, char** pp, char** frame, int* frame_size)
|
||||
{
|
||||
char* p = *pp;
|
||||
|
||||
|
@ -46,10 +46,10 @@ int read_audio_frame(char* data, int size, char** pp, char** frame, int* frame_s
|
|||
}
|
||||
|
||||
// @see srs_audio_write_raw_frame
|
||||
// each frame prefixed aac adts header, '1111 1111 1111'B, that is 0xFFF.,
|
||||
// each frame prefixed aac adts header, '1111 1111 1111'B, that is 0xFFF.,
|
||||
// for instance, frame = FF F1 5C 80 13 A0 FC 00 D0 33 83 E8 5B
|
||||
*frame = p;
|
||||
// skip some data.
|
||||
// skip some data.
|
||||
// @remark, user donot need to do this.
|
||||
p += srs_aac_adts_frame_size(p, size - (p - data));
|
||||
|
||||
|
@ -107,7 +107,7 @@ int main(int argc, char** argv)
|
|||
lseek(raw_fd, 0, SEEK_SET);
|
||||
ssize_t nb_read = 0;
|
||||
if ((nb_read = read(raw_fd, audio_raw, file_size)) != file_size) {
|
||||
srs_human_trace("buffer %s failed, expect=%dKB, actual=%dKB.",
|
||||
srs_human_trace("buffer %s failed, expect=%dKB, actual=%dKB.",
|
||||
raw_file, (int)(file_size / 1024), (int)(nb_read / 1024));
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
|
@ -164,15 +164,12 @@ int main(int argc, char** argv)
|
|||
timestamp += time_delta;
|
||||
|
||||
int ret = 0;
|
||||
if ((ret = srs_audio_write_raw_frame(rtmp,
|
||||
sound_format, sound_rate, sound_size, sound_type,
|
||||
data, size, timestamp)) != 0
|
||||
) {
|
||||
if ((ret = srs_audio_write_raw_frame(rtmp, sound_format, sound_rate, sound_size, sound_type, data, size, timestamp)) != 0) {
|
||||
srs_human_trace("send audio raw data failed. ret=%d", ret);
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
|
||||
srs_human_trace("sent packet: type=%s, time=%d, size=%d, codec=%d, rate=%d, sample=%d, channel=%d",
|
||||
srs_human_trace("sent packet: type=%s, time=%d, size=%d, codec=%d, rate=%d, sample=%d, channel=%d",
|
||||
srs_human_flv_tag_type2string(SRS_RTMP_TYPE_AUDIO), timestamp, size, sound_format, sound_rate, sound_size,
|
||||
sound_type);
|
||||
|
||||
|
|
|
@ -29,22 +29,21 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
#include "../../objs/include/srs_librtmp.h"
|
||||
|
||||
// https://github.com/ossrs/srs/issues/212#issuecomment-63648892
|
||||
// allspace:
|
||||
// Take this file as an example: https://github.com/allspace/files/blob/master/srs.pcm
|
||||
// It's captured using SDK callback method. I have filtered out h264 video, so it's audio only now.
|
||||
// For every frame, it's a 8 bytes vendor specific header, following 160 bytes audio frame.
|
||||
// For every frame, it's a 8 bytes vendor specific header, following 160 bytes audio frame.
|
||||
// The header part can be ignored.
|
||||
int read_audio_frame(char* audio_raw, int file_size, char** pp, char** pdata, int* psize)
|
||||
int read_audio_frame(char* audio_raw, int file_size, char** pp, char** pdata, int* psize)
|
||||
{
|
||||
char* p = *pp;
|
||||
|
||||
if (file_size - (p - audio_raw) < 168) {
|
||||
srs_human_trace("audio must be 160+8 bytes. left %d bytes.",
|
||||
(int)(file_size - (p - audio_raw)));
|
||||
srs_human_trace("audio must be 160+8 bytes. left %d bytes.", (int)(file_size - (p - audio_raw)));
|
||||
return - 1;
|
||||
}
|
||||
|
||||
|
@ -105,7 +104,7 @@ int main(int argc, char** argv)
|
|||
lseek(raw_fd, 0, SEEK_SET);
|
||||
ssize_t nb_read = 0;
|
||||
if ((nb_read = read(raw_fd, audio_raw, file_size)) != file_size) {
|
||||
srs_human_trace("buffer %s failed, expect=%dKB, actual=%dKB.",
|
||||
srs_human_trace("buffer %s failed, expect=%dKB, actual=%dKB.",
|
||||
raw_file, (int)(file_size / 1024), (int)(nb_read / 1024));
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
|
@ -161,15 +160,12 @@ int main(int argc, char** argv)
|
|||
|
||||
timestamp += time_delta;
|
||||
|
||||
if (srs_audio_write_raw_frame(rtmp,
|
||||
sound_format, sound_rate, sound_size, sound_type,
|
||||
data, size, timestamp) != 0
|
||||
) {
|
||||
if (srs_audio_write_raw_frame(rtmp, sound_format, sound_rate, sound_size, sound_type, data, size, timestamp) != 0) {
|
||||
srs_human_trace("send audio raw data failed.");
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
|
||||
srs_human_trace("sent packet: type=%s, time=%d, size=%d, codec=%d, rate=%d, sample=%d, channel=%d",
|
||||
srs_human_trace("sent packet: type=%s, time=%d, size=%d, codec=%d, rate=%d, sample=%d, channel=%d",
|
||||
srs_human_flv_tag_type2string(SRS_RTMP_TYPE_AUDIO), timestamp, size, sound_format, sound_rate, sound_size,
|
||||
sound_type);
|
||||
|
||||
|
|
|
@ -71,8 +71,8 @@ int do_check(srs_rtmp_t rtmp)
|
|||
}
|
||||
|
||||
if ((ret = srs_rtmp_bandwidth_check(rtmp,
|
||||
&start_time, &end_time, &play_kbps, &publish_kbps,
|
||||
&play_bytes, &publish_bytes, &play_duration, &publish_duration)) != 0
|
||||
&start_time, &end_time, &play_kbps, &publish_kbps, &play_bytes, &publish_bytes,
|
||||
&play_duration, &publish_duration)) != 0
|
||||
) {
|
||||
srs_human_trace("bandwidth check/test failed.");
|
||||
return ret;
|
||||
|
@ -120,7 +120,7 @@ int main(int argc, char** argv)
|
|||
(char*)sig, NULL, NULL,
|
||||
(char*)ip, major, minor, revision, build, pid, cid,
|
||||
(int)(end_time - start_time), play_duration, publish_duration,
|
||||
play_kbps,
|
||||
play_kbps,
|
||||
publish_kbps);
|
||||
|
||||
rtmp_destroy:
|
||||
|
|
|
@ -56,32 +56,32 @@ int main(int argc, char** argv)
|
|||
int duration = 0;
|
||||
int timeout = 0;
|
||||
enum srs_url_schema sus;
|
||||
|
||||
|
||||
printf("detect rtmp stream\n");
|
||||
printf("srs(ossrs) client librtmp library.\n");
|
||||
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
|
||||
|
||||
if (argc <= 3) {
|
||||
printf("detect stream on RTMP server, print result to stderr.\n"
|
||||
"Usage: %s <rtmp_url> <duration> <timeout> [url_schema]\n"
|
||||
" rtmp_url RTMP stream url to play\n"
|
||||
" duration how long to play, in seconds, stream time.\n"
|
||||
" timeout how long to timeout, in seconds, system time.\n"
|
||||
" url_schema the schema of url, default to vis, can be:\n"
|
||||
" normal: rtmp://vhost:port/app/stream\n"
|
||||
" via : rtmp://ip:port/vhost/app/stream\n"
|
||||
" vis : rtmp://ip:port/app/stream?vhost=xxx\n"
|
||||
" vis2 : rtmp://ip:port/app/stream?domain=xxx\n"
|
||||
"For example:\n"
|
||||
" %s rtmp://127.0.0.1:1935/bravo.chnvideo.com/live/livestream 3 10\n",
|
||||
argv[0], argv[0]);
|
||||
"Usage: %s <rtmp_url> <duration> <timeout> [url_schema]\n"
|
||||
" rtmp_url RTMP stream url to play\n"
|
||||
" duration how long to play, in seconds, stream time.\n"
|
||||
" timeout how long to timeout, in seconds, system time.\n"
|
||||
" url_schema the schema of url, default to vis, can be:\n"
|
||||
" normal: rtmp://vhost:port/app/stream\n"
|
||||
" via : rtmp://ip:port/vhost/app/stream\n"
|
||||
" vis : rtmp://ip:port/app/stream?vhost=xxx\n"
|
||||
" vis2 : rtmp://ip:port/app/stream?domain=xxx\n"
|
||||
"For example:\n"
|
||||
" %s rtmp://127.0.0.1:1935/bravo.chnvideo.com/live/livestream 3 10\n",
|
||||
argv[0], argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
rtmp_url = argv[1];
|
||||
duration = atoi(argv[2]);
|
||||
timeout = atoi(argv[3]);
|
||||
|
||||
|
||||
if (1) {
|
||||
char *p = "vis";
|
||||
if (argc > 4) {
|
||||
|
@ -102,7 +102,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
srs_human_trace("url schema: %s", p);
|
||||
}
|
||||
|
||||
|
||||
srs_human_trace("rtmp url: %s", rtmp_url);
|
||||
srs_human_trace("duration: %ds, timeout:%ds", duration, timeout);
|
||||
|
||||
|
@ -145,7 +145,7 @@ int main(int argc, char** argv)
|
|||
srs_human_trace("set url schema=%d failed, ret=%d", sus, ret);
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
|
||||
|
||||
if ((ret = srs_rtmp_connect_app(rtmp)) != 0) {
|
||||
srs_human_trace("connect vhost/app failed. ret=%d", ret);
|
||||
goto rtmp_destroy;
|
||||
|
@ -164,8 +164,7 @@ int main(int argc, char** argv)
|
|||
srs_human_trace("read packet failed. ret=%d", ret);
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
srs_human_trace("got packet: type=%s, time=%d, size=%d",
|
||||
srs_human_flv_tag_type2string(type), timestamp, size);
|
||||
srs_human_trace("got packet: type=%s, time=%d, size=%d", srs_human_flv_tag_type2string(type), timestamp, size);
|
||||
|
||||
if (SRS_RTMP_TYPE_VIDEO == type || SRS_RTMP_TYPE_AUDIO == type) {
|
||||
if (time_first_packet <= 0) {
|
||||
|
@ -231,7 +230,7 @@ rtmp_destroy:
|
|||
"\"remark0\": \"total = dns + tcp_connect + start_play + first_packet + last_packet\"",
|
||||
"\"remark1\": \"delay = stream - (time_cleanup - time_first_packet)\"",
|
||||
"\"remark2\": \"if code is not 0, user must ignore all data\""
|
||||
);
|
||||
);
|
||||
|
||||
srs_human_trace(" ");
|
||||
srs_human_trace("completed");
|
||||
|
|
|
@ -52,7 +52,7 @@ int main(int argc, char** argv)
|
|||
// temp variables.
|
||||
int tmp_file_size = 0;
|
||||
char* tmp_file;
|
||||
|
||||
|
||||
printf("inject flv file keyframes to metadata.\n");
|
||||
printf("srs(ossrs) client librtmp library.\n");
|
||||
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
|
||||
|
@ -79,7 +79,7 @@ int main(int argc, char** argv)
|
|||
srs_human_trace("input: %s", in_flv_file);
|
||||
srs_human_trace("output: %s", out_flv_file);
|
||||
srs_human_trace("tmp_file: %s", tmp_file);
|
||||
|
||||
|
||||
ret = process(in_flv_file, tmp_file, &ic, &oc);
|
||||
|
||||
srs_flv_close(ic);
|
||||
|
@ -136,9 +136,9 @@ int process(const char* in_flv_file, const char* out_flv_file, srs_flv_t* pic, s
|
|||
*poc = oc;
|
||||
|
||||
/**
|
||||
* we use two roundtrip to avoid the paddings of metadata,
|
||||
* to support large keyframes videos without padding fields.
|
||||
*/
|
||||
* we use two roundtrip to avoid the paddings of metadata,
|
||||
* to support large keyframes videos without padding fields.
|
||||
*/
|
||||
// build keyframes offset to metadata.
|
||||
if ((ret = build_keyframes(ic, &amf0_name, &amf0_data, &filepositions, &metadata_end_offset)) != 0) {
|
||||
return ret;
|
||||
|
@ -319,7 +319,7 @@ int do_inject_flv(srs_flv_t ic, srs_flv_t oc, srs_amf0_t amf0_name, srs_amf0_t a
|
|||
if (amf0_name != NULL && amf0_data != NULL) {
|
||||
amf0_name_size = srs_amf0_size(amf0_name);
|
||||
size = amf0_name_size + srs_amf0_size(amf0_data);
|
||||
|
||||
|
||||
// adjust all offset of keyframes.
|
||||
new_metadata_end_offset = srs_flv_tellg(oc) + srs_flv_size_tag(size);
|
||||
// the adjust is new offset sub the old offset of metadata end.
|
||||
|
|
|
@ -59,7 +59,7 @@ int main(int argc, char** argv)
|
|||
|
||||
in_flv_file = argv[1];
|
||||
srs_human_trace("input: %s", in_flv_file);
|
||||
|
||||
|
||||
if ((flv = srs_flv_open_read(in_flv_file)) == NULL) {
|
||||
ret = 2;
|
||||
srs_human_trace("open flv file failed. ret=%d", ret);
|
||||
|
@ -111,7 +111,7 @@ int parse_bytes(char* data, int size, char* hbuf, int hsize, char* tbuf, int tsi
|
|||
{
|
||||
memset(hbuf, 0, hsize);
|
||||
memset(tbuf, 0, tsize);
|
||||
|
||||
|
||||
if (size > 0) {
|
||||
digit_to_char(data, size, hbuf, hsize - 1);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ int parse_bytes(char* data, int size, char* hbuf, int hsize, char* tbuf, int tsi
|
|||
if (size > print_size * 2) {
|
||||
digit_to_char(data + size - print_size, size, tbuf, tsize - 1);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -168,8 +168,7 @@ int parse_flv(srs_flv_t flv)
|
|||
|
||||
char hbuf[48]; char tbuf[48];
|
||||
parse_bytes(data, size, hbuf, sizeof(hbuf), tbuf, sizeof(tbuf), 16);
|
||||
srs_human_raw("offset=%d, first and last 16 bytes:\n"
|
||||
"[+00, +15] %s\n[-15, EOF] %s\n", (int)offset, hbuf, tbuf);
|
||||
srs_human_raw("offset=%d, first and last 16 bytes:\n[+00, +15] %s\n[-15, EOF] %s\n", (int)offset, hbuf, tbuf);
|
||||
} else {
|
||||
srs_human_trace("print packet failed. ret=%d", ret);
|
||||
}
|
||||
|
|
|
@ -29,11 +29,11 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
|
||||
#include "../../objs/include/srs_librtmp.h"
|
||||
|
||||
int read_h264_frame(char* data, int size, char** pp, int* pnb_start_code, int fps,
|
||||
char** frame, int* frame_size, int* dts, int* pts)
|
||||
char** frame, int* frame_size, int* dts, int* pts)
|
||||
{
|
||||
char* p = *pp;
|
||||
|
||||
|
@ -46,7 +46,7 @@ int read_h264_frame(char* data, int size, char** pp, int* pnb_start_code, int fp
|
|||
}
|
||||
|
||||
// @see srs_write_h264_raw_frames
|
||||
// each frame prefixed h.264 annexb header, by N[00] 00 00 01, where N>=0,
|
||||
// each frame prefixed h.264 annexb header, by N[00] 00 00 01, where N>=0,
|
||||
// for instance, frame = header(00 00 00 01) + payload(67 42 80 29 95 A0 14 01 6E 40)
|
||||
*frame = p;
|
||||
p += *pnb_start_code;
|
||||
|
@ -69,7 +69,7 @@ int read_h264_frame(char* data, int size, char** pp, int* pnb_start_code, int fp
|
|||
// while the dts and pts must read from encode lib or device.
|
||||
*dts += 1000 / fps;
|
||||
*pts = *dts;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -121,8 +121,8 @@ int main(int argc, char** argv)
|
|||
lseek(raw_fd, 0, SEEK_SET);
|
||||
ssize_t nb_read = 0;
|
||||
if ((nb_read = read(raw_fd, h264_raw, file_size)) != file_size) {
|
||||
srs_human_trace("buffer %s failed, expect=%dKB, actual=%dKB.",
|
||||
raw_file, (int)(file_size / 1024), (int)(nb_read / 1024));
|
||||
srs_human_trace("buffer %s failed, expect=%dKB, actual=%dKB.",
|
||||
raw_file, (int)(file_size / 1024), (int)(nb_read / 1024));
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2017 SRS(ossrs)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2017 SRS(ossrs)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -107,7 +107,7 @@ int main(int argc, char** argv)
|
|||
|
||||
srs_human_trace("input: %s", in_flv_file);
|
||||
srs_human_trace("output: %s", out_rtmp_url);
|
||||
|
||||
|
||||
if ((flv = srs_flv_open_read(in_flv_file)) == NULL) {
|
||||
ret = 2;
|
||||
srs_human_trace("open flv file failed. ret=%d", ret);
|
||||
|
@ -115,7 +115,7 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
ortmp = srs_rtmp_create(out_rtmp_url);
|
||||
|
||||
|
||||
ret = proxy(flv, ortmp);
|
||||
srs_human_trace("ingest flv to RTMP completed");
|
||||
|
||||
|
@ -170,7 +170,7 @@ int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, int32_t* pstarttime, u
|
|||
srs_human_trace("irtmp get packet failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
if (*pstarttime < 0 && srs_utils_flv_tag_is_av(type)) {
|
||||
*pstarttime = *ptimestamp;
|
||||
}
|
||||
|
@ -267,8 +267,7 @@ void re_cleanup(int64_t re, int32_t starttime, uint32_t time)
|
|||
int64_t now = srs_utils_time_ms();
|
||||
int64_t diff = time - starttime - (now -re);
|
||||
if (diff > 0) {
|
||||
srs_human_trace("re_cleanup, diff=%d, start=%d, last=%d ms",
|
||||
(int)diff, starttime, time);
|
||||
srs_human_trace("re_cleanup, diff=%d, start=%d, last=%d ms", (int)diff, starttime, time);
|
||||
usleep((useconds_t)(diff * 1000));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,13 +39,13 @@ int main(int argc, char** argv)
|
|||
|
||||
if (argc <= 2) {
|
||||
printf("Ingest mp4 file and publish to RTMP server\n"
|
||||
"Usage: %s <-i in_mp4_file> <-y out_rtmp_url>\n"
|
||||
" in_mp4_file input mp4 file, ingest from this file.\n"
|
||||
" out_rtmp_url output rtmp url, publish to this url.\n"
|
||||
"@remark Only support non-seek mp4, see https://github.com/ossrs/srs/issues/738#issuecomment-276343669\n"
|
||||
"For example:\n"
|
||||
" %s -i avatar.mp4 -y rtmp://127.0.0.1/live/livestream\n",
|
||||
argv[0], argv[0]);
|
||||
"Usage: %s <-i in_mp4_file> <-y out_rtmp_url>\n"
|
||||
" in_mp4_file input mp4 file, ingest from this file.\n"
|
||||
" out_rtmp_url output rtmp url, publish to this url.\n"
|
||||
"@remark Only support non-seek mp4, see https://github.com/ossrs/srs/issues/738#issuecomment-276343669\n"
|
||||
"For example:\n"
|
||||
" %s -i avatar.mp4 -y rtmp://127.0.0.1/live/livestream\n",
|
||||
argv[0], argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ int main(int argc, char** argv)
|
|||
srs_rtmp_t irtmp, ortmp;
|
||||
|
||||
printf("Ingest RTMP to server like FFMPEG over srs-librtmp %d.%d.%d\n",
|
||||
srs_version_major(), srs_version_minor(), srs_version_revision());
|
||||
srs_version_major(), srs_version_minor(), srs_version_revision());
|
||||
|
||||
if (argc <= 2) {
|
||||
printf("ingest RTMP and publish to RTMP server\n"
|
||||
|
@ -57,9 +57,9 @@ int main(int argc, char** argv)
|
|||
" in_rtmp_url input rtmp url, ingest from this url.\n"
|
||||
" out_rtmp_url output rtmp url, publish to this url.\n"
|
||||
" verbose output verbose log.\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 -v verbose\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 -v verbose\n",
|
||||
argv[0], argv[0], argv[0]);
|
||||
exit(-1);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ int main(int argc, char** argv)
|
|||
|
||||
irtmp = srs_rtmp_create(in_rtmp_url);
|
||||
ortmp = srs_rtmp_create(out_rtmp_url);
|
||||
|
||||
|
||||
ret = proxy(irtmp, ortmp);
|
||||
srs_human_trace("proxy completed");
|
||||
|
||||
|
@ -116,7 +116,7 @@ int proxy(srs_rtmp_t irtmp, srs_rtmp_t ortmp)
|
|||
char* data;
|
||||
uint32_t timestamp;
|
||||
uint64_t nb_msgs = 0;
|
||||
|
||||
|
||||
if ((ret = connect_ic(irtmp)) != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -162,10 +162,10 @@ int proxy(srs_rtmp_t irtmp, srs_rtmp_t ortmp)
|
|||
|
||||
if (verbose) {
|
||||
srs_human_trace("ortmp sent packet: type=%s, time=%d, size=%d",
|
||||
srs_human_flv_tag_type2string(type), timestamp, size);
|
||||
srs_human_flv_tag_type2string(type), timestamp, size);
|
||||
} else {
|
||||
srs_human_verbose("ortmp sent packet: type=%s, time=%d, size=%d",
|
||||
srs_human_flv_tag_type2string(type), timestamp, size);
|
||||
srs_human_flv_tag_type2string(type), timestamp, size);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ int connect_ic(srs_rtmp_t irtmp)
|
|||
return ret;
|
||||
}
|
||||
srs_human_trace("irtmp connect ok, ip=%s, server=%s/%d.%d.%d.%d, pid=%d, cid=%d",
|
||||
ip, sig, major, minor, revision, build, pid, cid);
|
||||
ip, sig, major, minor, revision, build, pid, cid);
|
||||
|
||||
if ((ret = srs_rtmp_play_stream(irtmp)) != 0) {
|
||||
srs_human_trace("irtmp play stream failed. ret=%d", ret);
|
||||
|
@ -263,7 +263,7 @@ int connect_oc(srs_rtmp_t ortmp)
|
|||
return ret;
|
||||
}
|
||||
srs_human_trace("ortmp connect ok, ip=%s, server=%s/%d.%d.%d.%d, pid=%d, cid=%d",
|
||||
ip, sig, major, minor, revision, build, pid, cid);
|
||||
ip, sig, major, minor, revision, build, pid, cid);
|
||||
|
||||
if ((ret = srs_rtmp_publish_stream(ortmp)) != 0) {
|
||||
srs_human_trace("ortmp publish stream failed. ret=%d", ret);
|
||||
|
|
|
@ -44,7 +44,7 @@ int main(int argc, char** argv)
|
|||
|
||||
// warn it .
|
||||
// @see: https://github.com/ossrs/srs/issues/126
|
||||
srs_human_trace("\033[33m%s\033[0m",
|
||||
srs_human_trace("\033[33m%s\033[0m",
|
||||
"[warning] it's only a sample to use librtmp. "
|
||||
"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."
|
||||
|
@ -81,8 +81,7 @@ int main(int argc, char** argv)
|
|||
if (srs_rtmp_write_packet(rtmp, type, timestamp, data, size) != 0) {
|
||||
goto rtmp_destroy;
|
||||
}
|
||||
srs_human_trace("sent packet: type=%s, time=%d, size=%d",
|
||||
srs_human_flv_tag_type2string(type), timestamp, size);
|
||||
srs_human_trace("sent packet: type=%s, time=%d, size=%d", srs_human_flv_tag_type2string(type), timestamp, size);
|
||||
|
||||
usleep(40 * 1000);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue