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 E91F249A96 for ; Tue, 27 Feb 2024 14:56:12 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E8E9368CC0B; Tue, 27 Feb 2024 16:56:05 +0200 (EET) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E075E68CBD7 for ; Tue, 27 Feb 2024 16:55:58 +0200 (EET) Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-5101cd91017so6418327e87.2 for ; Tue, 27 Feb 2024 06:55:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709045758; x=1709650558; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RwW1CJQtfQILe+wiKC0hERGdn0Ju6cDDGRNPYfPybJo=; b=lVJruL453zS71iq+GdOZgpEXbVO6qKcI8pYRhqvtShf4ehpzl3ZfWmSC+9mm2SxncE ozGjOUiwpzyO1lMstWgWwCHWCQUtEOgct99bQhqakURe/x1YJ0sz7A9b7qkcrF8SRdNi JbpvWU4Tti6S+fO+8pzS8YLTY2QbOrd4C2QBEG4WVxku0FeFVLYWZVXJWv+e3162JO1O BBOXKc77wS5yVqSrj3VYXVoBhxbGuuRDpXNpkHhVM5DMS/I/IREvajY5PIJL4PvMQ0+O 3KaP0j5pdIeIcMniDk5csgMDlzup1ikyU9uC6h+vtLZzftbvtmodj/6j/wNVV9PGILy7 sQQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709045758; x=1709650558; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RwW1CJQtfQILe+wiKC0hERGdn0Ju6cDDGRNPYfPybJo=; b=FYi4qQnp4clpDdtIqPvGWewYArYtgOe1jhY8C3yarycx9wPDwypjpcVG9J4ZX9Vysd 2k4vdgIZnKrhd583GWH8PHf3YGyvSeD0YU7IL1vBpsARv29B0wifxyhuUF+cagxLWe9I Cs5WMXo5wado5FbQ4XmxDoiH8WmIjKydkqQJgoMsLeZxVyOr8hexguAexbrgddD39jNr TL5r5HCAuicDuzDfwhlnEr4UoybJtSNLnWhyqD+p1rRipmmHVS7RLPNMtULNdEAXs2DY DUQe5mRE5ERq11N2mKEWbu10cNU6qx+w87zsRU9wbLTEismuDaSApEI5rFlqb2bbGvIe m8tA== X-Gm-Message-State: AOJu0YzFVTHCvwH6AkzkUHE76f1lTOSWXW9tUEnS5Qudt0HBbu9fOGB3 RFtq48swbVE+YP01nzVLPrANQJQZmTLOP6UPd2BG1AxcmVMCkvjg9ITtedSV X-Google-Smtp-Source: AGHT+IH9fhF3drazEiKS9YgxhrH8VfEovVMv5i03h/tYz4Erw4hsWvZzS/8BU3XTDGZ/8C2z5T/V2Q== X-Received: by 2002:a05:6512:48da:b0:511:88cc:4f00 with SMTP id er26-20020a05651248da00b0051188cc4f00mr5759203lfb.56.1709045757666; Tue, 27 Feb 2024 06:55:57 -0800 (PST) Received: from localhost.localdomain (2a01cb040b6872000000000000000afa.ipv6.abo.wanadoo.fr. [2a01:cb04:b68:7200::afa]) by smtp.gmail.com with ESMTPSA id o9-20020a5d4a89000000b0033df1dc39f0sm1859627wrq.4.2024.02.27.06.55.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 06:55:57 -0800 (PST) From: Matthieu Bouron To: ffmpeg-devel@ffmpeg.org Date: Tue, 27 Feb 2024 15:50:37 +0100 Message-ID: <20240227145536.281991-2-matthieu.bouron@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227145536.281991-1-matthieu.bouron@gmail.com> References: <20240213230418.457056-1-matthieu.bouron@gmail.com> <20240227145536.281991-1-matthieu.bouron@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/6] avcodec: 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 Cc: Matthieu Bouron 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: This will allow users to pass the Android ApplicationContext which is mandatory to retrieve the ContentResolver responsible to resolve/open Android content-uri. --- libavcodec/jni.c | 40 ++++++++++++++++++++++++++++++++++++++++ libavcodec/jni.h | 17 +++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/libavcodec/jni.c b/libavcodec/jni.c index ae6490de9d..7d04d0a268 100644 --- a/libavcodec/jni.c +++ b/libavcodec/jni.c @@ -64,6 +64,36 @@ void *av_jni_get_java_vm(void *log_ctx) return vm; } +int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx) +{ + JNIEnv *env = avpriv_jni_get_env(c); + 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; +} + +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) @@ -76,4 +106,14 @@ void *av_jni_get_java_vm(void *log_ctx) return NULL; } +int av_jni_set_android_app_ctx(void *app_ctx, void *log_ctx) +{ + return AVERROR(ENOSYS); +} + +void *av_jni_get_android_app_ctx(void) +{ + return NULL; +} + #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); + #endif /* AVCODEC_JNI_H */ -- 2.44.0 _______________________________________________ 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".