mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #913: TS/HLS/MPEGTS support complex error
This commit is contained in:
parent
20a42599f3
commit
abcaba33ee
24 changed files with 699 additions and 823 deletions
|
|
@ -285,6 +285,7 @@ int SrsIngestHlsInput::parse(ISrsTsHandler* ts, ISrsAacHandler* aac)
|
|||
int SrsIngestHlsInput::parseTs(ISrsTsHandler* handler, char* body, int nb_body)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// use stream to parse ts packet.
|
||||
int nb_packet = (int)nb_body / SRS_TS_PACKET_SIZE;
|
||||
|
|
@ -295,7 +296,10 @@ int SrsIngestHlsInput::parseTs(ISrsTsHandler* handler, char* body, int nb_body)
|
|||
}
|
||||
|
||||
// process each ts packet
|
||||
if ((ret = context->decode(stream, handler)) != ERROR_SUCCESS) {
|
||||
if ((err = context->decode(stream, handler)) != srs_success) {
|
||||
// TODO: FIXME: Use error
|
||||
ret = srs_error_code(err);
|
||||
srs_freep(err);
|
||||
srs_error("mpegts: ignore parse ts packet failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -654,7 +658,7 @@ public:
|
|||
virtual ~SrsIngestHlsOutput();
|
||||
// interface ISrsTsHandler
|
||||
public:
|
||||
virtual int on_ts_message(SrsTsMessage* msg);
|
||||
virtual srs_error_t on_ts_message(SrsTsMessage* msg);
|
||||
// interface IAacHandler
|
||||
public:
|
||||
virtual int on_aac_frame(char* frame, int frame_size, double duration);
|
||||
|
|
@ -713,9 +717,10 @@ SrsIngestHlsOutput::~SrsIngestHlsOutput()
|
|||
queue.clear();
|
||||
}
|
||||
|
||||
int SrsIngestHlsOutput::on_ts_message(SrsTsMessage* msg)
|
||||
srs_error_t SrsIngestHlsOutput::on_ts_message(SrsTsMessage* msg)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// about the bytes of msg, specified by elementary stream which indicates by PES_packet_data_byte and stream_id
|
||||
// for example, when SrsTsStream of SrsTsChannel indicates stream_type is SrsTsStreamVideoMpeg4 and SrsTsStreamAudioMpeg4,
|
||||
|
|
@ -767,26 +772,22 @@ int SrsIngestHlsOutput::on_ts_message(SrsTsMessage* msg)
|
|||
|
||||
// when not audio/video, or not adts/annexb format, donot support.
|
||||
if (msg->stream_number() != 0) {
|
||||
ret = ERROR_STREAM_CASTER_TS_ES;
|
||||
srs_error("mpegts: unsupported stream format, sid=%#x(%s-%d). ret=%d",
|
||||
msg->sid, msg->is_audio()? "A":msg->is_video()? "V":"N", msg->stream_number(), ret);
|
||||
return ret;
|
||||
return srs_error_new(ERROR_STREAM_CASTER_TS_ES, "ts: unsupported stream format, sid=%#x(%s-%d)",
|
||||
msg->sid, msg->is_audio()? "A":msg->is_video()? "V":"N", msg->stream_number());
|
||||
}
|
||||
|
||||
// check supported codec
|
||||
if (msg->channel->stream != SrsTsStreamVideoH264 && msg->channel->stream != SrsTsStreamAudioAAC) {
|
||||
ret = ERROR_STREAM_CASTER_TS_CODEC;
|
||||
srs_error("mpegts: unsupported stream codec=%d. ret=%d", msg->channel->stream, ret);
|
||||
return ret;
|
||||
return srs_error_new(ERROR_STREAM_CASTER_TS_CODEC, "ts: unsupported stream codec=%d", msg->channel->stream);
|
||||
}
|
||||
|
||||
// we must use queue to cache the msg, then parse it if possible.
|
||||
queue.insert(std::make_pair(msg->dts, msg->detach()));
|
||||
if ((ret = parse_message_queue()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
return srs_error_new(ret, "ts: parse message");
|
||||
}
|
||||
|
||||
return ret;
|
||||
return err;
|
||||
}
|
||||
|
||||
int SrsIngestHlsOutput::on_aac_frame(char* frame, int frame_size, double duration)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue