diff --git a/api/include/mk_events_objects.h b/api/include/mk_events_objects.h index 425243a6..018988f4 100644 --- a/api/include/mk_events_objects.h +++ b/api/include/mk_events_objects.h @@ -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, diff --git a/api/source/mk_events_objects.cpp b/api/source/mk_events_objects.cpp index b92aa7e8..c8656cec 100644 --- a/api/source/mk_events_objects.cpp +++ b/api/source/mk_events_objects.cpp @@ -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(& (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){