From 85e971a5cc254f673a52d606b8215a657f807e51 Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Sat, 27 Oct 2018 14:01:45 +0000 Subject: [PATCH] 49_SSCam: contrib undefined subroutine git-svn-id: https://svn.fhem.de/fhem/trunk@17625 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/49_SSCam.pm | 37 ++- fhem/contrib/DS_Starter/49_SSCamSTRM.pm | 316 ++++++++++++++++++++++++ 2 files changed, 330 insertions(+), 23 deletions(-) create mode 100644 fhem/contrib/DS_Starter/49_SSCamSTRM.pm diff --git a/fhem/contrib/DS_Starter/49_SSCam.pm b/fhem/contrib/DS_Starter/49_SSCam.pm index 22d0857ce..494908bc5 100644 --- a/fhem/contrib/DS_Starter/49_SSCam.pm +++ b/fhem/contrib/DS_Starter/49_SSCam.pm @@ -36,10 +36,16 @@ package main; use strict; use warnings; +eval "use JSON qw( decode_json );1;" or my $SScamMMDBI = "JSON"; # Debian: apt-get install libjson-perl +use Data::Dumper; # Perl Core module +use MIME::Base64; +use Time::HiRes; +use HttpUtils; +# no if $] >= 5.017011, warnings => 'experimental'; # Versions History intern our %SSCam_vNotesIntern = ( - "7.2.2" => "24.10.2018 attribute \"livestreamprefix\" to widget sortable ", + "7.2.2" => "27.10.2018 Undefined subroutine &main::SSCam_ptzpanel ", "7.2.1" => "23.10.2018 new routine SSCam_versionCheck, COMPATIBILITY changed to 8.2.1 ", "7.2.0" => "20.10.2018 direct help for attributes, new get versionNotes command, fix PERL WARNING: Use of uninitialized value \$small, get versionNotes ", "7.1.1" => "18.10.2018 Message of \"Your current/simulated SVS-version...\" changed, commandref corrected ", @@ -84,7 +90,6 @@ our %SSCam_vNotesIntern = ( # Versions History extern our %SSCam_vNotesExtern = ( - "7.2.2" => "24.10.2018 attribute \"livestreamprefix\" contains defined port and server address for possible selction ", "7.2.1" => "23.10.2018 COMPATIBILITY changed to 8.2.1 ", "7.2.0" => "20.10.2018 direct help for attributes, new get versionNotes command, please see commandref for details ", "7.1.1" => "18.10.2018 Message of \"current/simulated SVS-version...\" changed, commandref corrected ", @@ -193,13 +198,6 @@ our %SSCam_vHintsExt_de = ( "1" => "Hilfreiche Hinweise zu SSCam im FHEM-Wiki" ); -eval "use JSON qw( decode_json );1;" or my $SScamMMDBI = "JSON"; # Debian: apt-get install libjson-perl -use Data::Dumper; # Perl Core module -use MIME::Base64; -use Time::HiRes; -use HttpUtils; -# no if $] >= 5.017011, warnings => 'experimental'; - # getestete SVS-Version my $compstat = "8.2.1"; @@ -247,7 +245,7 @@ my %SSCam_errlist = ( 600 => "Presetname and PresetID not found in Hash", ); -# Standardvariablen +# Standardvariablen und Forward-Declaration my $SSCam_slim = 3; # default Anzahl der abzurufenden Schnappschüsse mit snapGallery my $SSCAM_snum = "1,2,3,4,5,6,7,8,9,10"; # mögliche Anzahl der abzurufenden Schnappschüsse mit snapGallery @@ -256,6 +254,8 @@ use vars qw($FW_subdir); # Sub-path in URL, used by FLOORPLAN/weblink use vars qw($FW_room); # currently selected room use vars qw($FW_detail); # currently selected device for detail view +sub SSCam_ptzpanel($;$$); + sub SSCam_Initialize($) { my ($hash) = @_; $hash->{DefFn} = "SSCam_Define"; @@ -274,6 +274,7 @@ sub SSCam_Initialize($) { "genericStrmHtmlTag ". "httptimeout ". "htmlattr ". + "livestreamprefix ". "loginRetries:1,2,3,4,5,6,7,8,9,10 ". "videofolderMap ". "pollcaminfoall ". @@ -373,13 +374,9 @@ sub SSCam_Define($@) { } else { readingsBulkUpdate($hash,"state", "Initialized"); # Init für "state" wenn SVS } - readingsEndUpdate($hash,1); - - # allg. Userattr setzen - my $defpref = $hash->{PROTOCOL}."://".$hash->{SERVERADDR}.":".$hash->{SERVERPORT}; - addToDevAttrList($name, "livestreamprefix:sortable,$defpref"); + readingsEndUpdate($hash,1); - SSCam_getcredentials($hash,1); # Credentials lesen und in RAM laden ($boot=1) + SSCam_getcredentials($hash,1); # Credentials lesen und in RAM laden ($boot=1) # initiale Routinen nach Restart ausführen , verzögerter zufälliger Start RemoveInternalTimer($hash, "SSCam_initonboot"); @@ -417,8 +414,7 @@ return undef; ################################################################ sub SSCam_Attr($$$$) { - my @a = @_; - my ($cmd,$name,$aName,$aVal) = @a; + my ($cmd,$name,$aName,$aVal) = @_; my $hash = $defs{$name}; my ($do,$val); @@ -440,11 +436,6 @@ sub SSCam_Attr($$$$) { InternalTimer(gettimeofday()+0.7, "SSCam_addptzattr", "$name", 0); } - if($aName =~ /livestreamprefix/ && $cmd eq "set") { - $aVal = (split(",",$aVal))[0]; - $_[3] = $aVal; - } - if ($aName eq "disable") { if($cmd eq "set") { $do = ($aVal) ? 1 : 0; diff --git a/fhem/contrib/DS_Starter/49_SSCamSTRM.pm b/fhem/contrib/DS_Starter/49_SSCamSTRM.pm new file mode 100644 index 000000000..2ceea532a --- /dev/null +++ b/fhem/contrib/DS_Starter/49_SSCamSTRM.pm @@ -0,0 +1,316 @@ +######################################################################################################################## +# $Id: 49_SSCamSTRM.pm 16938 2018-07-03 17:31:13Z DS_Starter $ +######################################################################################################################### +# 49_SSCamSTRM.pm +# +# (c) 2018 by Heiko Maaz +# forked from 98_weblink.pm by Rudolf König +# e-mail: Heiko dot Maaz at t-online dot de +# +# This Module is used by module 49_SSCam to create Streaming devices. +# It can't be used without any SSCam-Device. +# +# This script is part of fhem. +# +# Fhem is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# Fhem is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with fhem. If not, see . +# +######################################################################################################################### +# Versions History: +# +# 1.2.4 27.10.2018 Undefined subroutine &main::SSCam_ptzpanel +# 1.2.3 03.07.2018 behavior changed if device is disabled +# 1.2.2 26.06.2018 make changes for generic stream dev +# 1.2.1 23.06.2018 no name add-on if MODEL is snapgallery +# 1.2.0 20.06.2018 running stream as human readable entry for SSCamSTRM-Device +# 1.1.0 16.06.2018 attr hideDisplayName regarding to Forum #88667 +# 1.0.1 14.06.2018 commandref revised +# 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 + + +package main; + +use strict; +use warnings; + +my $SSCamSTRMVersion = "1.2.4"; + +sub SSCam_ptzpanel($;$$); +sub SSCam_StreamDev($$$); + +################################################################ +sub SSCamSTRM_Initialize($) { + my ($hash) = @_; + + $hash->{DefFn} = "SSCamSTRM_Define"; + $hash->{AttrList} = "disable:1,0 forcePageRefresh:1,0 htmlattr hideDisplayName:1,0 "; + $hash->{FW_summaryFn} = "SSCamSTRM_FwFn"; + $hash->{FW_detailFn} = "SSCamSTRM_FwFn"; + $hash->{AttrFn} = "SSCamSTRM_Attr"; + $hash->{FW_hideDisplayName} = 1; # Forum 88667 + # $hash->{FW_addDetailToSummary} = 1; + # $hash->{FW_atPageEnd} = 1; # wenn 1 -> kein Longpoll ohne informid in HTML-Tag +} + + +################################################################ +sub SSCamSTRM_Define($$) { + my ($hash, $def) = @_; + my ($name, $type, $link) = split("[ \t]+", $def, 3); + + if(!$link) { + return "Usage: define SSCamSTRM "; + } + + my $arg = (split("[()]",$link))[1]; + $arg =~ s/'//g; + ($hash->{PARENT},$hash->{MODEL}) = ((split(",",$arg))[0],(split(",",$arg))[2]); + + $hash->{VERSION} = $SSCamSTRMVersion; + $hash->{LINK} = $link; + + readingsSingleUpdate($hash,"state", "initialized", 1); # Init für "state" + +return undef; +} + +################################################################ +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 ? "disabled" : "initialized"); + + readingsSingleUpdate($hash, "state", $val, 1); + } + +return undef; +} + +################################################################ +sub SSCamSTRM_FwFn($$$$) { + my ($FW_wname, $d, $room, $pageHash) = @_; # pageHash is set for summaryFn. + my $hash = $defs{$d}; + my $link = $hash->{LINK}; + + # return undef if(IsDisabled($d)); + + $link = AnalyzePerlCommand(undef, $link) if($link =~ m/^{(.*)}$/s); + my $show = $defs{$hash->{PARENT}}->{HELPER}{ACTSTRM} if($hash->{MODEL} =~ /switched/); + $show = $show?"($show)":""; + + my $alias = AttrVal($d, "alias", $d); # Linktext als Aliasname oder Devicename setzen + my $dlink = "$alias"; + + my $ret = ""; + $ret .= "$dlink $show
" if(!AttrVal($d,"hideDisplayName",0)); + if(IsDisabled($d)) { + if(AttrVal($d,"hideDisplayName",0)) { + $ret .= "Stream-device $d is disabled"; + } else { + $ret .= "Stream-device is disabled"; + } + } else { + $ret .= $link; + } + +return $ret; +} + +1; + +=pod +=item summary define a Streaming device by SSCam module +=item summary_DE Erstellung eines Streaming-Device durch das SSCam-Modul +=begin html + + +

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: +
    + + + + + + + + + + + + + + +
    Switch off - stops a running playback
    Refresh - refresh a view (no page reload)
    Restart - restart a running content (e.g. a HLS-Stream)
    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
    +
+
+ +
    + + Define + +
      + A SSCam Streaming-device is defined by the SSCam "set <name> createStreamDev" command. + Please refer to SSCam "createStreamDev" command. +

      +
    + + + Set
      N/A

    + + + Get
      N/A

    + + + Attributes +

    + +
      +
        + +
      • disable
        + deactivates the device definition +
      • +
        + +
      • forcePageRefresh
        + The attribute is evaluated by SSCam.
        + If set, a reload of all browser pages with active FHEMWEB-connections will be enforced. + This may be helpful if problems with longpoll are appear. +
      • +
        + +
      • hideDisplayName
        + hide the device/alias name (link to detail view) +
      • +
        + + +
      • htmlattr
        + HTML attributes to be used for Streaming device e.g.:

        +
          + + attr <name> htmlattr width="480" height="560"
          +
          +
        +
      • + +
      +
    + +
+ +=end html +=begin html_DE + + +

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: +
    + + + + + + + + + + + + + + +
    Switch off - stoppt eine laufende Wiedergabe
    Refresh - auffrischen einer Ansicht (kein Browser Seiten-Reload)
    Restart - neu starten eines laufenden Contents (z.B. eines HLS-Streams)
    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
    +
+
+ +
    + + Define + +
      + Ein SSCam Streaming-Device wird durch den SSCam Befehl "set <name> createStreamDev" erstellt. + Siehe auch die Beschreibung zum SSCam "createStreamDev" Befehl. +

      +
    + + + Set
      N/A

    + + + Get
      N/A

    + + + Attributes +

    + +
      +
        + +
      • disable
        + aktiviert/deaktiviert das Device +
      • +
        + +
      • forcePageRefresh
        + Das Attribut wird durch SSCam ausgewertet.
        + Wenn gesetzt, wird ein Reload aller Browserseiten mit aktiven FHEMWEB-Verbindungen bei bestimmten Aktionen erzwungen. + Das kann hilfreich sein, falls es mit Longpoll Probleme geben sollte. + eingefügt ist. +
      • +
        + +
      • hideDisplayName
        + verbirgt den Device/Alias-Namen (Link zur Detailansicht) +
      • +
        + + +
      • htmlattr
        + HTML-Attribute zur Darstellungsänderung des SSCam Streaming Device z.B.:

        +
          + + attr <name> htmlattr width="480" height="560"
          +
          +
        +
      • + +
      +
    + +
+ +=end html_DE +=cut