From: Matthieu Bouron <matthieu.bouron@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] Add protocol for Android content providers
Date: Thu, 15 Feb 2024 08:57:35 +0100
Message-ID: <Zc3D78N2iuIAZmYp@kusa> (raw)
In-Reply-To: <tencent_EAA7C54C930BC84113E3D37555C349178E05@qq.com>
On Thu, Feb 15, 2024 at 12:13:59PM +0800, Zhao Zhili wrote:
>
>
> > On Feb 14, 2024, at 06:50, Matthieu Bouron <matthieu.bouron@gmail.com> wrote:
> >
> > Hi,
> >
> > On Android, content providers are used for accessing files through shared
> > mechanisms. One typical case would be an app willing to open a video from
> > Google Photos, gallery apps, TikTok, Instagram or some other providers.
> > A content URI looks something like "content://authority/path/id", see:
> > https://developer.android.com/reference/android/content/ContentUris
> > https://developer.android.com/guide/topics/providers/content-provider-basics
> >
> > It can currently be somehow managed through clumsy means such as using a "fd:"
> > filename and crafting a special AVOption, which also has the drawback of
> > requiring the third party to carry around opened file descriptors (with the
> > multiple opened file limitations implied). Custom AVIOContexts are also an
>
> File descriptor is a general abstraction layer, it target more platforms than
> Android specific content provider. Android provided getFd() API since API
> level 12, I guess that’s the default method to deal with content provider in
> native code. It’s a few lines of code to get native fd in Java, but dozens of code
> in C with JNI, which is what this patchset done.
>
> For multiple opened file limitations issue, they can close the file descriptor after
> open. It’s unlikely to reach the limit in normal case without leak.
>
> I’m OK to provide this android_content_protocol helper if user requests.
I've been doing this kind of work for 3/4 users (including myself) at this
point and have to do it another time, this is what motivated me to propose
this patchset.
>
> > option. Both options will have to deal with the JNI though and end users will
> > have to re-implement the same exact thing.
>
> User still need to deal with JNI with the new android_content_protocol, more or
> less, it’s unavoidable.
The advantage I see of using this protocol is that the user only need to
call av_jni_set_jvm() + av_jni_set_android_app_ctx() at the start of the
application and FFmpeg will handle the content-uri transparently. This is
especially helpful if the Android application rely on multiple libraries
that in turn rely on FFmpeg to read medias.
>
> >
> > This patchset addresses this by adding a content provider protocol, which has
> > an API fairly similar to fopen. Android 11 appears to provide something
> > transparent within fopen(), but FFmpeg doesn't use it in the file protocol, and
> > Android < 11 are still widely used.
> >
> > The first part move the JNI infrastructure from avcodec to avutil (it remains
> > internally shared, there is little user implication),
>
> OK. JNI infrastructure should belong to avutil at the first place, so hwcontext_mediacodec
> and so on can use it. Unfortunately for those new avpriv_.
What do you mean by "Unfortunately" ? Would you like to make the JNI API
public ?
[...]
_______________________________________________
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".
next prev parent reply other threads:[~2024-02-15 7:57 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 22:50 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 [this message]
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
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=Zc3D78N2iuIAZmYp@kusa \
--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