gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog plugin/plugin.cpp plugin/plugin.h


From: Bastiaan Jacques
Subject: [Gnash-commit] gnash ChangeLog plugin/plugin.cpp plugin/plugin.h
Date: Mon, 02 Oct 2006 12:44:05 +0000

CVSROOT:        /sources/gnash
Module name:    gnash
Changes by:     Bastiaan Jacques <bjacques>     06/10/02 12:44:05

Modified files:
        .              : ChangeLog 
        plugin         : plugin.cpp plugin.h 

Log message:
        Pipe the SWF file to Gnash's standard input.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.984&r2=1.985
http://cvs.savannah.gnu.org/viewcvs/gnash/plugin/plugin.cpp?cvsroot=gnash&r1=1.58&r2=1.59
http://cvs.savannah.gnu.org/viewcvs/gnash/plugin/plugin.h?cvsroot=gnash&r1=1.23&r2=1.24

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.984
retrieving revision 1.985
diff -u -b -r1.984 -r1.985
--- ChangeLog   2 Oct 2006 11:33:08 -0000       1.984
+++ ChangeLog   2 Oct 2006 12:44:05 -0000       1.985
@@ -1,3 +1,8 @@
+2006-10-02 Bastiaan Jacques <address@hidden>
+
+       * plugin/plugin{.cpp, .h}: Pipe the SWF file to Gnash's standard
+       input.
+
 2006-10-02 Markus Gothe <address@hidden>
 
        * server/gnash.h: Added include <string> for create_movie(tu_file*,

Index: plugin/plugin.cpp
===================================================================
RCS file: /sources/gnash/gnash/plugin/plugin.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -b -r1.58 -r1.59
--- plugin/plugin.cpp   28 Sep 2006 16:07:36 -0000      1.58
+++ plugin/plugin.cpp   2 Oct 2006 12:44:05 -0000       1.59
@@ -35,7 +35,7 @@
 // 
 //
 
-/* $Id: plugin.cpp,v 1.58 2006/09/28 16:07:36 nihilus Exp $ */
+/* $Id: plugin.cpp,v 1.59 2006/10/02 12:44:05 bjacques Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -397,7 +397,7 @@
                             NPBool /* seekable */, uint16_t * /* stype */)
 {
     string url = stream->url;
-    string fname, opts;
+    string opts;
     size_t start, end, eq;
     bool dumpopts = false;
 
@@ -406,12 +406,8 @@
       (void *)this, stream->url);
 #endif
 
-    end   = url.find(".swf", 0) + 4;
-    start = url.rfind("/", end) + 1;
-    fname = "/tmp/";
-    fname += url.substr(start, end - start);
-
     // extract the parameters from the URL
+    end   = url.find(".swf", 0) + 4;
     start = url.find("?", end);
     end = url.size();
     if (start != string::npos) {
@@ -477,20 +473,10 @@
 #endif
 
 process:
-    WriteStatus("Loading Flash movie " + fname);
-
-    _streamfd = open(fname.c_str(), O_CREAT | O_WRONLY, 
S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH);
-    if (_streamfd < 0) {
-        WriteStatus(fname + " can't be opened, check your permissions!\n");
-        _streamfd = open(fname.c_str(), O_TRUNC | O_WRONLY, 
S_IRUSR|S_IRGRP|S_IROTH);
-        if (_streamfd < 0) {
-            WriteStatus(fname + " can't be created, check your 
permissions!\n");
-        }
-    }
-
-    _swf_file = fname;
     _swf_url = url;
 
+    startProc(_window);
+
     return NPERR_NO_ERROR;
 }
 
@@ -498,8 +484,6 @@
 NPError
 nsPluginInstance::DestroyStream(NPStream * /* stream */, NPError /* reason */)
 {
-    WriteStatus("Finished downloading Flash movie " + _swf_file +
-                ". Playing...");
 
 #if 0
     nsPluginInstance *arg = (nsPluginInstance *)this;
@@ -525,8 +509,6 @@
        }
     }
 
-    _childpid = startProc(_swf_file, _window);
-
     return NPERR_NO_ERROR;
 }
 
@@ -554,8 +536,8 @@
     return write(_streamfd, buffer, len);
 }
 
-int
-nsPluginInstance::startProc(const string& filespec, Window win)
+void
+nsPluginInstance::startProc(Window win)
 {
     string procname;
     char *gnash_env = getenv("GNASH_PLAYER");
@@ -571,23 +553,50 @@
     // See if the file actually exists, otherwise we can't spawn it
     if (stat(procname.c_str(), &procstats) == -1) {
         dbglogfile << "Invalid filename: " << procname << endl;
-        return 0;
+      return;
+    }
+
+    int pipefd[2]; // 0 For reading, 1 for writing.
+
+    int ret = pipe(pipefd);
+    if (ret == -1) {
+      dbglogfile << "ERROR: pipe() failed: " << strerror(errno) << endl;
     }
 
+    _streamfd = pipefd[1];
+
     _childpid = fork();
     // childpid is -1, if the fork failed, so print out an error message
     if (_childpid == -1) {
-        perror(strerror(errno));
-        return 0;
+      dbglogfile << "ERROR: dup2() failed: " << strerror(errno) << endl;
+      return;
     }
+
     // childpid is a positive integer, if we are the parent, and
     // fork() worked
     if (_childpid > 0) {
+      ret = close (pipefd[0]); // we want to write, so close read-fd0
+      if (ret == -1) {
+        dbglogfile << "ERROR: close() failed: " << strerror(errno) << endl;
+      }
+
         dbglogfile << "Forked sucessfully, child process PID is " << _childpid 
<< endl;
-        return _childpid;
+
+      return;
+    }
+
+    // This is the child scope.
+
+    ret = close (pipefd[1]); // We want to read, so close write-fd1
+    if (ret == -1) {
+      dbglogfile << "ERROR: close() failed: " << strerror(errno) << endl;
     }
 
-    // We are the child
+    // close standard input and direct read-fd1 to standard input
+    ret = dup2 (pipefd[0], fileno(stdin));
+    if (ret == -1) {
+      dbglogfile << "ERROR: dup2() failed: " << strerror(errno) << endl;
+    }
 
     // setup the command line
 
@@ -645,7 +654,7 @@
         argv[argc++] = const_cast<char*>( paramvalues[i].c_str() );
     }
 
-    argv[argc++] = const_cast<char*>( filespec.c_str() );
+    argv[argc++] = "-";
     argv[argc++] = 0;
 
     assert(argc <= maxargc);

Index: plugin/plugin.h
===================================================================
RCS file: /sources/gnash/gnash/plugin/plugin.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- plugin/plugin.h     27 Sep 2006 09:18:05 -0000      1.23
+++ plugin/plugin.h     2 Oct 2006 12:44:05 -0000       1.24
@@ -95,7 +95,7 @@
     NPError WriteStatus(char *msg) const;
     NPError WriteStatus(std::string msg) const;
 
-    int startProc(const std::string& filespec, Window win);
+    void startProc(Window win);
 
 private:
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]