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-11 16:10:32 +0800
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
2ea3440a12bb83828eafdfebfd131525797dc0bf
2ea3440a
2 parents
ca836cd3
f9756ea1
Merge branch 'srs.master'
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
189 行增加
和
1 行删除
trunk/configure
trunk/src/app/srs_app_pipe.cpp
trunk/src/app/srs_app_pipe.hpp
trunk/src/kernel/srs_kernel_error.hpp
trunk/src/srs/srs.upp
trunk/configure
查看文件 @
2ea3440
...
...
@@ -388,7 +388,8 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
"srs_app_thread"
"srs_app_bandwidth"
"srs_app_st"
"srs_app_log"
"srs_app_config"
"srs_app_pithy_print"
"srs_app_reload"
"srs_app_http_api"
"srs_app_http_conn"
"srs_app_http_hooks"
"srs_app_json"
"srs_app_ingest"
"srs_app_ffmpeg"
"srs_app_utility"
"srs_app_dvr"
"srs_app_edge"
"srs_app_kbps"
"srs_app_heartbeat"
"srs_app_empty"
"srs_app_http_client"
"srs_app_avc_aac"
)
"srs_app_kbps"
"srs_app_heartbeat"
"srs_app_empty"
"srs_app_http_client"
"srs_app_avc_aac"
"srs_app_pipe"
)
APP_INCS
=
"src/app"
;
MODULE_DIR
=
${
APP_INCS
}
. auto/modules.sh
APP_OBJS
=
"
${
MODULE_OBJS
[@]
}
"
fi
...
...
trunk/src/app/srs_app_pipe.cpp
0 → 100644
查看文件 @
2ea3440
/*
The MIT License (MIT)
Copyright (c) 2013-2014 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_app_pipe.hpp>
#include <unistd.h>
#include <srs_kernel_error.hpp>
#include <srs_kernel_log.hpp>
SrsPipe
::
SrsPipe
()
{
fds
[
0
]
=
fds
[
1
]
=
0
;
read_stfd
=
write_stfd
=
NULL
;
_already_written
=
false
;
}
SrsPipe
::~
SrsPipe
()
{
srs_close_stfd
(
read_stfd
);
srs_close_stfd
(
write_stfd
);
}
int
SrsPipe
::
initialize
()
{
int
ret
=
ERROR_SUCCESS
;
if
(
pipe
(
fds
)
<
0
)
{
ret
=
ERROR_SYSTEM_CREATE_PIPE
;
srs_error
(
"create pipe failed. ret=%d"
,
ret
);
return
ret
;
}
if
((
read_stfd
=
st_netfd_open
(
fds
[
0
]))
==
NULL
)
{
ret
=
ERROR_SYSTEM_CREATE_PIPE
;
srs_error
(
"open read pipe failed. ret=%d"
,
ret
);
return
ret
;
}
if
((
write_stfd
=
st_netfd_open
(
fds
[
1
]))
==
NULL
)
{
ret
=
ERROR_SYSTEM_CREATE_PIPE
;
srs_error
(
"open write pipe failed. ret=%d"
,
ret
);
return
ret
;
}
return
ret
;
}
bool
SrsPipe
::
already_written
()
{
return
_already_written
;
}
int
SrsPipe
::
active
()
{
int
ret
=
ERROR_SUCCESS
;
int
v
=
0
;
if
(
st_write
(
read_stfd
,
&
v
,
sizeof
(
int
),
ST_UTIME_NO_TIMEOUT
)
!=
sizeof
(
int
))
{
ret
=
ERROR_SYSTEM_WRITE_PIPE
;
srs_error
(
"write pipe failed. ret=%d"
,
ret
);
return
ret
;
}
_already_written
=
true
;
return
ret
;
}
int
SrsPipe
::
reset
()
{
int
ret
=
ERROR_SUCCESS
;
int
v
;
if
(
st_read
(
read_stfd
,
&
v
,
sizeof
(
int
),
ST_UTIME_NO_TIMEOUT
)
!=
sizeof
(
int
))
{
ret
=
ERROR_SYSTEM_READ_PIPE
;
srs_error
(
"read pipe failed. ret=%d"
,
ret
);
return
ret
;
}
_already_written
=
false
;
return
ret
;
}
...
...
trunk/src/app/srs_app_pipe.hpp
0 → 100644
查看文件 @
2ea3440
/*
The MIT License (MIT)
Copyright (c) 2013-2014 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.
*/
#ifndef SRS_APP_PIPE_HPP
#define SRS_APP_PIPE_HPP
/*
#include <srs_app_pipe.hpp>
*/
#include <srs_core.hpp>
#include <srs_app_st.hpp>
/**
* convert something to io,
* for example, signal or SrsConsumer event.
* for performance issue, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194
*/
class
SrsPipe
{
private
:
int
fds
[
2
];
st_netfd_t
read_stfd
;
st_netfd_t
write_stfd
;
/**
* for the event based service,
* for example, the consumer only care whether there is data writen in pipe,
* and the source will not write to pipe when pipe is already writen.
*/
bool
_already_written
;
public
:
SrsPipe
();
virtual
~
SrsPipe
();
public
:
/**
* initialize pipes, open fds.
*/
virtual
int
initialize
();
public
:
/**
* for event based service, whether already writen data.
*/
virtual
bool
already_written
();
/**
* for event based service,
* write an int to pipe and set the pipe to active.
*/
virtual
int
active
();
/**
* for event based service,
* read an int from pipe and reset the pipe to deactive.
*/
virtual
int
reset
();
};
#endif
...
...
trunk/src/kernel/srs_kernel_error.hpp
查看文件 @
2ea3440
...
...
@@ -88,6 +88,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define ERROR_SYSTEM_FILE_SEEK 1049
#define ERROR_SYSTEM_IO_INVALID 1050
#define ERROR_ST_EXCEED_THREADS 1051
#define ERROR_SYSTEM_READ_PIPE 1052
#define ERROR_SYSTEM_WRITE_PIPE 1053
///////////////////////////////////////////////////////
// RTMP protocol error.
...
...
trunk/src/srs/srs.upp
查看文件 @
2ea3440
...
...
@@ -92,6 +92,8 @@ file
..\app\srs_app_kbps.cpp,
..\app\srs_app_log.hpp,
..\app\srs_app_log.cpp,
..\app\srs_app_pipe.hpp,
..\app\srs_app_pipe.cpp,
..\app\srs_app_refer.hpp,
..\app\srs_app_refer.cpp,
..\app\srs_app_reload.hpp,
...
...
请
注册
或
登录
后发表评论