Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-11-08 18:37:15 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
606fc13a030930052fabd64573b9a9efb819d5d5
606fc13a
1 parent
3405f35d
rename the confict macro to srs_lib_trace
隐藏空白字符变更
内嵌
并排对比
正在显示
11 个修改的文件
包含
135 行增加
和
135 行删除
trunk/research/librtmp/srs_bandwidth_check.c
trunk/research/librtmp/srs_detect_rtmp.c
trunk/research/librtmp/srs_flv_injecter.c
trunk/research/librtmp/srs_flv_parser.c
trunk/research/librtmp/srs_h264_raw_publish.c
trunk/research/librtmp/srs_ingest_flv.c
trunk/research/librtmp/srs_ingest_rtmp.c
trunk/research/librtmp/srs_play.c
trunk/research/librtmp/srs_publish.c
trunk/src/core/srs_core.hpp
trunk/src/libs/srs_librtmp.hpp
trunk/research/librtmp/srs_bandwidth_check.c
查看文件 @
606fc13
...
...
@@ -80,31 +80,31 @@ int main(int argc, char** argv)
rtmp
=
srs_rtmp_create2
(
argv
[
1
]);
srs_trace
(
"bandwidth check/test url: %s"
,
argv
[
1
]);
srs_
lib_
trace
(
"bandwidth check/test url: %s"
,
argv
[
1
]);
if
((
ret
=
srs_simple_handshake
(
rtmp
))
!=
0
)
{
srs_trace
(
"simple handshake failed."
);
srs_
lib_
trace
(
"simple handshake failed."
);
goto
rtmp_destroy
;
}
srs_trace
(
"simple handshake success"
);
srs_
lib_
trace
(
"simple handshake success"
);
if
((
ret
=
srs_connect_app2
(
rtmp
,
srs_server_ip
,
srs_server
,
srs_primary_authors
,
srs_version
,
&
srs_id
,
&
srs_pid
))
!=
0
)
{
srs_trace
(
"connect vhost/app failed."
);
srs_
lib_
trace
(
"connect vhost/app failed."
);
goto
rtmp_destroy
;
}
srs_trace
(
"connect vhost/app success"
);
srs_
lib_
trace
(
"connect vhost/app success"
);
if
((
ret
=
srs_bandwidth_check
(
rtmp
,
&
start_time
,
&
end_time
,
&
play_kbps
,
&
publish_kbps
,
&
play_bytes
,
&
publish_bytes
,
&
play_duration
,
&
publish_duration
))
!=
0
)
{
srs_trace
(
"bandwidth check/test failed."
);
srs_
lib_
trace
(
"bandwidth check/test failed."
);
goto
rtmp_destroy
;
}
srs_trace
(
"bandwidth check/test success"
);
srs_
lib_
trace
(
"bandwidth check/test success"
);
srs_trace
(
"
\n
%s, %s
\n
"
srs_
lib_
trace
(
"
\n
%s, %s
\n
"
"%s, %s, srs_pid=%d, srs_id=%d
\n
"
"duration: %dms(%d+%d)
\n
"
"play: %dkbps
\n
"
...
...
@@ -136,8 +136,8 @@ rtmp_destroy:
(
int
)(
end_time
-
start_time
),
play_duration
,
publish_duration
,
play_kbps
,
publish_kbps
);
srs_trace
(
""
);
srs_trace
(
"completed"
);
srs_lib_trace
(
""
);
srs_lib_trace
(
"completed"
);
return
ret
;
}
...
...
trunk/research/librtmp/srs_detect_rtmp.c
查看文件 @
606fc13
...
...
@@ -79,55 +79,55 @@ int main(int argc, char** argv)
duration
=
atoi
(
argv
[
2
]);
timeout
=
atoi
(
argv
[
3
]);
srs_trace
(
"rtmp url: %s"
,
rtmp_url
);
srs_trace
(
"duration: %ds, timeout:%ds"
,
duration
,
timeout
);
srs_lib_trace
(
"rtmp url: %s"
,
rtmp_url
);
srs_lib_trace
(
"duration: %ds, timeout:%ds"
,
duration
,
timeout
);
if
(
duration
<=
0
||
timeout
<=
0
)
{
srs_trace
(
"duration and timeout must be positive."
);
srs_
lib_
trace
(
"duration and timeout must be positive."
);
exit
(
-
2
);
}
rtmp
=
srs_rtmp_create
(
rtmp_url
);
if
((
ret
=
__srs_dns_resolve
(
rtmp
))
!=
0
)
{
srs_trace
(
"dns resolve failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"dns resolve failed. ret=%d"
,
ret
);
goto
rtmp_destroy
;
}
srs_trace
(
"dns resolve success"
);
srs_
lib_
trace
(
"dns resolve success"
);
time_dns_resolve
=
srs_get_time_ms
();
if
((
ret
=
__srs_connect_server
(
rtmp
))
!=
0
)
{
srs_trace
(
"socket connect failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"socket connect failed. ret=%d"
,
ret
);
goto
rtmp_destroy
;
}
srs_trace
(
"socket connect success"
);
srs_
lib_
trace
(
"socket connect success"
);
time_socket_connect
=
srs_get_time_ms
();
if
((
ret
=
__srs_do_simple_handshake
(
rtmp
))
!=
0
)
{
srs_trace
(
"do simple handshake failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"do simple handshake failed. ret=%d"
,
ret
);
goto
rtmp_destroy
;
}
srs_trace
(
"do simple handshake success"
);
srs_
lib_
trace
(
"do simple handshake success"
);
if
((
ret
=
srs_connect_app
(
rtmp
))
!=
0
)
{
srs_trace
(
"connect vhost/app failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"connect vhost/app failed. ret=%d"
,
ret
);
goto
rtmp_destroy
;
}
srs_trace
(
"connect vhost/app success"
);
srs_
lib_
trace
(
"connect vhost/app success"
);
if
((
ret
=
srs_play_stream
(
rtmp
))
!=
0
)
{
srs_trace
(
"play stream failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"play stream failed. ret=%d"
,
ret
);
goto
rtmp_destroy
;
}
srs_trace
(
"play stream success"
);
srs_
lib_
trace
(
"play stream success"
);
time_play_stream
=
srs_get_time_ms
();
for
(;;)
{
if
((
ret
=
srs_read_packet
(
rtmp
,
&
type
,
&
timestamp
,
&
data
,
&
size
))
!=
0
)
{
srs_trace
(
"read packet failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"read packet failed. ret=%d"
,
ret
);
goto
rtmp_destroy
;
}
srs_trace
(
"got packet: type=%s, time=%d, size=%d"
,
srs_
lib_
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
)
{
...
...
@@ -142,12 +142,12 @@ int main(int argc, char** argv)
free
(
data
);
if
(
srs_get_time_ms
()
-
time_startup
>
timeout
*
1000
)
{
srs_trace
(
"timeout, terminate."
);
srs_
lib_
trace
(
"timeout, terminate."
);
goto
rtmp_destroy
;
}
if
((
timestamp
-
basetime
)
>
duration
*
1000
)
{
srs_trace
(
"duration exceed, terminate."
);
srs_
lib_
trace
(
"duration exceed, terminate."
);
goto
rtmp_destroy
;
}
}
...
...
@@ -196,8 +196,8 @@ rtmp_destroy:
"
\"
remark2
\"
:
\"
if code is not 0, user must ignore all data
\"
"
);
srs_trace
(
""
);
srs_trace
(
"completed"
);
srs_lib_trace
(
""
);
srs_lib_trace
(
"completed"
);
return
ret
;
}
...
...
trunk/research/librtmp/srs_flv_injecter.c
查看文件 @
606fc13
...
...
@@ -76,9 +76,9 @@ int main(int argc, char** argv)
tmp_file
=
(
char
*
)
malloc
(
tmp_file_size
);
snprintf
(
tmp_file
,
tmp_file_size
,
"%s.tmp"
,
out_flv_file
);
srs_trace
(
"input: %s"
,
in_flv_file
);
srs_trace
(
"output: %s"
,
out_flv_file
);
srs_trace
(
"tmp_file: %s"
,
tmp_file
);
srs_lib_trace
(
"input: %s"
,
in_flv_file
);
srs_lib_trace
(
"output: %s"
,
out_flv_file
);
srs_lib_trace
(
"tmp_file: %s"
,
tmp_file
);
ret
=
process
(
in_flv_file
,
tmp_file
,
&
ic
,
&
oc
);
...
...
@@ -89,13 +89,13 @@ int main(int argc, char** argv)
unlink
(
tmp_file
);
if
(
ret
==
ERROR_INJECTED
)
{
ret
=
0
;
srs_trace
(
"file already injected."
);
srs_
lib_
trace
(
"file already injected."
);
}
else
{
srs_trace
(
"error, remove tmp file."
);
srs_
lib_
trace
(
"error, remove tmp file."
);
}
}
else
{
rename
(
tmp_file
,
out_flv_file
);
srs_trace
(
"completed, rename to %s"
,
out_flv_file
);
srs_
lib_
trace
(
"completed, rename to %s"
,
out_flv_file
);
}
free
(
tmp_file
);
...
...
@@ -123,14 +123,14 @@ int process(const char* in_flv_file, const char* out_flv_file, srs_flv_t* pic, s
if
((
ic
=
srs_flv_open_read
(
in_flv_file
))
==
NULL
)
{
ret
=
2
;
srs_trace
(
"open input flv file failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"open input flv file failed. ret=%d"
,
ret
);
return
ret
;
}
*
pic
=
ic
;
if
((
oc
=
srs_flv_open_write
(
out_flv_file
))
==
NULL
)
{
ret
=
2
;
srs_trace
(
"open output flv file failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"open output flv file failed. ret=%d"
,
ret
);
return
ret
;
}
*
poc
=
oc
;
...
...
@@ -164,13 +164,13 @@ int parse_metadata(char* data, int size, srs_amf0_t* pname, srs_amf0_t* pdata)
*
pname
=
srs_amf0_parse
(
data
,
size
,
&
nparsed
);
if
(
*
pname
==
NULL
||
nparsed
>=
size
)
{
srs_trace
(
"invalid amf0 name data."
);
srs_
lib_
trace
(
"invalid amf0 name data."
);
return
-
1
;
}
*
pdata
=
srs_amf0_parse
(
data
+
nparsed
,
size
-
nparsed
,
&
nparsed
);
if
(
*
pdata
==
NULL
||
nparsed
>
size
)
{
srs_trace
(
"invalid amf0 value data"
);
srs_
lib_
trace
(
"invalid amf0 value data"
);
return
-
1
;
}
...
...
@@ -206,22 +206,22 @@ int build_keyframes(srs_flv_t ic, srs_amf0_t *pname, srs_amf0_t* pdata, srs_amf0
return
ret
;
}
srs_trace
(
"build keyframe infos from flv"
);
srs_
lib_
trace
(
"build keyframe infos from flv"
);
for
(;;)
{
offset
=
srs_flv_tellg
(
ic
);
// tag header
if
((
ret
=
srs_flv_read_tag_header
(
ic
,
&
type
,
&
size
,
&
timestamp
))
!=
0
)
{
if
(
srs_flv_is_eof
(
ret
))
{
srs_trace
(
"parse completed."
);
srs_
lib_
trace
(
"parse completed."
);
return
0
;
}
srs_trace
(
"flv get packet failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"flv get packet failed. ret=%d"
,
ret
);
return
ret
;
}
if
(
size
<=
0
)
{
srs_trace
(
"invalid size=%d"
,
size
);
srs_
lib_
trace
(
"invalid size=%d"
,
size
);
return
ret
;
}
...
...
@@ -343,20 +343,20 @@ int do_inject_flv(srs_flv_t ic, srs_flv_t oc, srs_amf0_t amf0_name, srs_amf0_t a
free
(
data
);
}
srs_trace
(
"build keyframe infos from flv"
);
srs_
lib_
trace
(
"build keyframe infos from flv"
);
for
(;;)
{
// tag header
if
((
ret
=
srs_flv_read_tag_header
(
ic
,
&
type
,
&
size
,
&
timestamp
))
!=
0
)
{
if
(
srs_flv_is_eof
(
ret
))
{
srs_trace
(
"parse completed."
);
srs_
lib_
trace
(
"parse completed."
);
return
0
;
}
srs_trace
(
"flv get packet failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"flv get packet failed. ret=%d"
,
ret
);
return
ret
;
}
if
(
size
<=
0
)
{
srs_trace
(
"invalid size=%d"
,
size
);
srs_
lib_
trace
(
"invalid size=%d"
,
size
);
break
;
}
...
...
trunk/research/librtmp/srs_flv_parser.c
查看文件 @
606fc13
...
...
@@ -61,11 +61,11 @@ int main(int argc, char** argv)
}
in_flv_file
=
argv
[
1
];
srs_trace
(
"input: %s"
,
in_flv_file
);
srs_
lib_
trace
(
"input: %s"
,
in_flv_file
);
if
((
flv
=
srs_flv_open_read
(
in_flv_file
))
==
NULL
)
{
ret
=
2
;
srs_trace
(
"open flv file failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"open flv file failed. ret=%d"
,
ret
);
return
ret
;
}
...
...
@@ -147,12 +147,12 @@ int parse_script_data(u_int32_t timestamp, char* data, int size, int64_t offset)
// amf0
amf0_name
=
srs_amf0_parse
(
data
,
size
,
&
nparsed
);
if
(
amf0_name
==
NULL
||
nparsed
>=
size
)
{
srs_trace
(
"invalid amf0 name data."
);
srs_
lib_
trace
(
"invalid amf0 name data."
);
return
-
1
;
}
amf0_data
=
srs_amf0_parse
(
data
+
nparsed
,
size
-
nparsed
,
&
nparsed
);
srs_trace
(
"packet type=%s, time=%d, size=%d, data-size=%d,
\n
"
srs_
lib_
trace
(
"packet type=%s, time=%d, size=%d, data-size=%d,
\n
"
"offset=%d
\n
[+00, +15] %s
\n
[-15, EOF] %s
\n
%s%s"
,
srs_type2string
(
SRS_RTMP_TYPE_SCRIPT
),
timestamp
,
size
+
FLV_HEADER_SIZE
,
size
,
(
int
)
offset
,
hbuf
,
tbuf
,
...
...
@@ -178,7 +178,7 @@ int parse_audio_data(u_int32_t timestamp, char* data, int size, int64_t offset)
// bytes
parse_bytes
(
data
,
size
,
hbuf
,
sizeof
(
hbuf
),
tbuf
,
sizeof
(
tbuf
),
16
);
srs_trace
(
"packet type=%s, time=%d, size=%d, data-size=%d,
\n
"
srs_
lib_
trace
(
"packet type=%s, time=%d, size=%d, data-size=%d,
\n
"
"offset=%d
\n
[+00, +15] %s
\n
[-15, EOF] %s
\n
"
,
srs_type2string
(
SRS_RTMP_TYPE_AUDIO
),
timestamp
,
size
+
FLV_HEADER_SIZE
,
size
,
(
int
)
offset
,
hbuf
,
tbuf
);
...
...
@@ -196,7 +196,7 @@ int parse_video_data(u_int32_t timestamp, char* data, int size, int64_t offset)
// bytes
parse_bytes
(
data
,
size
,
hbuf
,
sizeof
(
hbuf
),
tbuf
,
sizeof
(
tbuf
),
16
);
srs_trace
(
"packet type=%s, time=%d, size=%d, data-size=%d,
\n
"
srs_
lib_
trace
(
"packet type=%s, time=%d, size=%d, data-size=%d,
\n
"
"offset=%d
\n
[+00, +15] %s
\n
[-15, EOF] %s
\n
"
,
srs_type2string
(
SRS_RTMP_TYPE_VIDEO
),
timestamp
,
size
+
FLV_HEADER_SIZE
,
size
,
(
int
)
offset
,
hbuf
,
tbuf
);
...
...
@@ -221,22 +221,22 @@ int parse_flv(srs_flv_t flv)
return
ret
;
}
srs_trace
(
"start parse flv"
);
srs_
lib_
trace
(
"start parse flv"
);
for
(;;)
{
offset
=
srs_flv_tellg
(
flv
);
// tag header
if
((
ret
=
srs_flv_read_tag_header
(
flv
,
&
type
,
&
size
,
&
timestamp
))
!=
0
)
{
if
(
srs_flv_is_eof
(
ret
))
{
srs_trace
(
"parse completed."
);
srs_
lib_
trace
(
"parse completed."
);
return
0
;
}
srs_trace
(
"flv get packet failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"flv get packet failed. ret=%d"
,
ret
);
return
ret
;
}
if
(
size
<=
0
)
{
srs_trace
(
"invalid size=%d"
,
size
);
srs_
lib_
trace
(
"invalid size=%d"
,
size
);
break
;
}
...
...
trunk/research/librtmp/srs_h264_raw_publish.c
查看文件 @
606fc13
...
...
@@ -44,7 +44,7 @@ int read_h264_frame(char* data, int size, char** pp, int* pnb_start_code, int fp
// we search the h264 frame from the buffer which cached the h264 data.
// please get h264 raw data from device, it always a encoded frame.
if
(
!
srs_h264_startswith_annexb
(
p
,
size
-
(
p
-
data
),
pnb_start_code
))
{
srs_trace
(
"h264 raw data invalid."
);
srs_
lib_
trace
(
"h264 raw data invalid."
);
return
-
1
;
}
...
...
@@ -63,7 +63,7 @@ int read_h264_frame(char* data, int size, char** pp, int* pnb_start_code, int fp
*
pp
=
p
;
*
frame_size
=
p
-
*
frame
;
if
(
*
frame_size
<=
0
)
{
srs_trace
(
"h264 raw data invalid."
);
srs_
lib_
trace
(
"h264 raw data invalid."
);
return
-
1
;
}
...
...
@@ -95,32 +95,32 @@ int main(int argc, char** argv)
const
char
*
raw_file
=
argv
[
1
];
const
char
*
rtmp_url
=
argv
[
2
];
srs_trace
(
"raw_file=%s, rtmp_url=%s"
,
raw_file
,
rtmp_url
);
srs_
lib_
trace
(
"raw_file=%s, rtmp_url=%s"
,
raw_file
,
rtmp_url
);
// open file
int
raw_fd
=
open
(
raw_file
,
O_RDONLY
);
if
(
raw_fd
<
0
)
{
srs_trace
(
"open h264 raw file %s failed."
,
raw_fd
);
srs_
lib_
trace
(
"open h264 raw file %s failed."
,
raw_fd
);
goto
rtmp_destroy
;
}
off_t
file_size
=
lseek
(
raw_fd
,
0
,
SEEK_END
);
if
(
file_size
<=
0
)
{
srs_trace
(
"h264 raw file %s empty."
,
raw_file
);
srs_
lib_
trace
(
"h264 raw file %s empty."
,
raw_file
);
goto
rtmp_destroy
;
}
srs_trace
(
"read entirely h264 raw file, size=%dKB"
,
(
int
)(
file_size
/
1024
));
srs_
lib_
trace
(
"read entirely h264 raw file, size=%dKB"
,
(
int
)(
file_size
/
1024
));
char
*
h264_raw
=
(
char
*
)
malloc
(
file_size
);
if
(
!
h264_raw
)
{
srs_trace
(
"alloc raw buffer failed for file %s."
,
raw_file
);
srs_
lib_
trace
(
"alloc raw buffer failed for file %s."
,
raw_file
);
goto
rtmp_destroy
;
}
lseek
(
raw_fd
,
0
,
SEEK_SET
);
ssize_t
nb_read
=
0
;
if
((
nb_read
=
read
(
raw_fd
,
h264_raw
,
file_size
))
!=
file_size
)
{
srs_trace
(
"buffer %s failed, expect=%dKB, actual=%dKB."
,
srs_
lib_
trace
(
"buffer %s failed, expect=%dKB, actual=%dKB."
,
raw_file
,
(
int
)(
file_size
/
1024
),
(
int
)(
nb_read
/
1024
));
goto
rtmp_destroy
;
}
...
...
@@ -129,22 +129,22 @@ int main(int argc, char** argv)
srs_rtmp_t
rtmp
=
srs_rtmp_create
(
rtmp_url
);
if
(
srs_simple_handshake
(
rtmp
)
!=
0
)
{
srs_trace
(
"simple handshake failed."
);
srs_
lib_
trace
(
"simple handshake failed."
);
goto
rtmp_destroy
;
}
srs_trace
(
"simple handshake success"
);
srs_
lib_
trace
(
"simple handshake success"
);
if
(
srs_connect_app
(
rtmp
)
!=
0
)
{
srs_trace
(
"connect vhost/app failed."
);
srs_
lib_
trace
(
"connect vhost/app failed."
);
goto
rtmp_destroy
;
}
srs_trace
(
"connect vhost/app success"
);
srs_
lib_
trace
(
"connect vhost/app success"
);
if
(
srs_publish_stream
(
rtmp
)
!=
0
)
{
srs_trace
(
"publish stream failed."
);
srs_
lib_
trace
(
"publish stream failed."
);
goto
rtmp_destroy
;
}
srs_trace
(
"publish stream success"
);
srs_
lib_
trace
(
"publish stream success"
);
u_int32_t
dts
=
0
;
u_int32_t
pts
=
0
;
...
...
@@ -161,27 +161,27 @@ int main(int argc, char** argv)
if
(
read_h264_frame
(
h264_raw
,
file_size
,
&
p
,
&
nb_start_code
,
fps
,
&
data
,
&
size
,
&
dts
,
&
pts
)
<
0
)
{
srs_trace
(
"read a frame from file buffer failed."
);
srs_
lib_
trace
(
"read a frame from file buffer failed."
);
goto
rtmp_destroy
;
}
// send out the h264 packet over RTMP
if
(
srs_write_h264_raw_frames
(
rtmp
,
data
,
size
,
dts
,
pts
)
!=
0
)
{
srs_trace
(
"send h264 raw data failed."
);
srs_
lib_
trace
(
"send h264 raw data failed."
);
goto
rtmp_destroy
;
}
// 5bits, 7.3.1 NAL unit syntax,
// H.264-AVC-ISO_IEC_14496-10.pdf, page 44.
u_int8_t
nut
=
(
char
)
data
[
nb_start_code
]
&
0x1f
;
srs_trace
(
"sent packet: type=%s, time=%d, size=%d, fps=%d, b[%d]=%#x(%s)"
,
srs_
lib_
trace
(
"sent packet: type=%s, time=%d, size=%d, fps=%d, b[%d]=%#x(%s)"
,
srs_type2string
(
SRS_RTMP_TYPE_VIDEO
),
dts
,
size
,
fps
,
nb_start_code
,
(
char
)
data
[
nb_start_code
],
(
nut
==
7
?
"SPS"
:
(
nut
==
8
?
"PPS"
:
(
nut
==
5
?
"I"
:
(
nut
==
1
?
"P"
:
"Unknown"
)))));
// @remark, when use encode device, it not need to sleep.
usleep
(
1000
/
fps
*
1000
);
}
srs_trace
(
"h264 raw data completed"
);
srs_
lib_
trace
(
"h264 raw data completed"
);
rtmp_destroy:
srs_rtmp_destroy
(
rtmp
);
...
...
trunk/research/librtmp/srs_ingest_flv.c
查看文件 @
606fc13
...
...
@@ -89,19 +89,19 @@ int main(int argc, char** argv)
}
}
srs_trace
(
"input: %s"
,
in_flv_file
);
srs_trace
(
"output: %s"
,
out_rtmp_url
);
srs_lib_trace
(
"input: %s"
,
in_flv_file
);
srs_lib_trace
(
"output: %s"
,
out_rtmp_url
);
if
((
flv
=
srs_flv_open_read
(
in_flv_file
))
==
NULL
)
{
ret
=
2
;
srs_trace
(
"open flv file failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"open flv file failed. ret=%d"
,
ret
);
return
ret
;
}
ortmp
=
srs_rtmp_create
(
out_rtmp_url
);
ret
=
proxy
(
flv
,
ortmp
);
srs_trace
(
"ingest flv to RTMP completed"
);
srs_
lib_
trace
(
"ingest flv to RTMP completed"
);
srs_rtmp_destroy
(
ortmp
);
srs_flv_close
(
flv
);
...
...
@@ -118,20 +118,20 @@ int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, u_int32_t* ptimestamp)
int
size
;
char
*
data
=
NULL
;
srs_trace
(
"start ingest flv to RTMP stream"
);
srs_
lib_
trace
(
"start ingest flv to RTMP stream"
);
for
(;;)
{
// tag header
if
((
ret
=
srs_flv_read_tag_header
(
flv
,
&
type
,
&
size
,
ptimestamp
))
!=
0
)
{
if
(
srs_flv_is_eof
(
ret
))
{
srs_trace
(
"parse completed."
);
srs_
lib_
trace
(
"parse completed."
);
return
0
;
}
srs_trace
(
"flv get packet failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"flv get packet failed. ret=%d"
,
ret
);
return
ret
;
}
if
(
size
<=
0
)
{
srs_trace
(
"invalid size=%d"
,
size
);
srs_
lib_
trace
(
"invalid size=%d"
,
size
);
break
;
}
...
...
@@ -142,10 +142,10 @@ int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, u_int32_t* ptimestamp)
}
if
((
ret
=
srs_write_packet
(
ortmp
,
type
,
*
ptimestamp
,
data
,
size
))
!=
0
)
{
srs_trace
(
"irtmp get packet failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"irtmp get packet failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"ortmp sent packet: type=%s, time=%d, size=%d"
,
srs_
lib_
verbose
(
"ortmp sent packet: type=%s, time=%d, size=%d"
,
srs_type2string
(
type
),
*
ptimestamp
,
size
);
re_update
(
re
,
*
ptimestamp
);
...
...
@@ -182,22 +182,22 @@ int connect_oc(srs_rtmp_t ortmp)
int
ret
=
0
;
if
((
ret
=
srs_simple_handshake
(
ortmp
))
!=
0
)
{
srs_trace
(
"ortmp simple handshake failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"ortmp simple handshake failed. ret=%d"
,
ret
);
return
ret
;
}
srs_trace
(
"ortmp simple handshake success"
);
srs_
lib_
trace
(
"ortmp simple handshake success"
);
if
((
ret
=
srs_connect_app
(
ortmp
))
!=
0
)
{
srs_trace
(
"ortmp connect vhost/app failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"ortmp connect vhost/app failed. ret=%d"
,
ret
);
return
ret
;
}
srs_trace
(
"ortmp connect vhost/app success"
);
srs_
lib_
trace
(
"ortmp connect vhost/app success"
);
if
((
ret
=
srs_publish_stream
(
ortmp
))
!=
0
)
{
srs_trace
(
"ortmp publish stream failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"ortmp publish stream failed. ret=%d"
,
ret
);
return
ret
;
}
srs_trace
(
"ortmp publish stream success"
);
srs_
lib_
trace
(
"ortmp publish stream success"
);
return
ret
;
}
...
...
@@ -209,16 +209,16 @@ int64_t re_create()
// use the starttime to get the deviation
int64_t
deviation
=
re
-
tools_main_entrance_startup_time
;
srs_trace
(
"deviation is %d ms, pulse is %d ms"
,
(
int
)(
deviation
),
(
int
)(
RE_PULSE_MS
));
srs_
lib_
trace
(
"deviation is %d ms, pulse is %d ms"
,
(
int
)(
deviation
),
(
int
)(
RE_PULSE_MS
));
// so, we adjust time to max(0, deviation)
// because the last pulse, we already sleeped
int
adjust
=
(
int
)(
deviation
);
if
(
adjust
>
0
)
{
srs_trace
(
"adjust re time for %d ms"
,
adjust
);
srs_
lib_
trace
(
"adjust re time for %d ms"
,
adjust
);
re
-=
adjust
;
}
else
{
srs_trace
(
"no need to adjust re time"
);
srs_
lib_
trace
(
"no need to adjust re time"
);
}
return
re
;
...
...
@@ -239,7 +239,7 @@ void re_cleanup(int64_t re, u_int32_t time)
int64_t
now
=
srs_get_time_ms
();
int64_t
diff
=
time
-
(
now
-
re
);
if
(
diff
>
0
)
{
srs_trace
(
"re_cleanup sleep for the last pulse for %d ms"
,
(
int
)
diff
);
srs_
lib_
trace
(
"re_cleanup sleep for the last pulse for %d ms"
,
(
int
)
diff
);
usleep
(
diff
*
1000
);
}
}
...
...
trunk/research/librtmp/srs_ingest_rtmp.c
查看文件 @
606fc13
...
...
@@ -74,14 +74,14 @@ int main(int argc, char** argv)
}
}
srs_trace
(
"input: %s"
,
in_rtmp_url
);
srs_trace
(
"output: %s"
,
out_rtmp_url
);
srs_lib_trace
(
"input: %s"
,
in_rtmp_url
);
srs_lib_trace
(
"output: %s"
,
out_rtmp_url
);
irtmp
=
srs_rtmp_create
(
in_rtmp_url
);
ortmp
=
srs_rtmp_create
(
out_rtmp_url
);
ret
=
proxy
(
irtmp
,
ortmp
);
srs_trace
(
"proxy completed"
);
srs_
lib_
trace
(
"proxy completed"
);
srs_rtmp_destroy
(
irtmp
);
srs_rtmp_destroy
(
ortmp
);
...
...
@@ -105,20 +105,20 @@ int proxy(srs_rtmp_t irtmp, srs_rtmp_t ortmp)
return
ret
;
}
srs_trace
(
"start proxy RTMP stream"
);
srs_
lib_
trace
(
"start proxy RTMP stream"
);
for
(;;)
{
if
((
ret
=
srs_read_packet
(
irtmp
,
&
type
,
&
timestamp
,
&
data
,
&
size
))
!=
0
)
{
srs_trace
(
"irtmp get packet failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"irtmp get packet failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"irtmp got packet: type=%s, time=%d, size=%d"
,
srs_
lib_
verbose
(
"irtmp got packet: type=%s, time=%d, size=%d"
,
srs_type2string
(
type
),
timestamp
,
size
);
if
((
ret
=
srs_write_packet
(
ortmp
,
type
,
timestamp
,
data
,
size
))
!=
0
)
{
srs_trace
(
"irtmp get packet failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"irtmp get packet failed. ret=%d"
,
ret
);
return
ret
;
}
srs_verbose
(
"ortmp sent packet: type=%s, time=%d, size=%d"
,
srs_
lib_
verbose
(
"ortmp sent packet: type=%s, time=%d, size=%d"
,
srs_type2string
(
type
),
timestamp
,
size
);
}
...
...
@@ -130,22 +130,22 @@ int connect_ic(srs_rtmp_t irtmp)
int
ret
=
0
;
if
((
ret
=
srs_simple_handshake
(
irtmp
))
!=
0
)
{
srs_trace
(
"irtmp simple handshake failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"irtmp simple handshake failed. ret=%d"
,
ret
);
return
ret
;
}
srs_trace
(
"irtmp simple handshake success"
);
srs_
lib_
trace
(
"irtmp simple handshake success"
);
if
((
ret
=
srs_connect_app
(
irtmp
))
!=
0
)
{
srs_trace
(
"irtmp connect vhost/app failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"irtmp connect vhost/app failed. ret=%d"
,
ret
);
return
ret
;
}
srs_trace
(
"irtmp connect vhost/app success"
);
srs_
lib_
trace
(
"irtmp connect vhost/app success"
);
if
((
ret
=
srs_play_stream
(
irtmp
))
!=
0
)
{
srs_trace
(
"irtmp play stream failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"irtmp play stream failed. ret=%d"
,
ret
);
return
ret
;
}
srs_trace
(
"irtmp play stream success"
);
srs_
lib_
trace
(
"irtmp play stream success"
);
return
ret
;
}
...
...
@@ -155,22 +155,22 @@ int connect_oc(srs_rtmp_t ortmp)
int
ret
=
0
;
if
((
ret
=
srs_simple_handshake
(
ortmp
))
!=
0
)
{
srs_trace
(
"ortmp simple handshake failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"ortmp simple handshake failed. ret=%d"
,
ret
);
return
ret
;
}
srs_trace
(
"ortmp simple handshake success"
);
srs_
lib_
trace
(
"ortmp simple handshake success"
);
if
((
ret
=
srs_connect_app
(
ortmp
))
!=
0
)
{
srs_trace
(
"ortmp connect vhost/app failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"ortmp connect vhost/app failed. ret=%d"
,
ret
);
return
ret
;
}
srs_trace
(
"ortmp connect vhost/app success"
);
srs_
lib_
trace
(
"ortmp connect vhost/app success"
);
if
((
ret
=
srs_publish_stream
(
ortmp
))
!=
0
)
{
srs_trace
(
"ortmp publish stream failed. ret=%d"
,
ret
);
srs_
lib_
trace
(
"ortmp publish stream failed. ret=%d"
,
ret
);
return
ret
;
}
srs_trace
(
"ortmp publish stream success"
);
srs_
lib_
trace
(
"ortmp publish stream success"
);
return
ret
;
}
...
...
trunk/research/librtmp/srs_play.c
查看文件 @
606fc13
...
...
@@ -44,26 +44,26 @@ int main(int argc, char** argv)
exit
(
-
1
);
}
srs_trace
(
"rtmp url: %s"
,
argv
[
1
]);
srs_
lib_
trace
(
"rtmp url: %s"
,
argv
[
1
]);
srs_rtmp_t
rtmp
=
srs_rtmp_create
(
argv
[
1
]);
if
(
srs_simple_handshake
(
rtmp
)
!=
0
)
{
srs_trace
(
"simple handshake failed."
);
srs_
lib_
trace
(
"simple handshake failed."
);
goto
rtmp_destroy
;
}
srs_trace
(
"simple handshake success"
);
srs_
lib_
trace
(
"simple handshake success"
);
if
(
srs_connect_app
(
rtmp
)
!=
0
)
{
srs_trace
(
"connect vhost/app failed."
);
srs_
lib_
trace
(
"connect vhost/app failed."
);
goto
rtmp_destroy
;
}
srs_trace
(
"connect vhost/app success"
);
srs_
lib_
trace
(
"connect vhost/app success"
);
if
(
srs_play_stream
(
rtmp
)
!=
0
)
{
srs_trace
(
"play stream failed."
);
srs_
lib_
trace
(
"play stream failed."
);
goto
rtmp_destroy
;
}
srs_trace
(
"play stream success"
);
srs_
lib_
trace
(
"play stream success"
);
for
(;;)
{
int
type
,
size
;
...
...
@@ -73,7 +73,7 @@ int main(int argc, char** argv)
if
(
srs_read_packet
(
rtmp
,
&
type
,
&
timestamp
,
&
data
,
&
size
)
!=
0
)
{
goto
rtmp_destroy
;
}
srs_trace
(
"got packet: type=%s, time=%d, size=%d"
,
srs_
lib_
trace
(
"got packet: type=%s, time=%d, size=%d"
,
srs_type2string
(
type
),
timestamp
,
size
);
free
(
data
);
...
...
trunk/research/librtmp/srs_publish.c
查看文件 @
606fc13
...
...
@@ -47,31 +47,31 @@ int main(int argc, char** argv)
// warn it .
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/126
srs_trace
(
"
\033
[33m%s
\033
[0m"
,
srs_
lib_
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."
"read about: https://github.com/winlinvip/simple-rtmp-server/issues/126"
);
srs_trace
(
"rtmp url: %s"
,
argv
[
1
]);
srs_
lib_
trace
(
"rtmp url: %s"
,
argv
[
1
]);
srs_rtmp_t
rtmp
=
srs_rtmp_create
(
argv
[
1
]);
if
(
srs_simple_handshake
(
rtmp
)
!=
0
)
{
srs_trace
(
"simple handshake failed."
);
srs_
lib_
trace
(
"simple handshake failed."
);
goto
rtmp_destroy
;
}
srs_trace
(
"simple handshake success"
);
srs_
lib_
trace
(
"simple handshake success"
);
if
(
srs_connect_app
(
rtmp
)
!=
0
)
{
srs_trace
(
"connect vhost/app failed."
);
srs_
lib_
trace
(
"connect vhost/app failed."
);
goto
rtmp_destroy
;
}
srs_trace
(
"connect vhost/app success"
);
srs_
lib_
trace
(
"connect vhost/app success"
);
if
(
srs_publish_stream
(
rtmp
)
!=
0
)
{
srs_trace
(
"publish stream failed."
);
srs_
lib_
trace
(
"publish stream failed."
);
goto
rtmp_destroy
;
}
srs_trace
(
"publish stream success"
);
srs_
lib_
trace
(
"publish stream success"
);
u_int32_t
timestamp
=
0
;
for
(;;)
{
...
...
@@ -84,7 +84,7 @@ int main(int argc, char** argv)
if
(
srs_write_packet
(
rtmp
,
type
,
timestamp
,
data
,
size
)
!=
0
)
{
goto
rtmp_destroy
;
}
srs_trace
(
"sent packet: type=%s, time=%d, size=%d"
,
srs_
lib_
trace
(
"sent packet: type=%s, time=%d, size=%d"
,
srs_type2string
(
type
),
timestamp
,
size
);
usleep
(
40
*
1000
);
...
...
trunk/src/core/srs_core.hpp
查看文件 @
606fc13
...
...
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_REVISION 1
1
#define VERSION_REVISION 1
2
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
#define RTMP_SIG_SRS_ROLE "origin/edge server"
...
...
trunk/src/libs/srs_librtmp.hpp
查看文件 @
606fc13
...
...
@@ -237,8 +237,8 @@ extern int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp);
// log to console, for use srs-librtmp application.
extern
const
char
*
srs_format_time
();
#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_lib_trace(msg, ...) printf("[%s] ", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n")
#define srs_lib_verbose(msg, ...) printf("[%s] ", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n")
/*************************************************************
**************************************************************
...
...
请
注册
或
登录
后发表评论