Commit 96a17310 authored by conrad's avatar conrad

add private oggz_auto_identify_packet() function, and use it in

oggz_write_feed() when a bos page is encountered. This sets the content type
for writing, so that oggz can know how to structure comment packets etc.


git-svn-id: http://svn.annodex.net/liboggz/trunk@3365 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent de56cbc6
......@@ -94,7 +94,7 @@ read_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
oggz_comment_add_byname (mhdata->writer, serialno,
"EDITOR", "modify-headers");
op = oggz_comment_generate (mhdata->writer, serialno,
oggz_stream_get_content (mhdata->reader, serialno),
oggz_stream_get_content (mhdata->writer, serialno),
0);
}
......
......@@ -892,8 +892,8 @@ const oggz_auto_contenttype_t oggz_auto_codec_ident[] = {
{"", 0, "Unknown", NULL, NULL, NULL}
};
int
oggz_auto_identify_page (OGGZ *oggz, ogg_page *og, long serialno)
static int
oggz_auto_identify (OGGZ * oggz, long serialno, unsigned char * data, long len)
{
int i;
......@@ -901,8 +901,8 @@ oggz_auto_identify_page (OGGZ *oggz, ogg_page *og, long serialno)
{
const oggz_auto_contenttype_t *codec = oggz_auto_codec_ident + i;
if (og->body_len >= codec->bos_str_len &&
memcmp (og->body, codec->bos_str, codec->bos_str_len) == 0) {
if (len >= codec->bos_str_len &&
memcmp (data, codec->bos_str, codec->bos_str_len) == 0) {
oggz_stream_set_content (oggz, serialno, i);
......@@ -914,6 +914,18 @@ oggz_auto_identify_page (OGGZ *oggz, ogg_page *og, long serialno)
return 0;
}
int
oggz_auto_identify_page (OGGZ * oggz, ogg_page *og, long serialno)
{
return oggz_auto_identify (oggz, serialno, og->body, og->body_len);
}
int
oggz_auto_identify_packet (OGGZ * oggz, ogg_packet * op, long serialno)
{
return oggz_auto_identify (oggz, serialno, op->packet, op->bytes);
}
int
oggz_auto_get_granulerate (OGGZ * oggz, ogg_packet * op, long serialno,
void * user_data)
......
......@@ -291,6 +291,7 @@ oggz_auto_read_comments (OGGZ * oggz, oggz_stream_t * stream, long serialno,
ogg_packet * op);
int oggz_auto_identify_page (OGGZ *oggz, ogg_page *og, long serialno);
int oggz_auto_identify_packet (OGGZ * oggz, ogg_packet * op, long serialno);
/* comments */
int oggz_comments_init (oggz_stream_t * stream);
......
......@@ -247,6 +247,7 @@ oggz_write_feed (OGGZ * oggz, ogg_packet * op, long serialno, int flush,
if (b_o_s || !strict || suffix) {
stream = oggz_add_stream (oggz, serialno);
oggz_auto_identify_packet (oggz, op, serialno);
} else {
return OGGZ_ERR_BAD_SERIALNO;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment