mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
parent
73abb1a31d
commit
e87eacd499
5 changed files with 1 additions and 189 deletions
3
trunk/configure
vendored
3
trunk/configure
vendored
|
@ -388,8 +388,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
||||||
"srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config"
|
"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_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_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_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh
|
||||||
APP_OBJS="${MODULE_OBJS[@]}"
|
APP_OBJS="${MODULE_OBJS[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,105 +0,0 @@
|
||||||
/*
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
/*
|
|
||||||
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
|
|
||||||
|
|
|
@ -88,8 +88,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#define ERROR_SYSTEM_FILE_SEEK 1049
|
#define ERROR_SYSTEM_FILE_SEEK 1049
|
||||||
#define ERROR_SYSTEM_IO_INVALID 1050
|
#define ERROR_SYSTEM_IO_INVALID 1050
|
||||||
#define ERROR_ST_EXCEED_THREADS 1051
|
#define ERROR_ST_EXCEED_THREADS 1051
|
||||||
#define ERROR_SYSTEM_READ_PIPE 1052
|
|
||||||
#define ERROR_SYSTEM_WRITE_PIPE 1053
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
// RTMP protocol error.
|
// RTMP protocol error.
|
||||||
|
|
|
@ -92,8 +92,6 @@ file
|
||||||
..\app\srs_app_kbps.cpp,
|
..\app\srs_app_kbps.cpp,
|
||||||
..\app\srs_app_log.hpp,
|
..\app\srs_app_log.hpp,
|
||||||
..\app\srs_app_log.cpp,
|
..\app\srs_app_log.cpp,
|
||||||
..\app\srs_app_pipe.hpp,
|
|
||||||
..\app\srs_app_pipe.cpp,
|
|
||||||
..\app\srs_app_refer.hpp,
|
..\app\srs_app_refer.hpp,
|
||||||
..\app\srs_app_refer.cpp,
|
..\app\srs_app_refer.cpp,
|
||||||
..\app\srs_app_reload.hpp,
|
..\app\srs_app_reload.hpp,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue