mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-06 11:38:11 +08:00
实现媒体源pause/speed接口:#1129
This commit is contained in:
@@ -36,6 +36,7 @@ void FlvMuxer::start(const EventPoller::Ptr &poller, const RtmpMediaSource::Ptr
|
||||
onWriteFlvHeader(media);
|
||||
|
||||
std::weak_ptr<FlvMuxer> weakSelf = getSharedPtr();
|
||||
media->pause(false);
|
||||
_ring_reader = media->getRing()->attach(poller);
|
||||
_ring_reader->setDetachCB([weakSelf]() {
|
||||
auto strongSelf = weakSelf.lock();
|
||||
|
||||
@@ -204,6 +204,7 @@ inline void RtmpPusher::send_metaData(){
|
||||
sendRtmp(pkt->type_id, _stream_index, pkt, pkt->time_stamp, pkt->chunk_id);
|
||||
});
|
||||
|
||||
src->pause(false);
|
||||
_rtmp_reader = src->getRing()->attach(getPoller());
|
||||
weak_ptr<RtmpPusher> weak_self = dynamic_pointer_cast<RtmpPusher>(shared_from_this());
|
||||
_rtmp_reader->setReadCB([weak_self](const RtmpMediaSource::RingDataType &pkt) {
|
||||
|
||||
@@ -268,6 +268,7 @@ void RtmpSession::sendPlayResponse(const string &err,const RtmpMediaSource::Ptr
|
||||
|
||||
//音频同步于视频
|
||||
_stamp[0].syncTo(_stamp[1]);
|
||||
src->pause(false);
|
||||
_ring_reader = src->getRing()->attach(getPoller());
|
||||
weak_ptr<RtmpSession> weakSelf = dynamic_pointer_cast<RtmpSession>(shared_from_this());
|
||||
_ring_reader->setReadCB([weakSelf](const RtmpMediaSource::RingDataType &pkt) {
|
||||
@@ -275,9 +276,6 @@ void RtmpSession::sendPlayResponse(const string &err,const RtmpMediaSource::Ptr
|
||||
if (!strongSelf) {
|
||||
return;
|
||||
}
|
||||
if(strongSelf->_paused){
|
||||
return;
|
||||
}
|
||||
size_t i = 0;
|
||||
auto size = pkt->size();
|
||||
strongSelf->setSendFlushFlag(false);
|
||||
@@ -295,10 +293,8 @@ void RtmpSession::sendPlayResponse(const string &err,const RtmpMediaSource::Ptr
|
||||
}
|
||||
strongSelf->shutdown(SockException(Err_shutdown,"rtmp ring buffer detached"));
|
||||
});
|
||||
src->pause(false);
|
||||
_player_src = src;
|
||||
if (src->totalReaderCount() == 1) {
|
||||
src->seekTo(0);
|
||||
}
|
||||
//提高服务器发送性能
|
||||
setSocketFlags();
|
||||
}
|
||||
@@ -411,8 +407,6 @@ void RtmpSession::onCmd_pause(AMFDecoder &dec) {
|
||||
sendReply("onStatus", nullptr, status);
|
||||
//streamBegin
|
||||
sendUserControl(paused ? CONTROL_STREAM_EOF : CONTROL_STREAM_BEGIN, STREAM_MEDIA);
|
||||
_paused = paused;
|
||||
|
||||
auto strongSrc = _player_src.lock();
|
||||
if (strongSrc) {
|
||||
strongSrc->pause(paused);
|
||||
|
||||
@@ -87,7 +87,6 @@ private:
|
||||
void dumpMetadata(const AMFValue &metadata);
|
||||
|
||||
private:
|
||||
bool _paused = false;
|
||||
bool _set_meta_data = false;
|
||||
double _recv_req_id = 0;
|
||||
//消耗的总流量
|
||||
|
||||
Reference in New Issue
Block a user