Skip to content
Snippets Groups Projects
Commit b671efce authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Implement the missing ML folder/group query by id

parent c87b0b30
No related branches found
No related tags found
1 merge request!1833Implement the video grouping in the remote access
......@@ -1848,6 +1848,17 @@ folders(JNIEnv* env, jobject thiz, jint type, jint sortingCriteria, jboolean des
return foldersRefs;
}
jobject
getFolder(JNIEnv* env, jobject thiz, jint type, jlong id) {
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz);
medialibrary::FolderPtr folder = aml->folder(id);
if (folder == nullptr) return nullptr;
const auto query = aml->mediaFromFolder(folder.get(), (medialibrary::IMedia::Type)type);
int count = (query != nullptr ? query->count() : 0);
return convertFolderObject(env, &ml_fields, folder, count).release();;
}
jint
foldersCount(JNIEnv* env, jobject thiz, jint type) {
const auto query = MediaLibrary_getInstance(env, thiz)->folders(nullptr, (medialibrary::IMedia::Type)type);
......@@ -2065,6 +2076,14 @@ createMediaGroup(JNIEnv* env, jobject thiz, jlongArray mediaIds)
return convertVideoGroupObject(env, &ml_fields, group).release();
}
jobject
getMediaGroup(JNIEnv* env, jobject thiz, jlong id) {
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz);
medialibrary::MediaGroupPtr media = aml->videoGroup(id);
if (media == nullptr) return nullptr;
return convertVideoGroupObject(env, &ml_fields, media).release();;
}
jboolean regroupAll(JNIEnv* env, jobject thiz)
{
return MediaLibrary_getInstance(env, thiz)->regroupAll();
......@@ -2515,6 +2534,7 @@ static JNINativeMethod methods[] = {
{"nativeGetPlaylist", "(JZZ)Lorg/videolan/medialibrary/interfaces/media/Playlist;", (void*)getPlaylist },
{"nativeGetFolders", "(IIZZZII)[Lorg/videolan/medialibrary/interfaces/media/Folder;", (void*)folders },
{"nativeGetFoldersCount", "(I)I", (void*)foldersCount },
{"nativeGetFolder", "(IJ)Lorg/videolan/medialibrary/interfaces/media/Folder;", (void*)getFolder },
{"nativeSearchPagedFolders", "(Ljava/lang/String;IZZZII)[Lorg/videolan/medialibrary/interfaces/media/Folder;", (void*)searchFolders },
{"nativeGetSearchFoldersCount", "(Ljava/lang/String;)I", (void*)getSearchFoldersCount },
{"nativePauseBackgroundOperations", "()V", (void*)pauseBackgroundOperations },
......@@ -2533,6 +2553,7 @@ static JNINativeMethod methods[] = {
{"nativeCreateGroupByName", "(Ljava/lang/String;)Lorg/videolan/medialibrary/interfaces/media/VideoGroup;", (void*)createMediaGroupByName },
{"nativeSearchPagedGroups", "(Ljava/lang/String;IZZZII)[Lorg/videolan/medialibrary/interfaces/media/VideoGroup;", (void*)searchMediaGroups },
{"nativeCreateGroup", "([J)Lorg/videolan/medialibrary/interfaces/media/VideoGroup;", (void*)createMediaGroup },
{"nativeGetGroup", "(J)Lorg/videolan/medialibrary/interfaces/media/VideoGroup;", (void*)getMediaGroup },
{"nativeRegroupAll", "()Z", (void*)regroupAll },
{"nativeRegroup", "(J)Z", (void*)regroup },
{"nativeGetService", "(I)Lorg/videolan/medialibrary/interfaces/media/MlService;", (void*)getService},
......
......@@ -267,6 +267,11 @@ public class MedialibraryImpl extends Medialibrary {
return mIsInitiated && (ids.length != 0) ? nativeCreateGroup(ids) : null;
}
@Override
public VideoGroup getVideoGroup(long id) {
return mIsInitiated ? nativeGetGroup(id) : null;
}
@Override
public boolean regroupAll() {
return mIsInitiated && nativeRegroupAll();
......@@ -481,6 +486,11 @@ public class MedialibraryImpl extends Medialibrary {
return mIsInitiated ? nativeGetFolders(type, sort, desc, includeMissing, onlyFavorites, nbItems, offset) : new Folder[0];
}
@Override
public Folder getFolder(int type, long id) {
return mIsInitiated ? nativeGetFolder(type, id) : null;
}
@WorkerThread
public int getFoldersCount(int type) {
return mIsInitiated ? nativeGetFoldersCount(type) : 0;
......@@ -691,6 +701,7 @@ public class MedialibraryImpl extends Medialibrary {
private native VideoGroup nativeCreateGroupByName(String name);
private native VideoGroup nativeCreateGroup(long[] ids);
private native VideoGroup nativeGetGroup(long id);
private native boolean nativeRegroupAll();
......@@ -713,6 +724,7 @@ public class MedialibraryImpl extends Medialibrary {
private native Playlist nativeGetPlaylist(long playlistId, boolean includeMissing, boolean onlyFavorites);
private native Playlist nativePlaylistCreate(String name, boolean includeMissing, boolean onlyFavorites);
private native Folder[] nativeGetFolders(int type, int sort, boolean desc, boolean includeMissing, boolean onlyFavorites, int nbItems, int offset);
private native Folder nativeGetFolder(int type, long id);
private native int nativeGetFoldersCount(int type);
private native void nativePauseBackgroundOperations();
private native void nativeResumeBackgroundOperations();
......
......@@ -770,6 +770,8 @@ abstract public class Medialibrary {
abstract public VideoGroup createVideoGroup(long[] ids);
abstract public VideoGroup getVideoGroup(long id);
abstract public boolean regroupAll();
abstract public boolean regroup(long mediaId);
......@@ -816,6 +818,7 @@ abstract public class Medialibrary {
abstract public boolean flushUserProvidedThumbnails();
abstract public MediaWrapper addStream(String mrl, String title);
abstract public Folder[] getFolders(int type, int sort, boolean desc, boolean includeMissing, boolean onlyFavorites, int nbItems, int offset);
abstract public Folder getFolder(int type, long id);
abstract public int getFoldersCount(int type);
abstract public int setLastTime(long mediaId, long time);
abstract public boolean setLastPosition(long mediaId, float position);
......
......@@ -186,6 +186,11 @@ public class StubMedialibrary extends Medialibrary {
return null;
}
@Override
public VideoGroup getVideoGroup(long id) {
return null;
}
@Override
public boolean regroupAll() {
return false;
......@@ -490,6 +495,11 @@ public class StubMedialibrary extends Medialibrary {
return folders.toArray(new Folder[0]);
}
@Override
public Folder getFolder(int type, long id) {
return null;
}
public int getFoldersCount(int type) {
return getFolders(type, 0, false, true, false, 0, 0).length;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment