[svn r634] * GMyth-Streamer trunk
authormorphbr
Fri May 04 20:45:38 2007 +0100 (2007-05-04)
branchtrunk
changeset 628c6af9d7a88b5
parent 627 73df1c7e30ec
child 629 7ad2e23504e6
[svn r634] * GMyth-Streamer
- Updated mencoder plugin
- Updated server code
gmyth-stream/server/0.2/lib/server.py
gmyth-stream/server/0.2/plugins/transcoders/mencoder.py
     1.1 --- a/gmyth-stream/server/0.2/lib/server.py	Thu May 03 16:07:54 2007 +0100
     1.2 +++ b/gmyth-stream/server/0.2/lib/server.py	Fri May 04 20:45:38 2007 +0100
     1.3 @@ -114,7 +114,11 @@
     1.4          elif self.path == "/stream.do":
     1.5              self.serve_stream(body)
     1.6          else:
     1.7 -            self.send_error(404, "File not found")
     1.8 +            action = self.query.get("action", None)
     1.9 +            if action is not None:
    1.10 +                self.serve_stream(body)
    1.11 +            else:
    1.12 +                self.send_error(404, "File not found")
    1.13      # do_dispatch()
    1.14  
    1.15  
     2.1 --- a/gmyth-stream/server/0.2/plugins/transcoders/mencoder.py	Thu May 03 16:07:54 2007 +0100
     2.2 +++ b/gmyth-stream/server/0.2/plugins/transcoders/mencoder.py	Fri May 04 20:45:38 2007 +0100
     2.3 @@ -30,7 +30,7 @@
     2.4          self.args["local"]    = params_first("local", False)
     2.5          self.args["language"] = params_first("language", False)
     2.6          self.args["subtitle"] = params_first("subtitle", False)
     2.7 -        self.args["format"]   = params_first("format", "")
     2.8 +        self.args["format"]   = params_first("format", "mpeg1")
     2.9          self.args["outfile"]  = params_first("outfile", "-")
    2.10          self.args["sendback"] = params_first("sendback", True)
    2.11  
    2.12 @@ -82,7 +82,8 @@
    2.13              video += " -ovc lavc -lavcopts vcodec=%s:vbitrate=%s" % (
    2.14                  vcodec, self.args["vbitrate"])
    2.15  
    2.16 -        video += " %s" % self.args["format"]
    2.17 +        if self.args["mux"] == "mpeg":
    2.18 +            video += " -mpegopts format=%s" % self.args["format"]
    2.19          video += " -vf scale=%s:%s" % (self.args["width"], self.args["height"])
    2.20  
    2.21          return video
    2.22 @@ -110,7 +111,7 @@
    2.23              self._arg_append(args, "-subfps %s" % self.args["fps"])
    2.24  
    2.25          self._arg_append(args, "-idx")
    2.26 -        self._arg_append(args, "-cache 500")
    2.27 +        self._arg_append(args, "-cache 1024")
    2.28          self._arg_append(args, self._setup_audio())
    2.29          self._arg_append(args, self._setup_video())
    2.30  
    2.31 @@ -207,6 +208,7 @@
    2.32  
    2.33          except Exception, e:
    2.34              self.log.error("Problems handling data: %s" % e)
    2.35 +            self.stop()
    2.36              return False
    2.37  
    2.38          self.log.info("%s: Finished sending data to client" % repr(self))
    2.39 @@ -243,7 +245,6 @@
    2.40  
    2.41          gmyth_cat = utils.which("gmyth-cat")
    2.42          opts = [gmyth_cat, "-h", host, "-p", port, "-" + kind, fchan]
    2.43 -        gr, gw = os.pipe()
    2.44  
    2.45          try:
    2.46              self.gmyth = subprocess.Popen(opts, stdout=subprocess.PIPE, close_fds=True)
    2.47 @@ -254,12 +255,33 @@
    2.48          if not self._run_mencoder(input=self.gmyth.stdout, output=subprocess.PIPE):
    2.49              return False
    2.50  
    2.51 +        show_loading = 0
    2.52 +        show = True
    2.53 +
    2.54 +        #n800 150000 and 1000
    2.55 +
    2.56          try:
    2.57              while self.proc and self.proc.poll() == None:
    2.58 -                r, w, x = select([self.proc.stdout], [], [], 0)
    2.59 +                r, w, x = select([self.proc.stdout], [outfd], [], 0)
    2.60                  if self.proc.stdout in r:
    2.61                      d = self.proc.stdout.read(4096)
    2.62                      outfd.write(d)
    2.63 +                    self.log.debug("Sending tv data: %d" % show_loading)
    2.64 +                    if show_loading > 150000 and show:
    2.65 +                        self.log.debug("Disabling loading video")
    2.66 +                        show = False
    2.67 +
    2.68 +                elif show_loading % 10000 == 0 and show:
    2.69 +                    show_loading += 1
    2.70 +                    d = open("loading.mpg")
    2.71 +                    outfd.write(d.read())
    2.72 +                    self.log.debug("Sendind loading video: %d" % show_loading)
    2.73 +
    2.74 +                else:
    2.75 +                    show_loading += 1
    2.76 +
    2.77 +                #self.log.debug("SHOW_LOADING: %d" % show_loading)
    2.78 +
    2.79          except Exception, e:
    2.80              self.log.error("Problems handling data: %s" % e)
    2.81              return False