mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine the macro.
This commit is contained in:
parent
bc756d6ad9
commit
73c310cd2e
9 changed files with 43 additions and 43 deletions
|
@ -528,9 +528,9 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $SRS_INGEST = YES ]; then
|
if [ $SRS_INGEST = YES ]; then
|
||||||
echo "#define SRS_INGEST" >> $SRS_AUTO_HEADERS_H
|
echo "#define SRS_RTMP_INGEST" >> $SRS_AUTO_HEADERS_H
|
||||||
else
|
else
|
||||||
echo "#undef SRS_INGEST" >> $SRS_AUTO_HEADERS_H
|
echo "#undef SRS_RTMP_INGEST" >> $SRS_AUTO_HEADERS_H
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
|
|
|
@ -2128,13 +2128,13 @@ string SrsConfig::get_ingest_input_type(SrsConfDirective* ingest)
|
||||||
SrsConfDirective* conf = ingest->get("input");
|
SrsConfDirective* conf = ingest->get("input");
|
||||||
|
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
return SRS_INGEST_TYPE_FILE;
|
return SRS_RTMP_INGEST_TYPE_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
conf = conf->get("type");
|
conf = conf->get("type");
|
||||||
|
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
return SRS_INGEST_TYPE_FILE;
|
return SRS_RTMP_INGEST_TYPE_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return conf->arg0();
|
return conf->arg0();
|
||||||
|
|
|
@ -70,8 +70,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#define SRS_STAGE_INGESTER_INTERVAL_MS 2000
|
#define SRS_STAGE_INGESTER_INTERVAL_MS 2000
|
||||||
#define SRS_STAGE_HLS_INTERVAL_MS 2000
|
#define SRS_STAGE_HLS_INTERVAL_MS 2000
|
||||||
|
|
||||||
#define SRS_INGEST_TYPE_FILE "file"
|
#define SRS_RTMP_INGEST_TYPE_FILE "file"
|
||||||
#define SRS_INGEST_TYPE_STREAM "stream"
|
#define SRS_RTMP_INGEST_TYPE_STREAM "stream"
|
||||||
|
|
||||||
class SrsFileBuffer;
|
class SrsFileBuffer;
|
||||||
|
|
||||||
|
|
|
@ -37,14 +37,14 @@ using namespace std;
|
||||||
#ifdef SRS_RTMP_TRANSCODE
|
#ifdef SRS_RTMP_TRANSCODE
|
||||||
|
|
||||||
// when error, encoder sleep for a while and retry.
|
// when error, encoder sleep for a while and retry.
|
||||||
#define SRS_ENCODER_SLEEP_US (int64_t)(3*1000*1000LL)
|
#define SRS_RTMP_ENCODER_SLEEP_US (int64_t)(3*1000*1000LL)
|
||||||
|
|
||||||
// for encoder to detect the dead loop
|
// for encoder to detect the dead loop
|
||||||
static std::vector<std::string> _transcoded_url;
|
static std::vector<std::string> _transcoded_url;
|
||||||
|
|
||||||
SrsEncoder::SrsEncoder()
|
SrsEncoder::SrsEncoder()
|
||||||
{
|
{
|
||||||
pthread = new SrsThread(this, SRS_ENCODER_SLEEP_US);
|
pthread = new SrsThread(this, SRS_RTMP_ENCODER_SLEEP_US);
|
||||||
pithy_print = new SrsPithyPrint(SRS_STAGE_ENCODER);
|
pithy_print = new SrsPithyPrint(SRS_STAGE_ENCODER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ int SrsEncoder::cycle()
|
||||||
|
|
||||||
// pithy print
|
// pithy print
|
||||||
encoder();
|
encoder();
|
||||||
pithy_print->elapse(SRS_ENCODER_SLEEP_US / 1000);
|
pithy_print->elapse(SRS_RTMP_ENCODER_SLEEP_US / 1000);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,14 +41,14 @@ using namespace std;
|
||||||
|
|
||||||
#ifdef SRS_FFMPEG_STUB
|
#ifdef SRS_FFMPEG_STUB
|
||||||
|
|
||||||
#define SRS_ENCODER_COPY "copy"
|
#define SRS_RTMP_ENCODER_COPY "copy"
|
||||||
#define SRS_ENCODER_NO_VIDEO "vn"
|
#define SRS_RTMP_ENCODER_NO_VIDEO "vn"
|
||||||
#define SRS_ENCODER_NO_AUDIO "an"
|
#define SRS_RTMP_ENCODER_NO_AUDIO "an"
|
||||||
// only support libx264 encoder.
|
// only support libx264 encoder.
|
||||||
#define SRS_ENCODER_VCODEC "libx264"
|
#define SRS_RTMP_ENCODER_VCODEC "libx264"
|
||||||
// any aac encoder is ok which contains the aac,
|
// any aac encoder is ok which contains the aac,
|
||||||
// for example, libaacplus, aac, fdkaac
|
// for example, libaacplus, aac, fdkaac
|
||||||
#define SRS_ENCODER_ACODEC "aac"
|
#define SRS_RTMP_ENCODER_ACODEC "aac"
|
||||||
|
|
||||||
SrsFFMPEG::SrsFFMPEG(std::string ffmpeg_bin)
|
SrsFFMPEG::SrsFFMPEG(std::string ffmpeg_bin)
|
||||||
{
|
{
|
||||||
|
@ -118,17 +118,17 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine)
|
||||||
vwidth -= vwidth % 2;
|
vwidth -= vwidth % 2;
|
||||||
vheight -= vheight % 2;
|
vheight -= vheight % 2;
|
||||||
|
|
||||||
if (vcodec == SRS_ENCODER_NO_VIDEO && acodec == SRS_ENCODER_NO_AUDIO) {
|
if (vcodec == SRS_RTMP_ENCODER_NO_VIDEO && acodec == SRS_RTMP_ENCODER_NO_AUDIO) {
|
||||||
ret = ERROR_ENCODER_VCODEC;
|
ret = ERROR_ENCODER_VCODEC;
|
||||||
srs_warn("video and audio disabled. ret=%d", ret);
|
srs_warn("video and audio disabled. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vcodec != SRS_ENCODER_COPY && vcodec != SRS_ENCODER_NO_VIDEO) {
|
if (vcodec != SRS_RTMP_ENCODER_COPY && vcodec != SRS_RTMP_ENCODER_NO_VIDEO) {
|
||||||
if (vcodec != SRS_ENCODER_VCODEC) {
|
if (vcodec != SRS_RTMP_ENCODER_VCODEC) {
|
||||||
ret = ERROR_ENCODER_VCODEC;
|
ret = ERROR_ENCODER_VCODEC;
|
||||||
srs_error("invalid vcodec, must be %s, actual %s, ret=%d",
|
srs_error("invalid vcodec, must be %s, actual %s, ret=%d",
|
||||||
SRS_ENCODER_VCODEC, vcodec.c_str(), ret);
|
SRS_RTMP_ENCODER_VCODEC, vcodec.c_str(), ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if (vbitrate <= 0) {
|
if (vbitrate <= 0) {
|
||||||
|
@ -168,11 +168,11 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (acodec != SRS_ENCODER_COPY && acodec != SRS_ENCODER_NO_AUDIO) {
|
if (acodec != SRS_RTMP_ENCODER_COPY && acodec != SRS_RTMP_ENCODER_NO_AUDIO) {
|
||||||
if (acodec.find(SRS_ENCODER_ACODEC) == std::string::npos) {
|
if (acodec.find(SRS_RTMP_ENCODER_ACODEC) == std::string::npos) {
|
||||||
ret = ERROR_ENCODER_ACODEC;
|
ret = ERROR_ENCODER_ACODEC;
|
||||||
srs_error("invalid acodec, must be %s, actual %s, ret=%d",
|
srs_error("invalid acodec, must be %s, actual %s, ret=%d",
|
||||||
SRS_ENCODER_ACODEC, acodec.c_str(), ret);
|
SRS_RTMP_ENCODER_ACODEC, acodec.c_str(), ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
if (abitrate <= 0) {
|
if (abitrate <= 0) {
|
||||||
|
@ -207,8 +207,8 @@ int SrsFFMPEG::initialize_copy()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
vcodec = SRS_ENCODER_COPY;
|
vcodec = SRS_RTMP_ENCODER_COPY;
|
||||||
acodec = SRS_ENCODER_COPY;
|
acodec = SRS_RTMP_ENCODER_COPY;
|
||||||
|
|
||||||
if (_output.empty()) {
|
if (_output.empty()) {
|
||||||
ret = ERROR_ENCODER_OUTPUT;
|
ret = ERROR_ENCODER_OUTPUT;
|
||||||
|
@ -261,7 +261,7 @@ int SrsFFMPEG::start()
|
||||||
}
|
}
|
||||||
|
|
||||||
// video specified.
|
// video specified.
|
||||||
if (vcodec != SRS_ENCODER_NO_VIDEO) {
|
if (vcodec != SRS_RTMP_ENCODER_NO_VIDEO) {
|
||||||
params.push_back("-vcodec");
|
params.push_back("-vcodec");
|
||||||
params.push_back(vcodec);
|
params.push_back(vcodec);
|
||||||
} else {
|
} else {
|
||||||
|
@ -269,7 +269,7 @@ int SrsFFMPEG::start()
|
||||||
}
|
}
|
||||||
|
|
||||||
// the codec params is disabled when copy
|
// the codec params is disabled when copy
|
||||||
if (vcodec != SRS_ENCODER_COPY && vcodec != SRS_ENCODER_NO_VIDEO) {
|
if (vcodec != SRS_RTMP_ENCODER_COPY && vcodec != SRS_RTMP_ENCODER_NO_VIDEO) {
|
||||||
params.push_back("-b:v");
|
params.push_back("-b:v");
|
||||||
snprintf(tmp, sizeof(tmp), "%d", vbitrate * 1000);
|
snprintf(tmp, sizeof(tmp), "%d", vbitrate * 1000);
|
||||||
params.push_back(tmp);
|
params.push_back(tmp);
|
||||||
|
@ -310,7 +310,7 @@ int SrsFFMPEG::start()
|
||||||
}
|
}
|
||||||
|
|
||||||
// audio specified.
|
// audio specified.
|
||||||
if (acodec != SRS_ENCODER_NO_AUDIO) {
|
if (acodec != SRS_RTMP_ENCODER_NO_AUDIO) {
|
||||||
params.push_back("-acodec");
|
params.push_back("-acodec");
|
||||||
params.push_back(acodec);
|
params.push_back(acodec);
|
||||||
} else {
|
} else {
|
||||||
|
@ -318,7 +318,7 @@ int SrsFFMPEG::start()
|
||||||
}
|
}
|
||||||
|
|
||||||
// the codec params is disabled when copy
|
// the codec params is disabled when copy
|
||||||
if (acodec != SRS_ENCODER_COPY && acodec != SRS_ENCODER_NO_AUDIO) {
|
if (acodec != SRS_RTMP_ENCODER_COPY && acodec != SRS_RTMP_ENCODER_NO_AUDIO) {
|
||||||
params.push_back("-b:a");
|
params.push_back("-b:a");
|
||||||
snprintf(tmp, sizeof(tmp), "%d", abitrate * 1000);
|
snprintf(tmp, sizeof(tmp), "%d", abitrate * 1000);
|
||||||
params.push_back(tmp);
|
params.push_back(tmp);
|
||||||
|
|
|
@ -23,7 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#include <srs_app_ingest.hpp>
|
#include <srs_app_ingest.hpp>
|
||||||
|
|
||||||
#ifdef SRS_INGEST
|
#ifdef SRS_RTMP_INGEST
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ using namespace std;
|
||||||
|
|
||||||
// when error, ingester sleep for a while and retry.
|
// when error, ingester sleep for a while and retry.
|
||||||
// ingest never sleep a long time, for we must start the stream ASAP.
|
// ingest never sleep a long time, for we must start the stream ASAP.
|
||||||
#define SRS_INGESTER_SLEEP_US (int64_t)(6*100*1000LL)
|
#define SRS_RTMP_INGESTER_SLEEP_US (int64_t)(6*100*1000LL)
|
||||||
|
|
||||||
SrsIngesterFFMPEG::SrsIngesterFFMPEG(SrsFFMPEG* _ffmpeg, string _vhost, string _id)
|
SrsIngesterFFMPEG::SrsIngesterFFMPEG(SrsFFMPEG* _ffmpeg, string _vhost, string _id)
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,7 @@ SrsIngester::SrsIngester()
|
||||||
{
|
{
|
||||||
_srs_config->subscribe(this);
|
_srs_config->subscribe(this);
|
||||||
|
|
||||||
pthread = new SrsThread(this, SRS_INGESTER_SLEEP_US);
|
pthread = new SrsThread(this, SRS_RTMP_INGESTER_SLEEP_US);
|
||||||
pithy_print = new SrsPithyPrint(SRS_STAGE_INGESTER);
|
pithy_print = new SrsPithyPrint(SRS_STAGE_INGESTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ int SrsIngester::cycle()
|
||||||
|
|
||||||
// pithy print
|
// pithy print
|
||||||
ingester();
|
ingester();
|
||||||
pithy_print->elapse(SRS_INGESTER_SLEEP_US / 1000);
|
pithy_print->elapse(SRS_RTMP_INGESTER_SLEEP_US / 1000);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input_type == SRS_INGEST_TYPE_FILE) {
|
if (input_type == SRS_RTMP_INGEST_TYPE_FILE) {
|
||||||
std::string input_url = _srs_config->get_ingest_input_url(ingest);
|
std::string input_url = _srs_config->get_ingest_input_url(ingest);
|
||||||
if (input_url.empty()) {
|
if (input_url.empty()) {
|
||||||
ret = ERROR_ENCODER_NO_INPUT;
|
ret = ERROR_ENCODER_NO_INPUT;
|
||||||
|
@ -296,7 +296,7 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S
|
||||||
if ((ret = ffmpeg->initialize(input_url, output, log_file)) != ERROR_SUCCESS) {
|
if ((ret = ffmpeg->initialize(input_url, output, log_file)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
} else if (input_type == SRS_INGEST_TYPE_STREAM) {
|
} else if (input_type == SRS_RTMP_INGEST_TYPE_STREAM) {
|
||||||
std::string input_url = _srs_config->get_ingest_input_url(ingest);
|
std::string input_url = _srs_config->get_ingest_input_url(ingest);
|
||||||
if (input_url.empty()) {
|
if (input_url.empty()) {
|
||||||
ret = ERROR_ENCODER_NO_INPUT;
|
ret = ERROR_ENCODER_NO_INPUT;
|
||||||
|
|
|
@ -29,7 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <srs_core.hpp>
|
#include <srs_core.hpp>
|
||||||
|
|
||||||
#ifdef SRS_INGEST
|
#ifdef SRS_RTMP_INGEST
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,12 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <srs_app_http_api.hpp>
|
#include <srs_app_http_api.hpp>
|
||||||
#include <srs_app_http_conn.hpp>
|
#include <srs_app_http_conn.hpp>
|
||||||
#include <srs_app_http.hpp>
|
#include <srs_app_http.hpp>
|
||||||
#ifdef SRS_INGEST
|
#ifdef SRS_RTMP_INGEST
|
||||||
#include <srs_app_ingest.hpp>
|
#include <srs_app_ingest.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define SERVER_LISTEN_BACKLOG 512
|
#define SERVER_LISTEN_BACKLOG 512
|
||||||
#define SRS_TIME_RESOLUTION_MS 500
|
#define SRS_SYS_TIME_RESOLUTION_MS 500
|
||||||
|
|
||||||
SrsListener::SrsListener(SrsServer* server, SrsListenerType type)
|
SrsListener::SrsListener(SrsServer* server, SrsListenerType type)
|
||||||
{
|
{
|
||||||
|
@ -175,7 +175,7 @@ SrsServer::SrsServer()
|
||||||
#ifdef SRS_HTTP_SERVER
|
#ifdef SRS_HTTP_SERVER
|
||||||
http_stream_handler = NULL;
|
http_stream_handler = NULL;
|
||||||
#endif
|
#endif
|
||||||
#ifdef SRS_INGEST
|
#ifdef SRS_RTMP_INGEST
|
||||||
ingester = NULL;
|
ingester = NULL;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ SrsServer::~SrsServer()
|
||||||
#ifdef SRS_HTTP_SERVER
|
#ifdef SRS_HTTP_SERVER
|
||||||
srs_freep(http_stream_handler);
|
srs_freep(http_stream_handler);
|
||||||
#endif
|
#endif
|
||||||
#ifdef SRS_INGEST
|
#ifdef SRS_RTMP_INGEST
|
||||||
srs_freep(ingester);
|
srs_freep(ingester);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ int SrsServer::initialize()
|
||||||
srs_assert(!http_stream_handler);
|
srs_assert(!http_stream_handler);
|
||||||
http_stream_handler = SrsHttpHandler::create_http_stream();
|
http_stream_handler = SrsHttpHandler::create_http_stream();
|
||||||
#endif
|
#endif
|
||||||
#ifdef SRS_INGEST
|
#ifdef SRS_RTMP_INGEST
|
||||||
srs_assert(!ingester);
|
srs_assert(!ingester);
|
||||||
ingester = new SrsIngester();
|
ingester = new SrsIngester();
|
||||||
#endif
|
#endif
|
||||||
|
@ -377,7 +377,7 @@ int SrsServer::ingest()
|
||||||
{
|
{
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
#ifdef SRS_INGEST
|
#ifdef SRS_RTMP_INGEST
|
||||||
if ((ret = ingester->start()) != ERROR_SUCCESS) {
|
if ((ret = ingester->start()) != ERROR_SUCCESS) {
|
||||||
srs_error("start ingest streams failed. ret=%d", ret);
|
srs_error("start ingest streams failed. ret=%d", ret);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -393,7 +393,7 @@ int SrsServer::cycle()
|
||||||
|
|
||||||
// the deamon thread, update the time cache
|
// the deamon thread, update the time cache
|
||||||
while (true) {
|
while (true) {
|
||||||
st_usleep(SRS_TIME_RESOLUTION_MS * 1000);
|
st_usleep(SRS_SYS_TIME_RESOLUTION_MS * 1000);
|
||||||
srs_update_system_time_ms();
|
srs_update_system_time_ms();
|
||||||
|
|
||||||
// for gperf heap checker,
|
// for gperf heap checker,
|
||||||
|
@ -419,7 +419,7 @@ int SrsServer::cycle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SRS_INGEST
|
#ifdef SRS_RTMP_INGEST
|
||||||
ingester->stop();
|
ingester->stop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ private:
|
||||||
#ifdef SRS_HTTP_SERVER
|
#ifdef SRS_HTTP_SERVER
|
||||||
SrsHttpHandler* http_stream_handler;
|
SrsHttpHandler* http_stream_handler;
|
||||||
#endif
|
#endif
|
||||||
#ifdef SRS_INGEST
|
#ifdef SRS_RTMP_INGEST
|
||||||
SrsIngester* ingester;
|
SrsIngester* ingester;
|
||||||
#endif
|
#endif
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue