mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
add c api for MediaSource (#3433)
补充MediaSource C API 获取源地址 获取源类型 获取创建时间戳 --------- Co-authored-by: 李道甫 <lidf@ahtelit.com>
This commit is contained in:
parent
2159e90f78
commit
071f008108
@ -24,6 +24,10 @@
|
|||||||
# define API_CALL
|
# define API_CALL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#define _strdup strdup
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(_MSC_VER)
|
#if defined(_WIN32) && defined(_MSC_VER)
|
||||||
# if !defined(GENERATE_EXPORT)
|
# if !defined(GENERATE_EXPORT)
|
||||||
# if defined(MediaKitApi_EXPORTS)
|
# if defined(MediaKitApi_EXPORTS)
|
||||||
|
@ -103,6 +103,16 @@ API_EXPORT int API_CALL mk_media_source_get_track_count(const mk_media_source ct
|
|||||||
API_EXPORT mk_track API_CALL mk_media_source_get_track(const mk_media_source ctx, int index);
|
API_EXPORT mk_track API_CALL mk_media_source_get_track(const mk_media_source ctx, int index);
|
||||||
// MediaSource::broadcastMessage
|
// MediaSource::broadcastMessage
|
||||||
API_EXPORT int API_CALL mk_media_source_broadcast_msg(const mk_media_source ctx, const char *msg, size_t len);
|
API_EXPORT int API_CALL mk_media_source_broadcast_msg(const mk_media_source ctx, const char *msg, size_t len);
|
||||||
|
// MediaSource::getOriginUrl()
|
||||||
|
API_EXPORT const char* API_CALL mk_media_source_get_origin_url(const mk_media_source ctx);
|
||||||
|
// MediaSource::getOriginType()
|
||||||
|
API_EXPORT int API_CALL mk_media_source_get_origin_type(const mk_media_source ctx);
|
||||||
|
// MediaSource::getCreateStamp()
|
||||||
|
API_EXPORT uint64_t API_CALL mk_media_source_get_create_stamp(const mk_media_source ctx);
|
||||||
|
// MediaSource::isRecording() 0:hls,1:MP4
|
||||||
|
API_EXPORT int API_CALL mk_media_source_is_recording(const mk_media_source ctx, int type);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 直播源在ZLMediaKit中被称作为MediaSource,
|
* 直播源在ZLMediaKit中被称作为MediaSource,
|
||||||
|
@ -228,6 +228,30 @@ API_EXPORT int API_CALL mk_media_source_broadcast_msg(const mk_media_source ctx,
|
|||||||
return src->broadcastMessage(any);
|
return src->broadcastMessage(any);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
API_EXPORT const char* API_CALL mk_media_source_get_origin_url(const mk_media_source ctx) {
|
||||||
|
assert(ctx);
|
||||||
|
MediaSource *src = (MediaSource *)ctx;
|
||||||
|
return _strdup(src->getOriginUrl().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
API_EXPORT int API_CALL mk_media_source_get_origin_type(const mk_media_source ctx) {
|
||||||
|
assert(ctx);
|
||||||
|
MediaSource *src = (MediaSource *)ctx;
|
||||||
|
return static_cast<int>(src->getOriginType());
|
||||||
|
}
|
||||||
|
|
||||||
|
API_EXPORT uint64_t API_CALL mk_media_source_get_create_stamp(const mk_media_source ctx) {
|
||||||
|
assert(ctx);
|
||||||
|
MediaSource *src = (MediaSource *)ctx;
|
||||||
|
return src->getCreateStamp();
|
||||||
|
}
|
||||||
|
|
||||||
|
API_EXPORT int API_CALL mk_media_source_is_recording(const mk_media_source ctx,int type) {
|
||||||
|
assert(ctx);
|
||||||
|
MediaSource *src = (MediaSource *)ctx;
|
||||||
|
return src->isRecording((Recorder::type)type);
|
||||||
|
}
|
||||||
|
|
||||||
API_EXPORT int API_CALL mk_media_source_close(const mk_media_source ctx,int force){
|
API_EXPORT int API_CALL mk_media_source_close(const mk_media_source ctx,int force){
|
||||||
assert(ctx);
|
assert(ctx);
|
||||||
MediaSource *src = (MediaSource *)ctx;
|
MediaSource *src = (MediaSource *)ctx;
|
||||||
|
@ -21,10 +21,6 @@ using namespace std;
|
|||||||
using namespace toolkit;
|
using namespace toolkit;
|
||||||
using namespace mediakit;
|
using namespace mediakit;
|
||||||
|
|
||||||
#ifndef _WIN32
|
|
||||||
#define _strdup strdup
|
|
||||||
#endif
|
|
||||||
|
|
||||||
API_EXPORT void API_CALL mk_free(void *ptr) {
|
API_EXPORT void API_CALL mk_free(void *ptr) {
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user