Commit 19d6f1a0 by xiongguangjie Committed by GitHub

FLV player avoid script data first element not string (#2679 #2680)

兼容不规范的flv流,比如livegbs产生的flv流metadata flv tag解析异常
parent a31108cc
...@@ -91,10 +91,12 @@ void FlvSplitter::onRecvContent(const char *data, size_t len) { ...@@ -91,10 +91,12 @@ void FlvSplitter::onRecvContent(const char *data, size_t len) {
case MSG_DATA3: { case MSG_DATA3: {
BufferLikeString buffer(string(data, len)); BufferLikeString buffer(string(data, len));
AMFDecoder dec(buffer, _type == MSG_DATA3 ? 3 : 0); AMFDecoder dec(buffer, _type == MSG_DATA3 ? 3 : 0);
std::string type = dec.load<std::string>(); auto first = dec.load<AMFValue>();
bool flag = true; bool flag = true;
if (first.type() == AMFType::AMF_STRING) {
auto type = first.as_string();
if (type == "@setDataFrame") { if (type == "@setDataFrame") {
std::string type = dec.load<std::string>(); type = dec.load<std::string>();
if (type == "onMetaData") { if (type == "onMetaData") {
flag = onRecvMetadata(dec.load<AMFValue>()); flag = onRecvMetadata(dec.load<AMFValue>());
} else { } else {
...@@ -105,7 +107,10 @@ void FlvSplitter::onRecvContent(const char *data, size_t len) { ...@@ -105,7 +107,10 @@ void FlvSplitter::onRecvContent(const char *data, size_t len) {
} else { } else {
WarnL << "unknown notify:" << type; WarnL << "unknown notify:" << type;
} }
if(!flag){ } else {
WarnL << "Parse flv script data failed, invalid amf value: " << first.to_string();
}
if (!flag) {
throw std::invalid_argument("check rtmp metadata failed"); throw std::invalid_argument("check rtmp metadata failed");
} }
return; return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论