1
0
Fork 0
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:
winlin 2014-04-14 09:10:36 +08:00
parent bc756d6ad9
commit 73c310cd2e
9 changed files with 43 additions and 43 deletions

View file

@ -528,9 +528,9 @@ else
fi
if [ $SRS_INGEST = YES ]; then
echo "#define SRS_INGEST" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_RTMP_INGEST" >> $SRS_AUTO_HEADERS_H
else
echo "#undef SRS_INGEST" >> $SRS_AUTO_HEADERS_H
echo "#undef SRS_RTMP_INGEST" >> $SRS_AUTO_HEADERS_H
fi
#####################################################################################

View file

@ -2128,13 +2128,13 @@ string SrsConfig::get_ingest_input_type(SrsConfDirective* ingest)
SrsConfDirective* conf = ingest->get("input");
if (!conf) {
return SRS_INGEST_TYPE_FILE;
return SRS_RTMP_INGEST_TYPE_FILE;
}
conf = conf->get("type");
if (!conf) {
return SRS_INGEST_TYPE_FILE;
return SRS_RTMP_INGEST_TYPE_FILE;
}
return conf->arg0();

View file

@ -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_HLS_INTERVAL_MS 2000
#define SRS_INGEST_TYPE_FILE "file"
#define SRS_INGEST_TYPE_STREAM "stream"
#define SRS_RTMP_INGEST_TYPE_FILE "file"
#define SRS_RTMP_INGEST_TYPE_STREAM "stream"
class SrsFileBuffer;

View file

@ -37,14 +37,14 @@ using namespace std;
#ifdef SRS_RTMP_TRANSCODE
// 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
static std::vector<std::string> _transcoded_url;
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);
}
@ -112,7 +112,7 @@ int SrsEncoder::cycle()
// pithy print
encoder();
pithy_print->elapse(SRS_ENCODER_SLEEP_US / 1000);
pithy_print->elapse(SRS_RTMP_ENCODER_SLEEP_US / 1000);
return ret;
}

View file

@ -41,14 +41,14 @@ using namespace std;
#ifdef SRS_FFMPEG_STUB
#define SRS_ENCODER_COPY "copy"
#define SRS_ENCODER_NO_VIDEO "vn"
#define SRS_ENCODER_NO_AUDIO "an"
#define SRS_RTMP_ENCODER_COPY "copy"
#define SRS_RTMP_ENCODER_NO_VIDEO "vn"
#define SRS_RTMP_ENCODER_NO_AUDIO "an"
// only support libx264 encoder.
#define SRS_ENCODER_VCODEC "libx264"
#define SRS_RTMP_ENCODER_VCODEC "libx264"
// any aac encoder is ok which contains the aac,
// for example, libaacplus, aac, fdkaac
#define SRS_ENCODER_ACODEC "aac"
#define SRS_RTMP_ENCODER_ACODEC "aac"
SrsFFMPEG::SrsFFMPEG(std::string ffmpeg_bin)
{
@ -118,17 +118,17 @@ int SrsFFMPEG::initialize_transcode(SrsConfDirective* engine)
vwidth -= vwidth % 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;
srs_warn("video and audio disabled. ret=%d", ret);
return ret;
}
if (vcodec != SRS_ENCODER_COPY && vcodec != SRS_ENCODER_NO_VIDEO) {
if (vcodec != SRS_ENCODER_VCODEC) {
if (vcodec != SRS_RTMP_ENCODER_COPY && vcodec != SRS_RTMP_ENCODER_NO_VIDEO) {
if (vcodec != SRS_RTMP_ENCODER_VCODEC) {
ret = ERROR_ENCODER_VCODEC;
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;
}
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.find(SRS_ENCODER_ACODEC) == std::string::npos) {
if (acodec != SRS_RTMP_ENCODER_COPY && acodec != SRS_RTMP_ENCODER_NO_AUDIO) {
if (acodec.find(SRS_RTMP_ENCODER_ACODEC) == std::string::npos) {
ret = ERROR_ENCODER_ACODEC;
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;
}
if (abitrate <= 0) {
@ -207,8 +207,8 @@ int SrsFFMPEG::initialize_copy()
{
int ret = ERROR_SUCCESS;
vcodec = SRS_ENCODER_COPY;
acodec = SRS_ENCODER_COPY;
vcodec = SRS_RTMP_ENCODER_COPY;
acodec = SRS_RTMP_ENCODER_COPY;
if (_output.empty()) {
ret = ERROR_ENCODER_OUTPUT;
@ -261,7 +261,7 @@ int SrsFFMPEG::start()
}
// video specified.
if (vcodec != SRS_ENCODER_NO_VIDEO) {
if (vcodec != SRS_RTMP_ENCODER_NO_VIDEO) {
params.push_back("-vcodec");
params.push_back(vcodec);
} else {
@ -269,7 +269,7 @@ int SrsFFMPEG::start()
}
// 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");
snprintf(tmp, sizeof(tmp), "%d", vbitrate * 1000);
params.push_back(tmp);
@ -310,7 +310,7 @@ int SrsFFMPEG::start()
}
// audio specified.
if (acodec != SRS_ENCODER_NO_AUDIO) {
if (acodec != SRS_RTMP_ENCODER_NO_AUDIO) {
params.push_back("-acodec");
params.push_back(acodec);
} else {
@ -318,7 +318,7 @@ int SrsFFMPEG::start()
}
// 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");
snprintf(tmp, sizeof(tmp), "%d", abitrate * 1000);
params.push_back(tmp);

View file

@ -23,7 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_ingest.hpp>
#ifdef SRS_INGEST
#ifdef SRS_RTMP_INGEST
using namespace std;
@ -35,7 +35,7 @@ using namespace std;
// when error, ingester sleep for a while and retry.
// 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)
{
@ -53,7 +53,7 @@ SrsIngester::SrsIngester()
{
_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);
}
@ -187,7 +187,7 @@ int SrsIngester::cycle()
// pithy print
ingester();
pithy_print->elapse(SRS_INGESTER_SLEEP_US / 1000);
pithy_print->elapse(SRS_RTMP_INGESTER_SLEEP_US / 1000);
return ret;
}
@ -282,7 +282,7 @@ int SrsIngester::initialize_ffmpeg(SrsFFMPEG* ffmpeg, SrsConfDirective* vhost, S
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);
if (input_url.empty()) {
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) {
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);
if (input_url.empty()) {
ret = ERROR_ENCODER_NO_INPUT;

View file

@ -29,7 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_core.hpp>
#ifdef SRS_INGEST
#ifdef SRS_RTMP_INGEST
#include <vector>

View file

@ -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_conn.hpp>
#include <srs_app_http.hpp>
#ifdef SRS_INGEST
#ifdef SRS_RTMP_INGEST
#include <srs_app_ingest.hpp>
#endif
#define SERVER_LISTEN_BACKLOG 512
#define SRS_TIME_RESOLUTION_MS 500
#define SRS_SYS_TIME_RESOLUTION_MS 500
SrsListener::SrsListener(SrsServer* server, SrsListenerType type)
{
@ -175,7 +175,7 @@ SrsServer::SrsServer()
#ifdef SRS_HTTP_SERVER
http_stream_handler = NULL;
#endif
#ifdef SRS_INGEST
#ifdef SRS_RTMP_INGEST
ingester = NULL;
#endif
}
@ -209,7 +209,7 @@ SrsServer::~SrsServer()
#ifdef SRS_HTTP_SERVER
srs_freep(http_stream_handler);
#endif
#ifdef SRS_INGEST
#ifdef SRS_RTMP_INGEST
srs_freep(ingester);
#endif
}
@ -232,7 +232,7 @@ int SrsServer::initialize()
srs_assert(!http_stream_handler);
http_stream_handler = SrsHttpHandler::create_http_stream();
#endif
#ifdef SRS_INGEST
#ifdef SRS_RTMP_INGEST
srs_assert(!ingester);
ingester = new SrsIngester();
#endif
@ -377,7 +377,7 @@ int SrsServer::ingest()
{
int ret = ERROR_SUCCESS;
#ifdef SRS_INGEST
#ifdef SRS_RTMP_INGEST
if ((ret = ingester->start()) != ERROR_SUCCESS) {
srs_error("start ingest streams failed. ret=%d", ret);
return ret;
@ -393,7 +393,7 @@ int SrsServer::cycle()
// the deamon thread, update the time cache
while (true) {
st_usleep(SRS_TIME_RESOLUTION_MS * 1000);
st_usleep(SRS_SYS_TIME_RESOLUTION_MS * 1000);
srs_update_system_time_ms();
// for gperf heap checker,
@ -419,7 +419,7 @@ int SrsServer::cycle()
}
}
#ifdef SRS_INGEST
#ifdef SRS_RTMP_INGEST
ingester->stop();
#endif

View file

@ -85,7 +85,7 @@ private:
#ifdef SRS_HTTP_SERVER
SrsHttpHandler* http_stream_handler;
#endif
#ifdef SRS_INGEST
#ifdef SRS_RTMP_INGEST
SrsIngester* ingester;
#endif
private: