Commit 72ba87c8 by xia-chu

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

parent 23e24d07
......@@ -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,
......
......@@ -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){
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论