修复mk_media_source_get_track接口崩溃问题:#2552

This commit is contained in:
xia-chu 2023-06-17 09:14:51 +08:00
parent 23e24d07e6
commit 72ba87c803
2 changed files with 2 additions and 2 deletions

View File

@ -98,7 +98,7 @@ API_EXPORT int API_CALL mk_media_source_get_reader_count(const mk_media_source c
API_EXPORT int API_CALL mk_media_source_get_total_reader_count(const mk_media_source ctx);
// get track count from MediaSource
API_EXPORT int API_CALL mk_media_source_get_track_count(const mk_media_source ctx);
// get track by index from MediaSource
// copy track reference by index from MediaSource, please use mk_track_unref to release it
API_EXPORT mk_track API_CALL mk_media_source_get_track(const mk_media_source ctx, int index);
/**
* ZLMediaKit中被称作为MediaSource

View File

@ -211,7 +211,7 @@ API_EXPORT mk_track API_CALL mk_media_source_get_track(const mk_media_source ctx
if (index < 0 && index >= tracks.size()) {
return nullptr;
}
return reinterpret_cast<mk_track>(& (tracks[index]));
return (mk_track) new Track::Ptr(std::move(tracks[index]));
}
API_EXPORT int API_CALL mk_media_source_close(const mk_media_source ctx,int force){