Pass image MIME and private conversation generation through Android JNI

This commit is contained in:
evgeny committed 2026-10-28 12:08:06 +01:00
1 parent e4af3907c2
commit 233a3f78d1
3 files changed
+15 -10

No files matched your search

@@ -282,8 +282,9 @@ object NativeLib {
private external fun nativeStreamOpusClose(handle: Long)
/* ── Photo message ── */
fun photoSend(channelId: String, filePath: String, width: Int, height: Int, replyTo: String = "", requestId: Long = 0): Boolean =
nativePhotoSend(channelId, filePath, width, height, messageIdBytes(replyTo), requestId)
fun photoSend(channelId: String, filePath: String, width: Int, height: Int, contentType: String,
replyTo: String = "", requestId: Long = 0, generation: Long = 0): Boolean =
nativePhotoSend(channelId, filePath, width, height, messageIdBytes(replyTo), requestId, contentType, generation)
/* ── Voice playback ── */
fun voiceDecodeOpen(filePath: String, outInfo: IntArray): Long = nativeVoiceDecodeOpen(filePath, outInfo)
@@ -442,7 +443,7 @@ object NativeLib {
/* ── Photo message JNI ── */
private external fun nativePhotoSend(channelId: String, filePath: String, width: Int, height: Int,
replyTo: ByteArray, requestId: Long): Boolean
replyTo: ByteArray, requestId: Long, contentType: String, generation: Long): Boolean
/* ── Voice playback JNI ── */
private external fun nativeVoiceDecodeOpen(filePath: String, outInfo: IntArray): Long
@@ -1501,8 +1501,9 @@ int utun_bridge_video_send(const char* channel_id, const char* file_path, const
}
int utun_bridge_photo_send(const char* channel_id, const char* file_path, const char* db_path,
int width, int height, const uint8_t reply_to[32], uint64_t request_id) {
return photo_send(channel_id, file_path, db_path, width, height, reply_to, request_id);
int width, int height, const uint8_t reply_to[32], uint64_t request_id,
const char* content_type, uint64_t generation) {
return photo_send(channel_id, file_path, db_path, width, height, reply_to, request_id, content_type, generation);
}
/* ──────────────────────────────────────────────────────────────────
@@ -2636,13 +2637,15 @@ JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeVideoSend(
JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativePhotoSend(
JNIEnv* env, jobject thiz, jstring channelId, jstring filePath,
jint width, jint height, jbyteArray replyTo, jlong requestId) {
jint width, jint height, jbyteArray replyTo, jlong requestId, jstring contentType, jlong generation) {
(void)thiz;
uint8_t reply[32];
if (jni_message_id(env, replyTo, reply) < 0) return JNI_FALSE;
const char* ch = (*env)->GetStringUTFChars(env, channelId, NULL);
const char* fp = (*env)->GetStringUTFChars(env, filePath, NULL);
int rc = utun_bridge_photo_send(ch, fp, g_db_path, (int)width, (int)height, reply, (uint64_t)requestId);
const char* type = (*env)->GetStringUTFChars(env, contentType, NULL);
int rc = utun_bridge_photo_send(ch, fp, g_db_path, (int)width, (int)height, reply, (uint64_t)requestId, type, (uint64_t)generation);
if (type) (*env)->ReleaseStringUTFChars(env, contentType, type);
if (fp) (*env)->ReleaseStringUTFChars(env, filePath, fp);
if (ch) (*env)->ReleaseStringUTFChars(env, channelId, ch);
return (rc == 0) ? JNI_TRUE : JNI_FALSE;
@@ -139,10 +139,11 @@ int utun_bridge_attachment_download(const char* channel_id, int64_t msg_id);
int utun_bridge_video_send(const char* channel_id, const char* file_path, const char* db_path,
int duration_ms, int width, int height, const uint8_t reply_to[32], uint64_t request_id, uint64_t generation);
/* Готовое фото в канал, без декодирования; JPEG/PNG/GIF/BMP/WebP по расширению, caller задаёт размеры.
* db_path — каталог БД; источник остаётся у caller до завершения копирования. 0/-1, см. photo_sender.h. */
/* Готовое изображение: MIME/размеры проверяет Android, JPEG/PNG в канал или dm:<conv> с generation.
* 0 передаёт JPEG/PNG cache-файл задаче, -1 оставляет caller; дополнительные форматы — см. photo_sender.h. */
int utun_bridge_photo_send(const char* channel_id, const char* file_path, const char* db_path,
int width, int height, const uint8_t reply_to[32], uint64_t request_id);
int width, int height, const uint8_t reply_to[32], uint64_t request_id,
const char* content_type, uint64_t generation);
/* Декодирование собственного OPUS-файла (не Ogg): open возвращает owned handle либо NULL.
* Все три out обязательны: частота, число каналов, общее число int16 (включая interleaved каналы).