Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Matthieu Bouron <matthieu.bouron@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v4 1/6] avcodec: add av_jni_{get, set}_android_app_ctx helper
Date: Sun, 17 Mar 2024 23:43:50 +0100
Message-ID: <CAOmVQXGzXzUV0sw5et0tDh+L4Kb2h0yFxYFZ07wn_m4yH7576Q@mail.gmail.com> (raw)
In-Reply-To: <AS8P250MB07440FB9CB37CE30BDC187F88F2E2@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>

On Sun, Mar 17, 2024 at 11:38 PM Andreas Rheinhardt
<andreas.rheinhardt@outlook.com> wrote:
>
> Matthieu Bouron:
> > This will allow users to pass the Android ApplicationContext which is mandatory
> > to retrieve the ContentResolver responsible to resolve/open Android content-uri.
> > ---
> >  doc/APIchanges   |  3 +++
> >  libavcodec/jni.c | 42 ++++++++++++++++++++++++++++++++++++++++++
> >  libavcodec/jni.h | 17 +++++++++++++++++
> >  3 files changed, 62 insertions(+)
> >
> > diff --git a/doc/APIchanges b/doc/APIchanges
> > index a44c8e4f10..ae1868047e 100644
> > --- a/doc/APIchanges
> > +++ b/doc/APIchanges
> > @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2024-03-07
> >
> >  API changes, most recent first:
> >
> > +2024-03-xx - xxxxxxxxxx - lavc 61.2.100 - jni.h
> > +  Add av_jni_set_android_app_ctx() and av_jni_get_android_app_ctx().
> > +
> >  2024-03-xx - xxxxxxxxxx - lavu 59.2.100 - channel_layout.h
> >    Add AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL.
> >
> > diff --git a/libavcodec/jni.c b/libavcodec/jni.c
> > index ae6490de9d..cfe95bd1ec 100644
> > --- a/libavcodec/jni.c
> > +++ b/libavcodec/jni.c
> > @@ -77,3 +77,45 @@ void *av_jni_get_java_vm(void *log_ctx)
> >  }
> >
> >  #endif
> > +
> > +#if defined(__ANDROID__)
> > +
> > +int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx)
> > +{
> > +#if CONFIG_JNI
> > +    JNIEnv *env = ff_jni_get_env(log_ctx);
> > +    if (!env)
> > +        return AVERROR(EINVAL);
> > +
> > +    jobjectRefType type = (*env)->GetObjectRefType(env, app_ctx);
> > +    if (type != JNIGlobalRefType) {
> > +        av_log(log_ctx, AV_LOG_ERROR, "Application context must be passed as a global reference");
> > +        return AVERROR(EINVAL);
> > +    }
> > +
> > +    pthread_mutex_lock(&lock);
> > +    android_app_ctx = app_ctx;
> > +    pthread_mutex_unlock(&lock);
> > +
> > +    return 0;
> > +#else
> > +    return AVERROR(ENOSYS);
> > +#endif
> > +}
> > +
> > +void *av_jni_get_android_app_ctx(void)
> > +{
> > +#if CONFIG_JNI
> > +    void *ctx;
> > +
> > +    pthread_mutex_lock(&lock);
> > +    ctx = android_app_ctx;
> > +    pthread_mutex_unlock(&lock);
> > +
> > +    return ctx;
> > +#else
> > +    return NULL;
> > +#endif
> > +}
> > +
> > +#endif
> > diff --git a/libavcodec/jni.h b/libavcodec/jni.h
> > index dd99e92611..da8025f830 100644
> > --- a/libavcodec/jni.h
> > +++ b/libavcodec/jni.h
> > @@ -43,4 +43,21 @@ int av_jni_set_java_vm(void *vm, void *log_ctx);
> >   */
> >  void *av_jni_get_java_vm(void *log_ctx);
> >
> > +/*
> > + * Set the Android application context which will be used to retrieve the Android
> > + * content resolver to resolve content uris.
> > + *
> > + * @param app_ctx global JNI reference to the Android application context
> > + * @return 0 on success, < 0 otherwise
> > + */
> > +int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx);
> > +
> > +/*
> > + * Get the Android application context that has been set with
> > + * av_jni_set_android_app_ctx.
> > + *
> > + * @return a pointer the the Android application context
> > + */
> > +void *av_jni_get_android_app_ctx(void);
>
> This should mention that these functions are only available on android.

Added the following chunk locally to both functions:

  *
+ * This function is only available on Android.
+ *
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2024-03-17 22:44 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13 22:50 [FFmpeg-devel] Add protocol for Android content providers Matthieu Bouron
2024-02-13 22:50 ` [FFmpeg-devel] [PATCH 1/7] avcodec: move ffjni to avutil/jniutils Matthieu Bouron
2024-02-14 18:18   ` Michael Niedermayer
2024-02-14 22:23     ` Matthieu Bouron
2024-02-14 23:31   ` Mark Thompson
2024-02-15  7:40     ` Matthieu Bouron
2024-02-13 22:50 ` [FFmpeg-devel] [PATCH 2/7] avutil: add av_jni_{get, set}_android_app_ctx helper Matthieu Bouron
2024-02-27 13:42   ` Andreas Rheinhardt
2024-02-27 14:46     ` Matthieu Bouron
2024-02-13 22:50 ` [FFmpeg-devel] [PATCH 3/7] avformat: add Android content resolver protocol support Matthieu Bouron
2024-02-13 22:50 ` [FFmpeg-devel] [PATCH 4/7] avutil/jni: use size_t to store structure offsets Matthieu Bouron
2024-02-13 22:50 ` [FFmpeg-devel] [PATCH 5/7] avutil/jni: remove unnecessary NULL checks before calling DeleteLocalRef() Matthieu Bouron
2024-02-13 22:50 ` [FFmpeg-devel] [PATCH 6/7] avcodec/mediacodec_wrapper: use an OFFSET() macro where relevant Matthieu Bouron
2024-02-13 22:50 ` [FFmpeg-devel] [PATCH 7/7] avcodec/mediacodec_wrapper: remove unnecessary NULL checks before calling Delete{Global, Local}Ref() Matthieu Bouron
2024-02-15  4:13 ` [FFmpeg-devel] Add protocol for Android content providers Zhao Zhili
2024-02-15  7:57   ` Matthieu Bouron
2024-02-15  8:46     ` Zhao Zhili
2024-02-15  9:13       ` Matthieu Bouron
2024-02-24 11:29         ` Matthieu Bouron
2024-02-27  7:17           ` Matthieu Bouron
2024-02-27 13:14             ` Zhao Zhili
2024-02-27 13:19               ` Matthieu Bouron
2024-02-27 14:50 ` [FFmpeg-devel] Add protocol for Android content providers (v2) Matthieu Bouron
2024-02-27 14:50   ` [FFmpeg-devel] [PATCH v2 1/6] avcodec: add av_jni_{get, set}_android_app_ctx helper Matthieu Bouron
2024-03-04 11:30     ` Andreas Rheinhardt
2024-03-04 15:11       ` Matthieu Bouron
2024-03-04 16:35         ` Matthieu Bouron
2024-03-04 19:36           ` Matthieu Bouron
2024-02-27 14:50   ` [FFmpeg-devel] [PATCH v2 2/6] avformat: add Android content resolver protocol support Matthieu Bouron
2024-03-04 19:37     ` Matthieu Bouron
2024-03-17  4:33       ` Zhao Zhili
2024-03-17 22:34         ` Matthieu Bouron
2024-02-27 14:50   ` [FFmpeg-devel] [PATCH v2 3/6] avutil/jni: use size_t to store structure offsets Matthieu Bouron
2024-03-04 20:10     ` Andreas Rheinhardt
2024-03-05  7:58       ` Matthieu Bouron
2024-02-27 14:50   ` [FFmpeg-devel] [PATCH v2 4/6] avutil/jni: remove unnecessary NULL checks before calling DeleteLocalRef() Matthieu Bouron
2024-02-27 14:50   ` [FFmpeg-devel] [PATCH v2 5/6] avcodec/mediacodec_wrapper: use an OFFSET() macro where relevant Matthieu Bouron
2024-02-27 14:50   ` [FFmpeg-devel] [PATCH v2 6/6] avcodec/mediacodec_wrapper: remove unnecessary NULL checks before calling Delete{Global, Local}Ref() Matthieu Bouron
2024-03-04  8:21   ` [FFmpeg-devel] Add protocol for Android content providers (v2) Matthieu Bouron
2024-03-14  8:04     ` Matthieu Bouron
2024-03-17 22:28   ` [FFmpeg-devel] Add protocol for Android content providers (v4) Matthieu Bouron
2024-03-17 22:28     ` [FFmpeg-devel] [PATCH v4 1/6] avcodec: add av_jni_{get, set}_android_app_ctx helper Matthieu Bouron
2024-03-17 22:38       ` Andreas Rheinhardt
2024-03-17 22:43         ` Matthieu Bouron [this message]
2024-03-17 22:28     ` [FFmpeg-devel] [PATCH v4 2/6] avformat: add Android content resolver protocol support Matthieu Bouron
2024-03-17 22:28     ` [FFmpeg-devel] [PATCH v4 3/6] avcodec/jni: use size_t to store structure offsets Matthieu Bouron
2024-03-17 22:28     ` [FFmpeg-devel] [PATCH v4 4/6] avcodec/jni: remove unnecessary NULL checks before calling DeleteLocalRef() Matthieu Bouron
2024-03-17 22:28     ` [FFmpeg-devel] [PATCH v4 5/6] avcodec/mediacodec_wrapper: use an OFFSET() macro where relevant Matthieu Bouron
2024-03-17 22:28     ` [FFmpeg-devel] [PATCH v4 6/6] avcodec/mediacodec_wrapper: remove unnecessary NULL checks before calling Delete{Global, Local}Ref() Matthieu Bouron
2024-03-19 17:49     ` [FFmpeg-devel] Add protocol for Android content providers (v4) Matthieu Bouron
2024-03-23 10:40       ` Matthieu Bouron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOmVQXGzXzUV0sw5et0tDh+L4Kb2h0yFxYFZ07wn_m4yH7576Q@mail.gmail.com \
    --to=matthieu.bouron@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git