Commit 54194fe5 by 夏楚 Committed by GitHub

兼容不规范的rtmp推流器 (#2417 #2715)

有些rtmp推流器在服务器返回鉴权成功前就开启推送流数据
parent 5464313b
......@@ -536,7 +536,14 @@ void RtmpSession::onRtmpChunk(RtmpPacket::Ptr packet) {
case MSG_AUDIO:
case MSG_VIDEO: {
if (!_push_src) {
WarnL << "Not a rtmp push!";
if (_ring_reader) {
throw std::runtime_error("Rtmp player send media packets");
}
if (packet->isConfigFrame()) {
auto id = packet->type_id;
_push_config_packets.emplace(id, std::move(packet));
}
WarnL << "Rtmp pusher send media packet before handshake completed!";
return;
}
......@@ -544,6 +551,12 @@ void RtmpSession::onRtmpChunk(RtmpPacket::Ptr packet) {
_set_meta_data = true;
_push_src->setMetaData(_push_metadata ? _push_metadata : TitleMeta().getMetadata());
}
if (!_push_config_packets.empty()) {
for (auto &pr : _push_config_packets) {
_push_src->onWrite(std::move(pr.second));
}
_push_config_packets.clear();
}
_push_src->onWrite(std::move(packet));
break;
}
......
......@@ -97,6 +97,7 @@ private:
MediaInfo _media_info;
std::weak_ptr<RtmpMediaSource> _play_src;
AMFValue _push_metadata;
std::map<uint8_t, RtmpPacket::Ptr> _push_config_packets;
RtmpMediaSourceImp::Ptr _push_src;
std::shared_ptr<void> _push_src_ownership;
RtmpMediaSource::RingType::RingReader::Ptr _ring_reader;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论