Ml: Subscriptions add nbMedia new API

This commit is contained in:
Duncan McNamara 2022-11-16 15:58:28 +01:00 committed by Nicolas Pomepuy
parent 762d336e2d
commit 46c5f37616
4 changed files with 25 additions and 2 deletions

View File

@ -2303,7 +2303,7 @@ getSubscriptionNbUnplayedMedia(JNIEnv *env, jobject thiz, jobject medialibrary,
{
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, medialibrary);
medialibrary::SubscriptionPtr subscriptionPtr = aml->subscription(id);
if (subscriptionPtr == nullptr) return false;
if (subscriptionPtr == nullptr) return -1;
return subscriptionPtr->nbUnplayedMedia();
}
@ -2368,6 +2368,15 @@ getSubscriptionMedia(JNIEnv* env, jobject thiz, jobject ml, jlong id, jint sorti
return subsRefs;
}
jint getSubscriptionNbMedia(JNIEnv* env, jobject thiz, jobject ml, jlong id)
{
AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, ml);
medialibrary::SubscriptionPtr subscriptionPtr = aml->subscription(id);
if (subscriptionPtr == nullptr) return -1;
return subscriptionPtr->nbMedia();
}
/*
* JNI stuff
*/
@ -2600,7 +2609,8 @@ static JNINativeMethod subscription_methods[] = {
{"nativeGetChildSubscriptions", "(Lorg/videolan/medialibrary/interfaces/Medialibrary;JIZZ)[Lorg/videolan/medialibrary/interfaces/media/Subscription;", (void*)getChildSubscriptions},
{"nativeGetParent", "(Lorg/videolan/medialibrary/interfaces/Medialibrary;J)Lorg/videolan/medialibrary/interfaces/media/Subscription;", (void*)getParent},
{"nativeSubscriptionRefresh", "(Lorg/videolan/medialibrary/interfaces/Medialibrary;J)Z", (void*)refresh},
{"nativeGetSubscriptionMedia", "(Lorg/videolan/medialibrary/interfaces/Medialibrary;JIZZ)[Lorg/videolan/medialibrary/interfaces/media/MediaWrapper;", (void*)getSubscriptionMedia}
{"nativeGetSubscriptionMedia", "(Lorg/videolan/medialibrary/interfaces/Medialibrary;JIZZ)[Lorg/videolan/medialibrary/interfaces/media/MediaWrapper;", (void*)getSubscriptionMedia},
{"nativeGetSubscriptionNbMedia", "(Lorg/videolan/medialibrary/interfaces/Medialibrary;J)I", (void*)getSubscriptionNbMedia},
};
/* This function is called when a thread attached to the Java VM is canceled or

View File

@ -34,4 +34,5 @@ public abstract class Subscription {
public abstract Subscription getParent();
public abstract MediaWrapper[] getMedia(int sortingCriteria, boolean desc, boolean includeMissing);
public abstract boolean refresh();
public abstract int getNbMedia();
}

View File

@ -75,6 +75,12 @@ public class SubscriptionImpl extends Subscription {
return nativeGetSubscriptionMedia(ml, id, sortingCriteria, desc, includeMissing);
}
@Override
public int getNbMedia() {
final Medialibrary ml = Medialibrary.getInstance();
return nativeGetSubscriptionNbMedia(ml, id);
}
private native int nativeSubscriptionNewMediaNotification(Medialibrary ml, long id);
private native boolean nativeSetSubscriptionNewMediaNotification(Medialibrary ml, long id, int value);
private native long nativeGetSubscriptionCachedSize(Medialibrary ml, long id);
@ -85,4 +91,5 @@ public class SubscriptionImpl extends Subscription {
private native Subscription nativeGetParent(Medialibrary ml, long id);
private native boolean nativeSubscriptionRefresh(Medialibrary ml, long id);
private native MediaWrapper[] nativeGetSubscriptionMedia(Medialibrary ml, long id, int sortingCriteria, boolean desc, boolean includeMissing);
private native int nativeGetSubscriptionNbMedia(Medialibrary ml, long id);
}

View File

@ -63,4 +63,9 @@ public class StubSubscription extends Subscription {
public boolean refresh() {
return false;
}
@Override
public int getNbMedia() {
return 0;
}
}