From 8c214dc96753a102540152f9211b963df9109b74 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 28 Oct 2019 08:57:11 +0800 Subject: [PATCH 01/39] Cover protocol stack RTMP. 3.0.63 --- trunk/src/utest/srs_utest_protostack.cpp | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/trunk/src/utest/srs_utest_protostack.cpp b/trunk/src/utest/srs_utest_protostack.cpp index 3c26e3452..b880d3e04 100644 --- a/trunk/src/utest/srs_utest_protostack.cpp +++ b/trunk/src/utest/srs_utest_protostack.cpp @@ -147,5 +147,31 @@ VOID TEST(ProtoStackTest, ManualFlush) HELPER_EXPECT_SUCCESS(p.manual_response_flush()); EXPECT_EQ(12+6, io.out_buffer.length()); } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + // Always response ACK message. + HELPER_EXPECT_SUCCESS(p.set_in_window_ack_size(1)); + + // When not auto response, need to flush it manually. + p.set_auto_response(false); + HELPER_EXPECT_SUCCESS(p.response_ping_message(1024)); + EXPECT_EQ(0, io.out_buffer.length()); + + // If not flushed, the packets will be destroyed. + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + p.set_recv_buffer(0); + p.set_recv_buffer(131072 * 10); + + p.set_merge_read(true, NULL); + p.set_merge_read(false, NULL); + } } From a726a14b373b2f309a2b50753c6113889c9ebe0b Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 29 Oct 2019 10:02:03 +0800 Subject: [PATCH 02/39] Cover protocol stack RTMP. 3.0.63 --- trunk/src/utest/srs_utest_protostack.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/trunk/src/utest/srs_utest_protostack.cpp b/trunk/src/utest/srs_utest_protostack.cpp index b880d3e04..63c9bbf19 100644 --- a/trunk/src/utest/srs_utest_protostack.cpp +++ b/trunk/src/utest/srs_utest_protostack.cpp @@ -175,3 +175,13 @@ VOID TEST(ProtoStackTest, ManualFlush) } } +VOID TEST(ProtoStackTest, SendZeroMessages) +{ + srs_error_t err; + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + HELPER_EXPECT_SUCCESS(p.send_and_free_message(NULL, 0)); + } +} + From 9067786bd39ccee2899034e0d9278931873f5669 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 4 Nov 2019 09:31:30 +0800 Subject: [PATCH 03/39] Cover protocol stack RTMP. 3.0.63 --- trunk/src/kernel/srs_kernel_flv.cpp | 5 ++ trunk/src/utest/srs_utest_protostack.cpp | 59 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/trunk/src/kernel/srs_kernel_flv.cpp b/trunk/src/kernel/srs_kernel_flv.cpp index d9432ceb5..64642514b 100644 --- a/trunk/src/kernel/srs_kernel_flv.cpp +++ b/trunk/src/kernel/srs_kernel_flv.cpp @@ -284,6 +284,11 @@ int SrsSharedPtrMessage::count() bool SrsSharedPtrMessage::check(int stream_id) { + // Ignore error when message has no payload. + if (!ptr) { + return true; + } + // we donot use the complex basic header, // ensure the basic header is 1bytes. if (ptr->header.perfer_cid < 2) { diff --git a/trunk/src/utest/srs_utest_protostack.cpp b/trunk/src/utest/srs_utest_protostack.cpp index 63c9bbf19..e2323add2 100644 --- a/trunk/src/utest/srs_utest_protostack.cpp +++ b/trunk/src/utest/srs_utest_protostack.cpp @@ -183,5 +183,64 @@ VOID TEST(ProtoStackTest, SendZeroMessages) SrsProtocol p(&io); HELPER_EXPECT_SUCCESS(p.send_and_free_message(NULL, 0)); } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + SrsSharedPtrMessage* msg = new SrsSharedPtrMessage(); + HELPER_EXPECT_SUCCESS(p.send_and_free_message(msg, 1)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + SrsSharedPtrMessage* msgs[1024]; + for (int i = 0; i < 1024; i++) { + msgs[i] = new SrsSharedPtrMessage(); + } + HELPER_EXPECT_SUCCESS(p.send_and_free_messages(msgs, 1024, 0)); + } +} + +VOID TEST(ProtoStackTest, HugeMessages) +{ + srs_error_t err; + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsCommonMessage pkt; + pkt.header.initialize_audio(200, 1000, 1); + pkt.create_payload(256); + pkt.size = 256; + + SrsSharedPtrMessage* msg = new SrsSharedPtrMessage(); + msg->create(&pkt); + + HELPER_EXPECT_SUCCESS(p.send_and_free_message(msg, 1)); + EXPECT_EQ(269, io.out_buffer.length()); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsCommonMessage pkt; + pkt.header.initialize_audio(200, 1000, 1); + pkt.create_payload(256); + pkt.size = 256; + + SrsSharedPtrMessage* msg = new SrsSharedPtrMessage(); + msg->create(&pkt); + SrsAutoFree(SrsSharedPtrMessage, msg); + + SrsSharedPtrMessage* msgs[1024]; + for (int i = 0; i < 1024; i++) { + msgs[i] = msg->copy(); + } + + HELPER_EXPECT_SUCCESS(p.send_and_free_messages(msgs, 1024, 1)); + EXPECT_EQ(269*1024, io.out_buffer.length()); + } } From 918a2943c9b3550c0f973dee716ea49d526f2b38 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 5 Nov 2019 09:55:45 +0800 Subject: [PATCH 04/39] Cover protocol stack RTMP. 3.0.63 --- trunk/src/utest/srs_utest_protostack.cpp | 57 ++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/trunk/src/utest/srs_utest_protostack.cpp b/trunk/src/utest/srs_utest_protostack.cpp index e2323add2..fdb8c23ea 100644 --- a/trunk/src/utest/srs_utest_protostack.cpp +++ b/trunk/src/utest/srs_utest_protostack.cpp @@ -46,6 +46,15 @@ protected: } }; +class MockPayloadErrorPacket : public SrsPacket +{ +protected: + virtual srs_error_t encode(int& size, char*& payload) { + size = 1024; + return srs_success; + } +}; + VOID TEST(ProtoStackTest, PacketEncode) { srs_error_t err; @@ -175,6 +184,35 @@ VOID TEST(ProtoStackTest, ManualFlush) } } +VOID TEST(ProtoStackTest, SendPacketsError) +{ + srs_error_t err; + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsPacket* pkt = new MockErrorPacket(); + HELPER_EXPECT_FAILED(p.send_and_free_packet(pkt, 1)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsPacket* pkt = new SrsPacket(); + HELPER_EXPECT_SUCCESS(p.send_and_free_packet(pkt, 1)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsPacket* pkt = new MockPayloadErrorPacket(); + HELPER_EXPECT_SUCCESS(p.send_and_free_packet(pkt, 1)); + } +} + VOID TEST(ProtoStackTest, SendZeroMessages) { srs_error_t err; @@ -244,3 +282,22 @@ VOID TEST(ProtoStackTest, HugeMessages) } } +VOID TEST(ProtoStackTest, DecodeMessages) +{ + srs_error_t err; + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + // AMF0 message with 1B should fail. + SrsCommonMessage msg; + msg.header.initialize_amf0_script(1, 1); + msg.create_payload(1); + msg.size = 1; + + SrsPacket* pkt; + HELPER_EXPECT_FAILED(p.decode_message(&msg, &pkt)); + } +} + From ce8f778fe6eedd54136ef534b73a86358bc70b3b Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 5 Nov 2019 10:17:06 +0800 Subject: [PATCH 05/39] Cover protocol stack RTMP. 3.0.63 --- trunk/src/utest/srs_utest_protocol.cpp | 18 ++++++ trunk/src/utest/srs_utest_protocol.hpp | 4 ++ trunk/src/utest/srs_utest_protostack.cpp | 73 ++++++++++++++++++++---- 3 files changed, 85 insertions(+), 10 deletions(-) diff --git a/trunk/src/utest/srs_utest_protocol.cpp b/trunk/src/utest/srs_utest_protocol.cpp index 1a6a7a6e3..645e53296 100644 --- a/trunk/src/utest/srs_utest_protocol.cpp +++ b/trunk/src/utest/srs_utest_protocol.cpp @@ -95,6 +95,7 @@ MockBufferIO::MockBufferIO() { rtm = stm = SRS_UTIME_NO_TIMEOUT; rbytes = sbytes = 0; + in_err = out_err = srs_success; } MockBufferIO::~MockBufferIO() @@ -109,6 +110,10 @@ MockBufferIO* MockBufferIO::append(string data) srs_error_t MockBufferIO::read_fully(void* buf, size_t size, ssize_t* nread) { + if (in_err != srs_success) { + return srs_error_copy(in_err); + } + if (in_buffer.length() < (int)size) { return srs_error_new(ERROR_SOCKET_READ, "read"); } @@ -124,6 +129,10 @@ srs_error_t MockBufferIO::read_fully(void* buf, size_t size, ssize_t* nread) srs_error_t MockBufferIO::write(void* buf, size_t size, ssize_t* nwrite) { + if (out_err != srs_success) { + return srs_error_copy(out_err); + } + sbytes += size; if (nwrite) { *nwrite = size; @@ -165,6 +174,10 @@ int64_t MockBufferIO::get_send_bytes() srs_error_t MockBufferIO::writev(const iovec *iov, int iov_size, ssize_t* nwrite) { srs_error_t err = srs_success; + + if (out_err != srs_success) { + return srs_error_copy(out_err); + } ssize_t total = 0; for (int i = 0; i size; + payload = this->payload; + this->payload = NULL; return srs_success; } }; @@ -63,12 +81,16 @@ VOID TEST(ProtoStackTest, PacketEncode) char* payload; if (true) { - MockErrorPacket pkt; + MockPacket pkt; + pkt.size = 1024; + HELPER_EXPECT_FAILED(pkt.encode(size, payload)); } if (true) { - MockErrorPacket pkt; + MockPacket pkt; + pkt.size = 1024; + SrsBuffer b; HELPER_EXPECT_FAILED(pkt.decode(&b)); } @@ -81,7 +103,9 @@ VOID TEST(ProtoStackTest, PacketEncode) } if (true) { - MockErrorPacket pkt; + MockPacket pkt; + pkt.size = 1024; + EXPECT_EQ(1024, pkt.get_size()); } } @@ -192,7 +216,8 @@ VOID TEST(ProtoStackTest, SendPacketsError) MockBufferIO io; SrsProtocol p(&io); - SrsPacket* pkt = new MockErrorPacket(); + MockPacket* pkt = new MockPacket(); + pkt->size = 1024; HELPER_EXPECT_FAILED(p.send_and_free_packet(pkt, 1)); } @@ -208,11 +233,39 @@ VOID TEST(ProtoStackTest, SendPacketsError) MockBufferIO io; SrsProtocol p(&io); - SrsPacket* pkt = new MockPayloadErrorPacket(); + MockPacket2* pkt = new MockPacket2(); + pkt->size = 1024; HELPER_EXPECT_SUCCESS(p.send_and_free_packet(pkt, 1)); } } +VOID TEST(ProtoStackTest, SendHugePacket) +{ + srs_error_t err; + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + MockPacket2* pkt = new MockPacket2(); + pkt->size = 1024; + pkt->payload = new char[1024]; + HELPER_EXPECT_SUCCESS(p.send_and_free_packet(pkt, 1)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + MockPacket2* pkt = new MockPacket2(); + pkt->size = 16; + pkt->payload = new char[16]; + + io.out_err = srs_error_new(1, "fail"); + HELPER_EXPECT_FAILED(p.send_and_free_packet(pkt, 1)); + } +} + VOID TEST(ProtoStackTest, SendZeroMessages) { srs_error_t err; From 466f99a1c8b015e2f94b8637bde89df0de18e3fc Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 5 Nov 2019 10:31:21 +0800 Subject: [PATCH 06/39] Cover protocol stack RTMP. 3.0.63 --- trunk/src/utest/srs_utest_protostack.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/trunk/src/utest/srs_utest_protostack.cpp b/trunk/src/utest/srs_utest_protostack.cpp index 413af4d4e..7ff5d2092 100644 --- a/trunk/src/utest/srs_utest_protostack.cpp +++ b/trunk/src/utest/srs_utest_protostack.cpp @@ -333,6 +333,28 @@ VOID TEST(ProtoStackTest, HugeMessages) HELPER_EXPECT_SUCCESS(p.send_and_free_messages(msgs, 1024, 1)); EXPECT_EQ(269*1024, io.out_buffer.length()); } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsCommonMessage pkt; + pkt.header.initialize_audio(200, 1000, 1); + pkt.create_payload(256); + pkt.size = 256; + + SrsSharedPtrMessage* msg = new SrsSharedPtrMessage(); + msg->create(&pkt); + SrsAutoFree(SrsSharedPtrMessage, msg); + + SrsSharedPtrMessage* msgs[10240]; + for (int i = 0; i < 10240; i++) { + msgs[i] = msg->copy(); + } + + HELPER_EXPECT_SUCCESS(p.send_and_free_messages(msgs, 10240, 1)); + EXPECT_EQ(269*10240, io.out_buffer.length()); + } } VOID TEST(ProtoStackTest, DecodeMessages) From 78e5f46ff753f001d0d515c3e12a58b535f15bf7 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 5 Nov 2019 14:00:00 +0800 Subject: [PATCH 07/39] Cover protocol stack RTMP. 3.0.63 --- trunk/src/utest/srs_utest_protostack.cpp | 54 ++++++++++++++++++++---- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/trunk/src/utest/srs_utest_protostack.cpp b/trunk/src/utest/srs_utest_protostack.cpp index 7ff5d2092..6f80d7901 100644 --- a/trunk/src/utest/srs_utest_protostack.cpp +++ b/trunk/src/utest/srs_utest_protostack.cpp @@ -237,20 +237,43 @@ VOID TEST(ProtoStackTest, SendPacketsError) pkt->size = 1024; HELPER_EXPECT_SUCCESS(p.send_and_free_packet(pkt, 1)); } -} -VOID TEST(ProtoStackTest, SendHugePacket) -{ - srs_error_t err; + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsCommonMessage pkt; + pkt.header.initialize_audio(200, 1000, 1); + pkt.create_payload(256); + pkt.size = 256; + + SrsSharedPtrMessage* msg = new SrsSharedPtrMessage(); + msg->create(&pkt); + SrsAutoFree(SrsSharedPtrMessage, msg); + + SrsSharedPtrMessage* msgs[10240]; + for (int i = 0; i < 10240; i++) { + msgs[i] = msg->copy(); + } + + io.out_err = srs_error_new(1, "fail"); + HELPER_EXPECT_FAILED(p.send_and_free_messages(msgs, 10240, 1)); + } if (true) { MockBufferIO io; SrsProtocol p(&io); - MockPacket2* pkt = new MockPacket2(); - pkt->size = 1024; - pkt->payload = new char[1024]; - HELPER_EXPECT_SUCCESS(p.send_and_free_packet(pkt, 1)); + // Always response ACK message. + HELPER_EXPECT_SUCCESS(p.set_in_window_ack_size(1)); + + // When not auto response, need to flush it manually. + p.set_auto_response(false); + HELPER_EXPECT_SUCCESS(p.response_acknowledgement_message()); + EXPECT_EQ(0, io.out_buffer.length()); + + io.out_err = srs_error_new(1, "fail"); + HELPER_EXPECT_FAILED(p.manual_response_flush()); } if (true) { @@ -266,6 +289,21 @@ VOID TEST(ProtoStackTest, SendHugePacket) } } +VOID TEST(ProtoStackTest, SendHugePacket) +{ + srs_error_t err; + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + MockPacket2* pkt = new MockPacket2(); + pkt->size = 1024; + pkt->payload = new char[1024]; + HELPER_EXPECT_SUCCESS(p.send_and_free_packet(pkt, 1)); + } +} + VOID TEST(ProtoStackTest, SendZeroMessages) { srs_error_t err; From ea96e414caf0a624c5aeaf7bb8567a61753f520e Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 8 Nov 2019 09:26:57 +0800 Subject: [PATCH 08/39] Cover protocol stack RTMP. 3.0.63 --- trunk/src/utest/srs_utest_protostack.cpp | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/trunk/src/utest/srs_utest_protostack.cpp b/trunk/src/utest/srs_utest_protostack.cpp index 6f80d7901..035f544d8 100644 --- a/trunk/src/utest/srs_utest_protostack.cpp +++ b/trunk/src/utest/srs_utest_protostack.cpp @@ -414,3 +414,34 @@ VOID TEST(ProtoStackTest, DecodeMessages) } } +VOID TEST(ProtoStackTest, OnDecodeMessages) +{ + srs_error_t err; + + vector bytes; + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsSetChunkSizePacket* pkt = new SrsSetChunkSizePacket(); + pkt->chunk_size = 0; + + HELPER_EXPECT_SUCCESS(p.send_and_free_packet(pkt, 1)); + bytes.assign(io.out_buffer.bytes(), io.out_buffer.bytes() + io.out_buffer.length()); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + // Always response ACK message. + HELPER_EXPECT_SUCCESS(p.set_in_window_ack_size(1)); + + SrsCommonMessage* msg; + io.in_buffer.append(bytes.data(), bytes.size()); + HELPER_EXPECT_FAILED(p.recv_message(&msg)); + srs_freep(msg); + } +} + From 0529821580d7423f0e2cca10dd53a96d53387797 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 18 Nov 2019 17:08:33 +0800 Subject: [PATCH 09/39] Update issue templates --- .github/ISSUE_TEMPLATE/-bug.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/-bug.md diff --git a/.github/ISSUE_TEMPLATE/-bug.md b/.github/ISSUE_TEMPLATE/-bug.md new file mode 100644 index 000000000..a9226ab0e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/-bug.md @@ -0,0 +1,33 @@ +--- +name: 提Bug +about: 描述一个Bug帮助改进系统 +title: '' +labels: '' +assignees: '' + +--- + +**描述** +描述你遇到了什么问题。 + +**环境** +1. 操作系统:'...' +1. 编码器:'...' +1. SRS版本: '...' +1. SRS的日志如下: +``` +...... +``` + +**重现** +重现Bug的步骤如下: +1. 运行 '...' +1. 运行 '....' +1. 操作 '....' +1. 重现了Bug,关键信息如下: +``` +... +``` + +**期望行为** +描述你期望发生的事情。 From 4e8acf80cb557fbe4a1c48d7f281a6ba5756f4ca Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 18 Nov 2019 17:13:26 +0800 Subject: [PATCH 10/39] Update issue templates --- .github/ISSUE_TEMPLATE/---.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/---.md diff --git a/.github/ISSUE_TEMPLATE/---.md b/.github/ISSUE_TEMPLATE/---.md new file mode 100644 index 000000000..7a38c29ff --- /dev/null +++ b/.github/ISSUE_TEMPLATE/---.md @@ -0,0 +1,21 @@ +--- +name: 提功能 +about: 提功能需求,支持新的特性。 +title: '' +labels: '' +assignees: '' + +--- + +**你的功能是解决某个问题?** +请详细描述你的问题,例如在使用现有功能时碰到了困难。 + +**描述你期望的解决方案** +请详细描述你期望发生什么事情。 + +**请描述你考虑过的实现方法** +请描述你考虑过的实现方法。 + +**环境** +1. SRS的版本:'...' +1. 操作系统:'...' From c8bb7e71c939cc301bf31dba0818b9ed1e0b2f18 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 19 Nov 2019 11:47:31 +0800 Subject: [PATCH 11/39] Cover protocol stack RTMP. 3.0.63 --- trunk/src/utest/srs_utest_protostack.cpp | 47 ++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/trunk/src/utest/srs_utest_protostack.cpp b/trunk/src/utest/srs_utest_protostack.cpp index 035f544d8..f5992d9af 100644 --- a/trunk/src/utest/srs_utest_protostack.cpp +++ b/trunk/src/utest/srs_utest_protostack.cpp @@ -445,3 +445,50 @@ VOID TEST(ProtoStackTest, OnDecodeMessages) } } +SrsCommonMessage* _mock_create_message(char* bytes, int size, int stream_id) +{ + SrsCommonMessage* msg = new SrsCommonMessage(); + msg->header.initialize_amf0_script(size, stream_id); + msg->create_payload(size); + memcpy(msg->payload, bytes, size); + msg->size = size; + return msg; +} + +VOID TEST(ProtoStackTest, OnDecodeMessages2) +{ + srs_error_t err; + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x17, 0x02, 0x00, 0x01, 's', 0x00, 0,0,0,0,0,0,0,0, 0x03,0,0,9}; + SrsCommonMessage* msg = _mock_create_message((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + msg->header.message_type = RTMP_MSG_AMF3CommandMessage; + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + HELPER_EXPECT_SUCCESS(p.decode_message(msg, &pkt)); + + SrsCallPacket* call = (SrsCallPacket*)pkt; + EXPECT_STREQ("s", call->command_name.c_str()); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x17, 0x02, 0x00, 0x01, 's'}; + SrsCommonMessage* msg = _mock_create_message((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + msg->header.message_type = RTMP_MSG_AMF3CommandMessage; + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } +} + From 6eab86644e04771196c9548c7ad3afb49ed308e2 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 19 Nov 2019 18:18:43 +0800 Subject: [PATCH 12/39] Cover protocol stack RTMP. 3.0.63 --- trunk/src/utest/srs_utest_protostack.cpp | 71 +++++++++++++++++++++++- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/trunk/src/utest/srs_utest_protostack.cpp b/trunk/src/utest/srs_utest_protostack.cpp index f5992d9af..30076a6e1 100644 --- a/trunk/src/utest/srs_utest_protostack.cpp +++ b/trunk/src/utest/srs_utest_protostack.cpp @@ -445,7 +445,7 @@ VOID TEST(ProtoStackTest, OnDecodeMessages) } } -SrsCommonMessage* _mock_create_message(char* bytes, int size, int stream_id) +SrsCommonMessage* _create_amf0(char* bytes, int size, int stream_id) { SrsCommonMessage* msg = new SrsCommonMessage(); msg->header.initialize_amf0_script(size, stream_id); @@ -464,7 +464,7 @@ VOID TEST(ProtoStackTest, OnDecodeMessages2) SrsProtocol p(&io); uint8_t bytes[] = {0x17, 0x02, 0x00, 0x01, 's', 0x00, 0,0,0,0,0,0,0,0, 0x03,0,0,9}; - SrsCommonMessage* msg = _mock_create_message((char*)bytes, sizeof(bytes), 1); + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); SrsAutoFree(SrsCommonMessage, msg); msg->header.message_type = RTMP_MSG_AMF3CommandMessage; @@ -481,7 +481,7 @@ VOID TEST(ProtoStackTest, OnDecodeMessages2) SrsProtocol p(&io); uint8_t bytes[] = {0x17, 0x02, 0x00, 0x01, 's'}; - SrsCommonMessage* msg = _mock_create_message((char*)bytes, sizeof(bytes), 1); + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); SrsAutoFree(SrsCommonMessage, msg); msg->header.message_type = RTMP_MSG_AMF3CommandMessage; @@ -490,5 +490,70 @@ VOID TEST(ProtoStackTest, OnDecodeMessages2) HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x00}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + msg->header.message_type = 0xff; + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + HELPER_EXPECT_SUCCESS(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 0x01, 's'}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + msg->header.message_type = RTMP_MSG_AMF0DataMessage; + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + HELPER_EXPECT_SUCCESS(p.decode_message(msg, &pkt)); + } +} + +VOID TEST(ProtoStackTest, OnDecodeMessages3) +{ + srs_error_t err; + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 0x07, '_', 'r', 'e', 's', 'u', 'l', 't'}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + msg->header.message_type = RTMP_MSG_AMF0DataMessage; + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x17, 0x02, 0x00, 0x07, '_', 'r', 'e', 's', 'u', 'l', 't'}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + msg->header.message_type = RTMP_MSG_AMF0DataMessage; + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } } From 3365bc6b02a984c50505fe1de3c9f2db61af746d Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 20 Nov 2019 11:05:56 +0800 Subject: [PATCH 13/39] Cover protocol stack RTMP. 3.0.63 --- trunk/src/utest/srs_utest_protostack.cpp | 483 ++++++++++++++++++++++- 1 file changed, 481 insertions(+), 2 deletions(-) diff --git a/trunk/src/utest/srs_utest_protostack.cpp b/trunk/src/utest/srs_utest_protostack.cpp index 30076a6e1..c7b099ae6 100644 --- a/trunk/src/utest/srs_utest_protostack.cpp +++ b/trunk/src/utest/srs_utest_protostack.cpp @@ -530,7 +530,7 @@ VOID TEST(ProtoStackTest, OnDecodeMessages3) MockBufferIO io; SrsProtocol p(&io); - uint8_t bytes[] = {0x02, 0x00, 0x07, '_', 'r', 'e', 's', 'u', 'l', 't'}; + uint8_t bytes[] = {0x02, 0x00, 0x07, '_','r','e','s','u','l','t'}; SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); SrsAutoFree(SrsCommonMessage, msg); msg->header.message_type = RTMP_MSG_AMF0DataMessage; @@ -538,6 +538,7 @@ VOID TEST(ProtoStackTest, OnDecodeMessages3) SrsPacket* pkt; SrsAutoFree(SrsPacket, pkt); + // Decode the response failed, no transaction ID was set by request. HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); } @@ -545,7 +546,7 @@ VOID TEST(ProtoStackTest, OnDecodeMessages3) MockBufferIO io; SrsProtocol p(&io); - uint8_t bytes[] = {0x17, 0x02, 0x00, 0x07, '_', 'r', 'e', 's', 'u', 'l', 't'}; + uint8_t bytes[] = {0x17, 0x02, 0x00, 0x07, '_','r','e','s','u','l','t'}; SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); SrsAutoFree(SrsCommonMessage, msg); msg->header.message_type = RTMP_MSG_AMF0DataMessage; @@ -553,6 +554,484 @@ VOID TEST(ProtoStackTest, OnDecodeMessages3) SrsPacket* pkt; SrsAutoFree(SrsPacket, pkt); + // Decode the response failed, no transaction ID was set by request. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 0x07, '_','r','e','s','u','l','t', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + msg->header.message_type = RTMP_MSG_AMF0DataMessage; + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Decode the response failed, no transaction ID was set by request. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsConnectAppPacket* request = new SrsConnectAppPacket(); + request->transaction_id = 0.0; + HELPER_EXPECT_SUCCESS(p.send_and_free_packet(request, 1)); + + uint8_t bytes[] = {0x02, 0x00, 0x07, '_','r','e','s','u','l','t', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the response packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsCreateStreamPacket* request = new SrsCreateStreamPacket(); + request->transaction_id = 0.0; + HELPER_EXPECT_SUCCESS(p.send_and_free_packet(request, 1)); + + uint8_t bytes[] = {0x02, 0x00, 0x07, '_','r','e','s','u','l','t', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the response packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsFMLEStartPacket* request = SrsFMLEStartPacket::create_FC_publish("livestream"); + request->transaction_id = 0.0; + HELPER_EXPECT_SUCCESS(p.send_and_free_packet(request, 1)); + + uint8_t bytes[] = {0x02, 0x00, 0x07, '_','r','e','s','u','l','t', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the response packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsFMLEStartPacket* request = SrsFMLEStartPacket::create_release_stream("livestream"); + request->transaction_id = 0.0; + HELPER_EXPECT_SUCCESS(p.send_and_free_packet(request, 1)); + + uint8_t bytes[] = {0x02, 0x00, 0x07, '_','r','e','s','u','l','t', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the response packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsFMLEStartPacket* request = SrsFMLEStartPacket::create_release_stream("livestream"); + request->command_name = RTMP_AMF0_COMMAND_UNPUBLISH; + request->transaction_id = 0.0; + HELPER_EXPECT_SUCCESS(p.send_and_free_packet(request, 1)); + + uint8_t bytes[] = {0x02, 0x00, 0x07, '_','r','e','s','u','l','t', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the response packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } +} + +VOID TEST(ProtoStackTest, OnDecodeMessages4) +{ + srs_error_t err; + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 0x07, 'c','o','n','n','e','c','t', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 12, 'c','r','e','a','t','e','S','t','r','e','a','m', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 4, 'p','l','a','y', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 5, 'p','a','u','s','e', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 13, 'r','e','l','e','a','s','e','S','t','r','e','a','m', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 9, 'F','C','P','u','b','l','i','s','h', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 7, 'p','u','b','l','i','s','h', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 11, 'F','C','U','n','p','u','b','l','i','s','h', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 13, '@','s','e','t','D','a','t','a','F','r','a','m','e', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 10, 'o','n','M','e','t','a','D','a','t','a', 03,0,0,9}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + HELPER_EXPECT_SUCCESS(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 22, 'o','n','S','r','s','B','a','n','d','C','h','e','c','k','F','i','n','i','s','h','e','d', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 21, 'o','n','S','r','s','B','a','n','d','C','h','e','c','k','P','l','a','y','i','n','g', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 24, 'o','n','S','r','s','B','a','n','d','C','h','e','c','k','P','u','b','l','i','s','h','i','n','g', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 31, 'o','n','S','r','s','B','a','n','d','C','h','e','c','k','S','t','a','r','t','i','n','g','P','l','a','y','B','y','t','e','s', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 34, 'o','n','S','r','s','B','a','n','d','C','h','e','c','k','S','t','a','r','t','i','n','g','P','u','b','l','i','s','h','B','y','t','e','s', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 28, 'o','n','S','r','s','B','a','n','d','C','h','e','c','k','S','t','a','r','t','P','l','a','y','B','y','t','e','s', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 31, 'o','n','S','r','s','B','a','n','d','C','h','e','c','k','S','t','a','r','t','P','u','b','l','i','s','h','B','y','t','e','s', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 30, 'o','n','S','r','s','B','a','n','d','C','h','e','c','k','S','t','o','p','p','e','d','P','l','a','y','B','y','t','e','s', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 27, 'o','n','S','r','s','B','a','n','d','C','h','e','c','k','S','t','o','p','P','l','a','y','B','y','t','e','s', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 30, 'o','n','S','r','s','B','a','n','d','C','h','e','c','k','S','t','o','p','P','u','b','l','i','s','h','B','y','t','e','s', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 33, 'o','n','S','r','s','B','a','n','d','C','h','e','c','k','S','t','o','p','p','e','d','P','u','b','l','i','s','h','B','y','t','e','s', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 17, 'f','i','n','a','l','C','l','i','e','n','t','P','a','c','k','e','t', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 11, 'c','l','o','s','e','S','t','r','e','a','m', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x02, 0x00, 3, 's','r','s', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + msg->header.message_type = RTMP_MSG_AMF0CommandMessage; + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the request packet. HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); } } From 40e60aff4d9a7a41f80e953e24dc0ef8cc1ead00 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 20 Nov 2019 11:14:02 +0800 Subject: [PATCH 14/39] Cover protocol stack RTMP. 3.0.63 --- trunk/src/utest/srs_utest_protostack.cpp | 26 +++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/trunk/src/utest/srs_utest_protostack.cpp b/trunk/src/utest/srs_utest_protostack.cpp index c7b099ae6..a636d2707 100644 --- a/trunk/src/utest/srs_utest_protostack.cpp +++ b/trunk/src/utest/srs_utest_protostack.cpp @@ -549,7 +549,7 @@ VOID TEST(ProtoStackTest, OnDecodeMessages3) uint8_t bytes[] = {0x17, 0x02, 0x00, 0x07, '_','r','e','s','u','l','t'}; SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); SrsAutoFree(SrsCommonMessage, msg); - msg->header.message_type = RTMP_MSG_AMF0DataMessage; + msg->header.message_type = RTMP_MSG_AMF3DataMessage; SrsPacket* pkt; SrsAutoFree(SrsPacket, pkt); @@ -562,10 +562,10 @@ VOID TEST(ProtoStackTest, OnDecodeMessages3) MockBufferIO io; SrsProtocol p(&io); - uint8_t bytes[] = {0x02, 0x00, 0x07, '_','r','e','s','u','l','t', 0x00,0,0,0,0,0,0,0,0}; + uint8_t bytes[] = {0x17, 0x02, 0x00, 0x07, '_','r','e','s','u','l','t', 0x00,0,0,0,0,0,0,0,0}; SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); SrsAutoFree(SrsCommonMessage, msg); - msg->header.message_type = RTMP_MSG_AMF0DataMessage; + msg->header.message_type = RTMP_MSG_AMF3CommandMessage; SrsPacket* pkt; SrsAutoFree(SrsPacket, pkt); @@ -669,6 +669,26 @@ VOID TEST(ProtoStackTest, OnDecodeMessages3) // Without enough data, it fail when decoding the response packet. HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsFMLEStartPacket* request = new SrsFMLEStartPacket(); + request->command_name = "srs"; + request->transaction_id = 0.0; + HELPER_EXPECT_SUCCESS(p.send_and_free_packet(request, 1)); + + uint8_t bytes[] = {0x02, 0x00, 0x07, '_','r','e','s','u','l','t', 0x00,0,0,0,0,0,0,0,0}; + SrsCommonMessage* msg = _create_amf0((char*)bytes, sizeof(bytes), 1); + SrsAutoFree(SrsCommonMessage, msg); + + SrsPacket* pkt; + SrsAutoFree(SrsPacket, pkt); + + // Without enough data, it fail when decoding the response packet. + HELPER_EXPECT_FAILED(p.decode_message(msg, &pkt)); + } } VOID TEST(ProtoStackTest, OnDecodeMessages4) From 2731afc1614c75a2b35252344843eb0937535862 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 20 Nov 2019 14:08:53 +0800 Subject: [PATCH 15/39] Cover protocol stack RTMP. 3.0.63 --- trunk/src/protocol/srs_rtmp_stack.cpp | 15 +- trunk/src/utest/srs_utest_protostack.cpp | 169 +++++++++++++++++++++++ 2 files changed, 175 insertions(+), 9 deletions(-) diff --git a/trunk/src/protocol/srs_rtmp_stack.cpp b/trunk/src/protocol/srs_rtmp_stack.cpp index 5d2387aef..0099d5791 100644 --- a/trunk/src/protocol/srs_rtmp_stack.cpp +++ b/trunk/src/protocol/srs_rtmp_stack.cpp @@ -979,18 +979,18 @@ srs_error_t SrsProtocol::read_basic_header(char& fmt, int& cid) // 2-63, 1B chunk header if (cid > 1) { return err; - } - // 64-319, 2B chunk header - if (cid == 0) { + } else if (cid == 0) { if ((err = in_buffer->grow(skt, 1)) != srs_success) { return srs_error_wrap(err, "basic header requires 2 bytes"); } - + cid = 64; cid += (uint8_t)in_buffer->read_1byte(); - // 64-65599, 3B chunk header - } else if (cid == 1) { + // 64-65599, 3B chunk header + } else { + srs_assert(cid == 1); + if ((err = in_buffer->grow(skt, 2)) != srs_success) { return srs_error_wrap(err, "basic header requires 3 bytes"); } @@ -998,9 +998,6 @@ srs_error_t SrsProtocol::read_basic_header(char& fmt, int& cid) cid = 64; cid += (uint8_t)in_buffer->read_1byte(); cid += ((uint8_t)in_buffer->read_1byte()) * 256; - } else { - srs_error("invalid path, impossible basic header."); - srs_assert(false); } return err; diff --git a/trunk/src/utest/srs_utest_protostack.cpp b/trunk/src/utest/srs_utest_protostack.cpp index a636d2707..0f0b8021a 100644 --- a/trunk/src/utest/srs_utest_protostack.cpp +++ b/trunk/src/utest/srs_utest_protostack.cpp @@ -1056,3 +1056,172 @@ VOID TEST(ProtoStackTest, OnDecodeMessages4) } } +VOID TEST(ProtoStackTest, RecvMessage) +{ + srs_error_t err; + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x01, 0x00, 0x00}; + io.in_buffer.append((char*)bytes, sizeof(bytes)); + + SrsCommonMessage* msg; + SrsAutoFree(SrsCommonMessage, msg); + HELPER_EXPECT_FAILED(p.recv_message(&msg)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x00, 0x00}; + io.in_buffer.append((char*)bytes, sizeof(bytes)); + + SrsCommonMessage* msg; + SrsAutoFree(SrsCommonMessage, msg); + HELPER_EXPECT_FAILED(p.recv_message(&msg)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x00}; + io.in_buffer.append((char*)bytes, sizeof(bytes)); + + SrsCommonMessage* msg; + SrsAutoFree(SrsCommonMessage, msg); + HELPER_EXPECT_FAILED(p.recv_message(&msg)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsCommonMessage* msg; + SrsAutoFree(SrsCommonMessage, msg); + HELPER_EXPECT_FAILED(p.recv_message(&msg)); + } +} + +VOID TEST(ProtoStackTest, RecvMessage2) +{ + srs_error_t err; + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x03, 0,0,0, 0,0,4, 0, 0,0,0,0, 1,2,3}; + io.in_buffer.append((char*)bytes, sizeof(bytes)); + + SrsCommonMessage* msg; + SrsAutoFree(SrsCommonMessage, msg); + HELPER_EXPECT_FAILED(p.recv_message(&msg)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + p.in_chunk_size = 3; + + uint8_t bytes[] = {0x03, 0,0,0, 0,0,4, 0, 0,0,0,0, 1,2,3}; + io.in_buffer.append((char*)bytes, sizeof(bytes)); + + SrsCommonMessage* msg; + SrsAutoFree(SrsCommonMessage, msg); + HELPER_EXPECT_FAILED(p.recv_message(&msg)); + + uint8_t bytes2[] = {0x43, 0,0,0, 0,0,5, 0, 0,0,0,0, 1,2,3}; + io.in_buffer.append((char*)bytes2, sizeof(bytes2)); + HELPER_EXPECT_FAILED(p.recv_message(&msg)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x03}; + io.in_buffer.append((char*)bytes, sizeof(bytes)); + + SrsCommonMessage* msg; + SrsAutoFree(SrsCommonMessage, msg); + HELPER_EXPECT_FAILED(p.recv_message(&msg)); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + uint8_t bytes[] = {0x43, 0,0,0, 0,0,0, 0}; + io.in_buffer.append((char*)bytes, sizeof(bytes)); + + SrsCommonMessage* msg; + SrsAutoFree(SrsCommonMessage, msg); + HELPER_EXPECT_FAILED(p.recv_message(&msg)); + } +} + +VOID TEST(ProtoStackTest, RecvMessage3) +{ + if (true) { + SrsRequest req; + req.ip = "10.11.12.13"; + + SrsRequest* cp = req.copy(); + EXPECT_STREQ("10.11.12.13", cp->ip.c_str()); + srs_freep(cp); + } + + if (true) { + SrsRequest req; + req.ip = "10.11.12.13"; + + SrsAmf0Object* obj = SrsAmf0Any::object(); + obj->set("id", SrsAmf0Any::str("srs")); + req.args = obj; + + SrsRequest* cp = req.copy(); + EXPECT_STREQ("10.11.12.13", cp->ip.c_str()); + + SrsAmf0Object* cpa = dynamic_cast(cp->args); + SrsAmf0Any* cps = cpa->ensure_property_string("id"); + EXPECT_STREQ("srs", cps->to_str().c_str()); + srs_freep(cp); + } + + if (true) { + SrsRequest req; + EXPECT_STREQ("//", req.get_stream_url().c_str()); + } + + if (true) { + SrsRequest req; + EXPECT_STREQ("", req.schema.c_str()); + + req.as_http(); + EXPECT_STREQ("http", req.schema.c_str()); + } + + if (true) { + SrsResponse res; + EXPECT_EQ(1, res.stream_id); + } + + if (true) { + EXPECT_STREQ("Play", srs_client_type_string(SrsRtmpConnPlay).c_str()); + EXPECT_STREQ("flash-publish", srs_client_type_string(SrsRtmpConnFlashPublish).c_str()); + EXPECT_STREQ("fmle-publish", srs_client_type_string(SrsRtmpConnFMLEPublish).c_str()); + EXPECT_STREQ("haivision-publish", srs_client_type_string(SrsRtmpConnHaivisionPublish).c_str()); + EXPECT_STREQ("Unknown", srs_client_type_string(SrsRtmpConnType(0x0f)).c_str()); + + EXPECT_TRUE(srs_client_type_is_publish(SrsRtmpConnFlashPublish)); + EXPECT_TRUE(srs_client_type_is_publish(SrsRtmpConnFMLEPublish)); + EXPECT_TRUE(srs_client_type_is_publish(SrsRtmpConnHaivisionPublish)); + EXPECT_FALSE(srs_client_type_is_publish(SrsRtmpConnPlay)); + } +} + From 7bd704e695d3c64d1ea2d198ce13aa1698c823cf Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 22 Nov 2019 12:06:15 +0800 Subject: [PATCH 16/39] Cover protocol stack RTMP. 3.0.63 --- trunk/src/kernel/srs_kernel_stream.cpp | 5 +++ trunk/src/kernel/srs_kernel_stream.hpp | 1 + trunk/src/utest/srs_utest_protostack.cpp | 46 ++++++++++++++++++++++-- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/trunk/src/kernel/srs_kernel_stream.cpp b/trunk/src/kernel/srs_kernel_stream.cpp index 9873ced63..cec9f3d9a 100755 --- a/trunk/src/kernel/srs_kernel_stream.cpp +++ b/trunk/src/kernel/srs_kernel_stream.cpp @@ -68,3 +68,8 @@ void SrsSimpleStream::append(const char* bytes, int size) data.insert(data.end(), bytes, bytes + size); } + +void SrsSimpleStream::append(SrsSimpleStream* src) +{ + append(src->bytes(), src->length()); +} diff --git a/trunk/src/kernel/srs_kernel_stream.hpp b/trunk/src/kernel/srs_kernel_stream.hpp index 699673076..67e57ccb5 100644 --- a/trunk/src/kernel/srs_kernel_stream.hpp +++ b/trunk/src/kernel/srs_kernel_stream.hpp @@ -63,6 +63,7 @@ public: * @remark assert size is positive. */ virtual void append(const char* bytes, int size); + virtual void append(SrsSimpleStream* src); }; #endif diff --git a/trunk/src/utest/srs_utest_protostack.cpp b/trunk/src/utest/srs_utest_protostack.cpp index 0f0b8021a..64a0ce711 100644 --- a/trunk/src/utest/srs_utest_protostack.cpp +++ b/trunk/src/utest/srs_utest_protostack.cpp @@ -418,7 +418,7 @@ VOID TEST(ProtoStackTest, OnDecodeMessages) { srs_error_t err; - vector bytes; + SrsSimpleStream bytes; if (true) { MockBufferIO io; @@ -428,7 +428,7 @@ VOID TEST(ProtoStackTest, OnDecodeMessages) pkt->chunk_size = 0; HELPER_EXPECT_SUCCESS(p.send_and_free_packet(pkt, 1)); - bytes.assign(io.out_buffer.bytes(), io.out_buffer.bytes() + io.out_buffer.length()); + bytes.append(&io.out_buffer); } if (true) { @@ -439,7 +439,7 @@ VOID TEST(ProtoStackTest, OnDecodeMessages) HELPER_EXPECT_SUCCESS(p.set_in_window_ack_size(1)); SrsCommonMessage* msg; - io.in_buffer.append(bytes.data(), bytes.size()); + io.in_buffer.append(&bytes); HELPER_EXPECT_FAILED(p.recv_message(&msg)); srs_freep(msg); } @@ -1225,3 +1225,43 @@ VOID TEST(ProtoStackTest, RecvMessage3) } } +VOID TEST(ProtoStackTest, RecvMessage4) +{ + srs_error_t err; + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsSetChunkSizePacket* pkt = new SrsSetChunkSizePacket(); + pkt->chunk_size = 256; + HELPER_EXPECT_SUCCESS(p.send_and_free_packet(pkt, 0)); + + io.in_buffer.append(&io.out_buffer); + + SrsCommonMessage* msg; + SrsAutoFree(SrsCommonMessage, msg); + HELPER_EXPECT_SUCCESS(p.recv_message(&msg)); + + EXPECT_EQ(256, p.out_chunk_size); + } + + if (true) { + MockBufferIO io; + SrsProtocol p(&io); + + SrsUserControlPacket* pkt = new SrsUserControlPacket(); + pkt->event_type = SrcPCUCSetBufferLength; + pkt->extra_data = 256; + HELPER_EXPECT_SUCCESS(p.send_and_free_packet(pkt, 0)); + + io.in_buffer.append(&io.out_buffer); + + SrsCommonMessage* msg; + SrsAutoFree(SrsCommonMessage, msg); + HELPER_EXPECT_SUCCESS(p.recv_message(&msg)); + + EXPECT_EQ(256, p.in_buffer_length); + } +} + From f1c42f7ee012736b87725d3381db4228a94dc7d6 Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 29 Nov 2019 12:33:09 +0800 Subject: [PATCH 17/39] Change docker centos to dev --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9afa97503..ad37c7fe7 100755 --- a/README.md +++ b/README.md @@ -1072,7 +1072,7 @@ Winlin [console]: http://ossrs.net:1985/console [player]: http://ossrs.net:8000/players/srs_player.html [modules]: https://github.com/ossrs/srs/blob/develop/trunk/modules/readme.txt -[docker]: https://github.com/ossrs/srs-docker/tree/centos#usage +[docker]: https://github.com/ossrs/srs-docker/tree/dev#usage [v1_CN_Git]: https://github.com/ossrs/srs/wiki/v1_CN_Git [v1_EN_Git]: https://github.com/ossrs/srs/wiki/v1_EN_Git From ba02640c46b1f174d0c2489793a5150f9415d262 Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 29 Nov 2019 12:33:32 +0800 Subject: [PATCH 18/39] Refine tid in error log --- trunk/src/kernel/srs_kernel_error.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trunk/src/kernel/srs_kernel_error.cpp b/trunk/src/kernel/srs_kernel_error.cpp index 9ea9534de..de13304db 100644 --- a/trunk/src/kernel/srs_kernel_error.cpp +++ b/trunk/src/kernel/srs_kernel_error.cpp @@ -81,7 +81,7 @@ std::string SrsCplxError::description() { next = this; while (next) { - ss << "thread #" << next->cid << ": " + ss << "thread [" << next->cid << "]: " << next->func << "() [" << next->file << ":" << next->line << "]" << "[errno=" << next->rerrno << "]"; From 1c943f27c963f7dfd33f1c676ae78f9dbd17a0a1 Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 29 Nov 2019 18:26:40 +0800 Subject: [PATCH 19/39] Release 2.0.265, r2.0-r7 --- README.md | 4 ++++ trunk/auto/depends.sh | 7 +++---- trunk/src/core/srs_core.hpp | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 67031972d..de8a5aedc 100755 --- a/README.md +++ b/README.md @@ -294,6 +294,7 @@ Remark: ## Releases +* 2018-11-29, [Release v2.0-r7][r2.0r7], 2.0 release6, 2.0.265, 86994 lines. * 2018-10-28, [Release v2.0-r6][r2.0r6], 2.0 release6, 2.0.263, 86994 lines. * 2018-10-28, [Release v2.0-r5][r2.0r5], 2.0 release5, 2.0.258, 86916 lines. * 2018-08-12, [Release v2.0-r4][r2.0r4], 2.0 release4, 2.0.255, 86915 lines. @@ -336,6 +337,8 @@ Remark: ## History +* v2.0, 2019-11-29, [2.0 release6(2.0.265)][r2.0r7] released. 86994 lines. +* v2.0, 2019-11-29, For [srs-docker](https://github.com/ossrs/srs-docker/tree/master/2.0), install Cherrypy without sudo. 2.0.265 * v2.0, 2019-04-06, For [#1304][bug #1304], Default HSTRS to on. 2.0.264 * v2.0, 2019-04-05, [2.0 release6(2.0.263)][r2.0r6] released. 86994 lines. * v2.0, 2019-04-05, Merge [#1312][bug #1312], Fix GCC7 build error, this statement may fall through. 2.0.263 @@ -1354,6 +1357,7 @@ Winlin [exo #828]: https://github.com/google/ExoPlayer/pull/828 +[r2.0r7]: https://github.com/ossrs/srs/releases/tag/v2.0-r7 [r2.0r6]: https://github.com/ossrs/srs/releases/tag/v2.0-r6 [r2.0r5]: https://github.com/ossrs/srs/releases/tag/v2.0-r5 [r2.0r4]: https://github.com/ossrs/srs/releases/tag/v2.0-r4 diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index a7fc91655..a4c682277 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -573,12 +573,11 @@ if [ $SRS_HTTP_CALLBACK = YES ]; then if [[ -f ${SRS_OBJS}/CherryPy-3.2.4/setup.py ]]; then echo "CherryPy-3.2.4 is ok."; else - require_sudoer "install CherryPy-3.2.4" - echo "install CherryPy-3.2.4"; + echo "install CherryPy-3.2.4"; ( - sudo rm -rf ${SRS_OBJS}/CherryPy-3.2.4 && cd ${SRS_OBJS} && + rm -rf ${SRS_OBJS}/CherryPy-3.2.4 && cd ${SRS_OBJS} && unzip -q ../3rdparty/CherryPy-3.2.4.zip && cd CherryPy-3.2.4 && - sudo python setup.py install + python setup.py install --user ) fi # check status diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index cd2470f27..75de8d4c6 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -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 264 +#define VERSION_REVISION 265 // generated by configure, only macros. #include From a5b01fc6be16b048f4e842c106916ab647009499 Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 29 Nov 2019 18:27:59 +0800 Subject: [PATCH 20/39] Release r2.0-r7 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index de8a5aedc..6f11696b9 100755 --- a/README.md +++ b/README.md @@ -294,7 +294,7 @@ Remark: ## Releases -* 2018-11-29, [Release v2.0-r7][r2.0r7], 2.0 release6, 2.0.265, 86994 lines. +* 2018-11-29, [Release v2.0-r7][r2.0r7], 2.0 release7, 2.0.265, 86994 lines. * 2018-10-28, [Release v2.0-r6][r2.0r6], 2.0 release6, 2.0.263, 86994 lines. * 2018-10-28, [Release v2.0-r5][r2.0r5], 2.0 release5, 2.0.258, 86916 lines. * 2018-08-12, [Release v2.0-r4][r2.0r4], 2.0 release4, 2.0.255, 86915 lines. From d695cd958fede367f241ce79eb9824b4664e1882 Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 29 Nov 2019 18:28:19 +0800 Subject: [PATCH 21/39] Release r2.0-r7 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f11696b9..650895a69 100755 --- a/README.md +++ b/README.md @@ -337,7 +337,7 @@ Remark: ## History -* v2.0, 2019-11-29, [2.0 release6(2.0.265)][r2.0r7] released. 86994 lines. +* v2.0, 2019-11-29, [2.0 release7(2.0.265)][r2.0r7] released. 86994 lines. * v2.0, 2019-11-29, For [srs-docker](https://github.com/ossrs/srs-docker/tree/master/2.0), install Cherrypy without sudo. 2.0.265 * v2.0, 2019-04-06, For [#1304][bug #1304], Default HSTRS to on. 2.0.264 * v2.0, 2019-04-05, [2.0 release6(2.0.263)][r2.0r6] released. 86994 lines. From 02f459f784f3e3bed507017ac8062768c8dea53e Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 30 Nov 2019 13:58:10 +0800 Subject: [PATCH 22/39] Update bug template --- .github/ISSUE_TEMPLATE/-bug.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/-bug.md b/.github/ISSUE_TEMPLATE/-bug.md index a9226ab0e..9d51ecea1 100644 --- a/.github/ISSUE_TEMPLATE/-bug.md +++ b/.github/ISSUE_TEMPLATE/-bug.md @@ -11,20 +11,24 @@ assignees: '' 描述你遇到了什么问题。 **环境** -1. 操作系统:'...' -1. 编码器:'...' -1. SRS版本: '...' +1. 操作系统:```...``` +1. 编码器(工具和版本):```...``` +1. 播放器(工具和版本):```...``` +1. SRS版本: ```...``` 1. SRS的日志如下: + ``` ...... ``` **重现** 重现Bug的步骤如下: -1. 运行 '...' -1. 运行 '....' -1. 操作 '....' +1. 启动SRS,运行 ```...``` +1. 推流,运行 ```...``` +1. 播放,运行 ```...``` +1. 操作 ```...``` 1. 重现了Bug,关键信息如下: + ``` ... ``` From 4cd03a7c060a59f58e8356aa4f1483e1960a5087 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 30 Nov 2019 17:31:27 +0800 Subject: [PATCH 23/39] Refine debug info for edge. 3.0.64 --- README.md | 1 + trunk/src/app/srs_app_rtmp_conn.cpp | 3 ++- trunk/src/core/srs_core.hpp | 2 +- trunk/src/service/srs_service_rtmp_conn.cpp | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index acee07779..40b51c000 100755 --- a/README.md +++ b/README.md @@ -152,6 +152,7 @@ Please select according to languages: ### V3 changes +* v3.0, 2019-11-30, Refine debug info for edge. 3.0.64 * v3.0, 2019-10-30, Cover protocol stack RTMP. 3.0.63 * v3.0, 2019-10-23, Cover JSON codec. 3.0.62 * v3.0, 2019-10-13, Use http://ossrs.net:8000 as homepage. diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index e1dabc1c3..d91417715 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -1179,7 +1179,8 @@ srs_error_t SrsRtmpConn::do_token_traverse_auth(SrsRtmpClient* client) } // for token tranverse, always take the debug info(which carries token). - if ((err = client->connect_app(req->app, req->tcUrl, req, true, NULL)) != srs_success) { + SrsServerInfo si; + if ((err = client->connect_app(req->app, req->tcUrl, req, true, &si)) != srs_success) { return srs_error_wrap(err, "rtmp: connect tcUrl"); } diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 8f4e8f406..44eaadb76 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 63 +#define VERSION_REVISION 64 // The macros generated by configure script. #include diff --git a/trunk/src/service/srs_service_rtmp_conn.cpp b/trunk/src/service/srs_service_rtmp_conn.cpp index 366af9839..b5525e4fa 100644 --- a/trunk/src/service/srs_service_rtmp_conn.cpp +++ b/trunk/src/service/srs_service_rtmp_conn.cpp @@ -139,7 +139,8 @@ srs_error_t SrsBasicRtmpClient::do_connect_app(string local_ip, bool debug) // upnode server identity will show in the connect_app of client. // @see https://github.com/ossrs/srs/issues/160 // the debug_srs_upnode is config in vhost and default to true. - if ((err = client->connect_app(req->app, tc_url, req, debug, NULL)) != srs_success) { + SrsServerInfo si; + if ((err = client->connect_app(req->app, tc_url, req, debug, &si)) != srs_success) { return srs_error_wrap(err, "connect app tcUrl=%s, debug=%d", tc_url.c_str(), debug); } From 488f16f60c283b0f9bc2a7ddb3a0656bf139a4e5 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 30 Nov 2019 17:34:25 +0800 Subject: [PATCH 24/39] Random tid for docker. 3.0.65 --- README.md | 1 + trunk/src/core/srs_core.hpp | 2 +- trunk/src/service/srs_service_log.cpp | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 40b51c000..654735080 100755 --- a/README.md +++ b/README.md @@ -152,6 +152,7 @@ Please select according to languages: ### V3 changes +* v3.0, 2019-11-30, Random tid for docker. 3.0.65 * v3.0, 2019-11-30, Refine debug info for edge. 3.0.64 * v3.0, 2019-10-30, Cover protocol stack RTMP. 3.0.63 * v3.0, 2019-10-23, Cover JSON codec. 3.0.62 diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 44eaadb76..8fdfe44a6 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 64 +#define VERSION_REVISION 65 // The macros generated by configure script. #include diff --git a/trunk/src/service/srs_service_log.cpp b/trunk/src/service/srs_service_log.cpp index 895658560..d92cb5ce7 100644 --- a/trunk/src/service/srs_service_log.cpp +++ b/trunk/src/service/srs_service_log.cpp @@ -43,7 +43,11 @@ SrsThreadContext::~SrsThreadContext() int SrsThreadContext::generate_id() { - static int id = 100; + static int id = 0; + + if (id == 0) { + id = (100 + ((int)(int64_t)this)%1000); + } int gid = id++; cache[srs_thread_self()] = gid; From e5285ecabfcb861ae9b4dba25a27a862a712d278 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 30 Nov 2019 18:50:24 +0800 Subject: [PATCH 25/39] Fix #1501, use request ip for origin cluster. 3.0.66 --- README.md | 1 + trunk/src/app/srs_app_coworkers.cpp | 48 ++++++++++++++++--------- trunk/src/app/srs_app_coworkers.hpp | 2 +- trunk/src/app/srs_app_http_api.cpp | 4 +-- trunk/src/core/srs_core.hpp | 2 +- trunk/src/kernel/srs_kernel_consts.hpp | 2 ++ trunk/src/kernel/srs_kernel_utility.cpp | 4 +-- 7 files changed, 40 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 654735080..f189abc49 100755 --- a/README.md +++ b/README.md @@ -152,6 +152,7 @@ Please select according to languages: ### V3 changes +* v3.0, 2019-11-30, Fix #1501, use request ip for origin cluster. 3.0.66 * v3.0, 2019-11-30, Random tid for docker. 3.0.65 * v3.0, 2019-11-30, Refine debug info for edge. 3.0.64 * v3.0, 2019-10-30, Cover protocol stack RTMP. 3.0.63 diff --git a/trunk/src/app/srs_app_coworkers.cpp b/trunk/src/app/srs_app_coworkers.cpp index be9cba5d0..48338f6a0 100644 --- a/trunk/src/app/srs_app_coworkers.cpp +++ b/trunk/src/app/srs_app_coworkers.cpp @@ -58,30 +58,44 @@ SrsCoWorkers* SrsCoWorkers::instance() return _instance; } -SrsJsonAny* SrsCoWorkers::dumps(string vhost, string app, string stream) +SrsJsonAny* SrsCoWorkers::dumps(string vhost, string host, string app, string stream) { SrsRequest* r = find_stream_info(vhost, app, stream); if (!r) { // TODO: FIXME: Find stream from our origin util return to the start point. return SrsJsonAny::null(); } - - vector service_ports = _srs_config->get_listens(); - if (service_ports.empty()) { - return SrsJsonAny::null(); + + // The service port parsing from listen port. + string listen_host; + int listen_port = SRS_CONSTS_RTMP_DEFAULT_PORT; + vector listen_hostports = _srs_config->get_listens(); + if (!listen_hostports.empty()) { + string list_hostport = listen_hostports.at(0); + + if (list_hostport.find(":") != string::npos) { + srs_parse_hostport(list_hostport, listen_host, listen_port); + } else { + listen_port = ::atoi(list_hostport.c_str()); + } } - - string service_ip = srs_get_public_internet_address(); - string service_hostport = service_ports.at(0); - - int service_port = SRS_CONSTS_RTMP_DEFAULT_PORT; - if (service_hostport.find(":") != string::npos) { - string service_host; - srs_parse_hostport(service_hostport, service_host, service_port); - } else { - service_port = ::atoi(service_hostport.c_str()); + + // The ip of server, we use the request host as ip, if listen host is localhost or loopback. + // For example, the server may behind a NAT(192.x.x.x), while its ip is a docker ip(172.x.x.x), + // we should use the NAT(192.x.x.x) address as it's the exposed ip. + // @see https://github.com/ossrs/srs/issues/1501 + string service_ip; + if (listen_host != SRS_CONSTS_LOCALHOST && listen_host != SRS_CONSTS_LOOPBACK && listen_host != SRS_CONSTS_LOOPBACK6) { + service_ip = listen_host; } - + if (service_ip.empty()) { + service_ip = host; + } + if (service_ip.empty()) { + service_ip = srs_get_public_internet_address(); + } + + // The backend API endpoint. string backend = _srs_config->get_http_api_listen(); if (backend.find(":") == string::npos) { backend = service_ip + ":" + backend; @@ -92,7 +106,7 @@ SrsJsonAny* SrsCoWorkers::dumps(string vhost, string app, string stream) return SrsJsonAny::object() ->set("ip", SrsJsonAny::str(service_ip.c_str())) - ->set("port", SrsJsonAny::integer(service_port)) + ->set("port", SrsJsonAny::integer(listen_port)) ->set("vhost", SrsJsonAny::str(r->vhost.c_str())) ->set("api", SrsJsonAny::str(backend.c_str())) ->set("routers", routers); diff --git a/trunk/src/app/srs_app_coworkers.hpp b/trunk/src/app/srs_app_coworkers.hpp index b7be73dca..23094ddb6 100644 --- a/trunk/src/app/srs_app_coworkers.hpp +++ b/trunk/src/app/srs_app_coworkers.hpp @@ -46,7 +46,7 @@ private: public: static SrsCoWorkers* instance(); public: - virtual SrsJsonAny* dumps(std::string vhost, std::string app, std::string stream); + virtual SrsJsonAny* dumps(std::string vhost, std::string host, std::string app, std::string stream); private: virtual SrsRequest* find_stream_info(std::string vhost, std::string app, std::string stream); public: diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp index a41d74d01..9eb7ed2ca 100644 --- a/trunk/src/app/srs_app_http_api.cpp +++ b/trunk/src/app/srs_app_http_api.cpp @@ -1297,7 +1297,7 @@ srs_error_t SrsGoApiClusters::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess ->set("stream", SrsJsonAny::str(stream.c_str()))); SrsCoWorkers* coworkers = SrsCoWorkers::instance(); - data->set("origin", coworkers->dumps(vhost, app, stream)); + data->set("origin", coworkers->dumps(vhost, ip, app, stream)); return srs_api_response(w, r, obj->dumps()); } @@ -1342,7 +1342,7 @@ srs_error_t SrsHttpApi::do_cycle() { srs_error_t err = srs_success; - srs_trace("api get peer ip success. ip=%s", ip.c_str()); + srs_trace("API server client, ip=%s", ip.c_str()); // initialize parser if ((err = parser->initialize(HTTP_REQUEST, true)) != srs_success) { diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 8fdfe44a6..a25f6b096 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 65 +#define VERSION_REVISION 66 // The macros generated by configure script. #include diff --git a/trunk/src/kernel/srs_kernel_consts.hpp b/trunk/src/kernel/srs_kernel_consts.hpp index bb6d85292..8df891fd2 100644 --- a/trunk/src/kernel/srs_kernel_consts.hpp +++ b/trunk/src/kernel/srs_kernel_consts.hpp @@ -116,6 +116,8 @@ /////////////////////////////////////////////////////////// #define SRS_CONSTS_NULL_FILE "/dev/null" #define SRS_CONSTS_LOCALHOST "127.0.0.1" +#define SRS_CONSTS_LOOPBACK "0.0.0.0" +#define SRS_CONSTS_LOOPBACK6 "::" // The signal defines. // To reload the config file and apply new config. diff --git a/trunk/src/kernel/srs_kernel_utility.cpp b/trunk/src/kernel/srs_kernel_utility.cpp index 93ea6a895..9a2b7c46c 100644 --- a/trunk/src/kernel/srs_kernel_utility.cpp +++ b/trunk/src/kernel/srs_kernel_utility.cpp @@ -231,9 +231,9 @@ string srs_any_address_for_listener() } if (ipv6_active && !ipv4_active) { - return "::"; + return SRS_CONSTS_LOOPBACK6; } - return "0.0.0.0"; + return SRS_CONSTS_LOOPBACK; } void srs_parse_endpoint(string hostport, string& ip, int& port) From 517974d4513a03f8879f5acbdb2683e0ba13b2b9 Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 30 Nov 2019 19:06:41 +0800 Subject: [PATCH 26/39] Refine redirect flow for origin cluster --- README.md | 3 ++- trunk/src/app/srs_app_edge.cpp | 27 ++++++++++++++------------- trunk/src/app/srs_app_edge.hpp | 6 ++---- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index f189abc49..ea18f17b1 100755 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ Please select according to languages: ### V3 changes -* v3.0, 2019-11-30, Fix #1501, use request ip for origin cluster. 3.0.66 +* v3.0, 2019-11-30, Fix [#1501][bug #1501], use request ip for origin cluster. 3.0.66 * v3.0, 2019-11-30, Random tid for docker. 3.0.65 * v3.0, 2019-11-30, Refine debug info for edge. 3.0.64 * v3.0, 2019-10-30, Cover protocol stack RTMP. 3.0.63 @@ -1492,6 +1492,7 @@ Winlin [bug #1087]: https://github.com/ossrs/srs/issues/1087 [bug #1051]: https://github.com/ossrs/srs/issues/1051 [bug #1093]: https://github.com/ossrs/srs/issues/1093 +[bug #1501]: https://github.com/ossrs/srs/issues/1501 [bug #xxxxxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/src/app/srs_app_edge.cpp b/trunk/src/app/srs_app_edge.cpp index 11582373c..86bcd5fdf 100644 --- a/trunk/src/app/srs_app_edge.cpp +++ b/trunk/src/app/srs_app_edge.cpp @@ -160,7 +160,7 @@ SrsEdgeIngester::SrsEdgeIngester() edge = NULL; req = NULL; - upstream = new SrsEdgeRtmpUpstream(redirect); + upstream = new SrsEdgeRtmpUpstream(""); lb = new SrsLbRoundRobin(); trd = new SrsDummyCoroutine(); } @@ -243,7 +243,8 @@ srs_error_t SrsEdgeIngester::cycle() srs_error_t SrsEdgeIngester::do_cycle() { srs_error_t err = srs_success; - + + std::string redirect; while (true) { if ((err = trd->pull()) != srs_success) { return srs_error_wrap(err, "do cycle pull"); @@ -252,10 +253,6 @@ srs_error_t SrsEdgeIngester::do_cycle() srs_freep(upstream); upstream = new SrsEdgeRtmpUpstream(redirect); - // we only use the redict once. - // reset the redirect to empty, for maybe the origin changed. - redirect = ""; - if ((err = source->on_source_id_changed(_srs_context->get_id())) != srs_success) { return srs_error_wrap(err, "on source id changed"); } @@ -267,8 +264,11 @@ srs_error_t SrsEdgeIngester::do_cycle() if ((err = edge->on_ingest_play()) != srs_success) { return srs_error_wrap(err, "notify edge play"); } + + // set to larger timeout to read av data from origin. + upstream->set_recv_timeout(SRS_EDGE_INGESTER_TIMEOUT); - err = ingest(); + err = ingest(redirect); // retry for rtmp 302 immediately. if (srs_error_code(err) == ERROR_CONTROL_REDIRECT) { @@ -286,15 +286,16 @@ srs_error_t SrsEdgeIngester::do_cycle() return err; } -srs_error_t SrsEdgeIngester::ingest() +srs_error_t SrsEdgeIngester::ingest(string& redirect) { srs_error_t err = srs_success; SrsPithyPrint* pprint = SrsPithyPrint::create_edge(); SrsAutoFree(SrsPithyPrint, pprint); - - // set to larger timeout to read av data from origin. - upstream->set_recv_timeout(SRS_EDGE_INGESTER_TIMEOUT); + + // we only use the redict once. + // reset the redirect to empty, for maybe the origin changed. + redirect = ""; while (true) { srs_error_t err = srs_success; @@ -318,7 +319,7 @@ srs_error_t SrsEdgeIngester::ingest() srs_assert(msg); SrsAutoFree(SrsCommonMessage, msg); - if ((err = process_publish_message(msg)) != srs_success) { + if ((err = process_publish_message(msg, redirect)) != srs_success) { return srs_error_wrap(err, "process message"); } } @@ -326,7 +327,7 @@ srs_error_t SrsEdgeIngester::ingest() return err; } -srs_error_t SrsEdgeIngester::process_publish_message(SrsCommonMessage* msg) +srs_error_t SrsEdgeIngester::process_publish_message(SrsCommonMessage* msg, string& redirect) { srs_error_t err = srs_success; diff --git a/trunk/src/app/srs_app_edge.hpp b/trunk/src/app/srs_app_edge.hpp index 24512dc86..122e0f928 100644 --- a/trunk/src/app/srs_app_edge.hpp +++ b/trunk/src/app/srs_app_edge.hpp @@ -115,8 +115,6 @@ private: SrsCoroutine* trd; SrsLbRoundRobin* lb; SrsEdgeUpstream* upstream; - // For RTMP 302 redirect. - std::string redirect; public: SrsEdgeIngester(); virtual ~SrsEdgeIngester(); @@ -131,8 +129,8 @@ public: private: virtual srs_error_t do_cycle(); private: - virtual srs_error_t ingest(); - virtual srs_error_t process_publish_message(SrsCommonMessage* msg); + virtual srs_error_t ingest(std::string& redirect); + virtual srs_error_t process_publish_message(SrsCommonMessage* msg, std::string& redirect); }; // The edge used to forward stream to origin. From 75fd0412790ff8623f8415127ff2be275f174a1d Mon Sep 17 00:00:00 2001 From: winlin Date: Sat, 30 Nov 2019 19:16:12 +0800 Subject: [PATCH 27/39] Release v3.0-a2 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index ea18f17b1..bfdd86d69 100755 --- a/README.md +++ b/README.md @@ -152,6 +152,7 @@ Please select according to languages: ### V3 changes +* v3.0, 2019-11-30, [3.0 alpha2(3.0.66)][r3.0a2] released. 110831 lines. * v3.0, 2019-11-30, Fix [#1501][bug #1501], use request ip for origin cluster. 3.0.66 * v3.0, 2019-11-30, Random tid for docker. 3.0.65 * v3.0, 2019-11-30, Refine debug info for edge. 3.0.64 @@ -657,6 +658,7 @@ Please select according to languages: ### Releases +* 2019-11-30, [Release v3.0-a2][r3.0a2], 3.0 alpha2, 3.0.66, 110831 lines. * 2019-10-07, [Release v3.0-a1][r3.0a1], 3.0 alpha1, 3.0.60, 107962 lines. * 2019-10-04, [Release v3.0-a0][r3.0a0], 3.0 alpha0, 3.0.56, 107946 lines. * 2017-03-03, [Release v2.0-r0][r2.0r0], 2.0 release0, 2.0.234, 86373 lines. @@ -1497,6 +1499,7 @@ Winlin [exo #828]: https://github.com/google/ExoPlayer/pull/828 +[r3.0a2]: https://github.com/ossrs/srs/releases/tag/v3.0-a2 [r3.0a1]: https://github.com/ossrs/srs/releases/tag/v3.0-a1 [r3.0a0]: https://github.com/ossrs/srs/releases/tag/v3.0-a0 [r2.0r7]: https://github.com/ossrs/srs/releases/tag/v2.0-r7 From 5a3fd1e68a537065b3e2f700ef7245a7c710f498 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 1 Dec 2019 19:24:17 +0800 Subject: [PATCH 28/39] Release v3.0-a2, 3.0.67 --- README.md | 2 +- trunk/src/app/srs_app_coworkers.cpp | 17 +++++++++++++---- trunk/src/app/srs_app_coworkers.hpp | 2 +- trunk/src/app/srs_app_edge.cpp | 18 +++++++++++++++++- trunk/src/app/srs_app_edge.hpp | 6 ++++++ trunk/src/app/srs_app_http_api.cpp | 3 ++- trunk/src/app/srs_app_rtmp_conn.cpp | 3 ++- trunk/src/core/srs_core.hpp | 2 +- 8 files changed, 43 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index bfdd86d69..cd44f982c 100755 --- a/README.md +++ b/README.md @@ -153,7 +153,7 @@ Please select according to languages: ### V3 changes * v3.0, 2019-11-30, [3.0 alpha2(3.0.66)][r3.0a2] released. 110831 lines. -* v3.0, 2019-11-30, Fix [#1501][bug #1501], use request ip for origin cluster. 3.0.66 +* v3.0, 2019-11-30, Fix [#1501][bug #1501], use request coworker for origin cluster. 3.0.67 * v3.0, 2019-11-30, Random tid for docker. 3.0.65 * v3.0, 2019-11-30, Refine debug info for edge. 3.0.64 * v3.0, 2019-10-30, Cover protocol stack RTMP. 3.0.63 diff --git a/trunk/src/app/srs_app_coworkers.cpp b/trunk/src/app/srs_app_coworkers.cpp index 48338f6a0..2dae87871 100644 --- a/trunk/src/app/srs_app_coworkers.cpp +++ b/trunk/src/app/srs_app_coworkers.cpp @@ -58,7 +58,7 @@ SrsCoWorkers* SrsCoWorkers::instance() return _instance; } -SrsJsonAny* SrsCoWorkers::dumps(string vhost, string host, string app, string stream) +SrsJsonAny* SrsCoWorkers::dumps(string vhost, string coworker, string app, string stream) { SrsRequest* r = find_stream_info(vhost, app, stream); if (!r) { @@ -80,7 +80,7 @@ SrsJsonAny* SrsCoWorkers::dumps(string vhost, string host, string app, string st } } - // The ip of server, we use the request host as ip, if listen host is localhost or loopback. + // The ip of server, we use the request coworker-host as ip, if listen host is localhost or loopback. // For example, the server may behind a NAT(192.x.x.x), while its ip is a docker ip(172.x.x.x), // we should use the NAT(192.x.x.x) address as it's the exposed ip. // @see https://github.com/ossrs/srs/issues/1501 @@ -89,7 +89,13 @@ SrsJsonAny* SrsCoWorkers::dumps(string vhost, string host, string app, string st service_ip = listen_host; } if (service_ip.empty()) { - service_ip = host; + int coworker_port; + string coworker_host = coworker; + if (coworker.find(":") != string::npos) { + srs_parse_hostport(coworker, coworker_host, coworker_port); + } + + service_ip = coworker_host; } if (service_ip.empty()) { service_ip = srs_get_public_internet_address(); @@ -103,7 +109,10 @@ SrsJsonAny* SrsCoWorkers::dumps(string vhost, string host, string app, string st // The routers to detect loop and identify path. SrsJsonArray* routers = SrsJsonAny::array()->append(SrsJsonAny::str(backend.c_str())); - + + srs_trace("Redirect vhost=%s, path=%s/%s to ip=%s, port=%d, api=%s", + vhost.c_str(), app.c_str(), stream.c_str(), service_ip.c_str(), listen_port, backend.c_str()); + return SrsJsonAny::object() ->set("ip", SrsJsonAny::str(service_ip.c_str())) ->set("port", SrsJsonAny::integer(listen_port)) diff --git a/trunk/src/app/srs_app_coworkers.hpp b/trunk/src/app/srs_app_coworkers.hpp index 23094ddb6..c25f1f300 100644 --- a/trunk/src/app/srs_app_coworkers.hpp +++ b/trunk/src/app/srs_app_coworkers.hpp @@ -46,7 +46,7 @@ private: public: static SrsCoWorkers* instance(); public: - virtual SrsJsonAny* dumps(std::string vhost, std::string host, std::string app, std::string stream); + virtual SrsJsonAny* dumps(std::string vhost, std::string coworker, std::string app, std::string stream); private: virtual SrsRequest* find_stream_info(std::string vhost, std::string app, std::string stream); public: diff --git a/trunk/src/app/srs_app_edge.cpp b/trunk/src/app/srs_app_edge.cpp index 86bcd5fdf..a2d95e706 100644 --- a/trunk/src/app/srs_app_edge.cpp +++ b/trunk/src/app/srs_app_edge.cpp @@ -100,10 +100,13 @@ srs_error_t SrsEdgeRtmpUpstream::connect(SrsRequest* r, SrsLbRoundRobin* lb) string _schema, _vhost, _app, _stream, _param, _host; srs_discovery_tc_url(redirect, _schema, _host, _vhost, _app, _stream, _port, _param); - srs_warn("RTMP redirect %s:%d to %s:%d stream=%s", server.c_str(), port, _host.c_str(), _port, _stream.c_str()); server = _host; port = _port; } + + // Remember the current selected server. + selected_ip = server; + selected_port = port; // support vhost tranform for edge, // @see https://github.com/ossrs/srs/issues/372 @@ -144,6 +147,12 @@ void SrsEdgeRtmpUpstream::close() srs_freep(sdk); } +void SrsEdgeRtmpUpstream::selected(string& server, int& port) +{ + server = selected_ip; + port = selected_port; +} + void SrsEdgeRtmpUpstream::set_recv_timeout(srs_utime_t tm) { sdk->set_recv_timeout(tm); @@ -272,6 +281,13 @@ srs_error_t SrsEdgeIngester::do_cycle() // retry for rtmp 302 immediately. if (srs_error_code(err) == ERROR_CONTROL_REDIRECT) { + int port; + string server; + upstream->selected(server, port); + + string url = req->get_stream_url(); + srs_warn("RTMP redirect %s from %s:%d to %s", url.c_str(), server.c_str(), port, redirect.c_str()); + srs_error_reset(err); continue; } diff --git a/trunk/src/app/srs_app_edge.hpp b/trunk/src/app/srs_app_edge.hpp index 122e0f928..f9ead1f63 100644 --- a/trunk/src/app/srs_app_edge.hpp +++ b/trunk/src/app/srs_app_edge.hpp @@ -80,6 +80,7 @@ public: virtual srs_error_t decode_message(SrsCommonMessage* msg, SrsPacket** ppacket) = 0; virtual void close() = 0; public: + virtual void selected(std::string& server, int& port) = 0; virtual void set_recv_timeout(srs_utime_t tm) = 0; virtual void kbps_sample(const char* label, int64_t age) = 0; }; @@ -91,6 +92,10 @@ private: // use this as upstream. std::string redirect; SrsSimpleRtmpClient* sdk; +private: + // Current selected server, the ip:port. + std::string selected_ip; + int selected_port; public: // @param rediect, override the server. ignore if empty. SrsEdgeRtmpUpstream(std::string r); @@ -101,6 +106,7 @@ public: virtual srs_error_t decode_message(SrsCommonMessage* msg, SrsPacket** ppacket); virtual void close(); public: + virtual void selected(std::string& server, int& port); virtual void set_recv_timeout(srs_utime_t tm); virtual void kbps_sample(const char* label, int64_t age); }; diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp index 9eb7ed2ca..bd6c01ced 100644 --- a/trunk/src/app/srs_app_http_api.cpp +++ b/trunk/src/app/srs_app_http_api.cpp @@ -1290,6 +1290,7 @@ srs_error_t SrsGoApiClusters::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess string vhost = r->query_get("vhost"); string app = r->query_get("app"); string stream = r->query_get("stream"); + string coworker = r->query_get("coworker"); data->set("query", SrsJsonAny::object() ->set("ip", SrsJsonAny::str(ip.c_str())) ->set("vhost", SrsJsonAny::str(vhost.c_str())) @@ -1297,7 +1298,7 @@ srs_error_t SrsGoApiClusters::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess ->set("stream", SrsJsonAny::str(stream.c_str()))); SrsCoWorkers* coworkers = SrsCoWorkers::instance(); - data->set("origin", coworkers->dumps(vhost, ip, app, stream)); + data->set("origin", coworkers->dumps(vhost, coworker, app, stream)); return srs_api_response(w, r, obj->dumps()); } diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index d91417715..867c4aea1 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -610,7 +610,8 @@ srs_error_t SrsRtmpConn::playing(SrsSource* source) int port; string host; string url = "http://" + coworkers.at(i) + "/api/v1/clusters?" - + "vhost=" + req->vhost + "&ip=" + req->host + "&app=" + req->app + "&stream=" + req->stream; + + "vhost=" + req->vhost + "&ip=" + req->host + "&app=" + req->app + "&stream=" + req->stream + + "&coworker=" + coworkers.at(i); if ((err = SrsHttpHooks::discover_co_workers(url, host, port)) != srs_success) { return srs_error_wrap(err, "discover coworkers, url=%s", url.c_str()); } diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index a25f6b096..385fca95c 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -27,7 +27,7 @@ // The version config. #define VERSION_MAJOR 3 #define VERSION_MINOR 0 -#define VERSION_REVISION 66 +#define VERSION_REVISION 67 // The macros generated by configure script. #include From 67af179352c47acde6213c8ea9d0ed219a4da683 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 1 Dec 2019 19:30:08 +0800 Subject: [PATCH 29/39] Release v3.0-a3, 3.0.67 --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cd44f982c..15e6c8877 100755 --- a/README.md +++ b/README.md @@ -152,8 +152,10 @@ Please select according to languages: ### V3 changes +* v3.0, 2019-11-30, [3.0 alpha2(3.0.67)][r3.0a3] released. 110864 lines. +* v3.0, 2019-12-01, Fix [#1501][bug #1501], use request coworker for origin cluster. 3.0.67 * v3.0, 2019-11-30, [3.0 alpha2(3.0.66)][r3.0a2] released. 110831 lines. -* v3.0, 2019-11-30, Fix [#1501][bug #1501], use request coworker for origin cluster. 3.0.67 +* v3.0, 2019-11-30, Fix [#1501][bug #1501], use request coworker for origin cluster. 3.0.66 * v3.0, 2019-11-30, Random tid for docker. 3.0.65 * v3.0, 2019-11-30, Refine debug info for edge. 3.0.64 * v3.0, 2019-10-30, Cover protocol stack RTMP. 3.0.63 @@ -658,6 +660,7 @@ Please select according to languages: ### Releases +* 2019-11-30, [Release v3.0-a2][r3.0a3], 3.0 alpha2, 3.0.67, 110864 lines. * 2019-11-30, [Release v3.0-a2][r3.0a2], 3.0 alpha2, 3.0.66, 110831 lines. * 2019-10-07, [Release v3.0-a1][r3.0a1], 3.0 alpha1, 3.0.60, 107962 lines. * 2019-10-04, [Release v3.0-a0][r3.0a0], 3.0 alpha0, 3.0.56, 107946 lines. @@ -1499,6 +1502,7 @@ Winlin [exo #828]: https://github.com/google/ExoPlayer/pull/828 +[r3.0a3]: https://github.com/ossrs/srs/releases/tag/v3.0-a3 [r3.0a2]: https://github.com/ossrs/srs/releases/tag/v3.0-a2 [r3.0a1]: https://github.com/ossrs/srs/releases/tag/v3.0-a1 [r3.0a0]: https://github.com/ossrs/srs/releases/tag/v3.0-a0 From cedf2a603d1859c70c5f695835d3a8a5ecf9b0f4 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 2 Dec 2019 15:01:25 +0800 Subject: [PATCH 30/39] Update --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 15e6c8877..167bffa0c 100755 --- a/README.md +++ b/README.md @@ -1002,10 +1002,10 @@ A big THANK YOU goes to: ### Mirrors -OSChina: [http://git.oschina.net/winlinvip/srs.oschina][oschina], the GIT usage([CN][v1_CN_Git], [EN][v1_EN_Git]) +OSChina: [https://gitee.com/winlinvip/srs.oschina][oschina], the GIT usage([CN][v1_CN_Git], [EN][v1_EN_Git]) ``` -git clone https://git.oschina.net/winlinvip/srs.oschina.git +git clone https://gitee.com/winlinvip/srs.oschina.git ``` > Remark: For users in China, recomment to use mirror from CSDN or OSChina, because they are much faster. @@ -1072,7 +1072,7 @@ Winlin [libx264]: http://www.videolan.org/ [srs]: https://github.com/ossrs/srs [csdn]: https://code.csdn.net/winlinvip/srs-csdn -[oschina]: http://git.oschina.net/winlinvip/srs.oschina +[oschina]: https://gitee.com/winlinvip/srs.oschina [srs-dolphin]: https://github.com/ossrs/srs-dolphin [oryx]: https://github.com/ossrs/go-oryx [srs-bench]: https://github.com/ossrs/srs-bench From ef1f6c189e4c90e60a81bae571f3c514ee006dc3 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 2 Dec 2019 16:33:49 +0800 Subject: [PATCH 31/39] Fix the link problem --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 167bffa0c..5185696a3 100755 --- a/README.md +++ b/README.md @@ -794,7 +794,7 @@ The performance benchmark data and corelative commits are listed here. * See also: [Performance for x86/x64 Test Guide][v1_CN_Performance]. * See also: [Performance for RaspberryPi][v1_CN_RaspberryPi]. -* For multiple processes performance, read [#775: REUSEPORT][bug #775] or OriginCluster([CN](v3_EN_OriginCluster)/[EN](v3_EN_OriginCluster)) or [go-oryx][oryx]. +* For multiple processes performance, read [#775: REUSEPORT][bug #775] or OriginCluster([CN][v3_EN_OriginCluster]/[EN][v3_EN_OriginCluster]) or [go-oryx][oryx]. #### Play RTMP benchmark From 1df1485d342a3b998d26e0391bb2c648e5742e4e Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 2 Dec 2019 18:06:02 +0800 Subject: [PATCH 32/39] Update readme about run SRS in docker. --- README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5185696a3..106b5d376 100755 --- a/README.md +++ b/README.md @@ -53,7 +53,9 @@ cd srs/trunk ./configure && make ``` -> Remark: Recommend Centos6 64bits, for other OS recommend [docker][docker], please read wiki([CN][v3_CN_Build],[EN][v3_EN_Build]). +> Remark: Recommend Centos6 64bits, please read wiki([CN][v3_CN_Build],[EN][v3_EN_Build]). + +> Note: You can also build SRS in docker, please read [docker][docker-dev]. Step 3: Run SRS @@ -61,6 +63,12 @@ cd srs/trunk ./objs/srs -c conf/srs.conf ``` +You can also directly run SRS in [docker][docker-srs3]: + +``` +docker run -p 1935:1935 -p 1985:1985 -p 8080:8080 ossrs/srs:3 +``` + From here, strongly recommend to try other main use-scenarios: * Usage: How to delivery RTMP?([CN][v1_CN_SampleRTMP], [EN][v1_EN_SampleRTMP]) @@ -1082,7 +1090,8 @@ Winlin [console]: http://ossrs.net:1985/console [player]: http://ossrs.net:8000/players/srs_player.html [modules]: https://github.com/ossrs/srs/blob/develop/trunk/modules/readme.txt -[docker]: https://github.com/ossrs/srs-docker/tree/dev#usage +[docker-srs3]: https://github.com/ossrs/srs-docker#srs3 +[docker-dev]: https://github.com/ossrs/srs-docker/tree/dev#usage [v1_CN_Git]: https://github.com/ossrs/srs/wiki/v1_CN_Git [v1_EN_Git]: https://github.com/ossrs/srs/wiki/v1_EN_Git From e3488378a423b1b188079e603e2c05244f809074 Mon Sep 17 00:00:00 2001 From: winlin Date: Mon, 2 Dec 2019 18:41:17 +0800 Subject: [PATCH 33/39] Refine the readme, remove download site, recommend use docker --- README.md | 143 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 73 insertions(+), 70 deletions(-) diff --git a/README.md b/README.md index 106b5d376..c44a4e945 100755 --- a/README.md +++ b/README.md @@ -1,44 +1,18 @@ -# Simple-RTMP-Server +# SRS [![](https://circleci.com/gh/ossrs/srs/tree/3.0release.svg?style=svg&circle-token=1ef1d5b5b0cde6c8c282ed856a18199f9e8f85a9)](https://circleci.com/gh/ossrs/srs/tree/3.0release) [![](https://codecov.io/gh/ossrs/srs/branch/3.0release/graph/badge.svg)](https://codecov.io/gh/ossrs/srs/branch/3.0release) [![](https://cloud.githubusercontent.com/assets/2777660/22814959/c51cbe72-ef92-11e6-81cc-32b657b285d5.png)](https://github.com/ossrs/srs/wiki/v1_CN_Contact#wechat) SRS/3.0,[OuXuli][release3],是一个简单的流媒体直播集群,简单的快乐。
-SRS is a simple live streaming cluster, a simple joy. - -Download binaries from github.io: [Centos6-x86_64][centos0], [more...][more0]
-Download binaries from ossrs.net: [Centos6-x86_64][centos1], [more...][more1]
-About the wiki of SRS/3.0, please read [Chinese][srs_CN] or [English][srs_EN]. +SRS(Simple RTMP Server) is a simple live streaming cluster, a simple joy. > Remark: Although SRS is licenced under [MIT][LICENSE], but there are some depended libraries which are distributed using their own licenses, please read [License Mixing][LicenseMixing]. -Enjoy it! - -## Content - -* [Usage](#usage) -* [Wiki](#srs-30-wiki) -* [Features](#features) -* [v3.0 changes](#v3-changes) -* [v2.0 changes](#v2-changes) -* [v1.0 changes](#v1-changes) -* [Releases](#releases) -* [Compare](#compare) -* [Performance](#performance) -* [Architecture](#architecture) -* [System Architecture](#system-architecture) -* [Modularity Architecture](#modularity-architecture) -* [Stream Architecture](#stream-architecture) -* [Authors](#authors) -* [Mirrors](#mirrors) -* [System Requirements](#system-requirements) - +## Usage -### Usage - -Step 1: Get SRS. +**Step 1:** Get SRS. ``` git clone https://github.com/ossrs/srs && @@ -47,7 +21,7 @@ cd srs/trunk > Note: Repository too large? Please clone from these [mirrors](#mirrors) instead. -Step 2: Build SRS. +**Step 2:** Build SRS. ``` ./configure && make @@ -57,19 +31,19 @@ cd srs/trunk > Note: You can also build SRS in docker, please read [docker][docker-dev]. -Step 3: Run SRS +**Step 3:** Run SRS ``` ./objs/srs -c conf/srs.conf ``` -You can also directly run SRS in [docker][docker-srs3]: +**Whatever**, you can also directly run SRS in [docker][docker-srs3]: ``` docker run -p 1935:1935 -p 1985:1985 -p 8080:8080 ossrs/srs:3 ``` -From here, strongly recommend to try other main use-scenarios: +**From here,** strongly recommend to read bellow wikis: * Usage: How to delivery RTMP?([CN][v1_CN_SampleRTMP], [EN][v1_EN_SampleRTMP]) * Usage: How to delivery RTMP Edge Cluster?([CN][v3_CN_SampleRTMPCluster], [EN][v3_EN_SampleRTMPCluster]) @@ -86,14 +60,24 @@ docker run -p 1935:1935 -p 1985:1985 -p 8080:8080 ossrs/srs:3 * Usage: How to publish h.264 raw stream as RTMP? ([CN][v3_CN_SrsLibrtmp2], [EN][v3_EN_SrsLibrtmp2]) * Usage: How to improve edge performance by multiple CPUs? ([CN][v3_CN_REUSEPORT], [EN][v3_EN_REUSEPORT]) * Usage: Why choose SRS? About the milestone and product plan? ([CN][v1_CN_Product], [EN][v1_EN_Product]) +* Usage: How to file bug or chat with us? ([CN][v1_CN_Contact], [EN][v1_EN_Contact]) -### SRS 3.0 wiki + +## Wiki Please select according to languages: -* [SRS 3.0 English][v3_EN_Home] -* [SRS 3.0 Chinese][v3_CN_Home] -### Features +* [SRS 3.0 English Wiki][v3_EN_Home] +* [SRS 3.0 Chinese Wiki][v3_CN_Home] + +For previous versions, please read: + +* [SRS 2.0 English Wiki][v2_EN_Home] +* [SRS 2.0 Chinese Wiki][v2_CN_Home] +* [SRS 1.0 English Wiki][v1_EN_Home] +* [SRS 1.0 Chinese Wiki][v1_CN_Home] + +## Features - [x] Using coroutine by ST, it's really simple and stupid enough. - [x] Support cluster which consists of origin ([CN][v1_CN_DeliveryRTMP],[EN][v1_EN_DeliveryRTMP]) and edge([CN][v3_CN_Edge], [EN][v3_EN_Edge]) server and uses RTMP as default transport protocol. @@ -158,7 +142,7 @@ Please select according to languages: -### V3 changes +## V3 changes * v3.0, 2019-11-30, [3.0 alpha2(3.0.67)][r3.0a3] released. 110864 lines. * v3.0, 2019-12-01, Fix [#1501][bug #1501], use request coworker for origin cluster. 3.0.67 @@ -235,7 +219,7 @@ Please select according to languages: * v3.0, 2015-08-28, fix [#471][bug #471], api response the width and height. 3.0.2 * v3.0, 2015-08-25, fix [#367][bug #367], support nginx-rtmp exec. 3.0.1 -### V2 changes +## V2 changes * v2.0, 2019-11-29, [2.0 release7(2.0.265)][r2.0r7] released. 86994 lines. * v2.0, 2019-11-29, For [srs-docker](https://github.com/ossrs/srs-docker/tree/master/2.0), install Cherrypy without sudo. 2.0.265 @@ -476,7 +460,7 @@ Please select according to languages: * v2.0, 2014-10-18, remove supports for OSX(darwin). 2.0.1. * v2.0, 2014-10-16, revert github srs README to English. 2.0.0. -### V1 changes +## V1 changes * v1.0, 2014-12-05, [1.0 release(1.0.10)][r1.0r0] released. 59391 lines. * v1.0, 2014-10-09, [1.0 beta(1.0.0)][r1.0b0] released. 59316 lines. @@ -666,7 +650,7 @@ Please select according to languages: * v0.1, 2013-10-18, support rtmp message2chunk protocol(send\_message). * v0.1, 2013-10-17, support rtmp chunk2message protocol(recv\_message). -### Releases +## Releases * 2019-11-30, [Release v3.0-a2][r3.0a3], 3.0 alpha2, 3.0.67, 110864 lines. * 2019-11-30, [Release v3.0-a2][r3.0a2], 3.0 alpha2, 3.0.66, 110831 lines. @@ -705,11 +689,12 @@ Please select according to languages: * 2013-10-23, [Release v0.1.0][r0.1], support [rtmp FMLE/FFMPEG publish][v1_CN_DeliveryRTMP], vp6. 8287 lines. * 2013-10-17, Created. -### Compare +## Compare Comparing with other media servers, SRS is much better and stronger, for details please read Product([CN][v1_CN_Compare]/[EN][v1_EN_Compare]). -#### Stream Delivery + +**Stream Delivery** | Feature | SRS | NGINX | CRTMPD | FMS | WOWZA | | ----------- | ------- | ----- | --------- | -------- | ------ | @@ -721,7 +706,8 @@ Comparing with other media servers, SRS is much better and stronger, for details | MPEG-DASH | Experiment| X | X | X | X | | HTTP Server | Stable | Stable | X | X | Stable | -#### Cluster + +**Cluster** | Feature | SRS | NGINX | CRTMPD | FMS | WOWZA | | ----------- | ------- | ----- | --------- | -------- | ------ | @@ -731,8 +717,10 @@ Comparing with other media servers, SRS is much better and stronger, for details | Reload | Stable | X | X | X | X | | Forward | Stable | X | X | X | X | | ATC | Stable | X | X | X | X | +| Docker | Stable | X | X | X | X | -#### Stream Service + +**Stream Service** | Feature | SRS | NGINX | CRTMPD | FMS | WOWZA | | ----------- | ------- | ----- | --------- | -------- | ------ | @@ -748,7 +736,8 @@ Comparing with other media servers, SRS is much better and stronger, for details | Security | Stable | Stable | X | X | Stable | | Token Traverse| Stable | X | X | Stable | X | -#### Efficiency + +**Efficiency** | Feature | SRS | NGINX | CRTMPD | FMS | WOWZA | | ----------- | ------- | ----- | --------- | -------- | ------ | @@ -757,7 +746,8 @@ Comparing with other media servers, SRS is much better and stronger, for details | RTMP Latency| 0.1s | 3s | 3s | 3s | 3s | | HLS Latency | 10s | 30s | X | 30s | 30s | -#### Stream Caster + +**Stream Caster** | Feature | SRS | NGINX | CRTMPD | FMS | WOWZA | | ----------- | ------- | ----- | --------- | -------- | ------ | @@ -766,21 +756,24 @@ Comparing with other media servers, SRS is much better and stronger, for details | Push RTSP | Experiment| X | Stable | X | Stable | | Push HTTP FLV | Experiment| X | X | X | X | -#### Debug System + +**Debug System** | Feature | SRS | NGINX | CRTMPD | FMS | WOWZA | | ----------- | ------- | ----- | --------- | -------- | ------ | | BW check | Stable | X | X | X | X | | Tracable Log | Stable | X | X | X | X | -#### Docs + +**Docs** | Feature | SRS | NGINX | CRTMPD | FMS | WOWZA | | ----------- | ------- | ----- | --------- | -------- | ------ | | Demos | Stable | X | X | X | X | | WIKI(EN+CN) | Stable | EN only | X | X | Stable | -#### Others + +**Others** | Feature | SRS | NGINX | CRTMPD | FMS | WOWZA | | ----------- | ------- | ----- | --------- | -------- | ------ | @@ -796,7 +789,7 @@ Remark: 1. Security: The security includes access control, token authentication and referer check. 1. Reload: SRS and Nginx supports reload, but nginx-rtmp doesn't. -### Performance +## Performance The performance benchmark data and corelative commits are listed here. @@ -804,7 +797,8 @@ The performance benchmark data and corelative commits are listed here. * See also: [Performance for RaspberryPi][v1_CN_RaspberryPi]. * For multiple processes performance, read [#775: REUSEPORT][bug #775] or OriginCluster([CN][v3_EN_OriginCluster]/[EN][v3_EN_OriginCluster]) or [go-oryx][oryx]. -#### Play RTMP benchmark + +**Play RTMP benchmark** The data for playing RTMP was benchmarked by [SB][srs-bench]: @@ -824,7 +818,8 @@ The data for playing RTMP was benchmarked by [SB][srs-bench]: | 2014-12-05 | 2.0.57 | 9.0k(9000) | players | 90% | 468MB | [code][p11] | | 2014-12-07 | 2.0.67 | 10k(10000) | players | 95% | 656MB | [code][p12] | -#### Publish RTMP benchmark + +**Publish RTMP benchmark** The data for publishing RTMP was benchmarked by [SB][srs-bench]: @@ -840,7 +835,8 @@ The data for publishing RTMP was benchmarked by [SB][srs-bench]: | 2014-12-04 | 2.0.51 | 2.5k(2500) | publishers | 91% | 259MB | [code][p4] | | 2014-12-04 | 2.0.52 | 4.0k(4000) | publishers | 80% | 331MB | [code][p5] | -#### Play HTTP FLV benchmark + +**Play HTTP FLV benchmark** The data for playing HTTP FLV was benchmarked by [SB][srs-bench]: @@ -853,7 +849,8 @@ The data for playing HTTP FLV was benchmarked by [SB][srs-bench]: | 2014-05-24 | 2.0.170 | 3.0k(3000) | players | 89% | 96MB | [code][p19] | | 2014-05-25 | 2.0.171 | 6.0k(6000) | players | 84% | 297MB | [code][p20] | -#### Latency benchmark + +**Latency benchmark** The latency between encoder and player with realtime config([CN][v3_CN_LowLatency], [EN][v3_EN_LowLatency]): | @@ -870,7 +867,8 @@ We used FMLE as encoder for benchmark. The latency of server was 0.1s+, and the bottleneck was the encoder. For more information, read [bug #257][bug #257-c0]. -#### HLS overhead + +**HLS overhead** About the overhead of HLS overhead, we compared FFMPEG and SRS. @@ -906,7 +904,7 @@ SRS always use the simplest architecture to solve complex domain problems. * Modularity arch: the main modularity of SRS. * Stream arch: the stream dispatch arch of SRS. -### System Architecture +## System Architecture ``` +------------------------------------------------------+ @@ -924,7 +922,7 @@ SRS always use the simplest architecture to solve complex domain problems. +------------------------------------------------------+ ``` -### Modularity Architecture +## Modularity Architecture ``` +------------------------------------------------------+ @@ -946,7 +944,7 @@ Remark: 1. Modules: SRS supports code-level modularity, read [modules][modules]. -### Stream Architecture +## Stream Architecture ``` +---------+ +----------+ @@ -988,7 +986,7 @@ Remark: 1. Streamer: Remuxs other protocols to RTMP, please read [Streamer][v2_CN_Streamer]. 1. EXEC: Like NGINX-RTMP, EXEC forks external tools for events, please read [ng-exec][v3_CN_NgExec]. -### AUTHORS +## AUTHORS There are two types of people that have contributed to the SRS project: @@ -1008,7 +1006,7 @@ A big THANK YOU goes to: * [FFMPEG][FFMPEG] and [libx264][libx264] group for SRS to use as transcoder. * Guido van Rossum for creating Python for api-server for SRS. -### Mirrors +## Mirrors OSChina: [https://gitee.com/winlinvip/srs.oschina][oschina], the GIT usage([CN][v1_CN_Git], [EN][v1_EN_Git]) @@ -1030,13 +1028,12 @@ Gitlab: [https://gitlab.com/winlinvip/srs-gitlab][gitlab], the GIT usage([CN][v1 git clone https://gitlab.com/winlinvip/srs-gitlab.git ``` -### System Requirements +## System Requirements Supported operating systems and hardware: -* All Linux , both 32 and 64 bits -* Apple OSX(Darwin), both 32 and 64bits. -* All hardwares with x86/x86_64/arm/mips cpu. +* All Linux, both 32 and 64 bits +* Other OS, such as Windows, please use [docker][docker-srs3]. Beijing, 2013.10
Winlin @@ -1129,10 +1126,14 @@ Winlin [v1_EN_Sample]: https://github.com/ossrs/srs/wiki/v1_EN_Sample [v1_CN_Product]: https://github.com/ossrs/srs/wiki/v1_CN_Product [v1_EN_Product]: https://github.com/ossrs/srs/wiki/v1_EN_Product -[v1-wiki-cn]: https://github.com/ossrs/srs/wiki/v1-wiki-cn -[v1-wiki-en]: https://github.com/ossrs/srs/wiki/v1-wiki-en -[v2-wiki-cn]: https://github.com/ossrs/srs/wiki/v2-wiki-cn -[v2-wiki-en]: https://github.com/ossrs/srs/wiki/v2-wiki-en +[v1-wiki-cn]: https://github.com/ossrs/srs/wiki/v1_CN_Home +[v1-wiki-en]: https://github.com/ossrs/srs/wiki/v1_EN_Home +[v2-wiki-cn]: https://github.com/ossrs/srs/wiki/v2_CN_Home +[v2-wiki-en]: https://github.com/ossrs/srs/wiki/v2_EN_Home +[v1_CN_Home]: https://github.com/ossrs/srs/wiki/v1_CN_Home +[v1_EN_Home]: https://github.com/ossrs/srs/wiki/v1_EN_Home +[v2_CN_Home]: https://github.com/ossrs/srs/wiki/v2_CN_Home +[v2_EN_Home]: https://github.com/ossrs/srs/wiki/v2_EN_Home [v3_CN_Home]: https://github.com/ossrs/srs/wiki/v3_CN_Home [v3_EN_Home]: https://github.com/ossrs/srs/wiki/v3_EN_Home [donation0]: http://winlinvip.github.io/srs.release/donation/index.html @@ -1557,6 +1558,8 @@ Winlin [contact]: https://github.com/ossrs/srs/wiki/v1_CN_Contact +[v1_CN_Contact]: https://github.com/ossrs/srs/wiki/v1_CN_Contact +[v1_EN_Contact]: https://github.com/ossrs/srs/wiki/v1_EN_Contact [more0]: http://winlinvip.github.io/srs.release/releases/ [more1]: http://ossrs.net:8000/srs.release/releases/ From 643d06473fa8eec0e071141ca5500e963b96c685 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 3 Dec 2019 10:18:13 +0800 Subject: [PATCH 34/39] Refine player with statistics. --- trunk/research/players/index.html | 1 + trunk/research/players/jwplayer6.html | 1 + trunk/research/players/osmf.html | 1 + trunk/research/players/srs_bwt.html | 1 + trunk/research/players/srs_chat.html | 1 + trunk/research/players/srs_player.html | 1 + trunk/research/players/srs_publisher.html | 1 + trunk/research/players/vlc.html | 1 + 8 files changed, 8 insertions(+) diff --git a/trunk/research/players/index.html b/trunk/research/players/index.html index 2068f2631..4428aa57c 100644 --- a/trunk/research/players/index.html +++ b/trunk/research/players/index.html @@ -11,6 +11,7 @@ +