Changeset 320 for py-tcpmultiplexer


Ignore:
Timestamp:
Jul 19, 2011, 8:05:20 PM (13 years ago)
Author:
Rick van der Zwet
Message:

Making the boundry work

Location:
py-tcpmultiplexer
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • py-tcpmultiplexer/TCPMultiplexer.py

    r318 r320  
    113113        datatype = 'wav'
    114114      elif urltype == 'multipart/x-mixed-replace':
    115         datatype = 'mjeg'
     115        datatype = 'mjpeg'
    116116      else:
    117117        logger.warning("Cannot find file type of '%s'", url)
     
    123123        # WAV header
    124124        dataheader[urlid] = f.read(44)
    125       elif datatype == 'mjeg':
    126         # Get rid of Content-Length as not all pictures suits this setup
    127         headers = f.read(100).splitlines()[0:3]
     125      elif datatype == 'mjpeg':
     126        data  = f.read(1024 * 1024)
     127
     128        # Get the required headers
     129        headers = []
     130        for header in data.splitlines():
     131          if not header.strip(): break
     132          headers.append(header)
     133        boundry = headers[0]
     134        logger.info("Boundry line: %s", boundry)
    128135        logger.info("Image headers %s", headers)
    129         valid_image = headers[0] + f.read(100000).split(headers[0])[1]
    130         dataheader[urlid] = valid_image + '\n'.join([h for h in headers if not h.startswith('Content-length:')]) + '\n'
     136
     137        valid_image = boundry + data.split(boundry)[1]
     138        dataheader[urlid] = valid_image + '\n'.join(headers) + '\n'
    131139      else:
    132140        dataheader[urlid] = ''
  • py-tcpmultiplexer/htdocs/browser.html

    r319 r320  
    3232
    3333<input type="button" onclick="changeVideo('/cam1/video')" value="Click to display Cam1" />
    34 <input type="button" onclick="changeVideo('/cam2/video')" value="Click to display Cam2" /><br />
     34<input type="button" onclick="changeVideo('/cam2/video')" value="Click to display Cam2" />
     35<input type="button" onclick="changeVideo('/cam3/video')" value="Click to display Cam3" />
     36<br />
    3537<img id="player" src="img/logo.png" alt="Video feeds"/><br/>
    3638
Note: See TracChangeset for help on using the changeset viewer.