[svn r809] fixed bugs on transcode trunk
authorrenatofilho
Wed Aug 15 13:33:12 2007 +0100 (2007-08-15)
branchtrunk
changeset 803b1d0964060b3
parent 802 d0e8c542c38e
child 804 4b2192319f56
[svn r809] fixed bugs on transcode
gmyth-stream/server/0.3/lib/request_handler.py
gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py
     1.1 --- a/gmyth-stream/server/0.3/lib/request_handler.py	Mon Aug 13 23:03:08 2007 +0100
     1.2 +++ b/gmyth-stream/server/0.3/lib/request_handler.py	Wed Aug 15 13:33:12 2007 +0100
     1.3 @@ -362,7 +362,8 @@
     1.4              return
     1.5  
     1.6          #Only stream files on .transcode dir
     1.7 -        filename = ".transcode/" + os.path.basename(filename)
     1.8 +        filename = ".transcoded/" + os.path.basename(filename)
     1.9 +        self.log.error("Stream file: %s" % filename)
    1.10          if not os.path.exists (filename):
    1.11              self.send_error(404, "File not found")
    1.12              return
    1.13 @@ -386,13 +387,16 @@
    1.14          self.transcoders_log.insert(test_tid, "gms.Stream: %s" % filename)
    1.15  
    1.16          try:
    1.17 +            file_data = ""
    1.18              while data_in != "":
    1.19                  data_in = media.read(4096)
    1.20 -                total_read += 4096
    1.21 -                self.wfile.write(data_in)
    1.22 -                status = utils.progress_bar(total_read, size, 50)
    1.23 -                msg_status = "Status:%s:%s%%" % (test_tid, status)
    1.24 -                self.transcoders_log._update_status(test_tid, msg_status)
    1.25 +                file_data += data_in
    1.26 +
    1.27 +                #total_read += 4096
    1.28 +            self.wfile.write(file_data)
    1.29 +                #status = utils.progress_bar(total_read, size, 50)
    1.30 +                #msg_status = "Status:%s:%s%%" % (test_tid, status)
    1.31 +                #self.transcoders_log._update_status(test_tid, msg_status)
    1.32  
    1.33              self.transcoders_log._update_status(test_tid, "OK: Done")
    1.34  
    1.35 @@ -435,7 +439,11 @@
    1.36                  obj.log = self.transcoders_log
    1.37  
    1.38                  self.server.add_transcoders(self, obj)
    1.39 -                obj.start(self.wfile)
    1.40 +                if obj.start(self.wfile):
    1.41 +                    self.transcoders_log.info (test_tid, "OK")
    1.42 +                else:
    1.43 +                    self.transcoders_log.info (test_tid, "Fail")
    1.44 +
    1.45                  self.server.del_transcoders(self, obj)
    1.46                  files.TranscodedFile("", self.query)
    1.47  
     2.1 --- a/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py	Mon Aug 13 23:03:08 2007 +0100
     2.2 +++ b/gmyth-stream/server/0.3/plugins/transcoders/gmencoder.py	Wed Aug 15 13:33:12 2007 +0100
     2.3 @@ -34,17 +34,6 @@
     2.4          self.opts.append ("-d")
     2.5          self._parser_params ()
     2.6  
     2.7 -        outfile = self.params_first("outfile", "")
     2.8 -
     2.9 -        if outfile != "":
    2.10 -            path = os.path.join(sys.path[0], ".transcoded", outfile)
    2.11 -            self._insert_param("-o", "file://%s" % path)
    2.12 -        else:
    2.13 -            self._insert_param ("-o", "fd://%d" % outfd.fileno())
    2.14 -            self.opts.append ("-c")
    2.15 -
    2.16 -        cmd = " ".join(self.opts)
    2.17 -
    2.18      # __init__()
    2.19  
    2.20      def _insert_param (self, name, value):
    2.21 @@ -66,6 +55,16 @@
    2.22      # _parse_params
    2.23  
    2.24      def start(self, outfd):
    2.25 +        outfile = self.params_first("outfile", "")
    2.26 +
    2.27 +        if outfile != "":
    2.28 +            path = os.path.join(sys.path[0], ".transcoded", outfile)
    2.29 +            self._insert_param("-o", "file://%s" % path)
    2.30 +        else:
    2.31 +            self._insert_param ("-o", "fd://%d" % outfd.fileno())
    2.32 +            self.opts.append ("-c")
    2.33 +
    2.34 +        cmd = " ".join(self.opts)
    2.35          self.log.info(self.tid, "GMencoder: %s" % cmd)
    2.36  
    2.37          try:
    2.38 @@ -88,6 +87,10 @@
    2.39              return False
    2.40  
    2.41          self.status = 100;
    2.42 +
    2.43 +        if outfile:
    2.44 +           outfd.write("OK   ")
    2.45 +
    2.46          return True
    2.47      # start()
    2.48