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:
parent
cc22ca4890
commit
04aa6f8296
3 changed files with 37 additions and 0 deletions
|
@ -276,6 +276,13 @@ int main(int argc, char** argv)
|
|||
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) {
|
||||
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*
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue