1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

drop script data except the onMetaData packet.

This commit is contained in:
winlin 2015-01-17 13:23:30 +08:00
parent cc22ca4890
commit 04aa6f8296
3 changed files with 37 additions and 0 deletions

View file

@ -275,6 +275,13 @@ int main(int argc, char** argv)
// we only write some types of messages to flv file. // we only write some types of messages to flv file.
int is_flv_msg = type == SRS_RTMP_TYPE_AUDIO int is_flv_msg = type == SRS_RTMP_TYPE_AUDIO
|| type == SRS_RTMP_TYPE_VIDEO || type == SRS_RTMP_TYPE_SCRIPT; || 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 (flv) {
if (is_flv_msg) { if (is_flv_msg) {

View file

@ -1064,6 +1064,31 @@ int srs_rtmp_write_packet(srs_rtmp_t rtmp, char type, u_int32_t timestamp, char*
return ret; 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. * directly write a audio frame.
*/ */

View file

@ -264,6 +264,11 @@ extern int srs_rtmp_write_packet(srs_rtmp_t rtmp,
char type, u_int32_t timestamp, char* data, int size 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 * audio raw codec