From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id A041148A73 for ; Tue, 27 Feb 2024 14:46:33 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7AB2E68CB98; Tue, 27 Feb 2024 16:46:30 +0200 (EET) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D3C0668C7B8 for ; Tue, 27 Feb 2024 16:46:23 +0200 (EET) Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2d27184197cso53584671fa.1 for ; Tue, 27 Feb 2024 06:46:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709045183; x=1709649983; darn=ffmpeg.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=rUV2eMFpYk8hIp9rpMv0N3ykGcOL/lOjAb4aRw+oJB4=; b=Jd+QfQ9O4fRwp5XVVwhToPPQoxJRPv+gXD496+aZqxD5Yq4NNuAu5608bJ/LtNiQfW jsAfbWVJzqQpS+qAyLxT8UxM7mJEsnsQM2QJHz9wvmN498SZRAOErdvWyRJ1wEFl1TAR hiDTwpJ5NaMGufCucncCGioJHWIifmoY9AItWJa9ow4dksUwtlhs2qGhZ4biGFnpnlUd 8K54dMQf5123c8qhEBtEh05e4VGkRVvg/IFIzsZRqVNMi8O2FeBhkP8y35nPhqDwfs7o FArcX1Dd7D8+MPlxSOrPZ1oZn3xfnZwQDk3bzHSnMomckQXHachavhiXLri9IS6XP1mx 0Y3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709045183; x=1709649983; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=rUV2eMFpYk8hIp9rpMv0N3ykGcOL/lOjAb4aRw+oJB4=; b=JS8R5VimPabnl4plNhxal+r9M/B6rSkAQK+C+IQmU0MYn3lNGBNoLTsF1rpLzNgYBd w2AKhuhfqXSL56CefiuxcJ3G+HWplPKE5iMzNrM7eikhFFoGMqKi/RvoiD7BJUZwbBNE 3H7sA4Mk0Pk4pqDnz2BGE7zB0QvHrgl4ppfe/uG9ViixzgxWAL1fHQqKoTHjgtePQ5Y+ 8sq0o8ihrtIzkIVNUTdlpqJf5WvLpfK3KmPyaOGv3v4+NyCvm3ybvIIv+5gkyFqG/pkT IrXjwhGBY9xBryYQ5PMs21AZsWydJoW3p0nGkNIw/9vD88WqnehSu1VreSWqNx+fzBES N2HQ== X-Gm-Message-State: AOJu0YwwdLnnApXn2Ulv0G6dauNIWObb/KCDlu1y/ADh+so/dauM82nx 7FYNIoyq7QP5L+/GOUYE5MKsyR74ig1+yAAhe4pMW7Rxo+mGs2D87d0WG0Ih X-Google-Smtp-Source: AGHT+IHq6kRvHxAVlf4LYxlGJZ7lPQPArm8Eud9z8ubrYpK/IK0v2VgZiJflXz/0IBBBtYRXMRJgng== X-Received: by 2002:a2e:a70a:0:b0:2d2:af89:3d57 with SMTP id s10-20020a2ea70a000000b002d2af893d57mr103723lje.6.1709045182744; Tue, 27 Feb 2024 06:46:22 -0800 (PST) Received: from kusa (2a01cb040b6872000000000000000afa.ipv6.abo.wanadoo.fr. [2a01:cb04:b68:7200::afa]) by smtp.gmail.com with ESMTPSA id w21-20020a05600c015500b004128da16dddsm14965203wmm.15.2024.02.27.06.46.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 06:46:22 -0800 (PST) Date: Tue, 27 Feb 2024 15:46:20 +0100 From: Matthieu Bouron To: FFmpeg development discussions and patches Message-ID: References: <20240213230418.457056-1-matthieu.bouron@gmail.com> <20240213230418.457056-3-matthieu.bouron@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH 2/7] avutil: add av_jni_{get, set}_android_app_ctx helper X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Tue, Feb 27, 2024 at 02:42:01PM +0100, Andreas Rheinhardt 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. > > --- > > libavutil/jni.c | 28 ++++++++++++++++++++++++++++ > > libavutil/jni.h | 17 +++++++++++++++++ > > 2 files changed, 45 insertions(+) > > > > diff --git a/libavutil/jni.c b/libavutil/jni.c > > index 541747cb20..d6f96717b0 100644 > > --- a/libavutil/jni.c > > +++ b/libavutil/jni.c > > @@ -34,6 +34,7 @@ > > #include "libavutil/jni.h" > > > > static void *java_vm; > > +static void *android_app_ctx; > > static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; > > > > int av_jni_set_jvm(void *vm, void *log_ctx) > > @@ -63,6 +64,24 @@ void *av_jni_get_jvm(void *log_ctx) > > return vm; > > } > > > > +void av_jni_set_android_app_ctx(void *app_ctx) > > +{ > > + pthread_mutex_lock(&lock); > > + android_app_ctx = app_ctx; > > + pthread_mutex_unlock(&lock); > > +} > > + > > +void *av_jni_get_android_app_ctx(void) > > +{ > > + void *ctx; > > + > > + pthread_mutex_lock(&lock); > > + ctx = android_app_ctx; > > + pthread_mutex_unlock(&lock); > > + > > + return ctx; > > +} > > + > > #else > > > > int av_jni_set_java_vm(void *vm, void *log_ctx) > > @@ -75,4 +94,13 @@ void *av_jni_get_java_vm(void *log_ctx) > > return NULL; > > } > > > > +void av_jni_set_android_app_ctx(void *app_ctx) > > +{ > > +} > > + > > +void *av_jni_get_android_app_ctx(void) > > +{ > > + return NULL; > > +} > > + > > #endif > > diff --git a/libavutil/jni.h b/libavutil/jni.h > > index 700960dbb8..630f4074a1 100644 > > --- a/libavutil/jni.h > > +++ b/libavutil/jni.h > > @@ -43,4 +43,21 @@ int av_jni_set_jvm(void *vm, void *log_ctx); > > */ > > void *av_jni_get_jvm(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 > > + */ > > +void av_jni_set_android_app_ctx(void *app_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); > > + > > + > > #endif /* AVUTIL_JNI_H */ > > This adds global state in order to pass the application context to your > protocol (in lieu of an option to pass pointers to a protocol). Can > there be scenarios in which multiple application contexts are useful in > the same process? This is intended. In general, there is only one application context that lives for the entire application lifetime. I don't think there is any useful scenario where multiple application contexts are useful (and I haven't encountered any), even while unit testing (where you can easily craft multiple application contexts). _______________________________________________ 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".