Browse Source

Embed Video Encoder: Live View settings for the embedded MediaMTX

- getModuleSettings.php: new "Live View" tab (live mode off / camera
  passthrough / processed video with overlays, WebRTC port, bitrate and
  frame rate for re-encode, ICE servers, recording on/off and segment
  length). Fields save on change like the other module settings.
- doModuleOperation.php: opcodes 20-26 update the module_eve live_*
  columns with range checks; the ICE server list is escaped.
- getModuleEditor.php: module panel shows the live mode, port and
  recording state; defaults are used when the columns are missing.
- Labels in all 7 languages.

la_mojo notices the changed module_eve row in validate() and restarts
the module, so changes apply without a manual restart.

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
07b8cdbe5a
Failed to extract signature
  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. 39
      lib/controller/doModuleOperation.php
  9. 17
      lib/controller/getModuleEditor.php
  10. 140
      lib/controller/getModuleSettings.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

39
lib/controller/doModuleOperation.php

@ -143,6 +143,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 );

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;

140
lib/controller/getModuleSettings.php

@ -464,6 +464,16 @@ 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';
$TPL =<<<EFUFU $TPL =<<<EFUFU
{ {
xtype: 'tabpanel', xtype: 'tabpanel',
@ -650,6 +660,136 @@ EFUFU;
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',

Loading…
Cancel
Save