提高c sdk mk_media对象线程安全

This commit is contained in:
xia-chu
2023-03-11 11:02:20 +08:00
parent ba4296e180
commit c2a8d46a64
4 changed files with 36 additions and 3 deletions

View File

@@ -179,6 +179,27 @@ bool DevChannel::initAudio(const AudioInfo &info) {
}
}
bool DevChannel::inputFrame(const Frame::Ptr &frame) {
auto cached_frame = Frame::getCacheAbleFrame(frame);
weak_ptr<MultiMediaSourceMuxer> weak_self = shared_from_this();
getOwnerPoller(MediaSource::NullMediaSource())->async([weak_self, cached_frame]() {
if (auto strong_self = weak_self.lock()) {
strong_self->MultiMediaSourceMuxer::inputFrame(cached_frame);
}
});
return true;
}
bool DevChannel::addTrack(const Track::Ptr &track) {
bool ret;
getOwnerPoller(MediaSource::NullMediaSource())->sync([&]() { ret = MultiMediaSourceMuxer::addTrack(track); });
return ret;
}
void DevChannel::addTrackCompleted() {
getOwnerPoller(MediaSource::NullMediaSource())->sync([&]() { MultiMediaSourceMuxer::addTrackCompleted(); });
}
MediaOriginType DevChannel::getOriginType(MediaSource &sender) const {
return MediaOriginType::device_chn;
}