mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Fix #834, crash for TS context corrupt. 2.0.235
This commit is contained in:
parent
7d1a91ca7d
commit
b11ddc7f41
7 changed files with 31 additions and 2 deletions
|
@ -481,6 +481,14 @@ int SrsRtmpConn::stream_service_cycle()
|
|||
return ret;
|
||||
}
|
||||
srs_info("security check ok");
|
||||
|
||||
// Never allow the empty stream name, for HLS may write to a file with empty name.
|
||||
// @see https://github.com/ossrs/srs/issues/834
|
||||
if (req->stream.empty()) {
|
||||
ret = ERROR_RTMP_STREAM_NAME_EMPTY;
|
||||
srs_error("RTMP: Empty stream name not allowed, ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// client is identified, set the timeout to service timeout.
|
||||
rtmp->set_recv_timeout(SRS_CONSTS_RTMP_RECV_TIMEOUT_US);
|
||||
|
|
|
@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
// current release version
|
||||
#define VERSION_MAJOR 2
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_REVISION 234
|
||||
#define VERSION_REVISION 235
|
||||
|
||||
// generated by configure, only macros.
|
||||
#include <srs_auto_headers.hpp>
|
||||
|
|
|
@ -152,6 +152,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#define ERROR_RTSP_AUDIO_CONFIG 2047
|
||||
#define ERROR_RTMP_STREAM_NOT_FOUND 2048
|
||||
#define ERROR_RTMP_CLIENT_NOT_FOUND 2049
|
||||
#define ERROR_RTMP_STREAM_NAME_EMPTY 2050
|
||||
//
|
||||
// system control message,
|
||||
// not an error, but special control logic.
|
||||
|
@ -230,6 +231,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#define ERROR_RESPONSE_CODE 3064
|
||||
#define ERROR_RESPONSE_DATA 3065
|
||||
#define ERROR_REQUEST_DATA 3066
|
||||
#define ERROR_TS_CONTEXT_NOT_READY 3067
|
||||
|
||||
///////////////////////////////////////////////////////
|
||||
// HTTP/StreamCaster protocol error.
|
||||
|
|
|
@ -199,6 +199,7 @@ ISrsTsHandler::~ISrsTsHandler()
|
|||
|
||||
SrsTsContext::SrsTsContext()
|
||||
{
|
||||
ready = false;
|
||||
pure_audio = false;
|
||||
vcodec = SrsCodecVideoReserved;
|
||||
acodec = SrsCodecAudioReserved1;
|
||||
|
@ -234,6 +235,7 @@ void SrsTsContext::on_pmt_parsed()
|
|||
|
||||
void SrsTsContext::reset()
|
||||
{
|
||||
ready = false;
|
||||
vcodec = SrsCodecVideoReserved;
|
||||
acodec = SrsCodecAudioReserved1;
|
||||
}
|
||||
|
@ -432,6 +434,9 @@ int SrsTsContext::encode_pat_pmt(SrsFileWriter* writer, int16_t vpid, SrsTsStrea
|
|||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
// When PAT and PMT are writen, the context is ready now.
|
||||
ready = true;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -439,6 +444,13 @@ int SrsTsContext::encode_pat_pmt(SrsFileWriter* writer, int16_t vpid, SrsTsStrea
|
|||
int SrsTsContext::encode_pes(SrsFileWriter* writer, SrsTsMessage* msg, int16_t pid, SrsTsStream sid, bool pure_audio)
|
||||
{
|
||||
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;
|
||||
|
|
|
@ -346,6 +346,11 @@ public:
|
|||
*/
|
||||
class SrsTsContext
|
||||
{
|
||||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue