正在显示
4 个修改的文件
包含
42 行增加
和
1 行删除
| @@ -344,7 +344,8 @@ Remark: | @@ -344,7 +344,8 @@ Remark: | ||
| 344 | 344 | ||
| 345 | ### SRS 2.0 history | 345 | ### SRS 2.0 history |
| 346 | 346 | ||
| 347 | -* v2.0, 2015-05-30, fix [#420](https://github.com/simple-rtmp-server/srs/issues/420) remove ts for hls ram mode. | 347 | +* v2.0, 2015-06-06, fix [#421](https://github.com/simple-rtmp-server/srs/issues/421) drop video for unkown RTMP header. |
| 348 | +* v2.0, 2015-06-05, fix [#420](https://github.com/simple-rtmp-server/srs/issues/420) remove ts for hls ram mode. | ||
| 348 | * v2.0, 2015-05-30, fix [#209](https://github.com/simple-rtmp-server/srs/issues/209) cleanup hls when stop and timeout. 2.0.173. | 349 | * v2.0, 2015-05-30, fix [#209](https://github.com/simple-rtmp-server/srs/issues/209) cleanup hls when stop and timeout. 2.0.173. |
| 349 | * v2.0, 2015-05-29, fix [#409](https://github.com/simple-rtmp-server/srs/issues/409) support pure video hls. 2.0.172. | 350 | * v2.0, 2015-05-29, fix [#409](https://github.com/simple-rtmp-server/srs/issues/409) support pure video hls. 2.0.172. |
| 350 | * v2.0, 2015-05-28, support [srs-dolphin][srs-dolphin], the multiple-process SRS. | 351 | * v2.0, 2015-05-28, support [srs-dolphin][srs-dolphin], the multiple-process SRS. |
| @@ -1633,6 +1633,18 @@ int SrsSource::on_video(SrsCommonMessage* shared_video) | @@ -1633,6 +1633,18 @@ int SrsSource::on_video(SrsCommonMessage* shared_video) | ||
| 1633 | { | 1633 | { |
| 1634 | int ret = ERROR_SUCCESS; | 1634 | int ret = ERROR_SUCCESS; |
| 1635 | 1635 | ||
| 1636 | + // drop any unknown header video. | ||
| 1637 | + // @see https://github.com/simple-rtmp-server/srs/issues/421 | ||
| 1638 | + if (!SrsFlvCodec::video_is_acceptable(shared_video->payload, shared_video->size)) { | ||
| 1639 | + char b0 = 0x00; | ||
| 1640 | + if (shared_video->size > 0) { | ||
| 1641 | + b0 = shared_video->payload[0]; | ||
| 1642 | + } | ||
| 1643 | + | ||
| 1644 | + srs_warn("drop unknown header video, size=%d, bytes[0]=%#x", shared_video->size, b0); | ||
| 1645 | + return ret; | ||
| 1646 | + } | ||
| 1647 | + | ||
| 1636 | // convert shared_video to msg, user should not use shared_video again. | 1648 | // convert shared_video to msg, user should not use shared_video again. |
| 1637 | // the payload is transfer to msg, and set to NULL in shared_video. | 1649 | // the payload is transfer to msg, and set to NULL in shared_video. |
| 1638 | SrsSharedPtrMessage msg; | 1650 | SrsSharedPtrMessage msg; |
| @@ -266,6 +266,28 @@ bool SrsFlvCodec::audio_is_aac(char* data, int size) | @@ -266,6 +266,28 @@ bool SrsFlvCodec::audio_is_aac(char* data, int size) | ||
| 266 | return sound_format == SrsCodecAudioAAC; | 266 | return sound_format == SrsCodecAudioAAC; |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | +bool SrsFlvCodec::video_is_acceptable(char* data, int size) | ||
| 270 | +{ | ||
| 271 | + // 1bytes required. | ||
| 272 | + if (size < 1) { | ||
| 273 | + return false; | ||
| 274 | + } | ||
| 275 | + | ||
| 276 | + char frame_type = data[0]; | ||
| 277 | + char codec_id = frame_type & 0x0f; | ||
| 278 | + frame_type = (frame_type >> 4) & 0x0f; | ||
| 279 | + | ||
| 280 | + if (frame_type < 1 || frame_type > 5) { | ||
| 281 | + return false; | ||
| 282 | + } | ||
| 283 | + | ||
| 284 | + if (codec_id < 2 || codec_id > 7) { | ||
| 285 | + return false; | ||
| 286 | + } | ||
| 287 | + | ||
| 288 | + return true; | ||
| 289 | +} | ||
| 290 | + | ||
| 269 | string srs_codec_avc_nalu2str(SrsAvcNaluType nalu_type) | 291 | string srs_codec_avc_nalu2str(SrsAvcNaluType nalu_type) |
| 270 | { | 292 | { |
| 271 | switch (nalu_type) { | 293 | switch (nalu_type) { |
| @@ -222,6 +222,12 @@ public: | @@ -222,6 +222,12 @@ public: | ||
| 222 | * check codec aac. | 222 | * check codec aac. |
| 223 | */ | 223 | */ |
| 224 | static bool audio_is_aac(char* data, int size); | 224 | static bool audio_is_aac(char* data, int size); |
| 225 | + /** | ||
| 226 | + * check the video RTMP/flv header info, | ||
| 227 | + * @return true if video RTMP/flv header is ok. | ||
| 228 | + * @remark all type of audio is possible, no need to check audio. | ||
| 229 | + */ | ||
| 230 | + static bool video_is_acceptable(char* data, int size); | ||
| 225 | }; | 231 | }; |
| 226 | 232 | ||
| 227 | /** | 233 | /** |
-
请 注册 或 登录 后发表评论