mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Merge from SRS2, for #834
This commit is contained in:
commit
33375db401
6 changed files with 32 additions and 3 deletions
|
@ -158,7 +158,8 @@
|
|||
#define ERROR_RTMP_STREAM_NOT_FOUND 2048
|
||||
#define ERROR_RTMP_CLIENT_NOT_FOUND 2049
|
||||
#define ERROR_OpenSslCreateHMAC 2050
|
||||
//
|
||||
#define ERROR_RTMP_STREAM_NAME_EMPTY 2051
|
||||
//
|
||||
// system control message,
|
||||
// not an error, but special control logic.
|
||||
//
|
||||
|
@ -260,6 +261,7 @@
|
|||
#define ERROR_MP4_AVCC_CHANGE 3085
|
||||
#define ERROR_MP4_ASC_CHANGE 3086
|
||||
#define ERROR_DASH_WRITE_FAILED 3087
|
||||
#define ERROR_TS_CONTEXT_NOT_READY 3088
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// HTTP/StreamCaster/KAFKA protocol error.
|
||||
|
|
|
@ -199,6 +199,7 @@ ISrsTsHandler::~ISrsTsHandler()
|
|||
|
||||
SrsTsContext::SrsTsContext()
|
||||
{
|
||||
ready = false;
|
||||
pure_audio = false;
|
||||
sync_byte = 0x47; // ts default sync byte.
|
||||
vcodec = SrsVideoCodecIdReserved;
|
||||
|
@ -235,6 +236,7 @@ void SrsTsContext::on_pmt_parsed()
|
|||
|
||||
void SrsTsContext::reset()
|
||||
{
|
||||
ready = false;
|
||||
vcodec = SrsVideoCodecIdReserved;
|
||||
acodec = SrsAudioCodecIdReserved1;
|
||||
}
|
||||
|
@ -443,6 +445,9 @@ int SrsTsContext::encode_pat_pmt(SrsFileWriter* writer, int16_t vpid, SrsTsStrea
|
|||
}
|
||||
}
|
||||
|
||||
// When PAT and PMT are writen, the context is ready now.
|
||||
ready = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -450,6 +455,13 @@ int SrsTsContext::encode_pes(SrsFileWriter* writer, SrsTsMessage* msg, int16_t p
|
|||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// Sometimes, the context is not ready(PAT/PMT write failed), error in this situation.
|
||||
if (!ready) {
|
||||
ret = ERROR_TS_CONTEXT_NOT_READY;
|
||||
srs_error("TS: context not ready, ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (msg->payload->length() == 0) {
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -342,7 +342,12 @@ public:
|
|||
*/
|
||||
class SrsTsContext
|
||||
{
|
||||
// codec
|
||||
private:
|
||||
// Whether context is ready, failed if try to write data when not ready.
|
||||
// When PAT and PMT writen, the context is ready.
|
||||
// @see https://github.com/ossrs/srs/issues/834
|
||||
bool ready;
|
||||
// codec
|
||||
private:
|
||||
std::map<int, SrsTsChannel*> pids;
|
||||
bool pure_audio;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue