winlin

drop script data except the onMetaData packet.

@@ -276,6 +276,13 @@ int main(int argc, char** argv) @@ -276,6 +276,13 @@ int main(int argc, char** argv)
276 int is_flv_msg = type == SRS_RTMP_TYPE_AUDIO 276 int is_flv_msg = type == SRS_RTMP_TYPE_AUDIO
277 || type == SRS_RTMP_TYPE_VIDEO || type == SRS_RTMP_TYPE_SCRIPT; 277 || type == SRS_RTMP_TYPE_VIDEO || type == SRS_RTMP_TYPE_SCRIPT;
278 278
  279 + // for script data, ignore except onMetaData
  280 + if (type == SRS_RTMP_TYPE_SCRIPT) {
  281 + if (!srs_rtmp_is_onMetaData(type, data, size)) {
  282 + is_flv_msg = 0;
  283 + }
  284 + }
  285 +
279 if (flv) { 286 if (flv) {
280 if (is_flv_msg) { 287 if (is_flv_msg) {
281 if (srs_flv_write_tag(flv, type, timestamp, data, size) != 0) { 288 if (srs_flv_write_tag(flv, type, timestamp, data, size) != 0) {
@@ -1064,6 +1064,31 @@ int srs_rtmp_write_packet(srs_rtmp_t rtmp, char type, u_int32_t timestamp, char* @@ -1064,6 +1064,31 @@ int srs_rtmp_write_packet(srs_rtmp_t rtmp, char type, u_int32_t timestamp, char*
1064 return ret; 1064 return ret;
1065 } 1065 }
1066 1066
  1067 +srs_bool srs_rtmp_is_onMetaData(char type, char* data, int size)
  1068 +{
  1069 + int ret = ERROR_SUCCESS;
  1070 +
  1071 + if (type != SRS_RTMP_TYPE_SCRIPT) {
  1072 + return false;
  1073 + }
  1074 +
  1075 + SrsStream stream;
  1076 + if ((ret = stream.initialize(data, size)) != ERROR_SUCCESS) {
  1077 + return false;
  1078 + }
  1079 +
  1080 + std::string name;
  1081 + if ((ret = srs_amf0_read_string(&stream, name)) != ERROR_SUCCESS) {
  1082 + return false;
  1083 + }
  1084 +
  1085 + if (name != "onMetaData") {
  1086 + return false;
  1087 + }
  1088 +
  1089 + return true;
  1090 +}
  1091 +
1067 /** 1092 /**
1068 * directly write a audio frame. 1093 * directly write a audio frame.
1069 */ 1094 */
@@ -264,6 +264,11 @@ extern int srs_rtmp_write_packet(srs_rtmp_t rtmp, @@ -264,6 +264,11 @@ extern int srs_rtmp_write_packet(srs_rtmp_t rtmp,
264 char type, u_int32_t timestamp, char* data, int size 264 char type, u_int32_t timestamp, char* data, int size
265 ); 265 );
266 266
  267 +/**
  268 +* whether type is script data and the data is onMetaData.
  269 +*/
  270 +extern srs_bool srs_rtmp_is_onMetaData(char type, char* data, int size);
  271 +
267 /************************************************************* 272 /*************************************************************
268 ************************************************************** 273 **************************************************************
269 * audio raw codec 274 * audio raw codec