winlin

ignore the unknown flv tag.

@@ -127,6 +127,12 @@ int proxy(srs_rtmp_t irtmp, srs_rtmp_t ortmp) @@ -127,6 +127,12 @@ int proxy(srs_rtmp_t irtmp, srs_rtmp_t ortmp)
127 return ret; 127 return ret;
128 } 128 }
129 129
  130 + if (!srs_utils_flv_tag_is_ok(type)) {
  131 + srs_human_trace("ignore invalid flv tag=%d, dts=%d, %d bytes", type, timestamp, size);
  132 + free(data);
  133 + continue;
  134 + }
  135 +
130 if ((ret = srs_human_print_rtmp_packet(type, timestamp, data, size)) != 0) { 136 if ((ret = srs_human_print_rtmp_packet(type, timestamp, data, size)) != 0) {
131 srs_human_trace("print packet failed. ret=%d", ret); 137 srs_human_trace("print packet failed. ret=%d", ret);
132 return ret; 138 return ret;
@@ -1973,6 +1973,11 @@ int srs_utils_parse_timestamp( @@ -1973,6 +1973,11 @@ int srs_utils_parse_timestamp(
1973 1973
1974 return ret; 1974 return ret;
1975 } 1975 }
  1976 +
  1977 +srs_bool srs_utils_flv_tag_is_ok(char type)
  1978 +{
  1979 + return type == SRS_RTMP_TYPE_AUDIO || type == SRS_RTMP_TYPE_VIDEO || type == SRS_RTMP_TYPE_SCRIPT;
  1980 +}
1976 1981
1977 char srs_utils_flv_video_codec_id(char* data, int size) 1982 char srs_utils_flv_video_codec_id(char* data, int size)
1978 { 1983 {
@@ -2324,7 +2329,7 @@ int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int @@ -2324,7 +2329,7 @@ int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int
2324 ); 2329 );
2325 } else if (type == SRS_RTMP_TYPE_SCRIPT) { 2330 } else if (type == SRS_RTMP_TYPE_SCRIPT) {
2326 srs_human_verbose("Data packet type=%s, time=%d, size=%d", 2331 srs_human_verbose("Data packet type=%s, time=%d, size=%d",
2327 - srs_human_flv_tag_type2string(type), timestamp, size); 2332 + srs_human_flv_tag_type2string(type), timestamp, size);
2328 int nparsed = 0; 2333 int nparsed = 0;
2329 while (nparsed < size) { 2334 while (nparsed < size) {
2330 int nb_parsed_this = 0; 2335 int nb_parsed_this = 0;
@@ -2332,7 +2337,7 @@ int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int @@ -2332,7 +2337,7 @@ int srs_human_print_rtmp_packet(char type, u_int32_t timestamp, char* data, int
2332 if (amf0 == NULL) { 2337 if (amf0 == NULL) {
2333 break; 2338 break;
2334 } 2339 }
2335 - 2340 +
2336 nparsed += nb_parsed_this; 2341 nparsed += nb_parsed_this;
2337 2342
2338 char* amf0_str = NULL; 2343 char* amf0_str = NULL;
@@ -655,6 +655,12 @@ extern int srs_utils_parse_timestamp( @@ -655,6 +655,12 @@ extern int srs_utils_parse_timestamp(
655 u_int32_t time, char type, char* data, int size, 655 u_int32_t time, char type, char* data, int size,
656 u_int32_t* ppts 656 u_int32_t* ppts
657 ); 657 );
  658 +
  659 +/**
  660 + * whether the flv tag specified by param type is ok.
  661 + * @return true when tag is video/audio/script-data; otherwise, false.
  662 + */
  663 +extern srs_bool srs_utils_flv_tag_is_ok(char type);
658 664
659 /** 665 /**
660 * get the CodecID of video tag. 666 * get the CodecID of video tag.