Skip to content

Commit

Permalink
Fix #834, crash for TS context corrupt. 2.0.235
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Apr 9, 2017
1 parent 7d1a91c commit b11ddc7
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ Remark:

## History

* v2.0, 2017-04-09, Fix [#834][bug #834], crash for TS context corrupt. 2.0.235
* <strong>v2.0, 2017-03-03, [2.0 release0(2.0.234)][r2.0r0] released. 86373 lines.</strong>
* v2.0, 2017-02-25, for [#730][bug #730], remove the test code. 2.0.234
* v2.0, 2017-02-09, fix [#503][bug #503] disable utilities when reload a source. 2.0.233
Expand Down Expand Up @@ -1279,6 +1280,7 @@ Winlin
[bug #750]: https://github.com/ossrs/srs/issues/750
[bug #752]: https://github.com/ossrs/srs/issues/752
[bug #503]: https://github.com/ossrs/srs/issues/503
[bug #834]: https://github.com/ossrs/srs/issues/834
[bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx

[exo #828]: https://github.com/google/ExoPlayer/pull/828
Expand Down
2 changes: 1 addition & 1 deletion trunk/auto/build_ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ else
echo "build fdk-aac-0.1.3"
cd $ff_current_dir &&
rm -rf fdk-aac-0.1.3 && unzip -q ${ff_src_dir}/fdk-aac-0.1.3.zip &&
cd fdk-aac-0.1.3 && bash autogen.sh && ./configure --prefix=${ff_release_dir} --enable-static && make ${SRS_JOBS} && make install &&
cd fdk-aac-0.1.3 && bash autogen.sh && ./configure --prefix=${ff_release_dir} --enable-static && make ${SRS_JOBS} && make install
ret=$?; if [[ 0 -ne ${ret} ]]; then echo "build fdk-aac-0.1.3 failed"; exit 1; fi
fi

Expand Down
8 changes: 8 additions & 0 deletions trunk/src/app/srs_app_rtmp_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 2 additions & 0 deletions trunk/src/kernel/srs_kernel_error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions trunk/src/kernel/srs_kernel_ts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ ISrsTsHandler::~ISrsTsHandler()

SrsTsContext::SrsTsContext()
{
ready = false;
pure_audio = false;
vcodec = SrsCodecVideoReserved;
acodec = SrsCodecAudioReserved1;
Expand Down Expand Up @@ -234,6 +235,7 @@ void SrsTsContext::on_pmt_parsed()

void SrsTsContext::reset()
{
ready = false;
vcodec = SrsCodecVideoReserved;
acodec = SrsCodecAudioReserved1;
}
Expand Down Expand Up @@ -432,13 +434,23 @@ 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;
}

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;
Expand Down
5 changes: 5 additions & 0 deletions trunk/src/kernel/srs_kernel_ts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,11 @@ class ISrsTsHandler
*/
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;
Expand Down

0 comments on commit b11ddc7

Please sign in to comment.