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
2013-12-01 17:42:09 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2695e4d0c6d374f0b152a70f02f7982932fcc941
2695e4d0
1 parent
6af0794b
fix bug of core
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
134 行增加
和
133 行删除
trunk/conf/srs.conf
trunk/src/core/srs_core.cpp
trunk/conf/srs.conf
查看文件 @
2695e4d
...
...
@@ -20,7 +20,7 @@ vhost __defaultVhost__ {
transcode
{
enabled
on
;
ffmpeg
./
objs
/
ffmpeg
/
bin
/
ffmpeg
;
engine
ld
{
engine
ld
{
enabled
on
;
vfilter
{
vf
'drawtext=text=SimpleRtmpServer(SRS):x=10:y=10:fontcolor=#cccccc:fontfile=./doc/FreeSerifBold.ttf'
;
...
...
@@ -43,7 +43,7 @@ vhost __defaultVhost__ {
}
output
rtmp
://
127
.
0
.
0
.
1
:[
port
]/[
app
]?
vhost
=[
vhost
]/[
stream
]
_
[
engine
];
}
engine
sd
{
engine
sd
{
enabled
on
;
vfilter
{
vf
'split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2'
;
...
...
@@ -76,11 +76,11 @@ vhost dev {
hls_path
./
objs
/
nginx
/
html
;
hls_fragment
5
;
hls_window
30
;
forward
127
.
0
.
0
.
1
:
19350
?
vhost
=
dev
;
forward
127
.
0
.
0
.
1
:
19350
;
transcode
{
enabled
on
;
ffmpeg
./
objs
/
ffmpeg
/
bin
/
ffmpeg
;
engine
dev
{
engine
dev
{
enabled
on
;
vfilter
{
}
...
...
@@ -109,7 +109,7 @@ vhost mirror.transcode.vhost.com {
transcode
{
enabled
on
;
ffmpeg
./
objs
/
ffmpeg
/
bin
/
ffmpeg
;
engine
mirror
{
engine
mirror
{
enabled
on
;
vfilter
{
vf
'split [main][tmp]; [tmp] crop=iw:ih/2:0:0, vflip [flip]; [main][flip] overlay=0:H/2'
;
...
...
@@ -139,7 +139,7 @@ vhost drawtext.transcode.vhost.com {
transcode
{
enabled
on
;
ffmpeg
./
objs
/
ffmpeg
/
bin
/
ffmpeg
;
engine
drawtext
{
engine
drawtext
{
enabled
on
;
vfilter
{
vf
'drawtext=text=SimpleRtmpServer(SRS):x=10:y=10:fontcolor=#cccccc:fontfile=./doc/FreeSerifBold.ttf'
;
...
...
@@ -169,7 +169,7 @@ vhost crop.transcode.vhost.com {
transcode
{
enabled
on
;
ffmpeg
./
objs
/
ffmpeg
/
bin
/
ffmpeg
;
engine
crop
{
engine
crop
{
enabled
on
;
vfilter
{
vf
'crop=in_w-20:in_h-160:10:80'
;
...
...
@@ -199,7 +199,7 @@ vhost logo.transcode.vhost.com {
transcode
{
enabled
on
;
ffmpeg
./
objs
/
ffmpeg
/
bin
/
ffmpeg
;
engine
logo
{
engine
logo
{
enabled
on
;
vfilter
{
vf
'crop=200:100:10:10'
;
...
...
@@ -237,7 +237,7 @@ vhost all.transcode.vhost.com {
# the transcode engine for matched stream.
# all matched stream will transcoded to the following stream.
# the transcode set name(ie. hd) is optional and not used.
engine
ffsuper
{
engine
ffsuper
{
# whether the engine is enabled
# default: off.
enabled
on
;
...
...
@@ -300,7 +300,7 @@ vhost all.transcode.vhost.com {
# [engine] the tanscode engine name.
output
rtmp
://
127
.
0
.
0
.
1
:[
port
]/[
app
]?
vhost
=[
vhost
]/[
stream
]
_
[
engine
];
}
engine
ffhd
{
engine
ffhd
{
enabled
on
;
vcodec
libx264
;
vbitrate
1200
;
...
...
@@ -318,9 +318,9 @@ vhost all.transcode.vhost.com {
achannels
2
;
aparams
{
}
output
rtmp
://
[
vhost
]:[
port
]/[
app
]/[
stream
]
_
ffhd
;
output
rtmp
://
127
.
0
.
0
.
1
:[
port
]/[
app
]?
vhost
=[
vhost
]/[
stream
]
_
[
engine
]
;
}
engine
ffsd
{
engine
ffsd
{
enabled
on
;
vcodec
libx264
;
vbitrate
800
;
...
...
@@ -338,9 +338,9 @@ vhost all.transcode.vhost.com {
achannels
2
;
aparams
{
}
output
rtmp
://
[
vhost
]:[
port
]/[
app
]/[
stream
]
_
ffsd
;
output
rtmp
://
127
.
0
.
0
.
1
:[
port
]/[
app
]?
vhost
=[
vhost
]/[
stream
]
_
[
engine
]
;
}
engine
fffast
{
engine
fffast
{
enabled
on
;
vcodec
libx264
;
vbitrate
300
;
...
...
@@ -358,7 +358,7 @@ vhost all.transcode.vhost.com {
achannels
2
;
aparams
{
}
output
rtmp
://
[
vhost
]:[
port
]/[
app
]/[
stream
]
_
fffast
;
output
rtmp
://
127
.
0
.
0
.
1
:[
port
]/[
app
]?
vhost
=[
vhost
]/[
stream
]
_
[
engine
]
;
}
}
}
...
...
@@ -367,7 +367,7 @@ vhost ffempty.transcode.vhost.com {
transcode
{
enabled
on
;
ffmpeg
./
research
/
ffempty
/
ffempty
;
engine
empty
{
engine
empty
{
enabled
on
;
vcodec
libx264
;
vbitrate
300
;
...
...
@@ -385,7 +385,7 @@ vhost ffempty.transcode.vhost.com {
achannels
2
;
aparams
{
}
output
rtmp
://
[
vhost
]:[
port
]/[
app
]/[
stream
]
_
empty
;
output
rtmp
://
127
.
0
.
0
.
1
:[
port
]/[
app
]?
vhost
=[
vhost
]/[
stream
]
_
[
engine
]
;
}
}
}
...
...
@@ -396,7 +396,7 @@ vhost app.transcode.vhost.com {
transcode
live
{
enabled
on
;
ffmpeg
./
objs
/
ffmpeg
/
bin
/
ffmpeg
;
engine
fd
{
engine
{
enabled
off
;
}
}
...
...
@@ -408,13 +408,13 @@ vhost stream.transcode.vhost.com {
transcode
live
/
livestream
{
enabled
on
;
ffmpeg
./
objs
/
ffmpeg
/
bin
/
ffmpeg
;
engine
fd
{
engine
{
enabled
off
;
}
}
}
# the vhost which forward publish streams.
vhost
forward
.
vhost
.
com
{
vhost
same
.
vhost
.
forward
.
vhost
.
com
{
# forward all publish stream to the specified server.
# this used to split/forward the current stream for cluster active-standby,
# active-active for cdn to build high available fault tolerance system.
...
...
@@ -425,7 +425,7 @@ vhost forward.vhost.com {
forward
127
.
0
.
0
.
1
:
1936
127
.
0
.
0
.
1
:
1937
;
}
# the vhost which forward publish streams to other vhosts.
vhost
forward1
.
vhost
.
com
{
vhost
change
.
vhost
.
forward
.
vhost
.
com
{
forward
127
.
0
.
0
.
1
:
1936
?
vhost
=
forward2
.
vhost
.
com
127
.
0
.
0
.
1
:
1937
?
vhost
=
forward3
.
vhost
.
com
;
}
# the vhost disabled.
...
...
trunk/src/core/srs_core.cpp
100644 → 100755
查看文件 @
2695e4d
/*
The MIT License (MIT)
Copyright (c) 2013 winlin
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 <srs_core.hpp>
#include <sys/time.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <srs_core_log.hpp>
static
int64_t
_srs_system_time_us_cache
=
0
;
int64_t
srs_get_system_time_ms
()
{
return
_srs_system_time_us_cache
/
1000
;
}
void
srs_update_system_time_ms
()
{
timeval
now
;
gettimeofday
(
&
now
,
NULL
);
// we must convert the tv_sec/tv_usec to int64_t.
_srs_system_time_us_cache
=
now
.
tv_sec
*
1000
*
1000
+
now
.
tv_usec
;
_srs_system_time_us_cache
=
srs_max
(
0
,
_srs_system_time_us_cache
);
}
std
::
string
srs_replace
(
std
::
string
str
,
std
::
string
old_str
,
std
::
string
new_str
)
{
std
::
string
ret
=
str
;
if
(
old_str
==
new_str
)
{
return
ret
;
}
size_t
pos
=
0
;
while
((
pos
=
ret
.
find
(
old_str
,
pos
))
!=
std
::
string
::
npos
)
{
ret
=
ret
.
replace
(
pos
,
old_str
.
length
(),
new_str
);
pos
+=
new_str
.
length
();
}
return
ret
;
}
std
::
string
srs_dns_resolve
(
std
::
string
host
)
{
if
(
inet_addr
(
host
.
c_str
())
!=
INADDR_NONE
)
{
return
host
;
}
hostent
*
answer
=
gethostbyname
(
host
.
c_str
());
if
(
answer
==
NULL
)
{
srs_error
(
"dns resolve host %s error."
,
host
.
c_str
());
return
""
;
}
char
ipv4
[
16
];
memset
(
ipv4
,
0
,
sizeof
(
ipv4
));
for
(
int
i
=
0
;
i
<
answer
->
h_length
;
i
++
)
{
inet_ntop
(
AF_INET
,
answer
->
h_addr_list
[
i
],
ipv4
,
sizeof
(
ipv4
));
srs_info
(
"dns resolve host %s to %s."
,
host
.
c_str
(),
ipv4
);
break
;
}
return
ipv4
;
}
void
srs_vhost_resolve
(
std
::
string
&
vhost
,
std
::
string
&
app
)
{
app
=
srs_replace
(
app
,
"..."
,
"?"
);
if
((
pos
=
app
.
find
(
"?"
))
==
std
::
string
::
npos
)
{
return
;
}
std
::
string
query
=
app
.
substr
(
pos
+
1
);
app
=
app
.
substr
(
0
,
pos
);
if
((
pos
=
query
.
find
(
"vhost?"
))
!=
std
::
string
::
npos
||
(
pos
=
query
.
find
(
"vhost="
))
!=
std
::
string
::
npos
||
(
pos
=
query
.
find
(
"Vhost?"
))
!=
std
::
string
::
npos
||
(
pos
=
query
.
find
(
"Vhost="
))
!=
std
::
string
::
npos
)
{
query
=
query
.
substr
(
pos
+
6
);
if
(
!
query
.
empty
())
{
vhost
=
query
;
}
}
}
/*
The MIT License (MIT)
Copyright (c) 2013 winlin
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 <srs_core.hpp>
#include <sys/time.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <srs_core_log.hpp>
static
int64_t
_srs_system_time_us_cache
=
0
;
int64_t
srs_get_system_time_ms
()
{
return
_srs_system_time_us_cache
/
1000
;
}
void
srs_update_system_time_ms
()
{
timeval
now
;
gettimeofday
(
&
now
,
NULL
);
// we must convert the tv_sec/tv_usec to int64_t.
_srs_system_time_us_cache
=
now
.
tv_sec
*
1000
*
1000
+
now
.
tv_usec
;
_srs_system_time_us_cache
=
srs_max
(
0
,
_srs_system_time_us_cache
);
}
std
::
string
srs_replace
(
std
::
string
str
,
std
::
string
old_str
,
std
::
string
new_str
)
{
std
::
string
ret
=
str
;
if
(
old_str
==
new_str
)
{
return
ret
;
}
size_t
pos
=
0
;
while
((
pos
=
ret
.
find
(
old_str
,
pos
))
!=
std
::
string
::
npos
)
{
ret
=
ret
.
replace
(
pos
,
old_str
.
length
(),
new_str
);
pos
+=
new_str
.
length
();
}
return
ret
;
}
std
::
string
srs_dns_resolve
(
std
::
string
host
)
{
if
(
inet_addr
(
host
.
c_str
())
!=
INADDR_NONE
)
{
return
host
;
}
hostent
*
answer
=
gethostbyname
(
host
.
c_str
());
if
(
answer
==
NULL
)
{
srs_error
(
"dns resolve host %s error."
,
host
.
c_str
());
return
""
;
}
char
ipv4
[
16
];
memset
(
ipv4
,
0
,
sizeof
(
ipv4
));
for
(
int
i
=
0
;
i
<
answer
->
h_length
;
i
++
)
{
inet_ntop
(
AF_INET
,
answer
->
h_addr_list
[
i
],
ipv4
,
sizeof
(
ipv4
));
srs_info
(
"dns resolve host %s to %s."
,
host
.
c_str
(),
ipv4
);
break
;
}
return
ipv4
;
}
void
srs_vhost_resolve
(
std
::
string
&
vhost
,
std
::
string
&
app
)
{
app
=
srs_replace
(
app
,
"..."
,
"?"
);
size_t
pos
=
0
;
if
((
pos
=
app
.
find
(
"?"
))
==
std
::
string
::
npos
)
{
return
;
}
std
::
string
query
=
app
.
substr
(
pos
+
1
);
app
=
app
.
substr
(
0
,
pos
);
if
((
pos
=
query
.
find
(
"vhost?"
))
!=
std
::
string
::
npos
||
(
pos
=
query
.
find
(
"vhost="
))
!=
std
::
string
::
npos
||
(
pos
=
query
.
find
(
"Vhost?"
))
!=
std
::
string
::
npos
||
(
pos
=
query
.
find
(
"Vhost="
))
!=
std
::
string
::
npos
)
{
query
=
query
.
substr
(
pos
+
6
);
if
(
!
query
.
empty
())
{
vhost
=
query
;
}
}
}
...
...
请
注册
或
登录
后发表评论