Browse Source

upgrade_database.php: add module_eve live_* columns for embedded MediaMTX

la_mojo's kernelModuleEmbedVideo now serves the WebRTC (WHEP) live view
and records segments itself. Add its settings to module_eve:
live_mode (0 off, 1 camera H264 passthrough, 2 re-encoded frames with
overlays), live_port, live_record, live_record_segment, live_bitrate,
live_fps, live_ice_servers.

Columns are detected with PRAGMA table_info (works for empty tables and
NULL values) and added with exec() so each ALTER runs once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16
pull/3/head
Claude 4 hours ago
parent
commit
24aa170a8b
Failed to extract signature
  1. 25
      lib/upgrade_database.php

25
lib/upgrade_database.php

@ -144,6 +144,31 @@ CREATE TABLE "module_attention" (
DATA_BOUNDARY; DATA_BOUNDARY;
$DATABASE->Query( $QS ); $DATABASE->Query( $QS );
}; };
// module_eve: embedded MediaMTX (WebRTC live view + recording) settings.
// PRAGMA table_info is used instead of "SELECT * LIMIT 1" + isset(): it also works
// on an empty table and on columns whose value is NULL.
$QS = "SELECT name FROM sqlite_master WHERE type='table' AND name='module_eve';";
$JKA = $DATABASE->Query( $QS, false );
if( count( $JKA ) ){
$EVE_COLS = array();
foreach( $DATABASE->Query( "PRAGMA table_info(`module_eve`);", false ) as $COL ) $EVE_COLS[ $COL['name'] ] = true;
$EVE_NEW = array(
'live_mode' => "INTEGER DEFAULT 1", // 0 - off, 1 - camera H264 passthrough, 2 - re-encode processed frames (with overlays)
'live_port' => "INTEGER DEFAULT 8889", // WebRTC (WHEP) HTTP port
'live_record' => "INTEGER DEFAULT 1", // record fMP4 segments to the video scratch folder
'live_record_segment' => "INTEGER DEFAULT 60", // segment duration, seconds
'live_bitrate' => "INTEGER DEFAULT 2000", // kbit/s, live_mode = 2 only
'live_fps' => "INTEGER DEFAULT 15", // frames per second, live_mode = 2 only
'live_ice_servers' => "TEXT DEFAULT ''" // comma separated STUN/TURN urls, empty - host candidates only
);
foreach( $EVE_NEW as $NAME => $DEF ){
if( !isset( $EVE_COLS[ $NAME ] ) ){
// exec(): Query() would run a non INSERT/UPDATE statement twice (fetchArray re-steps it)
$DATABASE->DBLink->exec( "ALTER TABLE `module_eve` ADD COLUMN `{$NAME}` {$DEF};" );
$UPGRADE = true;
};
};
};
if( $UPGRADE ){ if( $UPGRADE ){
echo "Upgrade Done!\n\n"; echo "Upgrade Done!\n\n";
} else { } else {

Loading…
Cancel
Save