diff --git a/fhem/CHANGED b/fhem/CHANGED index 7003c40b9..fbb376a63 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,7 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - change: 49_SSCam: V5.2.0, support longpoll refresh of SSCamSTRM-Devices + Design change of SSCamSTRM-Devs due to longpoll support - change: 82_LGTV_WebOS: change launchApp Vvalue for AmatonVideo and add set command for AmazonVid - change: 74_XXiaomiBTLSens: Thermo/HydroSense new state format, new Reading diff --git a/fhem/FHEM/49_SSCam.pm b/fhem/FHEM/49_SSCam.pm index b2a6e3d40..04352e87b 100644 --- a/fhem/FHEM/49_SSCam.pm +++ b/fhem/FHEM/49_SSCam.pm @@ -27,6 +27,9 @@ ######################################################################################################################### # Versions History: # +# 5.2.0 14.06.2018 support longpoll refresh of SSCamSTRM-Devices +# 5.1.0 13.06.2018 more control elements (Start/Stop Recording, Take Snapshot) in func SSCam_StreamDev +# control of detaillink is moved to SSCamSTRM-device # 5.0.1 12.06.2018 control of page refresh improved (for e.g. Floorplan,Dashboard) # 5.0.0 11.06.2018 HLS Streaming, Buttons for Streaming-Devices, use of module SSCamSTRM for Streaming-Devices, # deletion of Streaming-devices if SSCam-device is deleted, some more improvements, minor bugfixes @@ -230,7 +233,7 @@ use Time::HiRes; use HttpUtils; # no if $] >= 5.017011, warnings => 'experimental'; -my $SSCamVersion = "5.0.1"; +my $SSCamVersion = "5.2.0"; # Aufbau Errorcode-Hashes (siehe Surveillance Station Web API) my %SSCam_errauthlist = ( @@ -2171,7 +2174,7 @@ sub SSCam_stopliveview ($) { SSCam_getapisites($hash); } else { # kein HLS Stream - SSCam_refresh($hash,1,1); # Room-Refresh, Longpoll + SSCam_refresh($hash,0,1,1); # kein Room-Refresh, Longpoll SSCam, Longpoll SSCamSTRM $hash->{HELPER}{ACTIVE} = "off"; if (AttrVal($name,"debugactivetoken",0)) { Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}"); @@ -3886,7 +3889,7 @@ sub SSCam_camop ($) { } } - SSCam_refresh($hash,1,1); # Room-Refresh, Longpoll + SSCam_refresh($hash,0,1,1); # kein Room-Refresh, Longpoll SSCam, Longpoll SSCamSTRM $hash->{HELPER}{ACTIVE} = "off"; if (AttrVal($name,"debugactivetoken",0)) { @@ -4039,6 +4042,8 @@ sub SSCam_camop_parse ($) { RemoveInternalTimer($hash, "SSCam_camstoprec"); InternalTimer(gettimeofday()+$rectime, "SSCam_camstoprec", $hash); } + + SSCam_refresh($hash,0,0,1); # kein Room-Refresh, kein Longpoll SSCam, Longpoll SSCamSTRM } elsif ($OpMode eq "Stop") { @@ -4052,6 +4057,8 @@ sub SSCam_camop_parse ($) { # Logausgabe Log3($name, 3, "$name - Camera $camname Recording stopped"); + SSCam_refresh($hash,0,0,1); # kein Room-Refresh, kein Longpoll SSCam, Longpoll SSCamSTRM + # Aktualisierung Eventlist der letzten Aufnahme SSCam_geteventlist($hash); @@ -4245,9 +4252,10 @@ sub SSCam_camop_parse ($) { } elsif ($OpMode eq "Snap") { # ein Schnapschuß wurde aufgenommen # falls Aufnahme noch läuft -> state = on setzen - my $st; - (ReadingsVal("$name", "Record", "") eq "Start")?$st="on":$st="off"; - readingsSingleUpdate($hash,"state", $st, 0); + # my $st; + # (ReadingsVal("$name", "Record", "") eq "Start")?$st="on":$st="off"; + # readingsSingleUpdate($hash,"state", $st, 0); + SSCam_refresh($hash,0,0,0); # kein Room-Refresh, kein Longpoll SSCam, kein Longpoll SSCamSTRM $snapid = $data->{data}{'id'}; @@ -4300,11 +4308,11 @@ sub SSCam_camop_parse ($) { delete $hash->{HELPER}{RUNVIEW}; # Aufnahmestatus in state abbilden my $st; - (ReadingsVal("$name", "Record", "") eq "Start")?$st="on":$st="off"; - readingsSingleUpdate($hash,"state", $st, 0); + # (ReadingsVal("$name", "Record", "") eq "Start")?$st="on":$st="off"; + # readingsSingleUpdate($hash,"state", $st, 0); $hash->{HELPER}{LINK} = $data->{data}{data}[0]{imageData}; - SSCam_refresh($hash,1,1); # Page Refresh, Longpoll + SSCam_refresh($hash,0,0,1); # kein Room-Refresh, kein Longpoll SSCam, Longpoll SSCamSTRM } if($OpMode eq "getsnapgallery") { @@ -4369,14 +4377,14 @@ sub SSCam_camop_parse ($) { Log3($name, 4, "$name - HLS Streaming of camera \"$name\" activated, Streaming-URL: $url") if(AttrVal($name,"verbose",3) == 4); Log3($name, 3, "$name - HLS Streaming of camera \"$name\" activated") if(AttrVal($name,"verbose",3) == 3); - SSCam_refresh($hash,1,1); # Page Refresh, Longpoll + SSCam_refresh($hash,0,1,1); # kein Room-Refresh, Longpoll SSCam, Longpoll SSCamSTRM } elsif ($OpMode eq "stopliveview_hls") { # HLS Streaming wurde deaktiviert, Aktivitätsstatus speichern $hash->{HELPER}{HLSSTREAM} = "inactive"; Log3($name, 3, "$name - HLS Streaming of camera \"$name\" deactivated"); - SSCam_refresh($hash,1,1); # Page Refresh, Longpoll + SSCam_refresh($hash,0,1,1); # kein Room-Refresh, Longpoll SSCam, Longpoll SSCamSTRM } elsif ($OpMode eq "reactivate_hls") { # HLS Streaming wurde deaktiviert, Aktivitätsstatus speichern @@ -4387,12 +4395,12 @@ sub SSCam_camop_parse ($) { $hash->{HELPER}{ACTIVE} = "off"; SSCam_hlsactivate($hash); - SSCam_refresh($hash,1,1); # Page Refresh, Longpoll - } elsif ($OpMode eq "activate_hls") { # HLS Streaming wurde aktiviert, Aktivitätsstatus speichern $hash->{HELPER}{HLSSTREAM} = "active"; Log3($name, 4, "$name - HLS Streaming of camera \"$name\" activated for streaming device"); + + SSCam_refresh($hash,0,1,1); # kein Room-Refresh, Longpoll SSCam, Longpoll SSCamSTRM } elsif ($OpMode eq "getsnapfilename") { # den Filenamen eines Schnapschusses ermitteln @@ -4414,7 +4422,7 @@ sub SSCam_camop_parse ($) { readingsBeginUpdate($hash); readingsBulkUpdate($hash,"Errorcode","none"); readingsBulkUpdate($hash,"Error","none"); - readingsBulkUpdate($hash,"CamStreamFormat", uc($sformat)); + readingsBulkUpdate($hash,"CamStreamFormat", uc($sformat)) if($sformat); readingsEndUpdate($hash, 1); } elsif ($OpMode eq "gopreset") { @@ -5388,17 +5396,17 @@ sub SSCam_evaljson($$) { return($hash,$success,$myjson); } -############################################################################### +###################################################################################################### # Refresh eines Raumes aus $hash->{HELPER}{STRMROOM} -# bzw. Longpoll -# $hash, $pload (1=Page reload), $longpoll (1=Event) -############################################################################### -sub SSCam_refresh($$$) { - my ($hash,$pload,$longpoll) = @_; +# bzw. Longpoll von SSCam bzw. eines SSCamSTRM Devices wenn +# $hash->{HELPER}{STRMDEV} gefüllt +# $hash, $pload (1=Page reload), $longpoll SSCam(1=Event), $longpoll SSCamSTRM (1=Event) +###################################################################################################### +sub SSCam_refresh($$$$) { + my ($hash,$pload,$lpoll_scm,$lpoll_strm) = @_; my $name = $hash->{NAME}; my $fpr = 0; - # my $r = $hash->{HELPER}{STRMROOM}?$hash->{HELPER}{STRMROOM}:""; # Kontext des SSCamSTRM-Devices speichern für SSCam_refresh my $sd = defined($hash->{HELPER}{STRMDEV})?$hash->{HELPER}{STRMDEV}:"\"not defined\""; # Name des aufrufenden SSCamSTRM-Devices my $sr = defined($hash->{HELPER}{STRMROOM})?$hash->{HELPER}{STRMROOM}:"\"not defined\""; # Raum aus dem das SSCamSTRM-Device die Funktion aufrief @@ -5421,14 +5429,24 @@ sub SSCam_refresh($$$) { } } - # Aufnahmestatus in state abbilden & Longpoll + # Aufnahmestatus in state abbilden & Longpoll SSCam-Device wenn Event 1 my $st = (ReadingsVal($name, "Record", "") eq "Start")?"on":"off"; - if($longpoll) { + if($lpoll_scm) { readingsSingleUpdate($hash,"state", $st, 1); } else { readingsSingleUpdate($hash,"state", $st, 0); } + # Longpoll des SSCamSTRM-Device + if($hash->{HELPER}{STRMDEV}) { + my $strmhash = $defs{$hash->{HELPER}{STRMDEV}}; + if($lpoll_strm) { + readingsSingleUpdate($strmhash,"state", $st, 1); + } else { + readingsSingleUpdate($strmhash,"state", $st, 0); + } + } + return; } @@ -5578,13 +5596,13 @@ sub SSCam_ptzpanel($;$$) { $ptz_ret = "
"; $ptz_ret.= ''; - + foreach my $rownr (0..9) { $rownr = sprintf("%2.2d",$rownr); $row = AttrVal("$name","ptzPanel_row$rownr",undef); next if (!$row); $rowisset = 1; - $ptz_ret .= "\n"; + $ptz_ret .= ""; my @btn = split (",",$row); # die Anzahl Buttons in einer Reihe foreach my $btnnr (0..$#btn) { @@ -5720,18 +5738,37 @@ sub SSCam_StreamDev($$$) { $hash->{HELPER}{STRMDEV} = $strmdev; # Name des aufrufenden SSCamSTRM-Devices $hash->{HELPER}{STRMROOM} = $FW_room?$FW_room:""; # Raum aus dem das SSCamSTRM-Device die Funktion aufrief $hash->{HELPER}{STRMDETAIL} = $FW_detail?$FW_detail:""; # Name des SSCamSTRM-Devices (wenn Detailansicht) - - my $ha = AttrVal($camname, "htmlattr", 'width="500" height="325"'); # HTML Attribute der Cam + + # Definition Tasten + my $cmdstop = "cmd=set $camname stopView"; # Stream deaktivieren + my $imgstop = ""; + my $cmdhlsreact = "cmd=set $camname hlsreactivate"; # HLS Stream reaktivieren + my $imghlsreact = ""; + my $cmdmjpegrun = "cmd=set $camname runView live_fw"; # MJPEG Stream aktivieren + my $imgmjpegrun = ""; + my $cmdhlsrun = "cmd=set $camname runView live_fw_hls"; # HLS Stream aktivieren + my $imghlsrun = ""; + my $cmdlrirun = "cmd=set $camname runView lastrec_fw"; # Last Record IFrame + my $imglrirun = ""; + my $cmdlh264run = "cmd=set $camname runView lastrec_fw_MPEG4/H.264"; # Last Record H.264 + my $imglh264run = ""; + my $cmdlmjpegrun = "cmd=set $camname runView lastrec_fw_MJPEG"; # Last Record MJPEG + my $imglmjpegrun = ""; + my $cmdlsnaprun = "cmd=set $camname runView lastsnap_fw"; # Last SNAP + my $imglsnaprun = ""; + my $cmdrecendless = "cmd=set $camname on 0"; # Endlosaufnahme Start + my $imgrecendless = ""; + my $cmdrecstop = "cmd=set $camname off"; # Aufnahme Stop + my $imgrecstop = ""; + my $cmddosnap = "cmd=set $camname snap"; # Snapshot auslösen + my $imgdosnap = ""; + + my $ha = AttrVal($camname, "htmlattr", 'width="500" height="325"'); # HTML Attribute der Cam $ha = AttrVal($strmdev, "htmlattr", $ha); # htmlattr mit htmattr Streaming-Device übersteuern my $hlslfw = (ReadingsVal($camname,"CamStreamFormat","MJPEG") eq "HLS")?"live_fw_hls,":undef; my $StmKey = ReadingsVal($camname,"StmKey",undef); - $wlalias = AttrVal($strmdev, "alias", $strmdev); # Linktext als Aliasname oder Devicename setzen - $devWlink = "$wlalias"; - $wlhash = $defs{$strmdev}; - - # Document Division - $ret = sprintf("
$devWlink"); + $ret = "
"; $ret .= '
'; $ret .= ''; $ret .= ''; @@ -5739,8 +5776,8 @@ sub SSCam_StreamDev($$$) { if(!$StmKey || ReadingsVal($camname, "Availability", "") ne "enabled" || IsDisabled($camname)) { # Ausgabe bei Fehler my $cam = AttrVal($camname, "alias", $camname); - $cause = !$StmKey?"Camera $cam has no Reading \"StmKey\" set !":"Camera \"$cam\" is disabled"; - $cause = "Camera \"$cam\" is disabled" if(IsDisabled($camname)); + $cause = !$StmKey?"Cam $cam has no Reading \"StmKey\" set !":"Cam \"$cam\" is disabled"; + $cause = "Cam \"$cam\" is disabled" if(IsDisabled($camname)); $ret .= ""; $ret .= ''; $ret .= ''; @@ -5750,7 +5787,6 @@ sub SSCam_StreamDev($$$) { } if($fmt =~ /mjpeg/) { - # $link = "http://$serveraddr:$serverport/webapi/$apivideostmpath?api=$apivideostm&version=$apivideostmmaxver&method=Stream&format=mjpeg&cameraId=$camid&StmKey=\"$StmKey\""; $link = "http://$serveraddr:$serverport/webapi/$apivideostmspath?api=$apivideostms&version=$apivideostmsmaxver&method=Stream&cameraId=$camid&format=mjpeg&_sid=$sid"; $audiolink = "http://$serveraddr:$serverport/webapi/$apiaudiostmpath?api=$apiaudiostm&version=$apiaudiostmmaxver&method=Stream&cameraId=$camid&_sid=$sid"; $ret .= ""; @@ -5760,39 +5796,30 @@ sub SSCam_StreamDev($$$) { $ret .= ""; } } - $ret .= ''; if($audiolink && ReadingsVal($camname, "CamAudioType", "Unknown") !~ /Unknown/) { + $ret .= ''; $ret .= ''; $ret .= ""; - $ret .= ''; } } elsif($fmt =~ /switched/) { my $wltype = $hash->{HELPER}{WLTYPE}; $link = $hash->{HELPER}{LINK}; - my $cmdstop = "cmd=set $camname stopView"; # Stream deaktivieren - my $imgstop = ""; - my $cmdhlsreact = "cmd=set $camname hlsreactivate"; # HLS Stream reaktivieren - my $imghlsreact = ""; - my $cmdmjpegrun = "cmd=set $camname runView live_fw"; # MJPEG Stream aktivieren - my $imgmjpegrun = ""; - my $cmdhlsrun = "cmd=set $camname runView live_fw_hls"; # HLS Stream aktivieren - my $imghlsrun = ""; - my $cmdlrirun = "cmd=set $camname runView lastrec_fw"; # Last Record IFrame - my $imglrirun = ""; - my $cmdlh264run = "cmd=set $camname runView lastrec_fw_MPEG4/H.264"; # Last Record H.264 - my $imglh264run = ""; - my $cmdlmjpegrun = "cmd=set $camname runView lastrec_fw_MJPEG"; # Last Record MJPEG - my $imglmjpegrun = ""; - my $cmdlsnaprun = "cmd=set $camname runView lastsnap_fw"; # Last SNAP - my $imglsnaprun = ""; if($link && $wltype =~ /image|iframe|video|base64img|embed|hls/) { if($wltype =~ /image/) { $ret .= ""; if(AttrVal($camname,"ptzPanel_use",1)) { my $ptz_ret = SSCam_ptzpanel($camname); @@ -5852,7 +5879,15 @@ sub SSCam_StreamDev($$$) { Your browser does not support the video tag
"; $ret .= "$imgstop "; - $ret .= "$imghlsreact "; + $ret .= "$imghlsreact "; + if(ReadingsVal($camname, "Record", "Stop") eq "Stop") { + # Aufnahmebutton endlos Start + $ret .= "$imgrecendless "; + } else { + # Aufnahmebutton Stop + $ret .= "$imgrecstop "; + } + $ret .= "$imgdosnap "; $ret .= ""; if(AttrVal($camname,"ptzPanel_use",1)) { my $ptz_ret = SSCam_ptzpanel($camname); @@ -5863,7 +5898,7 @@ sub SSCam_StreamDev($$$) { } } else { my $cam = AttrVal($camname, "alias", $camname); - $cause = "Videostream of camera \"$cam\" is switched off"; + $cause = "Playback cam \"$cam\" switched off"; $ret .= "

$cause

$ptz_ret

"; - $ret .= "$imgstop "; + $ret .= "$imgstop "; + if(ReadingsVal($camname, "Record", "Stop") eq "Stop") { + # Aufnahmebutton endlos Start + $ret .= "$imgrecendless "; + } else { + # Aufnahmebutton Stop + $ret .= "$imgrecstop "; + } + $ret .= "$imgdosnap "; $ret .= "

$cause

"; $ret .= "$imgmjpegrun "; $ret .= "$imghlsrun " if($hlslfw); @@ -5890,7 +5925,7 @@ return $ret; # Schnappschußgalerie zusammenstellen ############################################################################### sub composegallery ($;$$) { - my ($name,$wlname,$model) = @_; + my ($name,$strmdev,$model) = @_; my $hash = $defs{$name}; my $camname = $hash->{CAMNAME}; my $allsnaps = $hash->{HELPER}{".SNAPHASH"}; # = \%allsnaps @@ -5908,20 +5943,22 @@ sub composegallery ($;$$) { my $ha = AttrVal($name, "snapGalleryHtmlAttr", AttrVal($name, "htmlattr", 'width="500" height="325"')); # falls "composegallery" durch ein mit "createSnapGallery" angelegtes Device aufgerufen wird - my ($devWlink,$wlhash,$wlha,$wlalias); - if ($wlname) { - $wlalias = AttrVal($wlname, "alias", $wlname); # Linktext als Aliasname oder Devicename setzen - $devWlink = "$wlalias"; - $wlhash = $defs{$wlname}; - $wlha = AttrVal($wlname, "htmlattr", undef); - $ha = (defined($wlha))?$wlha:$ha; # htmlattr vom weblink-Device übernehmen falls von wl-Device aufgerufen und gesetzt + my ($devWlink); + if ($strmdev) { + if($defs{$strmdev}{TYPE} ne "SSCamSTRM") { + # Abfrage wegen Kompatibilität zu "alten" compose mit weblink-Modul + my $sdalias = AttrVal($strmdev, "alias", $strmdev); # Linktext als Aliasname oder Devicename setzen + $devWlink = "$sdalias
"; + } + my $wlha = AttrVal($strmdev, "htmlattr", undef); + $ha = (defined($wlha))?$wlha:$ha; # htmlattr vom weblink-Device übernehmen falls von wl-Device aufgerufen und gesetzt } else { $devWlink = " "; } # wenn Weblink genutzt wird und attr "snapGalleryBoost" nicht gesetzt ist -> Warnung in Gallerie ausgeben my $sgbnote = " "; - if($wlname && !AttrVal($name,"snapGalleryBoost",0)) { + if($strmdev && !AttrVal($name,"snapGalleryBoost",0)) { $sgbnote = "CAUTION - No snapshots can be retrieved. Please set the attribute \"snapGalleryBoost=1\" in device $name" if ($lang eq "EN"); $sgbnote = "ACHTUNG - Es können keine Schnappschüsse abgerufen werden. Bitte setzen sie das Attribut \"snapGalleryBoost=1\" im Device $name" if ($lang eq "DE"); } @@ -5943,7 +5980,7 @@ sub composegallery ($;$$) { # Ausgabetabelle erstellen my ($htmlCode,$ct); $htmlCode = ""; - $htmlCode .= sprintf("$devWlink
$header
"); + $htmlCode .= sprintf("$devWlink
$header
"); $htmlCode .= ""; $htmlCode .= ""; $htmlCode .= ""; @@ -6512,14 +6549,16 @@ sub SSCam_experror {

    -
  • set <name> [on|off]     (valid for CAM)

  • +
  • set <name> [on [<rectime>] | off]     (valid for CAM)

  • - The command "set <name> on" starts a recording. The default recording time takes 15 seconds. It can be changed by the attribute "rectime" individualy. - With the attribute (respectively the default value) provided recording time can be overwritten once by "set <name> on [rectime]". + The command "set <name> on" starts a recording. The default recording time takes 15 seconds. It can be changed by + the attribute "rectime" individualy. + With the attribute (respectively the default value) provided recording time can be overwritten + once by "set <name> on <rectime>". The recording will be stopped after processing time "rectime"automatically.
    - A special case is the start using "set <name> on 0" respectively the attribute value "rectime = 0". In that case a endless-recording will be started. One have to stop this recording - by command "set <name> off" explicitely.
    + A special case is start recording by "set <name> on 0" respectively the attribute value "rectime = 0". In that case + a endless-recording will be started. One have to stop this recording by command "set <name> off" explicitely.
    The recording behavior can be impacted with attribute "recextend" furthermore as explained as follows.

    @@ -7711,16 +7750,19 @@ http(s)://<hostname><port>/webapi/entry.cgi?api=SYNO.SurveillanceSta

      -
    • set <name> [on|off]     (gilt für CAM)

    • +
    • set <name> [on [<rectime>] | off]     (gilt für CAM)

    • - Der Befehl "set <name> on" startet eine Aufnahme. Die Standardaufnahmedauer beträgt 15 Sekunden. Sie kann mit dem Attribut "rectime" individuell festgelegt werden. - Die im Attribut (bzw. im Standard) hinterlegte Aufnahmedauer kann einmalig mit "set <name> on [rectime]" überschrieben werden. + Der Befehl "set <name> on" startet eine Aufnahme. Die Standardaufnahmedauer beträgt 15 Sekunden. Sie kann mit dem + Attribut "rectime" individuell festgelegt werden. + Die im Attribut (bzw. im Standard) hinterlegte Aufnahmedauer kann einmalig mit "set <name> on <rectime>" + überschrieben werden. Die Aufnahme stoppt automatisch nach Ablauf der Zeit "rectime".
      - Ein Sonderfall ist der Start einer Daueraufnahme mit "set <name> on 0" bzw. dem Attributwert "rectime = 0". In diesem Fall wird eine Daueraufnahme gestartet die - explizit wieder mit dem Befehl "set <name> off" gestoppt werden muß.
      + Ein Sonderfall ist der Start einer Daueraufnahme mit "set <name> on 0" bzw. dem Attributwert "rectime = 0". + In diesem Fall wird eine Daueraufnahme gestartet, die explizit wieder mit dem Befehl "set <name> off" gestoppt + werden muß.
      - Das Aufnahmeverhalten kann weiterhin mit dem Attribut "recextend" wie folgt beeinflusst werden.

      + Das Aufnahmeverhalten kann weiterhin mit dem Attribut "recextend" beeinflusst werden.

      Attribut "recextend = 0" bzw. nicht gesetzt (Standard):

        @@ -8055,7 +8097,7 @@ http(s)://<hostname><port>/webapi/entry.cgi?api=SYNO.SurveillanceSta
          Hinweis:
          - Abhängig von der Anzahl und Auflösung (Qualität) der Schnappschuß-Images werden entsprechende ausreichende CPU und/oder + Abhängig von der Anzahl und Auflösung (Qualität) der Schnappschuß-Images werden entsprechend ausreichende CPU und/oder RAM-Ressourcen benötigt.


        diff --git a/fhem/FHEM/49_SSCamSTRM.pm b/fhem/FHEM/49_SSCamSTRM.pm index 99168367e..e212167ba 100644 --- a/fhem/FHEM/49_SSCamSTRM.pm +++ b/fhem/FHEM/49_SSCamSTRM.pm @@ -28,6 +28,8 @@ ######################################################################################################################### # Versions History: # +# 1.0.0 14.06.2018 switch to longpoll refresh +# 0.4 13.06.2018 new attribute "noDetaillink" (deleted in V1.0.0) # 0.3 12.06.2018 new attribute "forcePageRefresh" # 0.2 11.06.2018 check in with SSCam 5.0.0 # 0.1 10.06.2018 initial Version @@ -37,9 +39,8 @@ package main; use strict; use warnings; -use vars qw($FW_subdir); # Sub-path in URL for extensions, e.g. 95_FLOORPLAN -my $SSCamSTRMVersion = "0.3"; +my $SSCamSTRMVersion = "1.0.0"; ################################################################ sub SSCamSTRM_Initialize($) { @@ -49,7 +50,8 @@ sub SSCamSTRM_Initialize($) { $hash->{AttrList} = "disable:1,0 forcePageRefresh:1,0 htmlattr "; $hash->{FW_summaryFn} = "SSCamSTRM_FwFn"; $hash->{FW_detailFn} = "SSCamSTRM_FwFn"; - $hash->{FW_atPageEnd} = 1; + $hash->{AttrFn} = "SSCamSTRM_Attr"; + # $hash->{FW_atPageEnd} = 1; } @@ -68,26 +70,34 @@ sub SSCamSTRM_Define($$) { $hash->{VERSION} = $SSCamSTRMVersion; $hash->{LINK} = $link; + $attr{$name}{alias} = "."; - readingsBeginUpdate($hash); - readingsBulkUpdate($hash,"state", "initialized"); # Init für "state" - readingsEndUpdate($hash,1); + readingsSingleUpdate($hash,"state", "initialized", 1); # Init für "state" return undef; } ################################################################ -sub SSCamSTRM_FwDetail($@) { - my ($d, $text, $nobr)= @_; - return "" if(AttrVal($d, "group", "")); - my $alias = AttrVal($d, "alias", $d); +sub SSCamSTRM_Attr($$$$) { + my ($cmd,$name,$aName,$aVal) = @_; + my $hash = $defs{$name}; + my ($do,$val); + + # $cmd can be "del" or "set" + # $name is device name + # aName and aVal are Attribute name and value + + if ($aName eq "disable") { + if($cmd eq "set") { + $do = ($aVal) ? 1 : 0; + } + $do = 0 if($cmd eq "del"); + $val = ($do == 1 ? "Stream-device of \"$hash->{PARENT}\" disabled" : "initialized"); + + readingsSingleUpdate($hash, "state", $val, 1); + } - my $ret = ($nobr ? "" : "
        "); - $ret .= "$text " if($text); - $ret .= FW_pHPlain("detail=$d", $alias) if(!$FW_subdir); - $ret .= "
        "; - -return $ret; +return undef; } ################################################################ @@ -95,14 +105,13 @@ sub SSCamSTRM_FwFn($$$$) { my ($FW_wname, $d, $room, $pageHash) = @_; # pageHash is set for summaryFn. my $hash = $defs{$d}; my $link = $hash->{LINK}; - my $ret = ""; - - return "" if(IsDisabled($d)); - my $attr = AttrVal($d, "htmlattr", ""); + return undef if(IsDisabled($d)); - $link = AnalyzePerlCommand(undef, $link) if($link =~ m/^{(.*)}$/s); - $ret = $link; + $link = AnalyzePerlCommand(undef, $link) if($link =~ m/^{(.*)}$/s); + + my $ret = ""; + $ret .= $link; return $ret; } @@ -116,6 +125,26 @@ return $ret;

        SSCamSTRM

        +
        +The module SSCamSTRM is a special device module synchronized to the SSCam module. It is used for definition of +Streaming-Devices.
        +Dependend of the Streaming-Device state, different buttons are provided to start actions: +
          +
+ + + + + + + + + + + +
MJPEG - starts a MJPEG Livestream
HLS - starts HLS (HTTP Live Stream)
Last Record - playback the last recording as iFrame
Last Rec H.264 - playback the last recording if available as H.264
Last Rec MJPEG - playback the last recording if available as MJPEG
Last SNAP - show the last snapshot
Start Recording - starts an endless recording
Stop Recording - stopps the recording
Take Snapshot - take a snapshot
Switch off - stops a running playback
+ +
    @@ -158,9 +187,8 @@ return $ret; HTML attributes to be used for Streaming device e.g.:

      - attr <name> htmlattr width="480" height="560" + attr <name> htmlattr width="480" height="560"
      -

    @@ -175,6 +203,26 @@ return $ret;

    SSCamSTRM

    +
    +Das Modul SSCamSTRM ist ein mit SSCam abgestimmtes Gerätemodul zur Definition von Streaming-Devices.
    +Abhängig vom Zustand des Streaming-Devices werden zum Start von Aktionen unterschiedliche Drucktasten angeboten: +
      + + + + + + + + + + + + +
      MJPEG - Startet MJPEG Livestream
      HLS - Startet HLS (HTTP Live Stream)
      Last Record - spielt die letzte Aufnahme als iFrame
      Last Rec H.264 - spielt die letzte Aufnahme wenn als H.264 vorliegend
      Last Rec MJPEG - spielt die letzte Aufnahme wenn als MJPEG vorliegend
      Last SNAP - zeigt den letzten Snapshot
      Start Recording - startet eine Endlosaufnahme
      Stop Recording - stoppt eine Aufnahme
      Take Snapshot - löst einen Schnappschuß aus
      Switch off - stoppt eine laufende Wiedergabe
      +
    +
    +
      Define @@ -217,9 +265,8 @@ return $ret; HTML-Attribute zur Darstellungsänderung des SSCam Streaming Device z.B.:

        - attr <name> htmlattr width="480" height="560" + attr <name> htmlattr width="480" height="560"
        -