Browse Source

Merge pull request 'Embed video Live View settings, app type/layout fields, complete translations' (#3) from feature/eve-live-columns into master

master
ClaudeAI 58 minutes ago
parent
commit
e7a983b968
  1. 2
      lib/1.json
  2. 2
      lib/2.json
  3. 2
      lib/3.json
  4. 2
      lib/4.json
  5. 2
      lib/5.json
  6. 2
      lib/6.json
  7. 2
      lib/7.json
  8. 9
      lib/controller/doApplicationOperation.php
  9. 100
      lib/controller/doModuleOperation.php
  10. 32
      lib/controller/getApplicationSettings.php
  11. 17
      lib/controller/getModuleEditor.php
  12. 244
      lib/controller/getModuleSettings.php
  13. 90
      lib/controller/updateServerModuleSettings.php
  14. 62
      lib/controller/uploadAsset.php
  15. 2
      lib/defines.php
  16. 86
      lib/javascript/jsapi_dynamic/rgoose_modules.js
  17. 25
      lib/upgrade_database.php

2
lib/1.json
File diff suppressed because it is too large
View File

2
lib/2.json
File diff suppressed because it is too large
View File

2
lib/3.json
File diff suppressed because it is too large
View File

2
lib/4.json
File diff suppressed because it is too large
View File

2
lib/5.json
File diff suppressed because it is too large
View File

2
lib/6.json
File diff suppressed because it is too large
View File

2
lib/7.json
File diff suppressed because it is too large
View File

9
lib/controller/doApplicationOperation.php

@ -20,6 +20,7 @@
}; };
case 2:{//Layout case 2:{//Layout
$PARAM = intval( $_POST['OPCODE'] ); $PARAM = intval( $_POST['OPCODE'] );
if( $PARAM < 0 ) $PARAM = 0;
$QS = "UPDATE `system_props` SET `app_layout`={$PARAM} WHERE `id`=1"; $QS = "UPDATE `system_props` SET `app_layout`={$PARAM} WHERE `id`=1";
$DATABASE->Query( $QS ); $DATABASE->Query( $QS );
$Data['q'] = $QS; $Data['q'] = $QS;
@ -118,6 +119,14 @@
$DATABASE->Query( $QS ); $DATABASE->Query( $QS );
break; break;
}; };
case 14:{//Application Type
$PARAM = intval( $_POST['OPCODE'] );
if( $PARAM < 0 ) $PARAM = 0;
$QS = "UPDATE `system_props` SET `type`={$PARAM} WHERE `id`=1";
$DATABASE->Query( $QS );
$Data['success'] = true;
break;
};
}; };
} else { } else {
$Data['msg']='Wrong Parameters!'; $Data['msg']='Wrong Parameters!';

100
lib/controller/doModuleOperation.php

@ -24,48 +24,27 @@
if( count( $TT ) ){ if( count( $TT ) ){
$JJ = $TT[0]; $JJ = $TT[0];
switch( $CMD ){ switch( $CMD ){
case 1:
switch( $JJ['type'] ){
case 1:{//ZL
$QS = "DELETE FROM `media_servers` WHERE `id`={$JJ['aux_id']}";
$DATABASE->Query( $QS );
$QS = "DELETE FROM `media_server_streams` WHERE `media_server_id`={$JJ['aux_id']}";
$DATABASE->Query( $QS );
break;
};
case 3:{//Kafka
$QS = "DELETE FROM `modules_kafka` WHERE `id`={$JJ['aux_id']}";
$DATABASE->Query( $QS );
$QS = "DELETE FROM `module_kafka_settings` WHERE `module_id`={$JJ['aux_id']}";
$DATABASE->Query( $QS );
break;
};
case 6:{//SSDP
$QS = "DELETE FROM `module_ssdp` WHERE `id`={$JJ['aux_id']}";
$DATABASE->Query( $QS );
break;
};
case 9:{// Embed VIO
$QS = "DELETE FROM `module_eve` WHERE `id`={$JJ['aux_id']}";
$DATABASE->Query( $QS );
break;
};
case 10:{// Modem Manager
$QS = "DELETE FROM `module_modem` WHERE `id`={$JJ['aux_id']}";
$DATABASE->Query( $QS );
$QS = "DELETE FROM `module_modem_phonebook`";
$DATABASE->Query( $QS );
break;
};
case 13:{
$QS = "DELETE FROM `module_bvms` WHERE `id`={$JJ['aux_id']}";
$DATABASE->Query( $QS );
break;
};
case 13:{
$QS = "DELETE FROM `module_attention` WHERE `id`={$JJ['aux_id']}";
$DATABASE->Query( $QS );
case 1:
// remove the module's own settings row(s); module_types ids:
// 2 Kafka, 6 SSDP, 8 Embed Video, 9 Modem Manager, 12 Bosch VMS, 13 Attention Cloud
$AUX = intval( $JJ['aux_id'] );
$DEL = array();
switch( intval( $JJ['type'] ) ){
case 2: $DEL[] = "DELETE FROM `module_kafka` WHERE `id`={$AUX}"; break;
case 6: $DEL[] = "DELETE FROM `module_ssdp` WHERE `id`={$AUX}"; break;
case 8: $DEL[] = "DELETE FROM `module_eve` WHERE `id`={$AUX}"; break;
case 9:
$DEL[] = "DELETE FROM `module_modem` WHERE `id`={$AUX}";
$DEL[] = "DELETE FROM `module_modem_phonebook`";
break; break;
case 12: $DEL[] = "DELETE FROM `module_bvms` WHERE `id`={$AUX}"; break;
case 13: $DEL[] = "DELETE FROM `module_attention` WHERE `id`={$AUX}"; break;
};
foreach( $DEL as $DQ ){
// skip tables missing in this database (Query() would die())
if( preg_match( '/FROM `([a-z_]+)`/', $DQ, $TM ) ){
$TX = $DATABASE->Query( "SELECT name FROM sqlite_master WHERE type='table' AND name='{$TM[1]}'", false );
if( count( $TX ) ) $DATABASE->Query( $DQ, false );
}; };
}; };
$QS = "DELETE FROM `modules` WHERE `id`={$MID}"; $QS = "DELETE FROM `modules` WHERE `id`={$MID}";
@ -143,6 +122,45 @@
$QS = "UPDATE `module_bvms` SET `camera_evt_id`={$OPCODE} WHERE `id`={$JJ['aux_id']}"; $QS = "UPDATE `module_bvms` SET `camera_evt_id`={$OPCODE} WHERE `id`={$JJ['aux_id']}";
break; break;
}; };
// module_eve: embedded MediaMTX live view / recording (la_mojo kernelModuleEmbedVideo)
case 20:{ // live_mode: 0 - off, 1 - camera H264 passthrough, 2 - re-encode processed frames
if( $OPCODE < 0 || $OPCODE > 2 ) $OPCODE = 1;
$QS = "UPDATE `module_eve` SET `live_mode`={$OPCODE} WHERE `id`={$JJ['aux_id']}";
break;
};
case 21:{ // live_port
if( $OPCODE < 1 || $OPCODE > 65535 ) $OPCODE = 8889;
$QS = "UPDATE `module_eve` SET `live_port`={$OPCODE} WHERE `id`={$JJ['aux_id']}";
break;
};
case 22:{ // live_record
$OPCODE = ( $OPCODE > 0 ) ? 1 : 0;
$QS = "UPDATE `module_eve` SET `live_record`={$OPCODE} WHERE `id`={$JJ['aux_id']}";
break;
};
case 23:{ // live_record_segment, seconds
if( $OPCODE == 0 ) $OPCODE = 60;
$OPCODE = max( 10, min( 3600, $OPCODE ) );
$QS = "UPDATE `module_eve` SET `live_record_segment`={$OPCODE} WHERE `id`={$JJ['aux_id']}";
break;
};
case 24:{ // live_bitrate, kbit/s
if( $OPCODE == 0 ) $OPCODE = 2000;
$OPCODE = max( 100, min( 20000, $OPCODE ) );
$QS = "UPDATE `module_eve` SET `live_bitrate`={$OPCODE} WHERE `id`={$JJ['aux_id']}";
break;
};
case 25:{ // live_fps
if( $OPCODE == 0 ) $OPCODE = 15;
$OPCODE = max( 1, min( 60, $OPCODE ) );
$QS = "UPDATE `module_eve` SET `live_fps`={$OPCODE} WHERE `id`={$JJ['aux_id']}";
break;
};
case 26:{ // live_ice_servers: comma separated stun:/turn: urls
$EIP = $DATABASE->escape( trim( isset( $_POST['OPCODE'] ) ? $_POST['OPCODE'] : '' ) );
$QS = "UPDATE `module_eve` SET `live_ice_servers`='{$EIP}' WHERE `id`={$JJ['aux_id']}";
break;
};
}; };
}; };
if( $QS != '' ) $DATABASE->Query( $QS ); if( $QS != '' ) $DATABASE->Query( $QS );

32
lib/controller/getApplicationSettings.php

@ -43,6 +43,8 @@
} else { } else {
$IDT = "----No-Identity-Set---"; $IDT = "----No-Identity-Set---";
}; };
$AP_TYPE = isset( $AP_DATA['type'] ) ? intval( $AP_DATA['type'] ) : 0;
$AP_LAYOUT = isset( $AP_DATA['app_layout'] ) ? intval( $AP_DATA['app_layout'] ) : 3;
$Data['content']=<<<DATA_BOUNDARY $Data['content']=<<<DATA_BOUNDARY
[{ [{
xtype: 'spacer', xtype: 'spacer',
@ -196,6 +198,36 @@
doApplicationOperation( 11, i ); doApplicationOperation( 11, i );
} }
} }
},{
xtype: 'spacer',
height: 10
},{
xtype: 'numberfield',
fieldLabel: "{$Labels->GetLabel('_APP_TYPE_')}",
width: 300,
allowDecimals: false,
allowNegative: false,
value: '{$AP_TYPE}',
listeners:{
change: function( a, c, b ){
if( c !== null ) doApplicationOperation( 14, c );
}
}
},{
xtype: 'spacer',
height: 10
},{
xtype: 'numberfield',
fieldLabel: "{$Labels->GetLabel('_APP_LAYOUT_')}",
width: 300,
allowDecimals: false,
allowNegative: false,
value: '{$AP_LAYOUT}',
listeners:{
change: function( a, c, b ){
if( c !== null ) doApplicationOperation( 2, c );
}
}
}] }]
DATA_BOUNDARY; DATA_BOUNDARY;
break; break;

17
lib/controller/getModuleEditor.php

@ -385,7 +385,22 @@ EFUFU;
EFUFU; EFUFU;
$TPL = str_ireplace( '%%%NAME%%%',$Labels->GetLabel('_EVE_DESC_SHO_') , $TPL ); $TPL = str_ireplace( '%%%NAME%%%',$Labels->GetLabel('_EVE_DESC_SHO_') , $TPL );
$TPL = str_ireplace( '%%%INFO%%%', $Labels->GetLabel('_EVE_DESC_LOO_'), $TPL ); $TPL = str_ireplace( '%%%INFO%%%', $Labels->GetLabel('_EVE_DESC_LOO_'), $TPL );
$TPL = str_ireplace( '%%%LOINFO%%%','' , $TPL );
// Embedded MediaMTX summary (live view / recording)
$R_nfo = '';
$QS = "SELECT * FROM `module_eve` WHERE `id`=".intval( $CR['aux_id'] );
$II = $DATABASE->Query( $QS, false );
if( count( $II ) ){
$CI = $II[0];
$LV_MODE = isset( $CI['live_mode'] ) ? intval( $CI['live_mode'] ) : 1;
$LV_PORT = isset( $CI['live_port'] ) ? intval( $CI['live_port'] ) : 8889;
$LV_REC = isset( $CI['live_record'] ) ? intval( $CI['live_record'] ) : 1;
$LV_SEG = isset( $CI['live_record_segment'] ) ? intval( $CI['live_record_segment'] ) : 60;
$LV_MODES = array( 0 => '_EVE_LIVE_OFF_', 1 => '_EVE_LIVE_PASS_', 2 => '_EVE_LIVE_ENC_' );
$R_nfo = $Labels->GetLabel('_EVE_LIVE_MODE_').': <b>'.$Labels->GetLabel( isset( $LV_MODES[$LV_MODE] ) ? $LV_MODES[$LV_MODE] : '_EVE_LIVE_PASS_' ).'</b>';
if( $LV_MODE > 0 ) $R_nfo .= '<br>'.$Labels->GetLabel('_EVE_LIVE_PORT_').': <b>'.$LV_PORT.'</b>';
$R_nfo .= '<br>'.$Labels->GetLabel('_EVE_LIVE_RECORD_').': <b>'.( $LV_REC ? $Labels->GetLabel('___ENABLED__').' ('.$LV_SEG.' s)' : $Labels->GetLabel('__DISABLED__') ).'</b>';
};
$TPL = str_ireplace( '%%%LOINFO%%%',$R_nfo , $TPL );
$TPL = str_ireplace( '%%%ENA_VAL%%%',$CR['enabled'], $TPL ); $TPL = str_ireplace( '%%%ENA_VAL%%%',$CR['enabled'], $TPL );
echo $TPL; echo $TPL;
break; break;

244
lib/controller/getModuleSettings.php

@ -464,6 +464,21 @@ EFUFU;
$YY = $CI['width'].'x'.$CI['height']; $YY = $CI['width'].'x'.$CI['height'];
for( $i=0; $i<count( $TS ); $i++ ) if( $TS[$i] == $YY ) break; for( $i=0; $i<count( $TS ); $i++ ) if( $TS[$i] == $YY ) break;
$CSID =($i==count($TS))?0:$i; $CSID =($i==count($TS))?0:$i;
// Embedded MediaMTX (live view / recording); defaults match la_mojo when a column is missing
$LV_MODE = isset( $CI['live_mode'] ) ? intval( $CI['live_mode'] ) : 1;
$LV_PORT = isset( $CI['live_port'] ) ? intval( $CI['live_port'] ) : 8889;
$LV_REC = isset( $CI['live_record'] ) ? intval( $CI['live_record'] ) : 1;
$LV_SEG = isset( $CI['live_record_segment'] ) ? intval( $CI['live_record_segment'] ) : 60;
$LV_BR = isset( $CI['live_bitrate'] ) ? intval( $CI['live_bitrate'] ) : 2000;
$LV_FPS = isset( $CI['live_fps'] ) ? intval( $CI['live_fps'] ) : 15;
$LV_ICE = json_encode( isset( $CI['live_ice_servers'] ) ? strval( $CI['live_ice_servers'] ) : '' );
$LV_ENC_DIS = ( $LV_MODE == 2 ) ? 'false' : 'true';
$LV_SEG_DIS = ( $LV_REC ) ? 'false' : 'true';
// OpenCV line types; old values 0 / 1 mean 8 / 4 connected
$EVE_LT = function( $V ){ $V = intval( $V ); if( $V == 0 ) return 8; if( $V == 1 ) return 4; return in_array( $V, array( 4, 8, 16 ) ) ? $V : 8; };
$TS_LT = $EVE_LT( $CI['ts_line_type'] );
$LBL_LT = $EVE_LT( $CI['label_line_type'] );
$LOGO_URL = ( isset( $CI['logo_md5'] ) && preg_match( '/^[0-9a-f]{32}$/', $CI['logo_md5'] ) && is_file( __DIR__.'/data/assets/images/'.$CI['logo_md5'].'.png' ) ) ? '/lib/controller/data/assets/images/'.$CI['logo_md5'].'.png' : '/lib/controller/data/assets/images/7shields.png';
$TPL =<<<EFUFU $TPL =<<<EFUFU
{ {
xtype: 'tabpanel', xtype: 'tabpanel',
@ -534,9 +549,6 @@ EFUFU;
title:'{$Labels->GetLabel("_ERROR_MSG_")}', title:'{$Labels->GetLabel("_ERROR_MSG_")}',
msg: data['msg'], msg: data['msg'],
buttons: Ext.Msg.OK, buttons: Ext.Msg.OK,
fn: function(){
SettingsLidar3D.hide();
},
icon: Ext.MessageBox.ERROR icon: Ext.MessageBox.ERROR
}); });
}; };
@ -631,46 +643,174 @@ EFUFU;
xtype: 'checkbox', xtype: 'checkbox',
fieldLabel: '{$Labels->GetLabel('_EVE_SHOW_TS_')}', fieldLabel: '{$Labels->GetLabel('_EVE_SHOW_TS_')}',
id: 'eve_show_ts', id: 'eve_show_ts',
disabled: true,
checked: {$CI['show_ts']}, checked: {$CI['show_ts']},
handler: updateFramePreview handler: updateFramePreview
},{ },{
xtype: 'checkbox', xtype: 'checkbox',
fieldLabel: '{$Labels->GetLabel('_EVE_SHOW_LBL_')}', fieldLabel: '{$Labels->GetLabel('_EVE_SHOW_LBL_')}',
id: 'eve_show_lbl', id: 'eve_show_lbl',
disabled: true,
checked: {$CI['show_label']}, checked: {$CI['show_label']},
handler: updateFramePreview handler: updateFramePreview
},{ },{
xtype: 'checkbox', xtype: 'checkbox',
fieldLabel: '{$Labels->GetLabel('_EVE_SHOW_LOGO_')}', fieldLabel: '{$Labels->GetLabel('_EVE_SHOW_LOGO_')}',
id: 'eve_show_logo', id: 'eve_show_logo',
disabled: true,
checked: {$CI['show_logo']}, checked: {$CI['show_logo']},
handler: updateFramePreview handler: updateFramePreview
}] }]
}] }]
},{
xtype: 'form',
title: '{$Labels->GetLabel('_EVE_LIVE_TAB_')}',
labelWidth: 250,
labelAlign: 'right',
items:[{
xtype: 'spacer',
height: 10
},{
xtype: 'combo',
fieldLabel: '{$Labels->GetLabel('_EVE_LIVE_MODE_')}',
id: 'LV_MODE',
width: 260,
typeAhead: false,
editable: false,
forceSelection: true,
triggerAction: 'all',
lazyRender:true,
mode: 'local',
store: {
xtype: 'arraystore',
fields: [ 'lmId', 'lmText' ],
data: [
[0, '{$Labels->GetLabel('_EVE_LIVE_OFF_')}'],
[1, '{$Labels->GetLabel('_EVE_LIVE_PASS_')}'],
[2, '{$Labels->GetLabel('_EVE_LIVE_ENC_')}']
]
},
valueField: 'lmId',
displayField: 'lmText',
value: {$LV_MODE},
listeners:{
select: function( t, r, i ){
doModuleOperation( {$EID}, 20, r.data.lmId, false );
Ext.getCmp('LV_BITRATE').setDisabled( r.data.lmId != 2 );
Ext.getCmp('LV_FPS').setDisabled( r.data.lmId != 2 );
}
}
},{
xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LIVE_PORT_')}',
id: 'LV_PORT',
width: 120,
allowDecimals: false,
minValue: 1,
maxValue: 65535,
value: {$LV_PORT},
listeners:{
change: function( t, n, o ){
doModuleOperation( {$EID}, 21, n, false );
}
}
},{
xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LIVE_BITRATE_')}',
id: 'LV_BITRATE',
width: 120,
allowDecimals: false,
minValue: 100,
maxValue: 20000,
disabled: {$LV_ENC_DIS},
value: {$LV_BR},
listeners:{
change: function( t, n, o ){
doModuleOperation( {$EID}, 24, n, false );
}
}
},{
xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LIVE_FPS_')}',
id: 'LV_FPS',
width: 120,
allowDecimals: false,
minValue: 1,
maxValue: 60,
disabled: {$LV_ENC_DIS},
value: {$LV_FPS},
listeners:{
change: function( t, n, o ){
doModuleOperation( {$EID}, 25, n, false );
}
}
},{
xtype: 'textfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LIVE_ICE_')}',
id: 'LV_ICE',
width: 400,
emptyText: 'stun:stun.l.google.com:19302',
value: {$LV_ICE},
listeners:{
change: function( t, n, o ){
doModuleOperation( {$EID}, 26, n, false );
}
}
},{
xtype: 'spacer',
height: 10
},{
xtype: 'checkbox',
fieldLabel: '{$Labels->GetLabel('_EVE_LIVE_RECORD_')}',
id: 'LV_RECORD',
checked: {$LV_REC},
handler: function( c, v ){
doModuleOperation( {$EID}, 22, v ? 1 : 0, false );
Ext.getCmp('LV_SEGMENT').setDisabled( !v );
}
},{
xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LIVE_SEGMENT_')}',
id: 'LV_SEGMENT',
width: 120,
allowDecimals: false,
minValue: 10,
maxValue: 3600,
disabled: {$LV_SEG_DIS},
value: {$LV_SEG},
listeners:{
change: function( t, n, o ){
doModuleOperation( {$EID}, 23, n, false );
}
}
},{
xtype: 'spacer',
height: 10
},{
xtype: 'panel',
border: false,
bodyStyle: 'padding: 0 10px',
html: '<p>{$Labels->GetLabel('_EVE_LIVE_HINT_')}</p>'
}]
},{ },{
xtype: 'form', xtype: 'form',
title: 'Time Stamp', title: 'Time Stamp',
labelWidth: 180, labelWidth: 180,
labelAlign: 'right', labelAlign: 'right',
disabled: true,
items:[{ items:[{
xtype: 'slider',
xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_TS_POSX_')}', fieldLabel: '{$Labels->GetLabel('_EVE_TS_POSX_')}',
id: 'TS_POSX', id: 'TS_POSX',
width: 120, width: 120,
minValue: 0,
maxValue: 100,
allowDecimals: false,
minValue: -1920,
maxValue: 1920,
value: {$CI['ts_x']} value: {$CI['ts_x']}
},{ },{
xtype: 'slider',
xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_TS_POSY_')}', fieldLabel: '{$Labels->GetLabel('_EVE_TS_POSY_')}',
id: 'TS_POSY', id: 'TS_POSY',
width: 120, width: 120,
minValue: 0,
maxValue: 100,
allowDecimals: false,
minValue: -1920,
maxValue: 1920,
value: {$CI['ts_y']} value: {$CI['ts_y']}
},{ },{
xtype: 'checkbox', xtype: 'checkbox',
@ -704,20 +844,22 @@ EFUFU;
displayField: 'szText', displayField: 'szText',
value: {$CI['ts_font_face']} value: {$CI['ts_font_face']}
},{ },{
xtype: 'slider',
xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_TS_FSCALE_')}', fieldLabel: '{$Labels->GetLabel('_EVE_TS_FSCALE_')}',
id: 'TS_FSCALE', id: 'TS_FSCALE',
width: 120, width: 120,
minValue: 0.0,
decimalPrecision: 1,
minValue: 0.1,
maxValue: 4.0, maxValue: 4.0,
value: {$CI['ts_font_scale']} value: {$CI['ts_font_scale']}
},{ },{
xtype: 'slider',
xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_TS_FTHICK_')}', fieldLabel: '{$Labels->GetLabel('_EVE_TS_FTHICK_')}',
id: 'TS_FTHICK', id: 'TS_FTHICK',
width: 120, width: 120,
allowDecimals: false,
minValue: 1, minValue: 1,
maxValue: 8.0,
maxValue: 8,
value: {$CI['ts_font_thickness']} value: {$CI['ts_font_thickness']}
},{ },{
xtype: 'combo', xtype: 'combo',
@ -732,36 +874,42 @@ EFUFU;
xtype: 'arraystore', xtype: 'arraystore',
fields: [ 'szId', 'szText' ], fields: [ 'szId', 'szText' ],
data: [ data: [
[0, 'THIN'],
[1, 'ANTIALIAZED'],
[2, 'THICK']
[8, 'NORMAL'],
[4, 'THIN'],
[16, 'ANTIALIASED']
] ]
}, },
valueField: 'szId', valueField: 'szId',
displayField: 'szText', displayField: 'szText',
value: {$CI['ts_line_type']}
value: {$TS_LT}
},{
xtype: 'panel',
border: false,
bodyStyle: 'padding: 10px',
html: '<p>{$Labels->GetLabel('_EVE_POS_HINT_')}</p><p>{$Labels->GetLabel('_EVE_TS_HINT_')}</p>'
}] }]
},{ },{
xtype: 'form', xtype: 'form',
title: 'Label', title: 'Label',
labelWidth: 180, labelWidth: 180,
labelAlign: 'right', labelAlign: 'right',
disabled: true,
items:[{ items:[{
xtype: 'slider',
xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LBL_POSX_')}', fieldLabel: '{$Labels->GetLabel('_EVE_LBL_POSX_')}',
id: 'LBL_POSX', id: 'LBL_POSX',
width: 120, width: 120,
minValue: 0,
maxValue: 100,
allowDecimals: false,
minValue: -1920,
maxValue: 1920,
value: {$CI['label_x']} value: {$CI['label_x']}
},{ },{
xtype: 'slider',
xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LBL_POSY_')}', fieldLabel: '{$Labels->GetLabel('_EVE_LBL_POSY_')}',
id: 'LBL_POSY', id: 'LBL_POSY',
width: 120, width: 120,
minValue: 0,
maxValue: 100,
allowDecimals: false,
minValue: -1920,
maxValue: 1920,
value: {$CI['label_y']} value: {$CI['label_y']}
},{ },{
xtype: 'checkbox', xtype: 'checkbox',
@ -795,20 +943,22 @@ EFUFU;
displayField: 'szText', displayField: 'szText',
value: {$CI['label_font_face']} value: {$CI['label_font_face']}
},{ },{
xtype: 'slider',
xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LBL_FSCALE_')}', fieldLabel: '{$Labels->GetLabel('_EVE_LBL_FSCALE_')}',
id: 'LBL_FSCALE', id: 'LBL_FSCALE',
width: 120, width: 120,
minValue: 0.0,
decimalPrecision: 1,
minValue: 0.1,
maxValue: 4.0, maxValue: 4.0,
value: {$CI['label_font_scale']} value: {$CI['label_font_scale']}
},{ },{
xtype: 'slider',
xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LBL_FTHICK_')}', fieldLabel: '{$Labels->GetLabel('_EVE_LBL_FTHICK_')}',
id: 'LBL_FTHICK', id: 'LBL_FTHICK',
width: 120, width: 120,
allowDecimals: false,
minValue: 1, minValue: 1,
maxValue: 8.0,
maxValue: 8,
value: {$CI['label_font_thickness']} value: {$CI['label_font_thickness']}
},{ },{
fieldLabel: '{$Labels->GetLabel('_EVE_LBL_LINE_T_')}', fieldLabel: '{$Labels->GetLabel('_EVE_LBL_LINE_T_')}',
@ -823,36 +973,42 @@ EFUFU;
xtype: 'arraystore', xtype: 'arraystore',
fields: [ 'szId', 'szText' ], fields: [ 'szId', 'szText' ],
data: [ data: [
[0, 'THIN'],
[1, 'ANTIALIAZED'],
[2, 'THICK']
[8, 'NORMAL'],
[4, 'THIN'],
[16, 'ANTIALIASED']
] ]
}, },
valueField: 'szId', valueField: 'szId',
displayField: 'szText', displayField: 'szText',
value: {$CI['label_line_type']}
value: {$LBL_LT}
},{
xtype: 'panel',
border: false,
bodyStyle: 'padding: 10px',
html: '<p>{$Labels->GetLabel('_EVE_POS_HINT_')}</p>'
}] }]
},{ },{
xtype: 'form', xtype: 'form',
title: 'Logo', title: 'Logo',
labelWidth: 180, labelWidth: 180,
labelAlign: 'right', labelAlign: 'right',
disabled: true,
items:[{ items:[{
xtype: 'slider',
xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LOGO_POSX_')}', fieldLabel: '{$Labels->GetLabel('_EVE_LOGO_POSX_')}',
id: 'LOGO_POSX', id: 'LOGO_POSX',
width: 120, width: 120,
minValue: 0,
maxValue: 100,
allowDecimals: false,
minValue: -1920,
maxValue: 1920,
value: {$CI['logo_x']} value: {$CI['logo_x']}
},{ },{
xtype: 'slider',
xtype: 'numberfield',
fieldLabel: '{$Labels->GetLabel('_EVE_LOGO_POSY_')}', fieldLabel: '{$Labels->GetLabel('_EVE_LOGO_POSY_')}',
id: 'LOGO_POSY', id: 'LOGO_POSY',
width: 120, width: 120,
minValue: 0,
maxValue: 100,
allowDecimals: false,
minValue: -1920,
maxValue: 1920,
value: {$CI['logo_y']} value: {$CI['logo_y']}
},{ },{
xtype: 'numberfield', xtype: 'numberfield',
@ -873,7 +1029,7 @@ EFUFU;
},{ },{
xtype: 'panel', xtype: 'panel',
id: 'eve_logo_ph', id: 'eve_logo_ph',
html: '<center><img width="100px" id="eve_logo_img" src="/lib/controller/data/assets/images/7shields.png"></center>'
html: '<center><img width="100px" id="eve_logo_img" src="{$LOGO_URL}"></center>'
},{ },{
xtype: 'panel', xtype: 'panel',
html: '<input id="eve_logo_upload" style="width: 120px;" type="file" onchange="uploadEveLogo();"/>' html: '<input id="eve_logo_upload" style="width: 120px;" type="file" onchange="uploadEveLogo();"/>'

90
lib/controller/updateServerModuleSettings.php

@ -0,0 +1,90 @@
<?php
// Saves the settings window of a module (getModuleSettings.php -> saveSettings()).
require_once('../ajax_asm.php');
if( $CUser->Data['id'] > 1 ){
$Data = array();
$Data['success'] = false;
$Data['msg'] = 'Module Not Selected!';
$MID = isset( $_POST['MID'] ) ? intval( $_POST['MID'] ) : 0;
if( $MID > 0 ){
$Data['msg'] = 'Module Does Not Exists!';
$RR = $DATABASE->Query( "SELECT * FROM `modules` WHERE `id`={$MID}", false );
if( count( $RR ) ){
$CMD = $RR[0];
$AUX = intval( $CMD['aux_id'] );
// clamp a numeric POST field to [min,max], $def when it is missing
$pInt = function( $Name, $Min, $Max, $Def ){
if( !isset( $_POST[$Name] ) || $_POST[$Name] === '' ) return $Def;
return max( $Min, min( $Max, intval( $_POST[$Name] ) ) );
};
$pFloat = function( $Name, $Min, $Max, $Def ){
if( !isset( $_POST[$Name] ) || $_POST[$Name] === '' ) return $Def;
return max( $Min, min( $Max, floatval( $_POST[$Name] ) ) );
};
$pBool = function( $Name ){
if( !isset( $_POST[$Name] ) ) return 0;
$V = strtolower( strval( $_POST[$Name] ) );
return ( $V === 'true' || $V === '1' || $V === 'on' ) ? 1 : 0;
};
// OpenCV line types la_mojo accepts (0 and 1 are old values: 8 / 4 connected)
$pLine = function( $Name ){
$V = isset( $_POST[$Name] ) ? intval( $_POST[$Name] ) : 8;
return in_array( $V, array( 0, 1, 4, 8, 16 ) ) ? $V : 8;
};
switch( intval( $CMD['type'] ) ){
case 8:{ // Embed Video Encoder (module_eve)
$SiW = array( 320, 640, 800, 1280, 1024, 1920 );
$SiH = array( 240, 480, 600, 720, 768, 1080 );
$SIZE = $pInt( 'SIZE', 0, count( $SiW ) - 1, 3 );
$W = $SiW[$SIZE];
$H = $SiH[$SIZE];
$F = array(
'web_port' => $pInt( 'PORT', 1, 65535, 8972 ),
'width' => $W,
'height' => $H,
'compression_quality' => $pInt( 'COMPRESSION', 0, 100, 70 ),
'show_ts' => $pBool( 'SHOW1' ),
'show_label' => $pBool( 'SHOW2' ),
'show_logo' => $pBool( 'SHOW3' ),
// positions in pixels, negative values are measured from the right / bottom edge
'ts_x' => $pInt( 'TS_POSX', -$W, $W, 5 ),
'ts_y' => $pInt( 'TS_POSY', -$H, $H, 5 ),
'ts_transperant' => $pBool( 'TS_TRANS' ),
'ts_font_face' => $pInt( 'TS_FONT', 0, 7, 1 ),
'ts_font_scale' => $pFloat( 'TS_FONT_SCALE', 0.1, 4.0, 1.0 ),
'ts_font_thickness' => $pInt( 'TS_FONT_THICK', 1, 8, 1 ),
'ts_line_type' => $pLine( 'TS_LINE' ),
'label_x' => $pInt( 'LBL_POSX', -$W, $W, 5 ),
'label_y' => $pInt( 'LBL_POSY', -$H, $H, -10 ),
'label_transperant' => $pBool( 'LBL_TRANS' ),
'label_font_face' => $pInt( 'LBL_FONT', 0, 7, 1 ),
'label_font_scale' => $pFloat( 'LBL_FONT_SCALE', 0.1, 4.0, 1.0 ),
'label_font_thickness' => $pInt( 'LBL_FONT_THICK', 1, 8, 1 ),
'label_line_type' => $pLine( 'LBL_LINE' ),
'logo_x' => $pInt( 'LOG_POSX', -$W, $W, 0 ),
'logo_y' => $pInt( 'LOG_POSY', -$H, $H, 0 ),
'logo_w' => $pInt( 'LOG_W', 0, $W, 0 ),
'logo_h' => $pInt( 'LOG_H', 0, $H, 0 )
);
$SET = array();
foreach( $F as $K => $V ) $SET[] = "`{$K}`=".( is_float( $V ) ? sprintf( '%.3F', $V ) : intval( $V ) );
// exec() reports a failure instead of die() in Query()
if( $DATABASE->DBLink->exec( "UPDATE `module_eve` SET ".implode( ', ', $SET )." WHERE `id`={$AUX}" ) ){
$Data['success'] = true;
$Data['msg'] = '';
} else {
$Data['msg'] = 'Unable to save the settings!';
};
break;
};
default:
$Data['msg'] = 'Saving the settings of this module type is not supported!';
break;
};
};
};
echo json_encode( $Data );
exit();
};
header( 'location: /');
?>

62
lib/controller/uploadAsset.php

@ -0,0 +1,62 @@
<?php
// Asset upload. type=eve_logo, id=<module id>: logo of the Embed Video Encoder.
// The picture is stored as an RGBA PNG in data/assets/images/<md5>.png (the path la_mojo
// loads, relative to its working folder) and module_eve.logo_md5 is updated.
require_once('../ajax_asm.php');
if( $CUser->Data['id'] > 1 ){
$Data = array();
$Data['success'] = false;
$Data['msg'] = 'Wrong Parameters';
$TYPE = isset( $_POST['type'] ) ? strval( $_POST['type'] ) : '';
$MID = isset( $_POST['id'] ) ? intval( $_POST['id'] ) : 0;
if( $TYPE == 'eve_logo' && $MID > 0 ){
$RR = $DATABASE->Query( "SELECT * FROM `modules` WHERE `id`={$MID} AND `type`=8", false );
if( !count( $RR ) ){
$Data['msg'] = 'Module Does Not Exists!';
} else if( !isset( $_FILES['file'] ) || $_FILES['file']['error'] != UPLOAD_ERR_OK || !is_uploaded_file( $_FILES['file']['tmp_name'] ) ){
$Data['msg'] = 'File upload failed!';
} else if( $_FILES['file']['size'] > 4 * 1024 * 1024 ){
$Data['msg'] = 'The picture is too big (max 4 MB)!';
} else if( !function_exists( 'imagecreatefromstring' ) ){
$Data['msg'] = 'PHP GD extension is missing!';
} else {
$IMG = @imagecreatefromstring( file_get_contents( $_FILES['file']['tmp_name'] ) );
if( $IMG === false ){
$Data['msg'] = 'Unsupported picture format!';
} else {
// normalise to a true colour picture with alpha channel (la_mojo uses alpha as mask)
$W = imagesx( $IMG );
$H = imagesy( $IMG );
$OUT = imagecreatetruecolor( $W, $H );
imagealphablending( $OUT, false );
imagesavealpha( $OUT, true );
imagefill( $OUT, 0, 0, imagecolorallocatealpha( $OUT, 0, 0, 0, 127 ) );
imagecopy( $OUT, $IMG, 0, 0, 0, 0, $W, $H );
imagedestroy( $IMG );
ob_start();
imagepng( $OUT );
$PNG = ob_get_clean();
imagedestroy( $OUT );
$MD5 = md5( $PNG );
$DIR = __DIR__.'/data/assets/images';
if( !is_dir( $DIR ) ) @mkdir( $DIR, 0775, true );
if( @file_put_contents( $DIR.'/'.$MD5.'.png', $PNG ) === false ){
$Data['msg'] = 'Unable to store the picture!';
} else {
$AUX = intval( $RR[0]['aux_id'] );
$DATABASE->DBLink->exec( "UPDATE `module_eve` SET `logo_md5`='{$MD5}' WHERE `id`={$AUX}" );
$Data['success'] = true;
$Data['msg'] = '';
$Data['md5'] = $MD5;
$Data['url'] = '/lib/controller/data/assets/images/'.$MD5.'.png';
$Data['width'] = $W;
$Data['height'] = $H;
};
};
};
};
echo json_encode( $Data );
exit();
};
header( 'location: /');
?>

2
lib/defines.php

@ -41,7 +41,7 @@ $Site_Languages = array(
array( 'id'=>3, 'name'=>'עברית', 'rtl'=>true ), array( 'id'=>3, 'name'=>'עברית', 'rtl'=>true ),
array( 'id'=>4, 'name'=>'Français', 'rtl'=>false ), array( 'id'=>4, 'name'=>'Français', 'rtl'=>false ),
array( 'id'=>5, 'name'=>'日本語', 'rtl'=>false ), array( 'id'=>5, 'name'=>'日本語', 'rtl'=>false ),
array( 'id'=>6, 'name'=>'中国人', 'rtl'=>false ),
array( 'id'=>6, 'name'=>'简体中文', 'rtl'=>false ),
array( 'id'=>7, 'name'=>'Română', 'rtl'=>false ), array( 'id'=>7, 'name'=>'Română', 'rtl'=>false ),
); );

86
lib/javascript/jsapi_dynamic/rgoose_modules.js

@ -71,7 +71,7 @@ function updateFramePreview(){
ctx.closePath(); ctx.closePath();
if( Ext.getCmp('eve_show_logo').getValue() ){ if( Ext.getCmp('eve_show_logo').getValue() ){
var image = document.getElementById('eve_logo_img'); var image = document.getElementById('eve_logo_img');
if( image.complete && image.naturalHeight !== 0 ){
if( image != null && image.complete && image.naturalHeight !== 0 ){
var i_w = Ext.getCmp('LOGO_WIDTH').getValue(); var i_w = Ext.getCmp('LOGO_WIDTH').getValue();
var i_h = Ext.getCmp('LOGO_HEIGHT').getValue(); var i_h = Ext.getCmp('LOGO_HEIGHT').getValue();
ctx.drawImage( image, 120, 120, i_w, i_h ); ctx.drawImage( image, 120, 120, i_w, i_h );
@ -92,44 +92,41 @@ async function uploadFile() {
} }
function uploadEveLogo(){ function uploadEveLogo(){
if( embedVideoEncoderId > -1 ){
var llMask = new Ext.LoadMask( Ext.getCmp('eve_logo_ph').getEl(), {msg:"Please wait..."});
llMask.show();
var formData = new FormData();
var img_upload = document.getElementById('eve_logo_upload');
formData.append("file", img_upload.files[0]);
formData.append("type", 'eve_logo');
formData.append("id", embedVideoEncoderId );
$.ajax({
type: 'POST',
url: '/lib/controller/uploadAsset.php',
data: formData,
cache: false,
contentType: false,
processData: false,
success: function( data ){
llMask.hide();
console.log("success");
console.log( data );
},
error: function( data ){
llMask.hide();
console.log("error");
console.log(data);
}
});
/*
Ext.Ajax.request({
url: SITE_URL+'upload/',
headers: {'Content-type':'multipart/form-data'},
form: filefield.up('form').getForm(),
isUpload: true,
success: function(response, options) { console.log(arguments); },
failure: function(response, options) { console.log(arguments); }
});
*/
};
var img_upload = document.getElementById('eve_logo_upload');
if( embedVideoEncoderId < 1 || img_upload == null || img_upload.files.length == 0 ) return;
var llMask = new Ext.LoadMask( Ext.getCmp('eve_logo_ph').getEl(), {msg:"Please wait..."});
llMask.show();
var formData = new FormData();
formData.append("file", img_upload.files[0]);
formData.append("type", 'eve_logo');
formData.append("id", embedVideoEncoderId );
formData.append("UID", <?=$UserID;?> );
formData.append("SID", '<?=$Session;?>' );
fetch( '/lib/controller/uploadAsset.php', { method: 'POST', body: formData, credentials: 'same-origin' } )
.then( function( r ){ return r.json(); } )
.then( function( data ){
llMask.hide();
if( data.success ){
var image = document.getElementById('eve_logo_img');
if( image ){
image.onload = updateFramePreview;
image.src = data.url;
};
// first upload: propose the picture size, kept inside 256x256
var lw = Ext.getCmp('LOGO_WIDTH'), lh = Ext.getCmp('LOGO_HEIGHT');
if( lw && lh && ( !lw.getValue() || !lh.getValue() ) ){
var k = Math.min( 1, 256 / Math.max( data.width, data.height ) );
lw.setValue( Math.round( data.width * k ) );
lh.setValue( Math.round( data.height * k ) );
};
} else {
Ext.Msg.show({ title: "<?=$Labels->GetLabel('_ERROR_MSG_');?>", msg: data.msg, buttons: Ext.Msg.OK, icon: Ext.MessageBox.ERROR });
};
})
.catch( function( e ){
llMask.hide();
Ext.Msg.show({ title: "<?=$Labels->GetLabel('_ERROR_MSG_');?>", msg: String( e ), buttons: Ext.Msg.OK, icon: Ext.MessageBox.ERROR });
});
}; };
var moduleSettingsEditorWindow = null; var moduleSettingsEditorWindow = null;
@ -147,6 +144,14 @@ function showModuleSettingsEditor( ModuleID ){
resizable: false, resizable: false,
items:[], items:[],
buttons: [{ buttons: [{
id: 'mo_se_ed_save',
text: "<?=$Labels->GetLabel('_SAVE_');?>",
hidden: true,
handler: function(){
var c = Ext.getCmp('mod_set_content');
if( c && typeof c.saveSettings == 'function' ) c.saveSettings();
}
},{
text: "<?=$Labels->GetLabel('_CLOSE_');?>", text: "<?=$Labels->GetLabel('_CLOSE_');?>",
handler: function(){ handler: function(){
moduleSettingsEditorWindow.hide(); moduleSettingsEditorWindow.hide();
@ -154,6 +159,8 @@ function showModuleSettingsEditor( ModuleID ){
}] }]
}); });
}; };
embedVideoEncoderId = ModuleID;
Ext.getCmp('mo_se_ed_save').hide();
moduleSettingsEditorWindow.show(); moduleSettingsEditorWindow.show();
Ext.Ajax.request({ Ext.Ajax.request({
url: '/lib/controller/getModuleSettings.php', url: '/lib/controller/getModuleSettings.php',
@ -170,6 +177,7 @@ function showModuleSettingsEditor( ModuleID ){
moduleSettingsEditorWindow.removeAll( true ); moduleSettingsEditorWindow.removeAll( true );
moduleSettingsEditorWindow.add( data ); moduleSettingsEditorWindow.add( data );
moduleSettingsEditorWindow.doLayout(); moduleSettingsEditorWindow.doLayout();
Ext.getCmp('mo_se_ed_save').setVisible( typeof data.saveSettings == 'function' );
} else { } else {
moduleSettingsEditorWindow.close(); moduleSettingsEditorWindow.close();
moduleSettingsEditorWindow = null; moduleSettingsEditorWindow = null;

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