mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
Squash: Merge SRS 4.0
This commit is contained in:
parent
28e3a1ca69
commit
40f8460929
4 changed files with 39 additions and 19 deletions
|
@ -96,8 +96,9 @@ void SrsAppCasterFlv::remove(ISrsResource* c)
|
|||
srs_error_t SrsAppCasterFlv::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
||||
{
|
||||
SrsHttpMessage* msg = dynamic_cast<SrsHttpMessage*>(r);
|
||||
SrsDynamicHttpConn* conn = dynamic_cast<SrsDynamicHttpConn*>(msg->connection());
|
||||
srs_assert(conn);
|
||||
SrsHttpConn* hconn = dynamic_cast<SrsHttpConn*>(msg->connection());
|
||||
SrsDynamicHttpConn* dconn = dynamic_cast<SrsDynamicHttpConn*>(hconn->handler());
|
||||
srs_assert(dconn);
|
||||
|
||||
std::string app = srs_path_dirname(r->path());
|
||||
app = srs_string_trim_start(app, "/");
|
||||
|
@ -116,7 +117,7 @@ srs_error_t SrsAppCasterFlv::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessa
|
|||
o = o.substr(0, o.length() - 4);
|
||||
}
|
||||
|
||||
srs_error_t err = conn->proxy(w, r, o);
|
||||
srs_error_t err = dconn->proxy(w, r, o);
|
||||
if (err != srs_success) {
|
||||
return srs_error_wrap(err, "proxy");
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ void srs_build_features(stringstream& ss)
|
|||
int nn_vhosts = 0;
|
||||
bool rtsp = false, forward = false, ingest = false, edge = false, hls = false, dvr = false, flv = false;
|
||||
bool hooks = false, dash = false, hds = false, exec = false, transcode = false, security = false;
|
||||
bool flv2 = false;
|
||||
|
||||
SrsConfDirective* root = _srs_config->get_root();
|
||||
// Note that we limit the loop, never detect all configs.
|
||||
|
@ -61,6 +62,8 @@ void srs_build_features(stringstream& ss)
|
|||
string engine = _srs_config->get_stream_caster_engine(conf);
|
||||
if (engine == "rtsp") {
|
||||
rtsp = true;
|
||||
} else if (engine == "flv") {
|
||||
flv2 = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,6 +120,7 @@ void srs_build_features(stringstream& ss)
|
|||
|
||||
SRS_CHECK_FEATURE2(nn_vhosts, "vhosts", ss);
|
||||
SRS_CHECK_FEATURE(rtsp, ss);
|
||||
SRS_CHECK_FEATURE(flv2, ss);
|
||||
SRS_CHECK_FEATURE(forward, ss);
|
||||
SRS_CHECK_FEATURE(ingest, ss);
|
||||
SRS_CHECK_FEATURE(edge, ss);
|
||||
|
|
|
@ -10,16 +10,32 @@
|
|||
#include <srs_kernel_error.hpp>
|
||||
#include <srs_kernel_log.hpp>
|
||||
|
||||
static const char* id2codec_name(SrsAudioCodecId id)
|
||||
static const AVCodec* srs_find_decoder_by_id(SrsAudioCodecId id)
|
||||
{
|
||||
switch (id) {
|
||||
case SrsAudioCodecIdAAC:
|
||||
return "aac";
|
||||
case SrsAudioCodecIdOpus:
|
||||
return "libopus";
|
||||
default:
|
||||
return "";
|
||||
if (id == SrsAudioCodecIdAAC) {
|
||||
return avcodec_find_decoder_by_name("aac");
|
||||
} else if (id == SrsAudioCodecIdOpus) {
|
||||
const AVCodec* codec = avcodec_find_decoder_by_name("libopus");
|
||||
if (!codec) {
|
||||
codec = avcodec_find_decoder_by_name("opus");
|
||||
}
|
||||
return codec;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const AVCodec* srs_find_encoder_by_id(SrsAudioCodecId id)
|
||||
{
|
||||
if (id == SrsAudioCodecIdAAC) {
|
||||
return avcodec_find_encoder_by_name("aac");
|
||||
} else if (id == SrsAudioCodecIdOpus) {
|
||||
const AVCodec* codec = avcodec_find_encoder_by_name("libopus");
|
||||
if (!codec) {
|
||||
codec = avcodec_find_encoder_by_name("opus");
|
||||
}
|
||||
return codec;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
class SrsFFmpegLogHelper {
|
||||
|
@ -175,10 +191,9 @@ void SrsAudioTranscoder::aac_codec_header(uint8_t **data, int *len)
|
|||
|
||||
srs_error_t SrsAudioTranscoder::init_dec(SrsAudioCodecId src_codec)
|
||||
{
|
||||
const char* codec_name = id2codec_name(src_codec);
|
||||
const AVCodec *codec = avcodec_find_decoder_by_name(codec_name);
|
||||
const AVCodec *codec = srs_find_decoder_by_id(src_codec);
|
||||
if (!codec) {
|
||||
return srs_error_new(ERROR_RTC_RTP_MUXER, "Codec not found by name(%d,%s)", src_codec, codec_name);
|
||||
return srs_error_new(ERROR_RTC_RTP_MUXER, "Codec not found by %d", src_codec);
|
||||
}
|
||||
|
||||
dec_ = avcodec_alloc_context3(codec);
|
||||
|
@ -208,15 +223,14 @@ srs_error_t SrsAudioTranscoder::init_dec(SrsAudioCodecId src_codec)
|
|||
|
||||
srs_error_t SrsAudioTranscoder::init_enc(SrsAudioCodecId dst_codec, int dst_channels, int dst_samplerate, int dst_bit_rate)
|
||||
{
|
||||
const char* codec_name = id2codec_name(dst_codec);
|
||||
const AVCodec *codec = avcodec_find_encoder_by_name(codec_name);
|
||||
const AVCodec *codec = srs_find_encoder_by_id(dst_codec);
|
||||
if (!codec) {
|
||||
return srs_error_new(ERROR_RTC_RTP_MUXER, "Codec not found by name(%d,%s)", dst_codec, codec_name);
|
||||
return srs_error_new(ERROR_RTC_RTP_MUXER, "Codec not found by %d", dst_codec);
|
||||
}
|
||||
|
||||
enc_ = avcodec_alloc_context3(codec);
|
||||
if (!enc_) {
|
||||
return srs_error_new(ERROR_RTC_RTP_MUXER, "Could not allocate audio codec context(%d,%s)", dst_codec, codec_name);
|
||||
return srs_error_new(ERROR_RTC_RTP_MUXER, "Could not allocate audio codec context %d", dst_codec);
|
||||
}
|
||||
|
||||
enc_->sample_rate = dst_samplerate;
|
||||
|
@ -228,6 +242,7 @@ srs_error_t SrsAudioTranscoder::init_enc(SrsAudioCodecId dst_codec, int dst_chan
|
|||
if (dst_codec == SrsAudioCodecIdOpus) {
|
||||
//TODO: for more level setting
|
||||
enc_->compression_level = 1;
|
||||
enc_->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
|
||||
} else if (dst_codec == SrsAudioCodecIdAAC) {
|
||||
enc_->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
|
||||
#define VERSION_MAJOR 4
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_REVISION 161
|
||||
#define VERSION_REVISION 162
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue