mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix bug to accept FFMPEG streaming
This commit is contained in:
parent
150489af51
commit
444a45facd
3 changed files with 40 additions and 5 deletions
|
@ -74,9 +74,11 @@ extern ILogContext* log_context;
|
||||||
#define srs_error(msg, ...) printf("[%s][%d][error][%s] ", log_context->format_time(), log_context->get_id(), __PRETTY_FUNCTION__);printf(msg, ##__VA_ARGS__);printf(" errno=%d(%s)", errno, strerror(errno));printf("\n")
|
#define srs_error(msg, ...) printf("[%s][%d][error][%s] ", log_context->format_time(), log_context->get_id(), __PRETTY_FUNCTION__);printf(msg, ##__VA_ARGS__);printf(" errno=%d(%s)", errno, strerror(errno));printf("\n")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 1
|
||||||
#undef srs_verbose
|
#undef srs_verbose
|
||||||
#define srs_verbose(msg, ...) (void)0
|
#define srs_verbose(msg, ...) (void)0
|
||||||
|
#endif
|
||||||
|
#if 1
|
||||||
#undef srs_info
|
#undef srs_info
|
||||||
#define srs_info(msg, ...) (void)0
|
#define srs_info(msg, ...) (void)0
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -94,6 +94,8 @@ SrsSource::SrsSource(std::string _stream_url)
|
||||||
{
|
{
|
||||||
stream_url = _stream_url;
|
stream_url = _stream_url;
|
||||||
cache_metadata = NULL;
|
cache_metadata = NULL;
|
||||||
|
cache_sh_video = NULL;
|
||||||
|
cache_sh_audio = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsSource::~SrsSource()
|
SrsSource::~SrsSource()
|
||||||
|
@ -106,6 +108,8 @@ SrsSource::~SrsSource()
|
||||||
consumers.clear();
|
consumers.clear();
|
||||||
|
|
||||||
srs_freep(cache_metadata);
|
srs_freep(cache_metadata);
|
||||||
|
srs_freep(cache_sh_video);
|
||||||
|
srs_freep(cache_sh_audio);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata)
|
int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata)
|
||||||
|
@ -184,6 +188,11 @@ int SrsSource::on_audio(SrsCommonMessage* audio)
|
||||||
}
|
}
|
||||||
srs_info("dispatch audio success.");
|
srs_info("dispatch audio success.");
|
||||||
|
|
||||||
|
if (!cache_sh_audio) {
|
||||||
|
srs_freep(cache_sh_audio);
|
||||||
|
cache_sh_audio = msg->copy();
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,19 +223,39 @@ int SrsSource::on_video(SrsCommonMessage* video)
|
||||||
}
|
}
|
||||||
srs_info("dispatch video success.");
|
srs_info("dispatch video success.");
|
||||||
|
|
||||||
|
if (!cache_sh_video) {
|
||||||
|
srs_freep(cache_sh_video);
|
||||||
|
cache_sh_video = msg->copy();
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SrsSource::create_consumer(SrsConsumer*& consumer)
|
int SrsSource::create_consumer(SrsConsumer*& consumer)
|
||||||
{
|
{
|
||||||
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
consumer = new SrsConsumer();
|
consumer = new SrsConsumer();
|
||||||
consumers.push_back(consumer);
|
consumers.push_back(consumer);
|
||||||
|
|
||||||
if (!cache_metadata) {
|
if (cache_metadata && (ret = consumer->enqueue(cache_metadata->copy())) != ERROR_SUCCESS) {
|
||||||
srs_info("no metadata found.");
|
srs_error("dispatch metadata failed. ret=%d", ret);
|
||||||
return ERROR_SUCCESS;
|
return ret;
|
||||||
}
|
}
|
||||||
|
srs_info("dispatch metadata success");
|
||||||
return consumer->enqueue(cache_metadata->copy());
|
|
||||||
|
if (cache_sh_video && (ret = consumer->enqueue(cache_sh_video->copy())) != ERROR_SUCCESS) {
|
||||||
|
srs_error("dispatch video sequence header failed. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
srs_info("dispatch video sequence header success");
|
||||||
|
|
||||||
|
if (cache_sh_audio && (ret = consumer->enqueue(cache_sh_audio->copy())) != ERROR_SUCCESS) {
|
||||||
|
srs_error("dispatch audio sequence header failed. ret=%d", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
srs_info("dispatch audio sequence header success");
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,10 @@ private:
|
||||||
std::vector<SrsConsumer*> consumers;
|
std::vector<SrsConsumer*> consumers;
|
||||||
private:
|
private:
|
||||||
SrsSharedPtrMessage* cache_metadata;
|
SrsSharedPtrMessage* cache_metadata;
|
||||||
|
// the cached video sequence header.
|
||||||
|
SrsSharedPtrMessage* cache_sh_video;
|
||||||
|
// the cached audio sequence header.
|
||||||
|
SrsSharedPtrMessage* cache_sh_audio;
|
||||||
public:
|
public:
|
||||||
SrsSource(std::string _stream_url);
|
SrsSource(std::string _stream_url);
|
||||||
virtual ~SrsSource();
|
virtual ~SrsSource();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue