mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 12:37:09 +08:00
onNoneReader事件避免重复触发
This commit is contained in:
parent
ec190e3273
commit
f5a80e3799
@ -181,7 +181,7 @@ bool MediaReader::close(MediaSource &sender,bool force){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MediaReader::onNoneReader(MediaSource &sender) {
|
void MediaReader::onNoneReader(MediaSource &sender) {
|
||||||
if(_mediaMuxer->readerCount() != 0){
|
if(!_mediaMuxer || _mediaMuxer->readerCount() != 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MediaSourceEvent::onNoneReader(sender);
|
MediaSourceEvent::onNoneReader(sender);
|
||||||
|
@ -167,7 +167,7 @@ bool PlayerProxy::close(MediaSource &sender,bool force) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlayerProxy::onNoneReader(MediaSource &sender) {
|
void PlayerProxy::onNoneReader(MediaSource &sender) {
|
||||||
if(_mediaMuxer->readerCount() != 0){
|
if(!_mediaMuxer || _mediaMuxer->readerCount() != 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MediaSourceEvent::onNoneReader(sender);
|
MediaSourceEvent::onNoneReader(sender);
|
||||||
|
@ -490,4 +490,22 @@ void RtmpSession::onSendMedia(const RtmpPacket::Ptr &pkt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool RtmpSession::close(MediaSource &sender,bool force) {
|
||||||
|
//此回调在其他线程触发
|
||||||
|
if(!_pPublisherSrc || (!force && _pPublisherSrc->readerCount() != 0)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
string err = StrPrinter << "close media:" << sender.getSchema() << "/" << sender.getVhost() << "/" << sender.getApp() << "/" << sender.getId() << " " << force;
|
||||||
|
safeShutdown(SockException(Err_shutdown,err));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RtmpSession::onNoneReader(MediaSource &sender) {
|
||||||
|
//此回调在其他线程触发
|
||||||
|
if(!_pPublisherSrc || _pPublisherSrc->readerCount() != 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MediaSourceEvent::onNoneReader(sender);
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace mediakit */
|
} /* namespace mediakit */
|
||||||
|
@ -81,14 +81,8 @@ private:
|
|||||||
sendResponse(MSG_CMD, invoke.data());
|
sendResponse(MSG_CMD, invoke.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool close(MediaSource &sender,bool force) override {
|
bool close(MediaSource &sender,bool force) override ;
|
||||||
if(!force && _pPublisherSrc->readerCount() != 0){
|
void onNoneReader(MediaSource &sender) override;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
string err = StrPrinter << "close media:" << sender.getSchema() << "/" << sender.getVhost() << "/" << sender.getApp() << "/" << sender.getId() << " " << force;
|
|
||||||
safeShutdown(SockException(Err_shutdown,err));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
std::string _strTcUrl;
|
std::string _strTcUrl;
|
||||||
MediaInfo _mediaInfo;
|
MediaInfo _mediaInfo;
|
||||||
|
@ -1089,7 +1089,8 @@ inline int RtspSession::getTrackIndexByInterleaved(int interleaved){
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool RtspSession::close(MediaSource &sender,bool force) {
|
bool RtspSession::close(MediaSource &sender,bool force) {
|
||||||
if(!force && _pushSrc->readerCount() != 0){
|
//此回调在其他线程触发
|
||||||
|
if(!_pushSrc || (!force && _pushSrc->readerCount() != 0)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
string err = StrPrinter << "close media:" << sender.getSchema() << "/" << sender.getVhost() << "/" << sender.getApp() << "/" << sender.getId() << " " << force;
|
string err = StrPrinter << "close media:" << sender.getSchema() << "/" << sender.getVhost() << "/" << sender.getApp() << "/" << sender.getId() << " " << force;
|
||||||
@ -1098,6 +1099,15 @@ bool RtspSession::close(MediaSource &sender,bool force) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void RtspSession::onNoneReader(MediaSource &sender){
|
||||||
|
//此回调在其他线程触发
|
||||||
|
if(!_pushSrc || _pushSrc->readerCount() != 0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MediaSourceEvent::onNoneReader(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void RtspSession::sendRtpPacket(const RtpPacket::Ptr & pkt) {
|
inline void RtspSession::sendRtpPacket(const RtpPacket::Ptr & pkt) {
|
||||||
//InfoP(this) <<(int)pkt.Interleaved;
|
//InfoP(this) <<(int)pkt.Interleaved;
|
||||||
switch (_rtpType) {
|
switch (_rtpType) {
|
||||||
|
@ -106,8 +106,10 @@ protected:
|
|||||||
void onRtpSorted(const RtpPacket::Ptr &rtppt, int trackidx) override;
|
void onRtpSorted(const RtpPacket::Ptr &rtppt, int trackidx) override;
|
||||||
//MediaSourceEvent override
|
//MediaSourceEvent override
|
||||||
bool close(MediaSource &sender,bool force) override ;
|
bool close(MediaSource &sender,bool force) override ;
|
||||||
|
void onNoneReader(MediaSource &sender) override;
|
||||||
|
|
||||||
//TcpSession override
|
|
||||||
|
//TcpSession override
|
||||||
int send(const Buffer::Ptr &pkt) override;
|
int send(const Buffer::Ptr &pkt) override;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user