winlin

drop script data except the onMetaData packet.

... ... @@ -275,6 +275,13 @@ int main(int argc, char** argv)
// we only write some types of messages to flv file.
int is_flv_msg = type == SRS_RTMP_TYPE_AUDIO
|| type == SRS_RTMP_TYPE_VIDEO || type == SRS_RTMP_TYPE_SCRIPT;
// for script data, ignore except onMetaData
if (type == SRS_RTMP_TYPE_SCRIPT) {
if (!srs_rtmp_is_onMetaData(type, data, size)) {
is_flv_msg = 0;
}
}
if (flv) {
if (is_flv_msg) {
... ...
... ... @@ -1064,6 +1064,31 @@ int srs_rtmp_write_packet(srs_rtmp_t rtmp, char type, u_int32_t timestamp, char*
return ret;
}
srs_bool srs_rtmp_is_onMetaData(char type, char* data, int size)
{
int ret = ERROR_SUCCESS;
if (type != SRS_RTMP_TYPE_SCRIPT) {
return false;
}
SrsStream stream;
if ((ret = stream.initialize(data, size)) != ERROR_SUCCESS) {
return false;
}
std::string name;
if ((ret = srs_amf0_read_string(&stream, name)) != ERROR_SUCCESS) {
return false;
}
if (name != "onMetaData") {
return false;
}
return true;
}
/**
* directly write a audio frame.
*/
... ...
... ... @@ -264,6 +264,11 @@ extern int srs_rtmp_write_packet(srs_rtmp_t rtmp,
char type, u_int32_t timestamp, char* data, int size
);
/**
* whether type is script data and the data is onMetaData.
*/
extern srs_bool srs_rtmp_is_onMetaData(char type, char* data, int size);
/*************************************************************
**************************************************************
* audio raw codec
... ...