Christopher Stanton wrote:

> On Tuesday 11 November 2003 14:48, Andrew Gaffney wrote:
> > Christopher Stanton wrote:
> > > RedHat Linux 9
> > > Perl v5.8.0 built for i386-linux-thread-multi
> > >
> > > I am trying to parse a mjpeg stream out of an html response. The http
> > > server is using server push to push the stream of jpegs to the client. I
> > > have written a test client and am able to receive the stream but am
> > > having trouble figuring out what Perl libraries I need to use to separate
> > > and save the individual jpegs as actual jpegs and not MIME encoded data.
> > >
> > > The Content Type is "multipart/x-mixed-replace; boundary=--myboundary".
> > > "--myboundry" is the flag used to delimit the individual data fields.
> > >
> > > This is a stream of JPEGs so, the server will continue streaming as long
> > > as the connection is open. I am using the Net::HTTP library since I have
> > > to parse as it arrives rather than wait for the whole page to be
> > > downloaded (since it can't be).
> > >
> > > The stream's format:

Ignore everything that isn't among the following:
 0 A            17 R            34 i            51 z
           1 B            18 S            35 j            52 0
           2 C            19 T            36 k            53 1
           3 D            20 U            37 l            54 2
           4 E            21 V            38 m            55 3
           5 F            22 W            39 n            56 4
           6 G            23 X            40 o            57 5
           7 H            24 Y            41 p            58 6
           8 I            25 Z            42 q            59 7
           9 J            26 a            43 r            60 8
          10 K            27 b            44 s            61 9
          11 L            28 c            45 t            62 +
          12 M            29 d            46 u            63 /
          13 N            30 e            47 v
          14 O            31 f            48 w         (pad) =
          15 P            32 g            49 x
          16 Q            33 h            50 y

from:
http://www.freesoft.org/CIE/RFC/1521/7.htm

Since the characters listed above are the only significant ones in base64, which
is the encoding used in most mail attachments.  Every four encoded characters
represent 3 bytes of binary data.  That is, each character represents six bits.The
trick is to string each set of four characters together as a number, then to
output that number in binary form, rather than as its text representation.  The
pack function should help with this, but I haven't used it much, so I'll leave it
to others to guide you there.

Say you have the string 'Mf8d':

(000000 + 12) * 64 = 768
(00768 + 31) * 64 = 51_136
(51_136 + 60) * 64 = 3_276_544  [Okay, I had to9 punt and use a calculator here]
 3_276_544 + 29 =  3_276_573

from here you would have three bytes of binary data.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to