Commit ceebb04d authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Medialibrary: Implement videogroups API

parent 4b0d0190
......@@ -510,6 +510,32 @@ medialibrary::Query<medialibrary::IFolder> AndroidMediaLibrary::subFolders(int64
return folder != nullptr ? folder->subfolders(params) : nullptr;
}
medialibrary::Query<medialibrary::IVideoGroup>
AndroidMediaLibrary::videoGroups( const medialibrary::QueryParameters* params )
{
return p_ml->videoGroups(params);
}
void
AndroidMediaLibrary::setVideoGroupsPrefixLength( uint32_t prefixLength )
{
p_ml->setVideoGroupsPrefixLength(prefixLength);
}
medialibrary::Query<medialibrary::IMedia>
AndroidMediaLibrary::mediaFromVideoGroup(const std::string& name, const medialibrary::QueryParameters* params )
{
medialibrary::VideoGroupPtr group = p_ml->videoGroup(name);
return group != nullptr ? group->media(params) : nullptr;
}
medialibrary::Query<medialibrary::IMedia>
AndroidMediaLibrary::searchFromVideoGroup( const std::string& name, const std::string& query, const medialibrary::QueryParameters* params )
{
auto group = p_ml->videoGroup(name);
return group == nullptr ? nullptr : group->searchMedia(query, params);
}
void
AndroidMediaLibrary::requestThumbnail( int64_t media_id, medialibrary::ThumbnailSizeType sizeType, uint32_t desiredWidth,
uint32_t desiredHeight, float position )
......
......@@ -11,12 +11,12 @@
#include "AndroidDeviceLister.h"
#include "utils.h"
#include <medialibrary/IAlbum.h>
#include <medialibrary/IArtist.h>
#include <medialibrary/IGenre.h>
#include <medialibrary/IPlaylist.h>
#include <medialibrary/IFolder.h>
#include <medialibrary/IVideoGroup.h>
#include <medialibrary/Types.h>
#include <medialibrary/IDeviceLister.h>
#include <medialibrary/IMedia.h>
......@@ -79,6 +79,7 @@ public:
medialibrary::MediaPtr addStream(const std::string& mrl, const std::string& title);
medialibrary::Query<medialibrary::IMedia> videoFiles( const medialibrary::QueryParameters* params = nullptr );
medialibrary::Query<medialibrary::IMedia> audioFiles( const medialibrary::QueryParameters* params = nullptr );
medialibrary::Query<medialibrary::IVideoGroup> videoGroups( const medialibrary::QueryParameters* params );
medialibrary::Query<medialibrary::IAlbum> albums(const medialibrary::QueryParameters* params);
medialibrary::AlbumPtr album(int64_t albumId);
medialibrary::Query<medialibrary::IArtist> artists(bool includeAll, const medialibrary::QueryParameters* params);
......@@ -99,6 +100,10 @@ public:
medialibrary::Query<medialibrary::IMedia> mediaFromFolder(int64_t folderId, medialibrary::IMedia::Type type, const medialibrary::QueryParameters* params = nullptr );
medialibrary::Query<medialibrary::IFolder> folders(const medialibrary::QueryParameters* params = nullptr, medialibrary::IMedia::Type type = medialibrary::IMedia::Type::Unknown );
medialibrary::Query<medialibrary::IFolder> subFolders(int64_t folderId, const medialibrary::QueryParameters* params = nullptr );
// VideoGroups
void setVideoGroupsPrefixLength( uint32_t prefixLength );
medialibrary::Query<medialibrary::IMedia> mediaFromVideoGroup(const std::string& name, const medialibrary::QueryParameters* params );
medialibrary::Query<medialibrary::IMedia> searchFromVideoGroup( const std::string& name, const std::string& query, const medialibrary::QueryParameters* params );
//PLaylists
bool playlistAppend(int64_t playlistId, int64_t mediaId);
bool playlistAdd(int64_t playlistId, int64_t mediaId, unsigned int position);
......
......@@ -1735,6 +1735,115 @@ foldersCount(JNIEnv* env, jobject thiz, jint type) {
return (jint) (query != nullptr ? query->count() : 0);
}
/*
* Video groups
*/
void
setVideoGroupsPrefixLength( JNIEnv* env, jobject thiz, jint prefixLength )
{
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz);
aml->setVideoGroupsPrefixLength(static_cast<uint32_t>(prefixLength));
}
jobjectArray
videoGroups(JNIEnv* env, jobject thiz, jint sortingCriteria, jboolean desc, jint nbItems, jint offset ) {
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz);
medialibrary::QueryParameters params {
static_cast<medialibrary::SortingCriteria>(sortingCriteria),
static_cast<bool>( desc )
};
const auto query = aml->videoGroups(&params);
if (query == nullptr) return (jobjectArray) env->NewObjectArray(0, ml_fields.VideoGroup.clazz, NULL);
std::vector<medialibrary::VideoGroupPtr> groupsList = nbItems != 0 ? query->items(nbItems, offset) : query->all();
jobjectArray groupsRefs = (jobjectArray) env->NewObjectArray(groupsList.size(), ml_fields.VideoGroup.clazz, NULL);
int index = -1;
for(medialibrary::VideoGroupPtr const& group : groupsList) {
try
{
jobject item = convertVideoGroupObject(env, &ml_fields, group);
env->SetObjectArrayElement(groupsRefs, ++index, item);
env->DeleteLocalRef(item);
}
catch( const medialibrary::fs::DeviceRemovedException& )
{
// Ignore this VideoGroup since it's on a removed device.
}
}
return groupsRefs;
}
jint
videoGroupsCount(JNIEnv* env, jobject thiz) {
const auto query = MediaLibrary_getInstance(env, thiz)->videoGroups(nullptr);
return (jint) (query != nullptr ? query->count() : 0);
}
jobjectArray
getPagedMediaFromvideoGroup(JNIEnv* env, jobject thiz, jobject medialibrary, jstring name, jint sortingCriteria, jboolean desc, jint nbItems, jint offset)
{
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, medialibrary);
medialibrary::QueryParameters params {
static_cast<medialibrary::SortingCriteria>(sortingCriteria),
static_cast<bool>( desc )
};
const char *char_name = env->GetStringUTFChars(name, JNI_FALSE);
const auto query = aml->mediaFromVideoGroup(char_name, &params);
if (query == nullptr) return (jobjectArray) env->NewObjectArray(0, ml_fields.MediaWrapper.clazz, NULL);
std::vector<medialibrary::MediaPtr> mediaList = nbItems != 0 ? query->items(nbItems, offset) : query->all();
jobjectArray mediaRefs = (jobjectArray) env->NewObjectArray(mediaList.size(), ml_fields.MediaWrapper.clazz, NULL);
int index = -1;
for(medialibrary::MediaPtr const& media : mediaList) {
jobject item = mediaToMediaWrapper(env, &ml_fields, media);
env->SetObjectArrayElement(mediaRefs, ++index, item);
env->DeleteLocalRef(item);
}
env->ReleaseStringUTFChars(name, char_name);
return mediaRefs;
}
jint
getvideoGroupMediaCount(JNIEnv* env, jobject thiz, jobject medialibrary, jstring name) {
const char *char_name = env->GetStringUTFChars(name, JNI_FALSE);
const auto query = MediaLibrary_getInstance(env, medialibrary)->mediaFromVideoGroup(char_name, nullptr);
env->ReleaseStringUTFChars(name, char_name);
return static_cast<jint> (query != nullptr ? query->count() : 0);
}
jobjectArray
searchFromvideoGroup(JNIEnv* env, jobject thiz, jobject medialibrary, jstring name, jstring filterQuery, jint sortingCriteria, jboolean desc, jint nbItems, jint offset)
{
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, medialibrary);
medialibrary::QueryParameters params {
static_cast<medialibrary::SortingCriteria>(sortingCriteria),
static_cast<bool>( desc )
};
const char *char_name = env->GetStringUTFChars(name, JNI_FALSE);
const char *queryChar = env->GetStringUTFChars(filterQuery, JNI_FALSE);
const auto query = aml->searchFromVideoGroup(char_name, queryChar, &params);
if (query == nullptr) return (jobjectArray) env->NewObjectArray(0, ml_fields.MediaWrapper.clazz, NULL);
std::vector<medialibrary::MediaPtr> mediaList = nbItems != 0 ? query->items(nbItems, offset) : query->all();
jobjectArray mediaRefs = (jobjectArray) env->NewObjectArray(mediaList.size(), ml_fields.MediaWrapper.clazz, NULL);
int index = -1;
for(medialibrary::MediaPtr const& media : mediaList) {
jobject item = mediaToMediaWrapper(env, &ml_fields, media);
env->SetObjectArrayElement(mediaRefs, ++index, item);
env->DeleteLocalRef(item);
}
env->ReleaseStringUTFChars(filterQuery, queryChar);
env->ReleaseStringUTFChars(name, char_name);
return mediaRefs;
}
jint
getSearchFromvideoGroupCount(JNIEnv* env, jobject thiz, jobject medialibrary, jstring name, jstring filterQuery) {
const char *queryChar = env->GetStringUTFChars(filterQuery, JNI_FALSE);
const char *char_name = env->GetStringUTFChars(name, JNI_FALSE);
const auto query = MediaLibrary_getInstance(env, medialibrary)->searchFromVideoGroup(char_name, queryChar, nullptr);
env->ReleaseStringUTFChars(filterQuery, queryChar);
env->ReleaseStringUTFChars(name, char_name);
return static_cast<jint> (query != nullptr ? query->count() : 0);
}
/*
* JNI stuff
*/
......@@ -1755,6 +1864,7 @@ static JNINativeMethod methods[] = {
{"nativeLastStreamsPlayed", "()[Lorg/videolan/medialibrary/interfaces/media/AbstractMediaWrapper;", (void*)lastStreamsPlayed },
{"nativeAddToHistory", "(Ljava/lang/String;Ljava/lang/String;)Z", (void*)addToHistory },
{"nativeClearHistory", "()Z", (void*)clearHistory },
{"nativeSetVideoGroupsPrefixLength", "(I)V", (void*)setVideoGroupsPrefixLength },
{"nativeGetVideos", "()[Lorg/videolan/medialibrary/interfaces/media/AbstractMediaWrapper;", (void*)getVideos },
{"nativeGetSortedVideos", "(IZ)[Lorg/videolan/medialibrary/interfaces/media/AbstractMediaWrapper;", (void*)getSortedVideos },
{"nativeGetSortedPagedVideos", "(IZII)[Lorg/videolan/medialibrary/interfaces/media/AbstractMediaWrapper;", (void*)getPagedVideos },
......@@ -1818,6 +1928,9 @@ static JNINativeMethod methods[] = {
{"nativeSetMediaUpdatedCbFlag", "(I)V", (void*)setMediaUpdatedCbFlag },
{"nativeSetMediaAddedCbFlag", "(I)V", (void*)setMediaAddedCbFlag },
{"nativePlaylistCreate", "(Ljava/lang/String;)Lorg/videolan/medialibrary/interfaces/media/AbstractPlaylist;", (void*)playlistCreate },
{"nativeGetVideoGroups", "(IZII)[Lorg/videolan/medialibrary/interfaces/media/AbstractVideoGroup;", (void*)videoGroups },
{"nativeGetVideoGroupsCount", "()I", (void*)videoGroupsCount },
};
static JNINativeMethod media_methods[] = {
......@@ -1877,6 +1990,13 @@ static JNINativeMethod folder_methods[] = {
{"nativeGetSearchCount", "(Lorg/videolan/medialibrary/interfaces/AbstractMedialibrary;JLjava/lang/String;I)I", (void*)getSearchMediaFromFolderCount },
};
static JNINativeMethod videogroup_methods[] = {
{"nativeMedia", "(Lorg/videolan/medialibrary/interfaces/AbstractMedialibrary;Ljava/lang/String;IZII)[Lorg/videolan/medialibrary/interfaces/media/AbstractMediaWrapper;", (void*)getPagedMediaFromvideoGroup },
// {"nativeMediaCount", "(Lorg/videolan/medialibrary/interfaces/AbstractMedialibrary;JI)I", (void*)getvideoGroupMediaCount },
{"nativeSearch", "(Lorg/videolan/medialibrary/interfaces/AbstractMedialibrary;Ljava/lang/String;Ljava/lang/String;IZII)[Lorg/videolan/medialibrary/interfaces/media/AbstractMediaWrapper;", (void*)searchFromvideoGroup },
{"nativeGetSearchCount", "(Lorg/videolan/medialibrary/interfaces/AbstractMedialibrary;Ljava/lang/String;Ljava/lang/String;)I", (void*)getSearchFromvideoGroupCount },
};
static JNINativeMethod playlist_methods[] = {
{"nativeGetTracks", "(Lorg/videolan/medialibrary/interfaces/AbstractMedialibrary;J)[Lorg/videolan/medialibrary/interfaces/media/AbstractMediaWrapper;", (void*)getMediaFromPlaylist },
{"nativeGetPagedTracks", "(Lorg/videolan/medialibrary/interfaces/AbstractMedialibrary;JII)[Lorg/videolan/medialibrary/interfaces/media/AbstractMediaWrapper;", (void*)getPagedMediaFromPlaylist },
......@@ -2026,12 +2146,25 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved)
"<init>", "([Lorg/videolan/medialibrary/interfaces/media/AbstractAlbum;[Lorg/videolan/medialibrary/interfaces/media/AbstractArtist;[Lorg/videolan/medialibrary/interfaces/media/AbstractGenre;[Lorg/videolan/medialibrary/interfaces/media/AbstractMediaWrapper;[Lorg/videolan/medialibrary/interfaces/media/AbstractMediaWrapper;[Lorg/videolan/medialibrary/interfaces/media/AbstractPlaylist;)V");
GET_CLASS(ml_fields.Folder.clazz, "org/videolan/medialibrary/media/Folder", true);
if (env->RegisterNatives(ml_fields.Folder.clazz, folder_methods, sizeof(folder_methods) / sizeof(folder_methods[0])) < 0) {
LOGE("RegisterNatives failed for org/videolan/medialibrary/media/Folder");
return -1;
}
GET_ID(GetMethodID,
ml_fields.Folder.initID,
ml_fields.Folder.clazz,
"<init>", "(JLjava/lang/String;Ljava/lang/String;)V");
GET_CLASS(ml_fields.VideoGroup.clazz, "org/videolan/medialibrary/media/VideoGroup", true);
if (env->RegisterNatives(ml_fields.VideoGroup.clazz, videogroup_methods, sizeof(videogroup_methods) / sizeof(videogroup_methods[0])) < 0) {
LOGE("RegisterNatives failed for 'org/videolan/medialibrary/media/VideoGroup");
return -1;
}
GET_ID(GetMethodID,
ml_fields.VideoGroup.initID,
ml_fields.VideoGroup.clazz,
"<init>", "(Ljava/lang/String;I)V");
GET_ID(GetFieldID,
ml_fields.MediaLibrary.instanceID,
ml_fields.MediaLibrary.clazz,
......
#include "utils.h"
#include <medialibrary/IAlbumTrack.h>
#include <medialibrary/IVideoTrack.h>
#include <medialibrary/IFile.h>
#include <medialibrary/IMedia.h>
#include <medialibrary/IArtist.h>
#include <medialibrary/IGenre.h>
#include <medialibrary/IAlbum.h>
#include <medialibrary/IPlaylist.h>
#include <medialibrary/IFolder.h>
#include <medialibrary/IMediaLibrary.h>
#include <medialibrary/IMetadata.h>
#include<medialibrary/filesystem/IDevice.h>
#define LOG_TAG "VLC/JNI/Utils"
#include "log.h"
......@@ -170,6 +158,16 @@ convertFolderObject(JNIEnv* env, fields *fields, medialibrary::FolderPtr const&
return item;
}
jobject
convertVideoGroupObject(JNIEnv* env, fields *fields, medialibrary::VideoGroupPtr const& videogroupPtr)
{
jstring name = env->NewStringUTF(videogroupPtr->name().c_str());
jobject item = env->NewObject(fields->VideoGroup.clazz, fields->VideoGroup.initID,
name, (jint)videogroupPtr->count());
env->DeleteLocalRef(name);
return item;
}
jobject
convertSearchAggregateObject(JNIEnv* env, fields *fields, medialibrary::SearchAggregate const& searchAggregatePtr)
{
......
......@@ -23,6 +23,19 @@
#include <jni.h>
#include <medialibrary/Types.h>
#include <medialibrary/IMediaLibrary.h>
#include <medialibrary/IAlbumTrack.h>
#include <medialibrary/IVideoTrack.h>
#include <medialibrary/IFile.h>
#include <medialibrary/IMedia.h>
#include <medialibrary/IArtist.h>
#include <medialibrary/IGenre.h>
#include <medialibrary/IAlbum.h>
#include <medialibrary/IPlaylist.h>
#include <medialibrary/IFolder.h>
#include <medialibrary/IMediaLibrary.h>
#include <medialibrary/IMetadata.h>
#include<medialibrary/filesystem/IDevice.h>
#include <medialibrary/IVideoGroup.h>
#define VLC_JNI_VERSION JNI_VERSION_1_2
......@@ -99,6 +112,10 @@ struct fields {
jclass clazz;
jmethodID initID;
} Folder;
struct VideoGroup {
jclass clazz;
jmethodID initID;
} VideoGroup;
};
jobject mediaToMediaWrapper(JNIEnv*, fields*, const medialibrary::MediaPtr &);
......@@ -107,6 +124,7 @@ jobject convertArtistObject(JNIEnv* env, fields *fields, medialibrary::ArtistPtr
jobject convertGenreObject(JNIEnv* env, fields *fields, medialibrary::GenrePtr const& genrePtr);
jobject convertPlaylistObject(JNIEnv* env, fields *fields, medialibrary::PlaylistPtr const& genrePtr);
jobject convertFolderObject(JNIEnv* env, fields *fields, medialibrary::FolderPtr const& folderPtr);
jobject convertVideoGroupObject(JNIEnv* env, fields *fields, medialibrary::VideoGroupPtr const& videogroupPtr);
jobject convertSearchAggregateObject(JNIEnv* env, fields *fields, medialibrary::SearchAggregate const& searchAggregatePtr);
jobjectArray filteredArray(JNIEnv* env, jobjectArray array, jclass clazz, int removalCount = -1);
......
......@@ -12,12 +12,14 @@ import org.videolan.medialibrary.interfaces.media.AbstractFolder;
import org.videolan.medialibrary.interfaces.media.AbstractGenre;
import org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper;
import org.videolan.medialibrary.interfaces.media.AbstractPlaylist;
import org.videolan.medialibrary.interfaces.media.AbstractVideoGroup;
import org.videolan.medialibrary.media.Album;
import org.videolan.medialibrary.media.Artist;
import org.videolan.medialibrary.media.Folder;
import org.videolan.medialibrary.media.Genre;
import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.medialibrary.media.Playlist;
import org.videolan.medialibrary.media.VideoGroup;
import org.videolan.medialibrary.stubs.StubAlbum;
import org.videolan.medialibrary.stubs.StubArtist;
import org.videolan.medialibrary.stubs.StubFolder;
......@@ -25,6 +27,7 @@ import org.videolan.medialibrary.stubs.StubGenre;
import org.videolan.medialibrary.stubs.StubMediaWrapper;
import org.videolan.medialibrary.stubs.StubMedialibrary;
import org.videolan.medialibrary.stubs.StubPlaylist;
import org.videolan.medialibrary.stubs.StubVideoGroup;
public class MLServiceLocator {
......@@ -181,6 +184,14 @@ public class MLServiceLocator {
}
}
public static AbstractVideoGroup getAbstractVideoGroup(Parcel in) {
if (sMode == LocatorMode.VLC_ANDROID) {
return new VideoGroup(in);
} else {
return new StubVideoGroup(in);
}
}
//Playlist
public static AbstractPlaylist getAbstractPlaylist(long id, String name, int trackCount) {
if (sMode == LocatorMode.VLC_ANDROID) {
......
......@@ -38,6 +38,7 @@ import org.videolan.medialibrary.interfaces.media.AbstractFolder;
import org.videolan.medialibrary.interfaces.media.AbstractGenre;
import org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper;
import org.videolan.medialibrary.interfaces.media.AbstractPlaylist;
import org.videolan.medialibrary.interfaces.media.AbstractVideoGroup;
import org.videolan.medialibrary.media.SearchAggregate;
import java.io.File;
......@@ -197,14 +198,34 @@ public class Medialibrary extends AbstractMedialibrary {
return mIsInitiated ? nativeGetRecentAudio() : new AbstractMediaWrapper[0];
}
@WorkerThread
public int getVideoCount() {
return mIsInitiated ? nativeGetVideoCount() : 0;
}
@WorkerThread
public int getAudioCount() {
return mIsInitiated ? nativeGetAudioCount() : 0;
}
@Override
@WorkerThread
public AbstractVideoGroup[] getVideoGroups(int sort, boolean desc, int nbItems, int offset) {
return mIsInitiated ? nativeGetVideoGroups(sort, desc, nbItems, offset) : new AbstractVideoGroup[0];
}
@Override
@WorkerThread
public int getVideoGroupsCount() {
return mIsInitiated ? nativeGetVideoGroupsCount() : 0;
}
@Override
@WorkerThread
public void setVideoGroupsPrefixLength(int lenght) {
if (mIsInitiated) nativeSetVideoGroupsPrefixLength(lenght);
}
@WorkerThread
public AbstractAlbum[] getAlbums() {
......@@ -533,6 +554,9 @@ public class Medialibrary extends AbstractMedialibrary {
private native AbstractMediaWrapper[] nativeGetRecentAudio();
private native int nativeGetVideoCount();
private native int nativeGetAudioCount();
private native AbstractVideoGroup[] nativeGetVideoGroups(int sort, boolean desc, int nbItems, int offset);
private native int nativeGetVideoGroupsCount();
private native void nativeSetVideoGroupsPrefixLength(int length);
private native AbstractAlbum[] nativeGetAlbums(int sort, boolean desc);
private native AbstractAlbum[] nativeGetPagedAlbums(int sort, boolean desc, int nbItems, int offset);
private native int nativeGetAlbumsCount();
......
......@@ -22,6 +22,7 @@ import org.videolan.medialibrary.interfaces.media.AbstractFolder;
import org.videolan.medialibrary.interfaces.media.AbstractGenre;
import org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper;
import org.videolan.medialibrary.interfaces.media.AbstractPlaylist;
import org.videolan.medialibrary.interfaces.media.AbstractVideoGroup;
import org.videolan.medialibrary.media.SearchAggregate;
import java.io.File;
......@@ -599,6 +600,9 @@ abstract public class AbstractMedialibrary {
abstract public AbstractMediaWrapper[] getRecentAudio();
abstract public int getVideoCount();
abstract public int getAudioCount();
abstract public AbstractVideoGroup[] getVideoGroups(int sort, boolean desc, int nbItems, int offset);
abstract public int getVideoGroupsCount();
abstract public void setVideoGroupsPrefixLength(int lenght);
abstract public AbstractAlbum[] getAlbums();
abstract public AbstractAlbum[] getAlbums(int sort, boolean desc);
abstract public AbstractAlbum[] getPagedAlbums(int sort, boolean desc, int nbItems, int offset);
......
package org.videolan.medialibrary.interfaces.media;
import android.os.Parcel;
import android.os.Parcelable;
import org.videolan.medialibrary.MLServiceLocator;
import org.videolan.medialibrary.media.MediaLibraryItem;
public abstract class AbstractVideoGroup extends MediaLibraryItem {
public int mCount;
public AbstractVideoGroup(String name, int count) {
super(0L, name);
mCount = count;
}
abstract public AbstractMediaWrapper[] media(int sort, boolean desc, int nbItems, int offset);
abstract public AbstractMediaWrapper[] searchTracks(String query, int sort, boolean desc, int nbItems, int offset);
abstract public int searchTracksCount(String query);
public int mediaCount() {
return mCount;
}
@Override
public AbstractMediaWrapper[] getTracks() {
return new AbstractMediaWrapper[0];
}
@Override
public int getTracksCount() {
return mCount;
}
@Override
public int getItemType() {
return TYPE_VIDEO_GROUP;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
super.writeToParcel(parcel, i);
parcel.writeInt(mCount);
}
public static Parcelable.Creator<AbstractVideoGroup> CREATOR = new Parcelable.Creator<AbstractVideoGroup>() {
@Override
public AbstractVideoGroup createFromParcel(Parcel in) {
return MLServiceLocator.getAbstractVideoGroup(in);
}
@Override
public AbstractVideoGroup[] newArray(int size) {
return new AbstractVideoGroup[size];
}
};
public AbstractVideoGroup(Parcel in) {
super(in);
this.mCount = in.readInt();
}
}
......@@ -8,15 +8,16 @@ import org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper;
public abstract class MediaLibraryItem implements Parcelable {
public static final int TYPE_ALBUM = 1 << 1;
public static final int TYPE_ARTIST = 1 << 2;
public static final int TYPE_GENRE = 1 << 3;
public static final int TYPE_PLAYLIST = 1 << 4;
public static final int TYPE_MEDIA = 1 << 5;
public static final int TYPE_DUMMY = 1 << 6;
public static final int TYPE_STORAGE = 1 << 7;
public static final int TYPE_HISTORY = 1 << 9;
public static final int TYPE_FOLDER = 1 << 10;
public static final int TYPE_ALBUM = 1 << 1;
public static final int TYPE_ARTIST = 1 << 2;
public static final int TYPE_GENRE = 1 << 3;
public static final int TYPE_PLAYLIST = 1 << 4;
public static final int TYPE_MEDIA = 1 << 5;
public static final int TYPE_DUMMY = 1 << 6;
public static final int TYPE_STORAGE = 1 << 7;
public static final int TYPE_HISTORY = 1 << 9;
public static final int TYPE_FOLDER = 1 << 10;
public static final int TYPE_VIDEO_GROUP = 1 << 11;
public static final int FLAG_NONE = 0;
public static final int FLAG_SELECTED = 1;
......
package org.videolan.medialibrary.media;
import android.os.Parcel;
import androidx.annotation.WorkerThread;
import org.videolan.medialibrary.interfaces.AbstractMedialibrary;
import org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper;
import org.videolan.medialibrary.interfaces.media.AbstractVideoGroup;
public class VideoGroup extends AbstractVideoGroup {
VideoGroup(String name, int count) {
super(name, count);
}
public VideoGroup(Parcel in) {
super(in);
}
@Override
@WorkerThread
public AbstractMediaWrapper[] media(int sort, boolean desc, int nbItems, int offset) {
final AbstractMedialibrary ml = AbstractMedialibrary.getInstance();
return ml.isInitiated() ? nativeMedia(ml, mTitle, sort, desc, nbItems, offset) : AbstractMedialibrary.EMPTY_COLLECTION;
}
@Override
@WorkerThread
public AbstractMediaWrapper[] searchTracks(String query, int sort, boolean desc, int nbItems, int offset) {
final AbstractMedialibrary ml = AbstractMedialibrary.getInstance();
return ml.isInitiated() ? nativeSearch(ml, mTitle, query, sort, desc, nbItems, offset) : AbstractMedialibrary.EMPTY_COLLECTION;
}
@Override
@WorkerThread
public int searchTracksCount(String query) {
final AbstractMedialibrary ml = AbstractMedialibrary.getInstance();
return ml.isInitiated() ? nativeGetSearchCount(ml, mTitle, query) : 0;
}
private native AbstractMediaWrapper[] nativeMedia(AbstractMedialibrary ml, String name, int sort, boolean desc, int nbItems, int offset);
private native AbstractMediaWrapper[] nativeSearch(AbstractMedialibrary ml, String name, String query, int sort, boolean desc, int nbItems, int offset);
private native int nativeGetSearchCount(AbstractMedialibrary ml, String name, String query);
}
......@@ -14,6 +14,7 @@ import org.videolan.medialibrary.interfaces.media.AbstractFolder;
import org.videolan.medialibrary.interfaces.media.AbstractGenre;
import org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper;
import org.videolan.medialibrary.interfaces.media.AbstractPlaylist;
import org.videolan.medialibrary.interfaces.media.AbstractVideoGroup;
import org.videolan.medialibrary.media.SearchAggregate;
import java.util.ArrayList;
......@@ -126,6 +127,19 @@ public class StubMedialibrary extends AbstractMedialibrary {
return dt.mAudioMediaWrappers.size();
}
@Override
public AbstractVideoGroup[] getVideoGroups(int sort, boolean desc, int nbItems, int offset) {
return new AbstractVideoGroup[0];
}
@Override