mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Merge branch '2.0release' into develop
This commit is contained in:
commit
b44987fac7
32 changed files with 306 additions and 166 deletions
|
@ -33,7 +33,6 @@ using namespace std;
|
|||
#include <srs_kernel_log.hpp>
|
||||
#include <srs_app_config.hpp>
|
||||
#include <srs_app_pithy_print.hpp>
|
||||
#include <srs_app_http.hpp>
|
||||
#include <srs_app_http_conn.hpp>
|
||||
#include <srs_core_autofree.hpp>
|
||||
#include <srs_kernel_flv.hpp>
|
||||
|
@ -89,9 +88,10 @@ void SrsAppCasterFlv::remove(SrsConnection* c)
|
|||
}
|
||||
}
|
||||
|
||||
int SrsAppCasterFlv::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
|
||||
int SrsAppCasterFlv::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
||||
{
|
||||
SrsDynamicHttpConn* conn = dynamic_cast<SrsDynamicHttpConn*>(r->connection());
|
||||
SrsHttpMessage* msg = dynamic_cast<SrsHttpMessage*>(r);
|
||||
SrsDynamicHttpConn* conn = dynamic_cast<SrsDynamicHttpConn*>(msg->connection());
|
||||
srs_assert(conn);
|
||||
|
||||
std::string app = srs_path_dirname(r->path());
|
||||
|
@ -134,13 +134,13 @@ SrsDynamicHttpConn::~SrsDynamicHttpConn()
|
|||
srs_freep(pprint);
|
||||
}
|
||||
|
||||
int SrsDynamicHttpConn::on_got_http_message(SrsHttpMessage* msg)
|
||||
int SrsDynamicHttpConn::on_got_http_message(ISrsHttpMessage* msg)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsDynamicHttpConn::proxy(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std::string o)
|
||||
int SrsDynamicHttpConn::proxy(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string o)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -430,7 +430,7 @@ int SrsHttpFileReader::read(void* buf, size_t count, ssize_t* pnread)
|
|||
}
|
||||
|
||||
int total_read = 0;
|
||||
while (total_read < count) {
|
||||
while (total_read < (int)count) {
|
||||
int nread = 0;
|
||||
if ((ret = http->read((char*)buf + total_read, (int)(count - total_read), &nread)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
|
|
|
@ -37,7 +37,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
class SrsConfDirective;
|
||||
class SrsHttpServeMux;
|
||||
class SrsHttpConn;
|
||||
class SrsRtmpClient;
|
||||
class SrsStSocket;
|
||||
class SrsRequest;
|
||||
|
@ -48,7 +47,6 @@ class SrsFlvDecoder;
|
|||
#include <srs_app_st.hpp>
|
||||
#include <srs_app_listener.hpp>
|
||||
#include <srs_app_conn.hpp>
|
||||
#include <srs_app_http.hpp>
|
||||
#include <srs_app_http_conn.hpp>
|
||||
#include <srs_kernel_file.hpp>
|
||||
|
||||
|
@ -75,7 +73,7 @@ public:
|
|||
virtual void remove(SrsConnection* c);
|
||||
// ISrsHttpHandler
|
||||
public:
|
||||
virtual int serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r);
|
||||
virtual int serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -96,9 +94,9 @@ public:
|
|||
SrsDynamicHttpConn(IConnectionManager* cm, st_netfd_t fd, SrsHttpServeMux* m);
|
||||
virtual ~SrsDynamicHttpConn();
|
||||
public:
|
||||
virtual int on_got_http_message(SrsHttpMessage* msg);
|
||||
virtual int on_got_http_message(ISrsHttpMessage* msg);
|
||||
public:
|
||||
virtual int proxy(ISrsHttpResponseWriter* w, SrsHttpMessage* r, std::string o);
|
||||
virtual int proxy(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string o);
|
||||
private:
|
||||
virtual int do_proxy(ISrsHttpResponseReader* rr, SrsFlvDecoder* dec);
|
||||
virtual int rtmp_write_packet(char type, u_int32_t timestamp, char* data, int size);
|
||||
|
|
|
@ -364,6 +364,8 @@ int SrsConfDirective::read_token(SrsConfigBuffer* buffer, vector<string>& args,
|
|||
|
||||
SrsConfig::SrsConfig()
|
||||
{
|
||||
dolphin = false;
|
||||
|
||||
show_help = false;
|
||||
show_version = false;
|
||||
test_conf = false;
|
||||
|
@ -378,6 +380,25 @@ SrsConfig::~SrsConfig()
|
|||
srs_freep(root);
|
||||
}
|
||||
|
||||
bool SrsConfig::is_dolphin()
|
||||
{
|
||||
return dolphin;
|
||||
}
|
||||
|
||||
void SrsConfig::set_config_directive(SrsConfDirective* parent, string dir, string value)
|
||||
{
|
||||
SrsConfDirective* d = parent->get(dir);
|
||||
|
||||
if (!d) {
|
||||
d = new SrsConfDirective();
|
||||
d->name = dir;
|
||||
parent->directives.push_back(d);
|
||||
}
|
||||
|
||||
d->args.clear();
|
||||
d->args.push_back(value);
|
||||
}
|
||||
|
||||
void SrsConfig::subscribe(ISrsReloadHandler* handler)
|
||||
{
|
||||
std::vector<ISrsReloadHandler*>::iterator it;
|
||||
|
@ -1260,6 +1281,19 @@ int SrsConfig::parse_argv(int& i, char** argv)
|
|||
show_help = false;
|
||||
test_conf = true;
|
||||
break;
|
||||
case 'p':
|
||||
dolphin = true;
|
||||
if (*p) {
|
||||
dolphin_port = p;
|
||||
continue;
|
||||
}
|
||||
if (argv[++i]) {
|
||||
dolphin_port = argv[i];
|
||||
continue;
|
||||
}
|
||||
ret = ERROR_SYSTEM_CONFIG_INVALID;
|
||||
srs_error("option \"-p\" requires params, ret=%d", ret);
|
||||
return ret;
|
||||
case 'v':
|
||||
case 'V':
|
||||
show_help = false;
|
||||
|
@ -1269,11 +1303,11 @@ int SrsConfig::parse_argv(int& i, char** argv)
|
|||
show_help = false;
|
||||
if (*p) {
|
||||
config_file = p;
|
||||
return ret;
|
||||
continue;
|
||||
}
|
||||
if (argv[++i]) {
|
||||
config_file = argv[i];
|
||||
return ret;
|
||||
continue;
|
||||
}
|
||||
ret = ERROR_SYSTEM_CONFIG_INVALID;
|
||||
srs_error("option \"-c\" requires parameter, ret=%d", ret);
|
||||
|
@ -1844,6 +1878,14 @@ int SrsConfig::parse_buffer(SrsConfigBuffer* buffer)
|
|||
if ((ret = root->parse(buffer)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
// mock by dolphin mode.
|
||||
// for the dolphin will start srs with specified params.
|
||||
if (dolphin) {
|
||||
set_config_directive(root, "listen", dolphin_port);
|
||||
set_config_directive(root, "daemon", "off");
|
||||
set_config_directive(root, "srs_log_tank", "console");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -266,6 +266,12 @@ class SrsConfig
|
|||
{
|
||||
// user command
|
||||
private:
|
||||
/**
|
||||
* whether srs is run in dolphin mode.
|
||||
* @see https://github.com/simple-rtmp-server/srs-dolphin
|
||||
*/
|
||||
bool dolphin;
|
||||
std::string dolphin_port;
|
||||
/**
|
||||
* whether show help and exit.
|
||||
*/
|
||||
|
@ -309,6 +315,14 @@ private:
|
|||
public:
|
||||
SrsConfig();
|
||||
virtual ~SrsConfig();
|
||||
// dolphin
|
||||
public:
|
||||
/**
|
||||
* whether srs is in dolphin mode.
|
||||
*/
|
||||
virtual bool is_dolphin();
|
||||
private:
|
||||
virtual void set_config_directive(SrsConfDirective* parent, std::string dir, std::string value);
|
||||
// reload
|
||||
public:
|
||||
/**
|
||||
|
|
|
@ -23,7 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include <srs_app_heartbeat.hpp>
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_PARSER
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
|
||||
#include <sstream>
|
||||
using namespace std;
|
||||
|
|
|
@ -29,7 +29,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
*/
|
||||
#include <srs_core.hpp>
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_PARSER
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
|
||||
/**
|
||||
* the http heartbeat to api-server to notice api
|
||||
|
|
|
@ -23,11 +23,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include <srs_app_hls.hpp>
|
||||
|
||||
/**
|
||||
* the HLS section, only available when HLS enabled.
|
||||
*/
|
||||
#ifdef SRS_AUTO_HLS
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
@ -72,6 +67,11 @@ ISrsHlsHandler::~ISrsHlsHandler()
|
|||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* * the HLS section, only available when HLS enabled.
|
||||
* */
|
||||
#ifdef SRS_AUTO_HLS
|
||||
|
||||
SrsHlsCacheWriter::SrsHlsCacheWriter(bool write_cache, bool write_file)
|
||||
{
|
||||
should_write_cache = write_cache;
|
||||
|
|
|
@ -29,11 +29,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
*/
|
||||
#include <srs_core.hpp>
|
||||
|
||||
/**
|
||||
* the HLS section, only available when HLS enabled.
|
||||
*/
|
||||
#ifdef SRS_AUTO_HLS
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -86,6 +81,11 @@ public:
|
|||
virtual int on_hls_unpublish(SrsRequest* req) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* * the HLS section, only available when HLS enabled.
|
||||
* */
|
||||
#ifdef SRS_AUTO_HLS
|
||||
|
||||
/**
|
||||
* write to file and cache.
|
||||
*/
|
||||
|
|
|
@ -23,7 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include <srs_app_http_client.hpp>
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_PARSER
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include <string>
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_PARSER
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
|
||||
#include <srs_app_st.hpp>
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include <srs_app_http_conn.hpp>
|
||||
|
||||
#if defined(SRS_AUTO_HTTP_PARSER) || defined(SRS_AUTO_HTTP_SERVER)
|
||||
#if defined(SRS_AUTO_HTTP_CORE) || defined(SRS_AUTO_HTTP_SERVER)
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
@ -55,7 +55,7 @@ using namespace std;
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_PARSER
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
|
||||
SrsHttpResponseWriter::SrsHttpResponseWriter(SrsStSocket* io)
|
||||
{
|
||||
|
@ -2423,6 +2423,9 @@ int SrsHttpServer::initialize_hls_streaming()
|
|||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
SrsHttpConn::SrsHttpConn(IConnectionManager* cm, st_netfd_t fd, SrsHttpServeMux* m)
|
||||
: SrsConnection(cm, fd)
|
||||
{
|
||||
|
|
|
@ -30,11 +30,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include <srs_core.hpp>
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_PARSER
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
#include <http_parser.h>
|
||||
#endif
|
||||
|
||||
#if defined(SRS_AUTO_HTTP_PARSER) || defined(SRS_AUTO_HTTP_SERVER)
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
@ -69,7 +69,7 @@ class SrsHttpMessage;
|
|||
|
||||
#endif
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_PARSER
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
|
||||
// the http chunked header size,
|
||||
// for writev, there always one chunk to send it.
|
||||
|
@ -214,7 +214,7 @@ public:
|
|||
virtual int update(std::string url, http_parser* header,
|
||||
SrsFastBuffer* body, std::vector<SrsHttpHeaderField>& headers
|
||||
);
|
||||
private:
|
||||
public:
|
||||
virtual SrsConnection* connection();
|
||||
public:
|
||||
virtual u_int8_t method();
|
||||
|
@ -711,6 +711,9 @@ private:
|
|||
virtual int initialize_hls_streaming();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
class SrsHttpConn : public SrsConnection
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -113,18 +113,18 @@ int SrsUdpListener::listen()
|
|||
|
||||
if ((_fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
|
||||
ret = ERROR_SOCKET_CREATE;
|
||||
srs_error("create linux socket error. port=%d, ret=%d", ip.c_str(), port, ret);
|
||||
srs_error("create linux socket error. ip=%s, port=%d, ret=%d", ip.c_str(), port, ret);
|
||||
return ret;
|
||||
}
|
||||
srs_verbose("create linux socket success. port=%d, fd=%d", ip.c_str(), port, _fd);
|
||||
srs_verbose("create linux socket success. ip=%s, port=%d, fd=%d", ip.c_str(), port, _fd);
|
||||
|
||||
int reuse_socket = 1;
|
||||
if (setsockopt(_fd, SOL_SOCKET, SO_REUSEADDR, &reuse_socket, sizeof(int)) == -1) {
|
||||
ret = ERROR_SOCKET_SETREUSE;
|
||||
srs_error("setsockopt reuse-addr error. port=%d, ret=%d", ip.c_str(), port, ret);
|
||||
srs_error("setsockopt reuse-addr error. ip=%s, port=%d, ret=%d", ip.c_str(), port, ret);
|
||||
return ret;
|
||||
}
|
||||
srs_verbose("setsockopt reuse-addr success. port=%d, fd=%d", ip.c_str(), port, _fd);
|
||||
srs_verbose("setsockopt reuse-addr success. ip=%s, port=%d, fd=%d", ip.c_str(), port, _fd);
|
||||
|
||||
sockaddr_in addr;
|
||||
addr.sin_family = AF_INET;
|
||||
|
|
|
@ -43,10 +43,13 @@ SrsThreadContext::~SrsThreadContext()
|
|||
{
|
||||
}
|
||||
|
||||
void SrsThreadContext::generate_id()
|
||||
int SrsThreadContext::generate_id()
|
||||
{
|
||||
static int id = 100;
|
||||
cache[st_thread_self()] = id++;
|
||||
|
||||
int gid = id++;
|
||||
cache[st_thread_self()] = gid;
|
||||
return gid;
|
||||
}
|
||||
|
||||
int SrsThreadContext::get_id()
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
SrsThreadContext();
|
||||
virtual ~SrsThreadContext();
|
||||
public:
|
||||
virtual void generate_id();
|
||||
virtual int generate_id();
|
||||
virtual int get_id();
|
||||
};
|
||||
|
||||
|
|
|
@ -154,9 +154,9 @@ int SrsStreamListener::listen(string i, int p)
|
|||
return ret;
|
||||
}
|
||||
|
||||
srs_info("listen thread cid=%d, current_cid=%d, "
|
||||
srs_info("listen thread current_cid=%d, "
|
||||
"listen at port=%d, type=%d, fd=%d started success, ep=%s:%d",
|
||||
pthread->cid(), _srs_context->get_id(), _port, _type, fd, ip.c_str(), port);
|
||||
_srs_context->get_id(), p, type, listener->fd(), i.c_str(), p);
|
||||
|
||||
srs_trace("%s listen at tcp://%s:%d, fd=%d", srs_listener_type2string(type).c_str(), ip.c_str(), port, listener->fd());
|
||||
|
||||
|
@ -327,9 +327,9 @@ int SrsUdpStreamListener::listen(string i, int p)
|
|||
return ret;
|
||||
}
|
||||
|
||||
srs_info("listen thread cid=%d, current_cid=%d, "
|
||||
srs_info("listen thread current_cid=%d, "
|
||||
"listen at port=%d, type=%d, fd=%d started success, ep=%s:%d",
|
||||
pthread->cid(), _srs_context->get_id(), port, type, fd, ip.c_str(), port);
|
||||
_srs_context->get_id(), p, type, listener->fd(), i.c_str(), p);
|
||||
|
||||
// notify the handler the fd changed.
|
||||
if ((ret = caster->on_stfd_change(listener->stfd())) != ERROR_SUCCESS) {
|
||||
|
@ -495,7 +495,7 @@ SrsServer::SrsServer()
|
|||
#ifdef SRS_AUTO_HTTP_SERVER
|
||||
http_stream_mux = new SrsHttpServer(this);
|
||||
#endif
|
||||
#ifdef SRS_AUTO_HTTP_PARSER
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
http_heartbeat = NULL;
|
||||
#endif
|
||||
#ifdef SRS_AUTO_INGEST
|
||||
|
@ -530,7 +530,7 @@ void SrsServer::destroy()
|
|||
srs_freep(http_stream_mux);
|
||||
#endif
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_PARSER
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
srs_freep(http_heartbeat);
|
||||
#endif
|
||||
|
||||
|
@ -589,7 +589,7 @@ int SrsServer::initialize(ISrsServerCycle* cycle_handler)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_PARSER
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
srs_assert(!http_heartbeat);
|
||||
http_heartbeat = new SrsHttpHeartbeat();
|
||||
#endif
|
||||
|
@ -607,7 +607,7 @@ int SrsServer::initialize_st()
|
|||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// init st
|
||||
if ((ret = srs_init_st()) != ERROR_SUCCESS) {
|
||||
if ((ret = srs_st_init()) != ERROR_SUCCESS) {
|
||||
srs_error("init st failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -639,6 +639,11 @@ int SrsServer::acquire_pid_file()
|
|||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// when srs in dolphin mode, no need the pid file.
|
||||
if (_srs_config->is_dolphin()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string pid_file = _srs_config->get_pid_file();
|
||||
|
||||
// -rw-r--r--
|
||||
|
@ -971,7 +976,7 @@ int SrsServer::do_cycle()
|
|||
srs_info("update network server kbps info.");
|
||||
resample_kbps();
|
||||
}
|
||||
#ifdef SRS_AUTO_HTTP_PARSER
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
if (_srs_config->get_heartbeat_enabled()) {
|
||||
if ((i % heartbeat_max_resolution) == 0) {
|
||||
srs_info("do http heartbeat, for internal server to report.");
|
||||
|
|
|
@ -240,7 +240,7 @@ private:
|
|||
#ifdef SRS_AUTO_HTTP_SERVER
|
||||
SrsHttpServer* http_stream_mux;
|
||||
#endif
|
||||
#ifdef SRS_AUTO_HTTP_PARSER
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
SrsHttpHeartbeat* http_heartbeat;
|
||||
#endif
|
||||
#ifdef SRS_AUTO_INGEST
|
||||
|
|
67
trunk/src/app/srs_app_source.cpp
Normal file → Executable file
67
trunk/src/app/srs_app_source.cpp
Normal file → Executable file
|
@ -357,52 +357,49 @@ int SrsMessageQueue::dump_packets(SrsConsumer* consumer, bool atc, int tba, int
|
|||
|
||||
void SrsMessageQueue::shrink()
|
||||
{
|
||||
int iframe_index = -1;
|
||||
SrsSharedPtrMessage* video_sh = NULL;
|
||||
SrsSharedPtrMessage* audio_sh = NULL;
|
||||
int msgs_size = (int)msgs.size();
|
||||
|
||||
// issue the first iframe.
|
||||
// skip the first frame, whatever the type of it,
|
||||
// for when we shrinked, the first is the iframe,
|
||||
// we will directly remove the gop next time.
|
||||
for (int i = 1; i < (int)msgs.size(); i++) {
|
||||
// remove all msg
|
||||
// igone the sequence header
|
||||
for (int i = 0; i < (int)msgs.size(); i++) {
|
||||
SrsSharedPtrMessage* msg = msgs.at(i);
|
||||
|
||||
if (msg->is_video()) {
|
||||
if (SrsFlvCodec::video_is_keyframe(msg->payload, msg->size)) {
|
||||
// the max frame index to remove.
|
||||
iframe_index = i;
|
||||
|
||||
// set the start time, we will remove until this frame.
|
||||
av_start_time = msg->timestamp;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (msg->is_video() && SrsFlvCodec::video_is_sequence_header(msg->payload, msg->size)) {
|
||||
srs_freep(video_sh);
|
||||
video_sh = msg;
|
||||
continue;
|
||||
}
|
||||
else if (msg->is_audio() && SrsFlvCodec::audio_is_sequence_header(msg->payload, msg->size)) {
|
||||
srs_freep(audio_sh);
|
||||
audio_sh = msg;
|
||||
continue;
|
||||
}
|
||||
|
||||
srs_freep(msg);
|
||||
}
|
||||
|
||||
// no iframe, for audio, clear the queue.
|
||||
// it is ok to clear for audio, for the shrink tell us the queue is full.
|
||||
// for video, we clear util the I-Frame, for the decoding must start from I-frame,
|
||||
// for audio, it's ok to clear any data, also we can clear the whole queue.
|
||||
// @see: https://github.com/simple-rtmp-server/srs/issues/134
|
||||
if (iframe_index < 0) {
|
||||
clear();
|
||||
return;
|
||||
msgs.clear();
|
||||
|
||||
// update av_start_time
|
||||
av_start_time = av_end_time;
|
||||
//push_back secquence header and update timestamp
|
||||
if (video_sh) {
|
||||
video_sh->timestamp = av_end_time;
|
||||
msgs.push_back(video_sh);
|
||||
}
|
||||
if (audio_sh) {
|
||||
audio_sh->timestamp = av_end_time;
|
||||
msgs.push_back(audio_sh);
|
||||
}
|
||||
|
||||
if (_ignore_shrink) {
|
||||
srs_info("shrink the cache queue, size=%d, removed=%d, max=%.2f",
|
||||
(int)msgs.size(), iframe_index, queue_size_ms / 1000.0);
|
||||
(int)msgs.size(), msgs_size - (int)msgs.size(), queue_size_ms / 1000.0);
|
||||
} else {
|
||||
srs_trace("shrink the cache queue, size=%d, removed=%d, max=%.2f",
|
||||
(int)msgs.size(), iframe_index, queue_size_ms / 1000.0);
|
||||
(int)msgs.size(), msgs_size - (int)msgs.size(), queue_size_ms / 1000.0);
|
||||
}
|
||||
|
||||
// remove the first gop from the front
|
||||
for (int i = 0; i < iframe_index; i++) {
|
||||
SrsSharedPtrMessage* msg = msgs.at(i);
|
||||
srs_freep(msg);
|
||||
}
|
||||
msgs.erase(msgs.begin(), msgs.begin() + iframe_index);
|
||||
}
|
||||
|
||||
void SrsMessageQueue::clear()
|
||||
|
|
|
@ -42,7 +42,7 @@ bool srs_st_epoll_is_supported(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
int srs_init_st()
|
||||
int srs_st_init()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <st.h>
|
||||
|
||||
// initialize st, requires epoll.
|
||||
extern int srs_init_st();
|
||||
extern int srs_st_init();
|
||||
|
||||
// close the netfd, and close the underlayer fd.
|
||||
extern void srs_close_stfd(st_netfd_t& stfd);
|
||||
|
|
|
@ -66,8 +66,9 @@ ISrsThreadContext::~ISrsThreadContext()
|
|||
{
|
||||
}
|
||||
|
||||
void ISrsThreadContext::generate_id()
|
||||
int ISrsThreadContext::generate_id()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ISrsThreadContext::get_id()
|
||||
|
|
|
@ -102,7 +102,7 @@ public:
|
|||
ISrsThreadContext();
|
||||
virtual ~ISrsThreadContext();
|
||||
public:
|
||||
virtual void generate_id();
|
||||
virtual int generate_id();
|
||||
virtual int get_id();
|
||||
};
|
||||
|
||||
|
|
|
@ -61,6 +61,8 @@ ISrsThreadContext* _srs_context = new ISrsThreadContext();
|
|||
SrsConfig* _srs_config = NULL;
|
||||
SrsServer* _srs_server = NULL;
|
||||
|
||||
#if defined(SRS_AUTO_HTTP_CORE)
|
||||
|
||||
/**
|
||||
* main entrance.
|
||||
*/
|
||||
|
@ -70,7 +72,7 @@ int main(int argc, char** argv)
|
|||
srs_assert(srs_is_little_endian());
|
||||
|
||||
// directly failed when compile limited.
|
||||
#if !defined(SRS_AUTO_HTTP_PARSER)
|
||||
#if !defined(SRS_AUTO_HTTP_CORE)
|
||||
srs_error("depends on http-parser.");
|
||||
exit(-1);
|
||||
#endif
|
||||
|
@ -1376,7 +1378,7 @@ int proxy_hls2rtmp(string hls, string rtmp)
|
|||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// init st.
|
||||
if ((ret = srs_init_st()) != ERROR_SUCCESS) {
|
||||
if ((ret = srs_st_init()) != ERROR_SUCCESS) {
|
||||
srs_error("init st failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -1402,3 +1404,15 @@ int proxy_hls2rtmp(string hls, string rtmp)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
#ifndef SRS_AUTO_HTTP_CORE
|
||||
srs_error("ingest requires http-api or http-server");
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ void show_macro_features()
|
|||
srs_warn("check feature http server: off");
|
||||
#endif
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_PARSER
|
||||
#ifdef SRS_AUTO_HTTP_CORE
|
||||
srs_trace("check feature http parser: on");
|
||||
#else
|
||||
srs_warn("check feature http parser: off");
|
||||
|
|
|
@ -961,8 +961,8 @@ int SrsProtocol::recv_interlaced_message(SrsCommonMessage** pmsg)
|
|||
return ret;
|
||||
}
|
||||
srs_verbose("read message header success. "
|
||||
"fmt=%d, mh_size=%d, ext_time=%d, size=%d, message(type=%d, size=%d, time=%"PRId64", sid=%d)",
|
||||
fmt, mh_size, chunk->extended_timestamp, (chunk->msg? chunk->msg->size : 0), chunk->header.message_type,
|
||||
"fmt=%d, ext_time=%d, size=%d, message(type=%d, size=%d, time=%"PRId64", sid=%d)",
|
||||
fmt, chunk->extended_timestamp, (chunk->msg? chunk->msg->size : 0), chunk->header.message_type,
|
||||
chunk->header.payload_length, chunk->header.timestamp, chunk->header.stream_id);
|
||||
|
||||
// read msg payload from chunk stream.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue