mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix bug #217, add reuse conn to play different player.
This commit is contained in:
parent
3e81e6e0f1
commit
3d97048c3a
9 changed files with 209 additions and 1 deletions
|
@ -54,6 +54,11 @@ bool SrsRecvThread::empty()
|
|||
return queue.empty();
|
||||
}
|
||||
|
||||
int SrsRecvThread::size()
|
||||
{
|
||||
return (int)queue.size();
|
||||
}
|
||||
|
||||
SrsMessage* SrsRecvThread::pump()
|
||||
{
|
||||
srs_assert(!queue.empty());
|
||||
|
@ -79,6 +84,15 @@ int SrsRecvThread::cycle()
|
|||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// we only recv one message and then process it,
|
||||
// for the message may cause the thread to stop,
|
||||
// when stop, the thread is freed, so the messages
|
||||
// are dropped.
|
||||
if (!queue.empty()) {
|
||||
st_usleep(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
|
||||
return ret;
|
||||
}
|
||||
|
||||
SrsMessage* msg = NULL;
|
||||
|
||||
if ((ret = rtmp->recv_message(&msg)) != ERROR_SUCCESS) {
|
||||
|
@ -93,6 +107,10 @@ int SrsRecvThread::cycle()
|
|||
}
|
||||
srs_verbose("play loop recv message. ret=%d", ret);
|
||||
|
||||
// put into queue, the send thread will get and process it,
|
||||
// @see SrsRtmpConn::process_play_control_msg
|
||||
queue.push_back(msg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
virtual ~SrsRecvThread();
|
||||
public:
|
||||
virtual bool empty();
|
||||
virtual int size();
|
||||
virtual SrsMessage* pump();
|
||||
public:
|
||||
virtual int start();
|
||||
|
|
|
@ -514,6 +514,11 @@ int SrsRtmpConn::playing(SrsSource* source)
|
|||
// stop isolate recv thread
|
||||
trd.stop();
|
||||
|
||||
// warn for the message is dropped.
|
||||
if (!trd.empty()) {
|
||||
srs_warn("drop the received %d messages", trd.size());
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -549,7 +554,7 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsRecvThread* trd)
|
|||
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/217
|
||||
while (!trd->empty()) {
|
||||
SrsMessage* msg = trd->pump();
|
||||
srs_warn("pump client message to process.");
|
||||
srs_verbose("pump client message to process.");
|
||||
|
||||
if ((ret = process_play_control_msg(consumer, msg)) != ERROR_SUCCESS) {
|
||||
if (!srs_is_system_control_error(ret)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue