正在显示
9 个修改的文件
包含
44 行增加
和
328 行删除
| @@ -388,8 +388,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then | @@ -388,8 +388,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then | ||
| 388 | "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config" | 388 | "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log" "srs_app_config" |
| 389 | "srs_app_pithy_print" "srs_app_reload" "srs_app_http_api" "srs_app_http_conn" "srs_app_http_hooks" | 389 | "srs_app_pithy_print" "srs_app_reload" "srs_app_http_api" "srs_app_http_conn" "srs_app_http_hooks" |
| 390 | "srs_app_json" "srs_app_ingest" "srs_app_ffmpeg" "srs_app_utility" "srs_app_dvr" "srs_app_edge" | 390 | "srs_app_json" "srs_app_ingest" "srs_app_ffmpeg" "srs_app_utility" "srs_app_dvr" "srs_app_edge" |
| 391 | - "srs_app_kbps" "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client" "srs_app_avc_aac" | ||
| 392 | - "srs_app_pipe") | 391 | + "srs_app_kbps" "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client" "srs_app_avc_aac") |
| 393 | APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh | 392 | APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh |
| 394 | APP_OBJS="${MODULE_OBJS[@]}" | 393 | APP_OBJS="${MODULE_OBJS[@]}" |
| 395 | fi | 394 | fi |
trunk/src/app/srs_app_config.cpp
100755 → 100644
此 diff 太大无法显示。
trunk/src/app/srs_app_pipe.cpp
已删除
100644 → 0
| 1 | -/* | ||
| 2 | -The MIT License (MIT) | ||
| 3 | - | ||
| 4 | -Copyright (c) 2013-2014 winlin | ||
| 5 | - | ||
| 6 | -Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| 7 | -this software and associated documentation files (the "Software"), to deal in | ||
| 8 | -the Software without restriction, including without limitation the rights to | ||
| 9 | -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| 10 | -the Software, and to permit persons to whom the Software is furnished to do so, | ||
| 11 | -subject to the following conditions: | ||
| 12 | - | ||
| 13 | -The above copyright notice and this permission notice shall be included in all | ||
| 14 | -copies or substantial portions of the Software. | ||
| 15 | - | ||
| 16 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| 18 | -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| 19 | -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| 20 | -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 21 | -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 22 | -*/ | ||
| 23 | - | ||
| 24 | -#include <srs_app_pipe.hpp> | ||
| 25 | - | ||
| 26 | -#include <unistd.h> | ||
| 27 | - | ||
| 28 | -#include <srs_kernel_error.hpp> | ||
| 29 | -#include <srs_kernel_log.hpp> | ||
| 30 | - | ||
| 31 | -SrsPipe::SrsPipe() | ||
| 32 | -{ | ||
| 33 | - fds[0] = fds[1] = 0; | ||
| 34 | - read_stfd = write_stfd = NULL; | ||
| 35 | - _already_written = false; | ||
| 36 | -} | ||
| 37 | - | ||
| 38 | -SrsPipe::~SrsPipe() | ||
| 39 | -{ | ||
| 40 | - srs_close_stfd(read_stfd); | ||
| 41 | - srs_close_stfd(write_stfd); | ||
| 42 | -} | ||
| 43 | - | ||
| 44 | -int SrsPipe::initialize() | ||
| 45 | -{ | ||
| 46 | - int ret = ERROR_SUCCESS; | ||
| 47 | - | ||
| 48 | - if (pipe(fds) < 0) { | ||
| 49 | - ret = ERROR_SYSTEM_CREATE_PIPE; | ||
| 50 | - srs_error("create pipe failed. ret=%d", ret); | ||
| 51 | - return ret; | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - if ((read_stfd = st_netfd_open(fds[0])) == NULL) { | ||
| 55 | - ret = ERROR_SYSTEM_CREATE_PIPE; | ||
| 56 | - srs_error("open read pipe failed. ret=%d", ret); | ||
| 57 | - return ret; | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | - if ((write_stfd = st_netfd_open(fds[1])) == NULL) { | ||
| 61 | - ret = ERROR_SYSTEM_CREATE_PIPE; | ||
| 62 | - srs_error("open write pipe failed. ret=%d", ret); | ||
| 63 | - return ret; | ||
| 64 | - } | ||
| 65 | - | ||
| 66 | - return ret; | ||
| 67 | -} | ||
| 68 | - | ||
| 69 | -st_netfd_t SrsPipe::rfd() | ||
| 70 | -{ | ||
| 71 | - return read_stfd; | ||
| 72 | -} | ||
| 73 | - | ||
| 74 | -bool SrsPipe::already_written() | ||
| 75 | -{ | ||
| 76 | - return _already_written; | ||
| 77 | -} | ||
| 78 | - | ||
| 79 | -int SrsPipe::active() | ||
| 80 | -{ | ||
| 81 | - int ret = ERROR_SUCCESS; | ||
| 82 | - | ||
| 83 | - int v = 0; | ||
| 84 | - if (st_write(write_stfd, &v, sizeof(int), ST_UTIME_NO_TIMEOUT) != sizeof(int)) { | ||
| 85 | - ret = ERROR_SYSTEM_WRITE_PIPE; | ||
| 86 | - srs_error("write pipe failed. ret=%d", ret); | ||
| 87 | - return ret; | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - _already_written = true; | ||
| 91 | - | ||
| 92 | - return ret; | ||
| 93 | -} | ||
| 94 | - | ||
| 95 | -int SrsPipe::reset() | ||
| 96 | -{ | ||
| 97 | - int ret = ERROR_SUCCESS; | ||
| 98 | - | ||
| 99 | - int v; | ||
| 100 | - if (st_read(read_stfd, &v, sizeof(int), ST_UTIME_NO_TIMEOUT) != sizeof(int)) { | ||
| 101 | - ret = ERROR_SYSTEM_READ_PIPE; | ||
| 102 | - srs_error("read pipe failed. ret=%d", ret); | ||
| 103 | - return ret; | ||
| 104 | - } | ||
| 105 | - | ||
| 106 | - _already_written = false; | ||
| 107 | - | ||
| 108 | - return ret; | ||
| 109 | -} | ||
| 110 | - |
trunk/src/app/srs_app_pipe.hpp
已删除
100644 → 0
| 1 | -/* | ||
| 2 | -The MIT License (MIT) | ||
| 3 | - | ||
| 4 | -Copyright (c) 2013-2014 winlin | ||
| 5 | - | ||
| 6 | -Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| 7 | -this software and associated documentation files (the "Software"), to deal in | ||
| 8 | -the Software without restriction, including without limitation the rights to | ||
| 9 | -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| 10 | -the Software, and to permit persons to whom the Software is furnished to do so, | ||
| 11 | -subject to the following conditions: | ||
| 12 | - | ||
| 13 | -The above copyright notice and this permission notice shall be included in all | ||
| 14 | -copies or substantial portions of the Software. | ||
| 15 | - | ||
| 16 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| 18 | -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| 19 | -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| 20 | -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 21 | -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 22 | -*/ | ||
| 23 | - | ||
| 24 | -#ifndef SRS_APP_PIPE_HPP | ||
| 25 | -#define SRS_APP_PIPE_HPP | ||
| 26 | - | ||
| 27 | -/* | ||
| 28 | -#include <srs_app_pipe.hpp> | ||
| 29 | -*/ | ||
| 30 | - | ||
| 31 | -#include <srs_core.hpp> | ||
| 32 | - | ||
| 33 | -#include <srs_app_st.hpp> | ||
| 34 | - | ||
| 35 | -/** | ||
| 36 | -* convert something to io, | ||
| 37 | -* for example, signal or SrsConsumer event. | ||
| 38 | -* for performance issue, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194 | ||
| 39 | -*/ | ||
| 40 | -class SrsPipe | ||
| 41 | -{ | ||
| 42 | -private: | ||
| 43 | - int fds[2]; | ||
| 44 | - st_netfd_t read_stfd; | ||
| 45 | - st_netfd_t write_stfd; | ||
| 46 | - /** | ||
| 47 | - * for the event based service, | ||
| 48 | - * for example, the consumer only care whether there is data writen in pipe, | ||
| 49 | - * and the source will not write to pipe when pipe is already writen. | ||
| 50 | - */ | ||
| 51 | - bool _already_written; | ||
| 52 | -public: | ||
| 53 | - SrsPipe(); | ||
| 54 | - virtual ~SrsPipe(); | ||
| 55 | -public: | ||
| 56 | - /** | ||
| 57 | - * initialize pipes, open fds. | ||
| 58 | - */ | ||
| 59 | - virtual int initialize(); | ||
| 60 | - /** | ||
| 61 | - * get the read fd to poll. | ||
| 62 | - */ | ||
| 63 | - virtual st_netfd_t rfd(); | ||
| 64 | -public: | ||
| 65 | - /** | ||
| 66 | - * for event based service, whether already writen data. | ||
| 67 | - */ | ||
| 68 | - virtual bool already_written(); | ||
| 69 | - /** | ||
| 70 | - * for event based service, | ||
| 71 | - * write an int to pipe and set the pipe to active. | ||
| 72 | - */ | ||
| 73 | - virtual int active(); | ||
| 74 | - /** | ||
| 75 | - * for event based service, | ||
| 76 | - * read an int from pipe and reset the pipe to deactive. | ||
| 77 | - */ | ||
| 78 | - virtual int reset(); | ||
| 79 | -}; | ||
| 80 | - | ||
| 81 | -#endif | ||
| 82 | - |
| @@ -516,12 +516,7 @@ int SrsRtmpConn::playing(SrsSource* source) | @@ -516,12 +516,7 @@ int SrsRtmpConn::playing(SrsSource* source) | ||
| 516 | SrsAutoFree(SrsConsumer, consumer); | 516 | SrsAutoFree(SrsConsumer, consumer); |
| 517 | srs_verbose("consumer created success."); | 517 | srs_verbose("consumer created success."); |
| 518 | 518 | ||
| 519 | - // TODO: FIXME: remove it. | ||
| 520 | rtmp->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US); | 519 | rtmp->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US); |
| 521 | - // disable the timeout. | ||
| 522 | - // TODO: FIXME: maybe can use larger timeout? | ||
| 523 | - rtmp->set_recv_timeout(ST_UTIME_NO_TIMEOUT); | ||
| 524 | - rtmp->set_send_timeout(ST_UTIME_NO_TIMEOUT); | ||
| 525 | 520 | ||
| 526 | SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PLAY_USER); | 521 | SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PLAY_USER); |
| 527 | 522 | ||
| @@ -530,30 +525,12 @@ int SrsRtmpConn::playing(SrsSource* source) | @@ -530,30 +525,12 @@ int SrsRtmpConn::playing(SrsSource* source) | ||
| 530 | bool user_specified_duration_to_stop = (req->duration > 0); | 525 | bool user_specified_duration_to_stop = (req->duration > 0); |
| 531 | int64_t starttime = -1; | 526 | int64_t starttime = -1; |
| 532 | 527 | ||
| 533 | - pollfd pds[2]; | ||
| 534 | - // poll the client incoming fd. | ||
| 535 | - pds[0].fd = st_netfd_fileno(stfd); | ||
| 536 | - pds[0].events = POLLIN; | ||
| 537 | - // poll the consumer queue pipe. | ||
| 538 | - pds[1].fd = st_netfd_fileno(consumer->pipe_fd()); | ||
| 539 | - pds[1].events = POLLIN; | ||
| 540 | - | ||
| 541 | while (true) { | 528 | while (true) { |
| 542 | // collect elapse for pithy print. | 529 | // collect elapse for pithy print. |
| 543 | pithy_print.elapse(); | 530 | pithy_print.elapse(); |
| 544 | - | ||
| 545 | - pds[0].revents = 0; | ||
| 546 | - pds[1].revents = 0; | ||
| 547 | 531 | ||
| 548 | - // wait for packet incoming or data outgoing. | ||
| 549 | - if (st_poll(pds, 2, ST_UTIME_NO_TIMEOUT) <= 0) { | ||
| 550 | - srs_error("st_poll failed."); | ||
| 551 | - break; | ||
| 552 | - } | ||
| 553 | - | ||
| 554 | - // packet incoming, read from RTMP. | ||
| 555 | // read from client. | 532 | // read from client. |
| 556 | - if (pds[0].revents & POLLIN) { | 533 | + if (true) { |
| 557 | SrsMessage* msg = NULL; | 534 | SrsMessage* msg = NULL; |
| 558 | ret = rtmp->recv_message(&msg); | 535 | ret = rtmp->recv_message(&msg); |
| 559 | srs_verbose("play loop recv message. ret=%d", ret); | 536 | srs_verbose("play loop recv message. ret=%d", ret); |
| @@ -576,52 +553,49 @@ int SrsRtmpConn::playing(SrsSource* source) | @@ -576,52 +553,49 @@ int SrsRtmpConn::playing(SrsSource* source) | ||
| 576 | } | 553 | } |
| 577 | } | 554 | } |
| 578 | 555 | ||
| 579 | - // data outgoing, sendout packets. | ||
| 580 | - if (pds[1].revents & POLLIN) { | ||
| 581 | - // get messages from consumer. | ||
| 582 | - int count = 0; | ||
| 583 | - if ((ret = consumer->dump_packets(msgs.size, msgs.msgs, count)) != ERROR_SUCCESS) { | ||
| 584 | - srs_error("get messages from consumer failed. ret=%d", ret); | ||
| 585 | - return ret; | ||
| 586 | - } | ||
| 587 | - | ||
| 588 | - // reportable | ||
| 589 | - if (pithy_print.can_print()) { | ||
| 590 | - kbps->sample(); | ||
| 591 | - srs_trace("-> "SRS_CONSTS_LOG_PLAY | ||
| 592 | - " time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d", | ||
| 593 | - pithy_print.age(), count, | ||
| 594 | - kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(), | ||
| 595 | - kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m()); | ||
| 596 | - } | 556 | + // get messages from consumer. |
| 557 | + int count = 0; | ||
| 558 | + if ((ret = consumer->dump_packets(msgs.size, msgs.msgs, count)) != ERROR_SUCCESS) { | ||
| 559 | + srs_error("get messages from consumer failed. ret=%d", ret); | ||
| 560 | + return ret; | ||
| 561 | + } | ||
| 562 | + | ||
| 563 | + // reportable | ||
| 564 | + if (pithy_print.can_print()) { | ||
| 565 | + kbps->sample(); | ||
| 566 | + srs_trace("-> "SRS_CONSTS_LOG_PLAY | ||
| 567 | + " time=%"PRId64", msgs=%d, okbps=%d,%d,%d, ikbps=%d,%d,%d", | ||
| 568 | + pithy_print.age(), count, | ||
| 569 | + kbps->get_send_kbps(), kbps->get_send_kbps_30s(), kbps->get_send_kbps_5m(), | ||
| 570 | + kbps->get_recv_kbps(), kbps->get_recv_kbps_30s(), kbps->get_recv_kbps_5m()); | ||
| 571 | + } | ||
| 572 | + | ||
| 573 | + // sendout messages | ||
| 574 | + // @remark, becareful, all msgs must be free explicitly, | ||
| 575 | + // free by send_and_free_message or srs_freep. | ||
| 576 | + for (int i = 0; i < count; i++) { | ||
| 577 | + SrsSharedPtrMessage* msg = msgs.msgs[i]; | ||
| 597 | 578 | ||
| 598 | - // sendout messages | ||
| 599 | - // @remark, becareful, all msgs must be free explicitly, | ||
| 600 | - // free by send_and_free_message or srs_freep. | ||
| 601 | - for (int i = 0; i < count; i++) { | ||
| 602 | - SrsSharedPtrMessage* msg = msgs.msgs[i]; | ||
| 603 | - | ||
| 604 | - // the send_message will free the msg, | ||
| 605 | - // so set the msgs[i] to NULL. | ||
| 606 | - msgs.msgs[i] = NULL; | ||
| 607 | - | ||
| 608 | - // only when user specifies the duration, | ||
| 609 | - // we start to collect the durations for each message. | ||
| 610 | - if (user_specified_duration_to_stop) { | ||
| 611 | - // foreach msg, collect the duration. | ||
| 612 | - // @remark: never use msg when sent it, for the protocol sdk will free it. | ||
| 613 | - if (starttime < 0 || starttime > msg->header.timestamp) { | ||
| 614 | - starttime = msg->header.timestamp; | ||
| 615 | - } | ||
| 616 | - duration += msg->header.timestamp - starttime; | 579 | + // the send_message will free the msg, |
| 580 | + // so set the msgs[i] to NULL. | ||
| 581 | + msgs.msgs[i] = NULL; | ||
| 582 | + | ||
| 583 | + // only when user specifies the duration, | ||
| 584 | + // we start to collect the durations for each message. | ||
| 585 | + if (user_specified_duration_to_stop) { | ||
| 586 | + // foreach msg, collect the duration. | ||
| 587 | + // @remark: never use msg when sent it, for the protocol sdk will free it. | ||
| 588 | + if (starttime < 0 || starttime > msg->header.timestamp) { | ||
| 617 | starttime = msg->header.timestamp; | 589 | starttime = msg->header.timestamp; |
| 618 | } | 590 | } |
| 619 | - | ||
| 620 | - // no need to assert msg, for the rtmp will assert it. | ||
| 621 | - if ((ret = rtmp->send_and_free_message(msg, res->stream_id)) != ERROR_SUCCESS) { | ||
| 622 | - srs_error("send message to client failed. ret=%d", ret); | ||
| 623 | - return ret; | ||
| 624 | - } | 591 | + duration += msg->header.timestamp - starttime; |
| 592 | + starttime = msg->header.timestamp; | ||
| 593 | + } | ||
| 594 | + | ||
| 595 | + // no need to assert msg, for the rtmp will assert it. | ||
| 596 | + if ((ret = rtmp->send_and_free_message(msg, res->stream_id)) != ERROR_SUCCESS) { | ||
| 597 | + srs_error("send message to client failed. ret=%d", ret); | ||
| 598 | + return ret; | ||
| 625 | } | 599 | } |
| 626 | } | 600 | } |
| 627 | 601 |
| @@ -41,7 +41,6 @@ using namespace std; | @@ -41,7 +41,6 @@ using namespace std; | ||
| 41 | #include <srs_app_edge.hpp> | 41 | #include <srs_app_edge.hpp> |
| 42 | #include <srs_kernel_utility.hpp> | 42 | #include <srs_kernel_utility.hpp> |
| 43 | #include <srs_app_avc_aac.hpp> | 43 | #include <srs_app_avc_aac.hpp> |
| 44 | -#include <srs_app_pipe.hpp> | ||
| 45 | 44 | ||
| 46 | #define CONST_MAX_JITTER_MS 500 | 45 | #define CONST_MAX_JITTER_MS 500 |
| 47 | #define DEFAULT_FRAME_TIME_MS 40 | 46 | #define DEFAULT_FRAME_TIME_MS 40 |
| @@ -172,11 +171,6 @@ void SrsMessageQueue::set_queue_size(double queue_size) | @@ -172,11 +171,6 @@ void SrsMessageQueue::set_queue_size(double queue_size) | ||
| 172 | queue_size_ms = (int)(queue_size * 1000); | 171 | queue_size_ms = (int)(queue_size * 1000); |
| 173 | } | 172 | } |
| 174 | 173 | ||
| 175 | -bool SrsMessageQueue::empty() | ||
| 176 | -{ | ||
| 177 | - return msgs.size() == 0; | ||
| 178 | -} | ||
| 179 | - | ||
| 180 | int SrsMessageQueue::enqueue(SrsSharedPtrMessage* msg) | 174 | int SrsMessageQueue::enqueue(SrsSharedPtrMessage* msg) |
| 181 | { | 175 | { |
| 182 | int ret = ERROR_SUCCESS; | 176 | int ret = ERROR_SUCCESS; |
| @@ -296,7 +290,6 @@ SrsConsumer::SrsConsumer(SrsSource* _source) | @@ -296,7 +290,6 @@ SrsConsumer::SrsConsumer(SrsSource* _source) | ||
| 296 | jitter = new SrsRtmpJitter(); | 290 | jitter = new SrsRtmpJitter(); |
| 297 | queue = new SrsMessageQueue(); | 291 | queue = new SrsMessageQueue(); |
| 298 | should_update_source_id = false; | 292 | should_update_source_id = false; |
| 299 | - pipe = new SrsPipe(); | ||
| 300 | } | 293 | } |
| 301 | 294 | ||
| 302 | SrsConsumer::~SrsConsumer() | 295 | SrsConsumer::~SrsConsumer() |
| @@ -306,23 +299,6 @@ SrsConsumer::~SrsConsumer() | @@ -306,23 +299,6 @@ SrsConsumer::~SrsConsumer() | ||
| 306 | srs_freep(queue); | 299 | srs_freep(queue); |
| 307 | } | 300 | } |
| 308 | 301 | ||
| 309 | -int SrsConsumer::initialize() | ||
| 310 | -{ | ||
| 311 | - int ret = ERROR_SUCCESS; | ||
| 312 | - | ||
| 313 | - if ((ret = pipe->initialize()) != ERROR_SUCCESS) { | ||
| 314 | - srs_error("initialize the pipe for consumer failed. ret=%d", ret); | ||
| 315 | - return ret; | ||
| 316 | - } | ||
| 317 | - | ||
| 318 | - return ret; | ||
| 319 | -} | ||
| 320 | - | ||
| 321 | -st_netfd_t SrsConsumer::pipe_fd() | ||
| 322 | -{ | ||
| 323 | - return pipe->rfd(); | ||
| 324 | -} | ||
| 325 | - | ||
| 326 | void SrsConsumer::set_queue_size(double queue_size) | 302 | void SrsConsumer::set_queue_size(double queue_size) |
| 327 | { | 303 | { |
| 328 | queue->set_queue_size(queue_size); | 304 | queue->set_queue_size(queue_size); |
| @@ -353,18 +329,11 @@ int SrsConsumer::enqueue(SrsSharedPtrMessage* msg, bool atc, int tba, int tbv, S | @@ -353,18 +329,11 @@ int SrsConsumer::enqueue(SrsSharedPtrMessage* msg, bool atc, int tba, int tbv, S | ||
| 353 | return ret; | 329 | return ret; |
| 354 | } | 330 | } |
| 355 | 331 | ||
| 356 | - // notify the rtmp connection to resume to send packet. | ||
| 357 | - if (!pipe->already_written()) { | ||
| 358 | - pipe->active(); | ||
| 359 | - } | ||
| 360 | - | ||
| 361 | return ret; | 332 | return ret; |
| 362 | } | 333 | } |
| 363 | 334 | ||
| 364 | int SrsConsumer::dump_packets(int max_count, SrsSharedPtrMessage** pmsgs, int& count) | 335 | int SrsConsumer::dump_packets(int max_count, SrsSharedPtrMessage** pmsgs, int& count) |
| 365 | { | 336 | { |
| 366 | - int ret = ERROR_SUCCESS; | ||
| 367 | - | ||
| 368 | srs_assert(max_count > 0); | 337 | srs_assert(max_count > 0); |
| 369 | 338 | ||
| 370 | if (should_update_source_id) { | 339 | if (should_update_source_id) { |
| @@ -377,15 +346,7 @@ int SrsConsumer::dump_packets(int max_count, SrsSharedPtrMessage** pmsgs, int& c | @@ -377,15 +346,7 @@ int SrsConsumer::dump_packets(int max_count, SrsSharedPtrMessage** pmsgs, int& c | ||
| 377 | return ERROR_SUCCESS; | 346 | return ERROR_SUCCESS; |
| 378 | } | 347 | } |
| 379 | 348 | ||
| 380 | - if ((ret = queue->dump_packets(max_count, pmsgs, count)) != ERROR_SUCCESS) { | ||
| 381 | - return ret; | ||
| 382 | - } | ||
| 383 | - | ||
| 384 | - if (queue->empty()) { | ||
| 385 | - return pipe->reset(); | ||
| 386 | - } | ||
| 387 | - | ||
| 388 | - return ret; | 349 | + return queue->dump_packets(max_count, pmsgs, count); |
| 389 | } | 350 | } |
| 390 | 351 | ||
| 391 | int SrsConsumer::on_play_client_pause(bool is_pause) | 352 | int SrsConsumer::on_play_client_pause(bool is_pause) |
| @@ -1493,13 +1454,7 @@ void SrsSource::on_unpublish() | @@ -1493,13 +1454,7 @@ void SrsSource::on_unpublish() | ||
| 1493 | { | 1454 | { |
| 1494 | int ret = ERROR_SUCCESS; | 1455 | int ret = ERROR_SUCCESS; |
| 1495 | 1456 | ||
| 1496 | - SrsConsumer* c = new SrsConsumer(this); | ||
| 1497 | - if ((ret = c->initialize()) != ERROR_SUCCESS) { | ||
| 1498 | - srs_freep(c); | ||
| 1499 | - return ret; | ||
| 1500 | - } | ||
| 1501 | - | ||
| 1502 | - consumer = c; | 1457 | + consumer = new SrsConsumer(this); |
| 1503 | consumers.push_back(consumer); | 1458 | consumers.push_back(consumer); |
| 1504 | 1459 | ||
| 1505 | double queue_size = _srs_config->get_queue_length(_req->vhost); | 1460 | double queue_size = _srs_config->get_queue_length(_req->vhost); |
| @@ -58,7 +58,6 @@ class SrsDvr; | @@ -58,7 +58,6 @@ class SrsDvr; | ||
| 58 | class SrsEncoder; | 58 | class SrsEncoder; |
| 59 | #endif | 59 | #endif |
| 60 | class SrsStream; | 60 | class SrsStream; |
| 61 | -class SrsPipe; | ||
| 62 | 61 | ||
| 63 | /** | 62 | /** |
| 64 | * the time jitter algorithm: | 63 | * the time jitter algorithm: |
| @@ -123,10 +122,6 @@ public: | @@ -123,10 +122,6 @@ public: | ||
| 123 | virtual void set_queue_size(double queue_size); | 122 | virtual void set_queue_size(double queue_size); |
| 124 | public: | 123 | public: |
| 125 | /** | 124 | /** |
| 126 | - * whether queue is empty. | ||
| 127 | - */ | ||
| 128 | - virtual bool empty(); | ||
| 129 | - /** | ||
| 130 | * enqueue the message, the timestamp always monotonically. | 125 | * enqueue the message, the timestamp always monotonically. |
| 131 | * @param msg, the msg to enqueue, user never free it whatever the return code. | 126 | * @param msg, the msg to enqueue, user never free it whatever the return code. |
| 132 | */ | 127 | */ |
| @@ -153,7 +148,6 @@ private: | @@ -153,7 +148,6 @@ private: | ||
| 153 | class SrsConsumer | 148 | class SrsConsumer |
| 154 | { | 149 | { |
| 155 | private: | 150 | private: |
| 156 | - SrsPipe* pipe; | ||
| 157 | SrsRtmpJitter* jitter; | 151 | SrsRtmpJitter* jitter; |
| 158 | SrsSource* source; | 152 | SrsSource* source; |
| 159 | SrsMessageQueue* queue; | 153 | SrsMessageQueue* queue; |
| @@ -165,16 +159,6 @@ public: | @@ -165,16 +159,6 @@ public: | ||
| 165 | virtual ~SrsConsumer(); | 159 | virtual ~SrsConsumer(); |
| 166 | public: | 160 | public: |
| 167 | /** | 161 | /** |
| 168 | - * initialize the consumer. | ||
| 169 | - */ | ||
| 170 | - virtual int initialize(); | ||
| 171 | - /** | ||
| 172 | - * source can use this fd to poll with the read event, | ||
| 173 | - * for performance issue, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194 | ||
| 174 | - */ | ||
| 175 | - virtual st_netfd_t pipe_fd(); | ||
| 176 | -public: | ||
| 177 | - /** | ||
| 178 | * set the size of queue. | 162 | * set the size of queue. |
| 179 | */ | 163 | */ |
| 180 | virtual void set_queue_size(double queue_size); | 164 | virtual void set_queue_size(double queue_size); |
| @@ -88,8 +88,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -88,8 +88,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 88 | #define ERROR_SYSTEM_FILE_SEEK 1049 | 88 | #define ERROR_SYSTEM_FILE_SEEK 1049 |
| 89 | #define ERROR_SYSTEM_IO_INVALID 1050 | 89 | #define ERROR_SYSTEM_IO_INVALID 1050 |
| 90 | #define ERROR_ST_EXCEED_THREADS 1051 | 90 | #define ERROR_ST_EXCEED_THREADS 1051 |
| 91 | -#define ERROR_SYSTEM_READ_PIPE 1052 | ||
| 92 | -#define ERROR_SYSTEM_WRITE_PIPE 1053 | ||
| 93 | 91 | ||
| 94 | /////////////////////////////////////////////////////// | 92 | /////////////////////////////////////////////////////// |
| 95 | // RTMP protocol error. | 93 | // RTMP protocol error. |
| @@ -92,8 +92,6 @@ file | @@ -92,8 +92,6 @@ file | ||
| 92 | ..\app\srs_app_kbps.cpp, | 92 | ..\app\srs_app_kbps.cpp, |
| 93 | ..\app\srs_app_log.hpp, | 93 | ..\app\srs_app_log.hpp, |
| 94 | ..\app\srs_app_log.cpp, | 94 | ..\app\srs_app_log.cpp, |
| 95 | - ..\app\srs_app_pipe.hpp, | ||
| 96 | - ..\app\srs_app_pipe.cpp, | ||
| 97 | ..\app\srs_app_refer.hpp, | 95 | ..\app\srs_app_refer.hpp, |
| 98 | ..\app\srs_app_refer.cpp, | 96 | ..\app\srs_app_refer.cpp, |
| 99 | ..\app\srs_app_reload.hpp, | 97 | ..\app\srs_app_reload.hpp, |
-
请 注册 或 登录 后发表评论