diff --git a/lib/upgrade_database.php b/lib/upgrade_database.php index 231b1bd..c575c9b 100644 --- a/lib/upgrade_database.php +++ b/lib/upgrade_database.php @@ -144,6 +144,31 @@ CREATE TABLE "module_attention" ( DATA_BOUNDARY; $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 ){ echo "Upgrade Done!\n\n"; } else {