onNoneReader事件避免重复触发

This commit is contained in:
xiongziliang 2019-05-31 15:40:55 +08:00
parent ec190e3273
commit f5a80e3799
6 changed files with 36 additions and 12 deletions

View File

@ -181,7 +181,7 @@ bool MediaReader::close(MediaSource &sender,bool force){
}
void MediaReader::onNoneReader(MediaSource &sender) {
if(_mediaMuxer->readerCount() != 0){
if(!_mediaMuxer || _mediaMuxer->readerCount() != 0){
return;
}
MediaSourceEvent::onNoneReader(sender);

View File

@ -167,7 +167,7 @@ bool PlayerProxy::close(MediaSource &sender,bool force) {
}
void PlayerProxy::onNoneReader(MediaSource &sender) {
if(_mediaMuxer->readerCount() != 0){
if(!_mediaMuxer || _mediaMuxer->readerCount() != 0){
return;
}
MediaSourceEvent::onNoneReader(sender);

View File

@ -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 */

View File

@ -81,14 +81,8 @@ private:
sendResponse(MSG_CMD, invoke.data());
}
bool close(MediaSource &sender,bool force) override {
if(!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;
}
bool close(MediaSource &sender,bool force) override ;
void onNoneReader(MediaSource &sender) override;
private:
std::string _strTcUrl;
MediaInfo _mediaInfo;

View File

@ -1089,7 +1089,8 @@ inline int RtspSession::getTrackIndexByInterleaved(int interleaved){
}
bool RtspSession::close(MediaSource &sender,bool force) {
if(!force && _pushSrc->readerCount() != 0){
//此回调在其他线程触发
if(!_pushSrc || (!force && _pushSrc->readerCount() != 0)){
return false;
}
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) {
//InfoP(this) <<(int)pkt.Interleaved;
switch (_rtpType) {

View File

@ -106,8 +106,10 @@ protected:
void onRtpSorted(const RtpPacket::Ptr &rtppt, int trackidx) override;
//MediaSourceEvent override
bool close(MediaSource &sender,bool force) override ;
void onNoneReader(MediaSource &sender) override;
//TcpSession override
//TcpSession override
int send(const Buffer::Ptr &pkt) override;