On Fri, Jan 17, 2014 at 11:45 AM, jeff shanab <[email protected]> wrote:
> I deal with security cameras and a lot of them stream audio out via post
> using a multipart/x-mixed-replace mime header.
> It is the servers responsibility in these cases to take the payloads out
> of each section, the parts marked with --MyBoundry.
>
> AFAIK This mime type was originaly created for the other direction. For
> browsers to display MJPEG by letting them just keep replacing the image.
> But has been adopted to stream to a server.
> This would mean the server must work on each chunk not the whole post. So
> I would guess there would be two callbacks. One at post start and one for
> each myBoundry section.
>
Thanks Jeff.
Assume that URI handler is called with POST data buffered in a
temporary file. I.e. a handler has FILE * stream opened. Assume that
that file stream has multipart POST data in it.
>From this point on, there are 2 basic approaches on how to parse that data.
1. As Jeff suggested, callback-based approach:
mg_parse_multipart_file(FILE *fp, void (*callback)(char *file_name, FILE
*data, int data_len));
mg_parse_multipart() would call a callback function for every chunk in
in multipart data, passing file name and a data pointer to the callback.
2. Another approach is a "synchronous" one. There no callbacks,
mg_parse_multipart_file()
can be called multiple times until it fails. Each time
mg_parse_multipart_file() is called,
it would advance to the next chunk. This approach is implemented in
existing
mg_parse_multipart() function.
int mg_parse_multipart_file(FILE *fp,
char *var_name, int var_name_len,
char *file_name, int file_name_len,
FILE *data, int *data_len);
Implementation-wise, these two would be very similar. The difference is in
the API.
I prefer the second one.
What are your thoughts?
--
You received this message because you are subscribed to the Google Groups
"mongoose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mongoose-users.
For more options, visit https://groups.google.com/groups/opt_out.