mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-14 03:55:58 +08:00
修复FFmpeg拉流代理功能缺陷的问题:#533
This commit is contained in:
@@ -92,8 +92,19 @@ void MediaSource::setListener(const std::weak_ptr<MediaSourceEvent> &listener){
|
||||
_listener = listener;
|
||||
}
|
||||
|
||||
const std::weak_ptr<MediaSourceEvent>& MediaSource::getListener() const{
|
||||
return _listener;
|
||||
std::weak_ptr<MediaSourceEvent> MediaSource::getListener(bool next) const{
|
||||
if (!next) {
|
||||
return _listener;
|
||||
}
|
||||
auto listener = dynamic_pointer_cast<MediaSourceEventInterceptor>(_listener.lock());
|
||||
if (!listener) {
|
||||
//不是MediaSourceEventInterceptor对象或者对象已经销毁
|
||||
return _listener;
|
||||
}
|
||||
//获取被拦截的对象
|
||||
auto next_obj = listener->getDelegate();
|
||||
//有则返回之
|
||||
return next_obj ? next_obj : _listener;
|
||||
}
|
||||
|
||||
int MediaSource::totalReaderCount(){
|
||||
@@ -644,6 +655,17 @@ bool MediaSourceEventInterceptor::stopSendRtp(MediaSource &sender){
|
||||
return false;
|
||||
}
|
||||
|
||||
void MediaSourceEventInterceptor::setDelegate(const std::weak_ptr<MediaSourceEvent> &listener) {
|
||||
if (listener.lock().get() == this) {
|
||||
throw std::invalid_argument("can not set self as a delegate");
|
||||
}
|
||||
_listener = listener;
|
||||
}
|
||||
|
||||
std::shared_ptr<MediaSourceEvent> MediaSourceEventInterceptor::getDelegate() const{
|
||||
return _listener.lock();
|
||||
}
|
||||
|
||||
/////////////////////////////////////FlushPolicy//////////////////////////////////////
|
||||
|
||||
static bool isFlushAble_default(bool is_video, uint64_t last_stamp, uint64_t new_stamp, int cache_size) {
|
||||
|
||||
Reference in New Issue
Block a user