|
@@ -83,13 +83,17 @@ void sig_crash(int sig) {
|
|
|
fd = NULL;
|
|
|
}
|
|
|
|
|
|
-long video_similarity_detection_init(const char *url) {
|
|
|
+long video_similarity_detection_init(const char *url, VideoSimilarity **vs) {
|
|
|
auto *ctx = (VideoSimilarityContext *) malloc(sizeof(VideoSimilarityContext));
|
|
|
if (!ctx)return -1;
|
|
|
memset(ctx, 0, sizeof(VideoSimilarityContext));
|
|
|
- if (url)
|
|
|
- ctx->video_path = strdup(url);
|
|
|
- else return -1;
|
|
|
+ if (url) {
|
|
|
+ *vs = json2VideoSimilarity(url);
|
|
|
+ if (!(*vs))return -1L;
|
|
|
+ if ((*vs)->videoPath)
|
|
|
+ ctx->video_path = (*vs)->videoPath;
|
|
|
+ else return -1L;
|
|
|
+ }
|
|
|
return (long) ctx;
|
|
|
}
|
|
|
|
|
@@ -180,7 +184,7 @@ int video_similarity_detection_close(long id) {
|
|
|
auto *ctx = (VideoSimilarityContext *) id;
|
|
|
LOGE("video_similarity_detection_close \n");
|
|
|
if (ctx->video_path) {
|
|
|
- free((void *) ctx->video_path);
|
|
|
+// free((void *) ctx->video_path);
|
|
|
ctx->video_path = NULL;
|
|
|
}
|
|
|
if (ctx->log) {
|
|
@@ -290,12 +294,10 @@ const char *get_video_similarity_list(const char *inputjson) {
|
|
|
signal(SIGSEGV, sig_crash);
|
|
|
if (!inputjson)return NULL;
|
|
|
printf("get_video_similarity_list=%s \n", inputjson);
|
|
|
- auto *vs = json2VideoSimilarity(inputjson);
|
|
|
- if (!vs)return NULL;
|
|
|
- long id = video_similarity_detection_init(vs->videoPath);
|
|
|
+ VideoSimilarity *vs = NULL;
|
|
|
+ long id = video_similarity_detection_init(inputjson, &vs);
|
|
|
const char *ret_json = NULL;
|
|
|
if (id > 0) {
|
|
|
-
|
|
|
if (!(((VideoSimilarityContext *) id)->log)) {
|
|
|
int n = strlen(((VideoSimilarityContext *) id)->video_path); //计算字符串的长度(包括'\0')
|
|
|
const char *name = GetFileName(((VideoSimilarityContext *) id)->video_path, n); //把字符串及其长度传给函数
|