Commit e7fc22ad by xiongziliang

初步支持聚合包

parent d5d03ce9
...@@ -57,7 +57,7 @@ protected: ...@@ -57,7 +57,7 @@ protected:
virtual void onMediaData(const RtmpPacket::Ptr &chunkData) =0; virtual void onMediaData(const RtmpPacket::Ptr &chunkData) =0;
uint32_t getProgressMilliSecond() const; uint32_t getProgressMilliSecond() const;
void seekToMilliSecond(uint32_t ms); void seekToMilliSecond(uint32_t ms);
private: protected:
void _onShutdown(const SockException &ex) { void _onShutdown(const SockException &ex) {
WarnL << ex.getErrCode() << " " << ex.what(); WarnL << ex.getErrCode() << " " << ex.what();
_pPlayTimer.reset(); _pPlayTimer.reset();
......
...@@ -72,7 +72,8 @@ private: ...@@ -72,7 +72,8 @@ private:
} }
if(!_parser){ if(!_parser){
_parser.reset(new RtmpDemuxer()); _parser.reset(new RtmpDemuxer());
} _onPlayResult(SockException(Err_success,"play rtmp success"));
}
_parser->inputRtmp(chunkData); _parser->inputRtmp(chunkData);
checkInited(); checkInited();
} }
......
...@@ -677,8 +677,61 @@ void RtmpProtocol::handle_rtmpChunk(RtmpPacket& chunkData) { ...@@ -677,8 +677,61 @@ void RtmpProtocol::handle_rtmpChunk(RtmpPacket& chunkData) {
TraceL << "MSG_SET_PEER_BW:" << _ui32WinSize; TraceL << "MSG_SET_PEER_BW:" << _ui32WinSize;
} }
break; break;
case MSG_AGGREGATE: case MSG_AGGREGATE: {
throw std::runtime_error("streaming FLV not supported"); auto ptr = (uint8_t*)chunkData.strBuf.data();
auto ptr_tail = (uint8_t*)&chunkData.strBuf.back();
while(ptr < ptr_tail - 8 - 3){
auto type = *ptr;
ptr += 1;
auto size = load_be24(ptr);
ptr += 3;
auto ts = load_be24(ptr);
ptr += 3;
ts |= (*ptr << 24);
ptr += 1;
//参考ffmpeg忽略了3个字节
/**
* while (next - pkt->data < pkt->size - RTMP_HEADER) {
type = bytestream_get_byte(&next);
size = bytestream_get_be24(&next);
cts = bytestream_get_be24(&next);
cts |= bytestream_get_byte(&next) << 24;
if (!pts)
pts = cts;
ts += cts - pts;
pts = cts;
if (size + 3 + 4 > pkt->data + pkt->size - next)
break;
bytestream_put_byte(&p, type);
bytestream_put_be24(&p, size);
bytestream_put_be24(&p, ts);
bytestream_put_byte(&p, ts >> 24);
memcpy(p, next, size + 3 + 4);
p += size + 3;
bytestream_put_be32(&p, size + RTMP_HEADER);
next += size + 3 + 4;
}
*/
ptr += 3;
//参考FFmpeg多拷贝了4个字节
size += 4;
if(ptr + size > ptr_tail){
break;
}
// DebugL << (int)type << " " << size << " " << ts << " " << hexdump(ptr,size > 32 ? 32 : size);
RtmpPacket sub_packet ;
sub_packet.strBuf.resize(size);
memcpy((char *)sub_packet.strBuf.data(),ptr,size);
sub_packet.typeId = type;
sub_packet.bodySize = size;
sub_packet.timeStamp = ts;
sub_packet.streamId = chunkData.streamId;
sub_packet.chunkId = chunkData.chunkId;
handle_rtmpChunk(sub_packet);
ptr += size;
}
}
break; break;
default: default:
onRtmpChunk(chunkData); onRtmpChunk(chunkData);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论