mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
Merge branch 'srs.master'
This commit is contained in:
commit
0285395628
2 changed files with 69 additions and 43 deletions
|
@ -81,7 +81,7 @@ int SrsPipe::active()
|
|||
int ret = ERROR_SUCCESS;
|
||||
|
||||
int v = 0;
|
||||
if (st_write(read_stfd, &v, sizeof(int), ST_UTIME_NO_TIMEOUT) != sizeof(int)) {
|
||||
if (st_write(write_stfd, &v, sizeof(int), ST_UTIME_NO_TIMEOUT) != sizeof(int)) {
|
||||
ret = ERROR_SYSTEM_WRITE_PIPE;
|
||||
srs_error("write pipe failed. ret=%d", ret);
|
||||
return ret;
|
||||
|
|
|
@ -516,7 +516,12 @@ int SrsRtmpConn::playing(SrsSource* source)
|
|||
SrsAutoFree(SrsConsumer, consumer);
|
||||
srs_verbose("consumer created success.");
|
||||
|
||||
// TODO: FIXME: remove it.
|
||||
rtmp->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
|
||||
// disable the timeout.
|
||||
// TODO: FIXME: maybe can use larger timeout?
|
||||
rtmp->set_recv_timeout(ST_UTIME_NO_TIMEOUT);
|
||||
rtmp->set_send_timeout(ST_UTIME_NO_TIMEOUT);
|
||||
|
||||
SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PLAY_USER);
|
||||
|
||||
|
@ -525,12 +530,30 @@ int SrsRtmpConn::playing(SrsSource* source)
|
|||
bool user_specified_duration_to_stop = (req->duration > 0);
|
||||
int64_t starttime = -1;
|
||||
|
||||
pollfd pds[2];
|
||||
// poll the client incoming fd.
|
||||
pds[0].fd = st_netfd_fileno(stfd);
|
||||
pds[0].events = POLLIN;
|
||||
// poll the consumer queue pipe.
|
||||
pds[1].fd = st_netfd_fileno(consumer->pipe_fd());
|
||||
pds[1].events = POLLIN;
|
||||
|
||||
while (true) {
|
||||
// collect elapse for pithy print.
|
||||
pithy_print.elapse();
|
||||
|
||||
pds[0].revents = 0;
|
||||
pds[1].revents = 0;
|
||||
|
||||
// wait for packet incoming or data outgoing.
|
||||
if (st_poll(pds, 2, ST_UTIME_NO_TIMEOUT) <= 0) {
|
||||
srs_error("st_poll failed.");
|
||||
break;
|
||||
}
|
||||
|
||||
// packet incoming, read from RTMP.
|
||||
// read from client.
|
||||
if (true) {
|
||||
if (pds[0].revents & POLLIN) {
|
||||
SrsMessage* msg = NULL;
|
||||
ret = rtmp->recv_message(&msg);
|
||||
srs_verbose("play loop recv message. ret=%d", ret);
|
||||
|
@ -553,6 +576,8 @@ int SrsRtmpConn::playing(SrsSource* source)
|
|||
}
|
||||
}
|
||||
|
||||
// data outgoing, sendout packets.
|
||||
if (pds[1].revents & POLLIN) {
|
||||
// get messages from consumer.
|
||||
int count = 0;
|
||||
if ((ret = consumer->dump_packets(msgs.size, msgs.msgs, count)) != ERROR_SUCCESS) {
|
||||
|
@ -598,6 +623,7 @@ int SrsRtmpConn::playing(SrsSource* source)
|
|||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if duration specified, and exceed it, stop play live.
|
||||
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/45
|
||||
|
|
Loading…
Reference in a new issue