Commit 30b63ad6 by ziyue

Rtmp: rtmp分发改成绝对时间戳

parent b749cfb8
...@@ -248,22 +248,12 @@ void RtmpSession::sendPlayResponse(const string &err,const RtmpMediaSource::Ptr ...@@ -248,22 +248,12 @@ void RtmpSession::sendPlayResponse(const string &err,const RtmpMediaSource::Ptr
invoke.clear(); invoke.clear();
invoke << "onMetaData" << metadata; invoke << "onMetaData" << metadata;
sendResponse(MSG_DATA, invoke.data()); sendResponse(MSG_DATA, invoke.data());
auto duration = metadata["duration"];
if(duration && duration.as_number() > 0){
//这是点播,使用绝对时间戳
_stamp[0].setPlayBack();
_stamp[1].setPlayBack();
} }
}
src->getConfigFrame([&](const RtmpPacket::Ptr &pkt) { src->getConfigFrame([&](const RtmpPacket::Ptr &pkt) {
//DebugP(this)<<"send initial frame";
onSendMedia(pkt); onSendMedia(pkt);
}); });
//音频同步于视频
_stamp[0].syncTo(_stamp[1]);
src->pause(false); src->pause(false);
_ring_reader = src->getRing()->attach(getPoller()); _ring_reader = src->getRing()->attach(getPoller());
weak_ptr<RtmpSession> weakSelf = dynamic_pointer_cast<RtmpSession>(shared_from_this()); weak_ptr<RtmpSession> weakSelf = dynamic_pointer_cast<RtmpSession>(shared_from_this());
...@@ -532,13 +522,9 @@ void RtmpSession::onCmd_seek(AMFDecoder &dec) { ...@@ -532,13 +522,9 @@ void RtmpSession::onCmd_seek(AMFDecoder &dec) {
} }
void RtmpSession::onSendMedia(const RtmpPacket::Ptr &pkt) { void RtmpSession::onSendMedia(const RtmpPacket::Ptr &pkt) {
//rtmp播放器时间戳从零开始 sendRtmp(pkt->type_id, pkt->stream_index, pkt, pkt->time_stamp, pkt->chunk_id);
int64_t dts_out;
_stamp[pkt->type_id % 2].revise(pkt->time_stamp, 0, dts_out, dts_out);
sendRtmp(pkt->type_id, pkt->stream_index, pkt, (uint32_t)dts_out, pkt->chunk_id);
} }
bool RtmpSession::close(MediaSource &sender,bool force) { bool RtmpSession::close(MediaSource &sender,bool force) {
//此回调在其他线程触发 //此回调在其他线程触发
if(!_publisher_src || (!force && _publisher_src->totalReaderCount())){ if(!_publisher_src || (!force && _publisher_src->totalReaderCount())){
......
...@@ -91,9 +91,8 @@ private: ...@@ -91,9 +91,8 @@ private:
double _recv_req_id = 0; double _recv_req_id = 0;
//消耗的总流量 //消耗的总流量
uint64_t _total_bytes = 0; uint64_t _total_bytes = 0;
std::string _tc_url; std::string _tc_url;
//时间戳修整器 //推流时间戳修整器
Stamp _stamp[2]; Stamp _stamp[2];
//数据接收超时计时器 //数据接收超时计时器
Ticker _ticker; Ticker _ticker;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论