ffmpeg: add build script and CMake integration

This commit is contained in:
Evgeny committed 2026-07-27 17:59:07 +03:00
1 parent d497a8dc92
commit 2d53b3120f
13 files changed
+446 -40

No files matched your search

+47 -8
View File
@@ -280,6 +280,7 @@ int topo_node_sqlite_channel_put(sqlite3* db, const char* channel_id,
2=EIM NAT 3=(не исп.) 4=суперузел(DIRECT+"supernode=yes") */
" node_RTT INTEGER," /* RTT до узла в мс, часть индекса (node_type, node_RTT) */
" connected INTEGER NOT NULL DEFAULT 0," /* 1 = было активное подключение к узлу */
" storage INTEGER NOT NULL DEFAULT 0," /* 1 = приоритетный хранитель аттачей */
" local_nick TEXT" /* локальный ник (GUI only, не синхронизируется) */
")";
@@ -303,6 +304,16 @@ int topo_node_sqlite_channel_put(sqlite3* db, const char* channel_id,
u_free(idx_sql);
}
int sidx_sz = snprintf(NULL, 0,
"CREATE INDEX IF NOT EXISTS \"idx_%s_storage\" ON \"%s\" (storage)", peers_tbl, peers_tbl);
char* sidx_sql = u_malloc(sidx_sz + 1);
if (sidx_sql) {
snprintf(sidx_sql, sidx_sz + 1,
"CREATE INDEX IF NOT EXISTS \"idx_%s_storage\" ON \"%s\" (storage)", peers_tbl, peers_tbl);
sqlite3_exec(db, sidx_sql, NULL, NULL, NULL);
u_free(sidx_sql);
}
sqlite3_stmt* stmt = NULL;
if (sqlite3_prepare_v2(db,
"INSERT OR REPLACE INTO channels(channel_id, name, owner_node_id,"
@@ -326,7 +337,8 @@ int topo_node_sqlite_member_put(sqlite3* db, const char* channel_id, uint64_t no
const uint8_t* join_sig, uint64_t join_ts,
const uint8_t* update_sig, uint64_t update_ts,
const uint8_t* x25519_pubkey, const uint8_t* ed25519_pubkey, const char* userinfo,
const uint8_t* creator_sig) {
const uint8_t* creator_sig,
const char* adm_tags, const uint8_t* adm_tags_sig, int storage) {
if (!db || !channel_id || !x25519_pubkey || !ed25519_pubkey) return -1;
char peers_tbl[80]; peers_table_name(channel_id, peers_tbl, sizeof(peers_tbl));
char sql[256];
@@ -349,7 +361,23 @@ int topo_node_sqlite_member_put(sqlite3* db, const char* channel_id, uint64_t no
if (creator_sig) sqlite3_bind_blob(stmt, 9, creator_sig, PEERS_JOIN_SIG_SIZE, SQLITE_STATIC);
else sqlite3_bind_null(stmt, 9);
int rc = sqlite3_step(stmt); sqlite3_finalize(stmt);
return rc == SQLITE_DONE ? 0 : -1;
if (rc != SQLITE_DONE) return -1;
if (adm_tags || adm_tags_sig || storage > 0) {
snprintf(sql, sizeof(sql),
"UPDATE \"%s\" SET adm_tags=?, adm_tags_sig=?, storage=? WHERE node_id=?", peers_tbl);
sqlite3_stmt* u = NULL;
if (sqlite3_prepare_v2(db, sql, -1, &u, NULL) == SQLITE_OK) {
if (adm_tags && adm_tags[0]) sqlite3_bind_text(u, 1, adm_tags, -1, SQLITE_STATIC);
else sqlite3_bind_null(u, 1);
if (adm_tags_sig) sqlite3_bind_blob(u, 2, adm_tags_sig, 64, SQLITE_STATIC);
else sqlite3_bind_null(u, 2);
sqlite3_bind_int(u, 3, storage);
sqlite3_bind_int64(u, 4, (sqlite3_int64)node_id);
sqlite3_step(u); sqlite3_finalize(u);
}
}
return 0;
}
int topo_node_sqlite_node_update_verified(sqlite3* db, uint64_t node_id,
@@ -440,7 +468,7 @@ int topo_node_sqlite_channel_peers_all(sqlite3* db, const char* channel_id,
char sql[512];
snprintf(sql, sizeof(sql),
"SELECT node_id, x25519_pubkey, ed25519_pubkey,"
" join_sig, join_ts, update_sig, update_ts, userinfo"
" join_sig, join_ts, update_sig, update_ts, userinfo, adm_tags, adm_tags_sig"
" FROM \"%s\" ORDER BY node_id ASC", peers_tbl);
if (sqlite3_prepare_v2(db, sql, -1, &stmt, NULL) != SQLITE_OK) return -1;
@@ -458,8 +486,11 @@ int topo_node_sqlite_channel_peers_all(sqlite3* db, const char* channel_id,
const uint8_t* update_sig = (const uint8_t*)sqlite3_column_blob(stmt, 5);
uint64_t update_ts = (uint64_t)sqlite3_column_int64(stmt, 6);
const char* puserinfo = (const char*)sqlite3_column_text(stmt, 7);
const char* adm_tags_s = (const char*)sqlite3_column_text(stmt, 8);
const uint8_t* adm_tags_sig_b = (const uint8_t*)sqlite3_column_blob(stmt, 9);
if (!x25519 || !ed_pub) continue;
uint8_t nl = puserinfo ? (uint8_t)strnlen(puserinfo, 255) : 0;
uint8_t atl = adm_tags_s ? (uint8_t)strnlen(adm_tags_s, 255) : 0;
sqlite3_stmt* ast = NULL;
snprintf(sql, sizeof(sql),
@@ -488,7 +519,7 @@ int topo_node_sqlite_channel_peers_all(sqlite3* db, const char* channel_id,
sqlite3_finalize(ast);
uint8_t flags = (join_sig && join_ts) ? PEERS_FLAG_HAS_JOIN : 0;
size_t peer_needed = 8 + 32 + 32 + 1 + (flags & PEERS_FLAG_HAS_JOIN ? 64+8 : 0) + 64 + 8 + 1 + (size_t)nl + 1;
size_t peer_needed = 8 + 32 + 32 + 1 + (flags & PEERS_FLAG_HAS_JOIN ? 64+8 : 0) + 64 + 8 + 1 + (size_t)nl + 1 + (size_t)atl + 64 + 1;
size_t addr_sz = off - addr_start;
if (addr_cnt > 0) {
if (off + peer_needed > buf_sz) { sqlite3_finalize(stmt); return -2; }
@@ -516,6 +547,10 @@ int topo_node_sqlite_channel_peers_all(sqlite3* db, const char* channel_id,
buf[off++] = nl;
if (nl) { memcpy(buf + off, puserinfo, nl); off += nl; }
buf[off++] = addr_cnt;
buf[off++] = atl;
if (atl) { memcpy(buf + off, adm_tags_s, atl); off += atl; }
if (adm_tags_sig_b && sqlite3_column_bytes(stmt, 9) >= 64) { memcpy(buf + off, adm_tags_sig_b, 64); off += 64; }
else { memset(buf + off, 0, 64); off += 64; }
off += addr_sz;
(*cnt_ptr)++;
}
@@ -593,7 +628,7 @@ int topo_node_sqlite_nodeinfo_updated(sqlite3* db, uint64_t node_id) {
while (sqlite3_step(s) == SQLITE_ROW) {
const char* tbl = (const char*)sqlite3_column_text(s, 0);
int node_type = base_type;
int node_type = base_type; int is_storage = 0;
if (best_at == ADDR_TYPE_DIRECT && base_type == 1) {
snprintf(sql, sizeof(sql),
"SELECT adm_tags FROM \"%s\" WHERE node_id=?", tbl);
@@ -602,18 +637,22 @@ int topo_node_sqlite_nodeinfo_updated(sqlite3* db, uint64_t node_id) {
sqlite3_bind_int64(a, 1, (sqlite3_int64)node_id);
if (sqlite3_step(a) == SQLITE_ROW) {
const char* tags = (const char*)sqlite3_column_text(a, 0);
if (tags && strstr(tags, "supernode=yes")) node_type = 4;
if (tags) {
if (strstr(tags, "supernode=yes")) node_type = 4;
if (strstr(tags, "storage=yes")) is_storage = 1;
}
}
sqlite3_finalize(a);
}
}
snprintf(sql, sizeof(sql),
"UPDATE \"%s\" SET node_type=? WHERE node_id=?", tbl);
"UPDATE \"%s\" SET node_type=?, storage=? WHERE node_id=?", tbl);
sqlite3_stmt* u = NULL;
if (sqlite3_prepare_v2(db, sql, -1, &u, NULL) == SQLITE_OK) {
sqlite3_bind_int(u, 1, node_type);
sqlite3_bind_int64(u, 2, (sqlite3_int64)node_id);
sqlite3_bind_int(u, 2, is_storage);
sqlite3_bind_int64(u, 3, (sqlite3_int64)node_id);
sqlite3_step(u); sqlite3_finalize(u);
}
}