fix #98: workaround for librtmp ping(fmt=1,cid=2 fresh stream).
正在显示
3 个修改的文件
包含
19 行增加
和
5 行删除
| @@ -231,6 +231,7 @@ Supported operating systems and hardware: | @@ -231,6 +231,7 @@ Supported operating systems and hardware: | ||
| 231 | * 2013-10-17, Created.<br/> | 231 | * 2013-10-17, Created.<br/> |
| 232 | 232 | ||
| 233 | ## History | 233 | ## History |
| 234 | +* v1.0, 2014-06-14, fix [#98](https://github.com/winlinvip/simple-rtmp-server/issues/98), workaround for librtmp ping(fmt=1,cid=2 fresh stream). 0.9.124 | ||
| 234 | * v1.0, 2014-05-29, support flv inject and flv http streaming with start=bytes. 0.9.122 | 235 | * v1.0, 2014-05-29, support flv inject and flv http streaming with start=bytes. 0.9.122 |
| 235 | * <strong>v1.0, 2014-05-28, [1.0 mainline4(0.9.120)](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0.mainline4) released. 39200 lines.</strong> | 236 | * <strong>v1.0, 2014-05-28, [1.0 mainline4(0.9.120)](https://github.com/winlinvip/simple-rtmp-server/releases/tag/1.0.mainline4) released. 39200 lines.</strong> |
| 236 | * v1.0, 2014-05-27, fix [#87](https://github.com/winlinvip/simple-rtmp-server/issues/87), add source id for full trackable log. 0.9.120 | 237 | * v1.0, 2014-05-27, fix [#87](https://github.com/winlinvip/simple-rtmp-server/issues/87), add source id for full trackable log. 0.9.120 |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR "0" | 32 | #define VERSION_MAJOR "0" |
| 33 | #define VERSION_MINOR "9" | 33 | #define VERSION_MINOR "9" |
| 34 | -#define VERSION_REVISION "123" | 34 | +#define VERSION_REVISION "124" |
| 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION | 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION |
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
| @@ -954,10 +954,23 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz | @@ -954,10 +954,23 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz | ||
| 954 | // but, we can ensure that when a chunk stream is fresh, | 954 | // but, we can ensure that when a chunk stream is fresh, |
| 955 | // the fmt must be 0, a new stream. | 955 | // the fmt must be 0, a new stream. |
| 956 | if (chunk->msg_count == 0 && fmt != RTMP_FMT_TYPE0) { | 956 | if (chunk->msg_count == 0 && fmt != RTMP_FMT_TYPE0) { |
| 957 | - ret = ERROR_RTMP_CHUNK_START; | ||
| 958 | - srs_error("chunk stream is fresh, fmt must be %d, actual is %d. cid=%d, ret=%d", | ||
| 959 | - RTMP_FMT_TYPE0, fmt, chunk->cid, ret); | ||
| 960 | - return ret; | 957 | + // for librtmp, if ping, it will send a fresh stream with fmt=1, |
| 958 | + // 0x42 where: fmt=1, cid=2, protocol contorl user-control message | ||
| 959 | + // 0x00 0x00 0x00 where: timestamp=0 | ||
| 960 | + // 0x00 0x00 0x06 where: payload_length=6 | ||
| 961 | + // 0x04 where: message_type=4(protocol control user-control message) | ||
| 962 | + // 0x00 0x06 where: event Ping(0x06) | ||
| 963 | + // 0x00 0x00 0x0d 0x0f where: event data 4bytes ping timestamp. | ||
| 964 | + // @see: https://github.com/winlinvip/simple-rtmp-server/issues/98 | ||
| 965 | + if (chunk->cid == RTMP_CID_ProtocolControl && fmt == RTMP_FMT_TYPE1) { | ||
| 966 | + srs_warn("accept cid=2, fmt=1 to make librtmp happy."); | ||
| 967 | + } else { | ||
| 968 | + // must be a RTMP protocol level error. | ||
| 969 | + ret = ERROR_RTMP_CHUNK_START; | ||
| 970 | + srs_error("chunk stream is fresh, fmt must be %d, actual is %d. cid=%d, ret=%d", | ||
| 971 | + RTMP_FMT_TYPE0, fmt, chunk->cid, ret); | ||
| 972 | + return ret; | ||
| 973 | + } | ||
| 961 | } | 974 | } |
| 962 | 975 | ||
| 963 | // when exists cache msg, means got an partial message, | 976 | // when exists cache msg, means got an partial message, |
-
请 注册 或 登录 后发表评论