[X2Go-Commits] [mteleplayer] 01/01: Move mediaFileInfo stuff into mteleplayer and make it use the right mplayer(2) on distros like Debian etc.

git-admin at x2go.org git-admin at x2go.org
Sat Jun 21 23:13:32 CEST 2014


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository mteleplayer.

commit 41ddac11f5e778ab3cf3700df629ca2e18fe4ca7
Author: gznget <opensource at gznianguan.com>
Date:   Sat Jun 21 12:38:58 2014 +0200

    Move mediaFileInfo stuff into mteleplayer and make it use the right mplayer(2) on distros like Debian etc.
---
 serverside/bin/mteleplayer |   45 +++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 42 insertions(+), 3 deletions(-)

diff --git a/serverside/bin/mteleplayer b/serverside/bin/mteleplayer
index f39406e..afd0e54 100755
--- a/serverside/bin/mteleplayer
+++ b/serverside/bin/mteleplayer
@@ -46,7 +46,7 @@ use File::Spec;
 use Glib qw/TRUE FALSE/; 
 use IO::Socket::UNIX qw( SOCK_STREAM );
 use Time::HiRes qw( usleep gettimeofday tv_interval clock_gettime clock_getres clock_nanosleep clock stat );
-use X2Go::Telekinesis::Apps::AppCore qw(getTeKiPaths tkappDie appDBugLog cleanUpOldAppSession checkAppSesLOCKnDirs mediaFileINFO  initLOCKandDirs getXWinPosNDim showAboutPOP  getBasicServersideInfo epicFailPOP);
+use X2Go::Telekinesis::Apps::AppCore qw(getTeKiPaths tkappDie appDBugLog cleanUpOldAppSession checkAppSesLOCKnDirs initLOCKandDirs getXWinPosNDim showAboutPOP  getBasicServersideInfo epicFailPOP);
 use X2Go::Telekinesis::CommonCore qw(sanitizer  genRandFID  checkPID sanitizeFilePath sanitizeDirPath genRandSID clups); 
 use Gtk2;
 use Gtk2::SimpleMenu;
@@ -79,6 +79,10 @@ my %PlayerStatus;$PlayerStatus{'timePos'} = 0;$PlayerStatus{'timeLength'} = 0;$P
 our  ($UserName,$UserHome,$X2GoSID,$X2GoSesHome,$X2GoTKSHome,$TeKiLSockPath) = getBasicServersideInfo();
 my $LocalSocket;
 my $mTPMainMediaEBOX;
+my $mPlayerPath = "/usr/bin/mplayer";
+if (-X "/usr/bin/mplayer2") {
+  $mPlayerPath = "/usr/bin/mplayer2";
+}
 appDBugLog("-------------------------------------------\nStarting.....");
 ########################################
 #
@@ -709,8 +713,8 @@ sub mtpTeKiRemoteFileSetup {
   my $remoteDir = sanitizeDirPath($_[1]);
   if ($inMediaLine =~ /^FILE:(.*)$/) {
     my $AbsoluteMediaFilePath = sanitizeFilePath(File::Spec->rel2abs($1));
-    my ($isItMedia,$AorV,%Info) = mediaFileINFO($AbsoluteMediaFilePath);
-    # since mediaFileInfo will handle the checking of the actuall existance of a file... AGAIN.... we will not doing the -f check yet again...
+    my ($isItMedia,$AorV,%Info) = getMediaFileINFO($AbsoluteMediaFilePath);
+    # since getMediaFileINFO will handle the checking of the actuall existance of a file... AGAIN.... we will not doing the -f check yet again...
     # If its not a media file... its not "a file to us" anyway....
     if ($isItMedia eq 1) {
 #      print "Type: $AorV\n",Dumper(%Info),"\n";
@@ -950,6 +954,41 @@ sub theMenuTreeSUB {
 }
 
 
+########################################################################################################
+# GET Media FILE Info 
+# Initially we we're using another perl module for this but it turned out to have some (b) ithchy dependencies on some never distros so...
+# "Self made" is not always well made.... but it takes less to rigg this short sub rather than debugging 3rd party crud.
+# Plan to expand on the content of the returned %FileInfo but at the moment this is all we need for preliminary validation that the file is actually a playable file.
+sub getMediaFileINFO {
+  my $FilePath = sanitizeFilePath($_[0]);
+  my %FileInfo;
+  if (-f $FilePath) {
+    open(MPINFO,"-|",$mPlayerPath,'-vo','null','-ao','null', '-identify','-frames','0','-nolirc',$FilePath);
+    my @MPInfo = <MPINFO>;
+    close(MPINFO); 
+    foreach my $line (@MPInfo) {
+      $line =~ s/\n//g;
+      if ($line =~ /^ID\_LENGTH\=([\d\.]*)$/) {
+        $FileInfo{'length'} = $1;
+      } elsif ($line =~ /^ID\_VIDEO\_CODEC\=(.*)$/) {
+        $FileInfo{'vcodec'} = $1;
+      } elsif ($line =~ /^ID\_AUDIO\_CODEC\=(.*)$/) {
+        $FileInfo{'acodec'} = $1;
+      }
+    } 
+    if ($FileInfo{'length'} > 0) {
+      if ($FileInfo{'vcodec'}) {
+        return (1,"V",%FileInfo);
+      } else {
+        if ($FileInfo{'acodec'}) {
+	  return (1,"A",%FileInfo);
+        } else {return 0;}        
+      }
+    } else {return 0;}
+  } else {
+    return 0;
+  }
+}
 
 #################################################################################################################################
 # This sub, supposedly try to do a clean termination of the application...

--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/mteleplayer.git


More information about the x2go-commits mailing list