static int test_comments () { th_comment tc; int n; char * value; INFO ("+ Initializing th_comment"); th_comment_init (&tc); INFO ("+ Adding ARTIST1"); th_comment_add (&tc, "ARTIST=" ARTIST1); INFO ("+ Adding LICENSE by tag"); th_comment_add_tag (&tc, "LICENSE", LICENSE); INFO ("+ Adding ARTIST2 by tag"); th_comment_add_tag (&tc, "ARTIST", ARTIST2); INFO ("+ Querying value of LICENSE"); value = th_comment_query (&tc, "LICENSE", 0); printf("foo %s\n", value); if (strcmp (value, LICENSE)) FAIL ("Incorrect value for LICENSE"); INFO ("+ Querying count of ARTIST comments"); n = th_comment_query_count (&tc, "ARTIST"); if (n != 2) FAIL ("Incorrect count of ARTIST comments"); INFO ("+ Querying value of ARTIST index 0"); value = th_comment_query (&tc, "ARTIST", 0); if (strcmp (value, ARTIST1)) FAIL ("Incorrect value for ARTIST index 0"); INFO ("+ Querying value of ARTIST index 1"); value = th_comment_query (&tc, "ARTIST", 1); if (strcmp (value, ARTIST2)) FAIL ("Incorrect value for ARTIST index 1"); INFO ("+ Querying value of ARTIST index 2 (out of bounds)"); value = th_comment_query (&tc, "ARTIST", 2); if (value != NULL) FAIL ("Non-NULL value for ARTIST index 2 (out of bounds)"); INFO ("+ Querying value of UNDEF index 7 (tag not defined)"); value = th_comment_query (&tc, "UNDEF", 7); if (value != NULL) FAIL ("Non-NULL value for UNDEF index 7 (tag not defined)"); INFO ("+ Clearing th_comment"); th_comment_clear (&tc); return 0; }
/* * Theora beginning of stream */ nsresult MediaRecorder::SetupTheoraBOS() { int i; nsresult rv; PRUint32 wr; ogg_uint32_t keyframe; if (ogg_stream_init(&vState->os, rand())) { PR_LOG(log, PR_LOG_NOTICE, ("Failed ogg_stream_init\n")); return NS_ERROR_FAILURE; } th_info_init(&vState->ti); /* Must be multiples of 16 */ vState->ti.frame_width = (params->width + 15) & ~0xF; vState->ti.frame_height = (params->height + 15) & ~0xF; vState->ti.pic_width = params->width; vState->ti.pic_height = params->height; vState->ti.pic_x = (vState->ti.frame_width - params->width) >> 1 & ~1; vState->ti.pic_y = (vState->ti.frame_height - params->height) >> 1 & ~1; vState->ti.fps_numerator = params->fps_n; vState->ti.fps_denominator = params->fps_d; /* Are these the right values? */ keyframe = 64 - 1; for (i = 0; keyframe; i++) keyframe >>= 1; vState->ti.quality = (int)(params->qual * 100); vState->ti.colorspace = TH_CS_ITU_REC_470M; vState->ti.pixel_fmt = TH_PF_420; vState->ti.keyframe_granule_shift = i; vState->th = th_encode_alloc(&vState->ti); th_info_clear(&vState->ti); /* Header init */ th_comment_init(&vState->tc); th_comment_add_tag(&vState->tc, (char *)"ENCODER", (char *)"rainbow"); if (th_encode_flushheader( vState->th, &vState->tc, &vState->op) <= 0) { PR_LOG(log, PR_LOG_NOTICE, ("Internal Theora library error\n")); return NS_ERROR_FAILURE; } th_comment_clear(&vState->tc); ogg_stream_packetin(&vState->os, &vState->op); if (ogg_stream_pageout(&vState->os, &vState->og) != 1) { PR_LOG(log, PR_LOG_NOTICE, ("Internal Ogg library error\n")); return NS_ERROR_FAILURE; } rv = WriteData(vState->og.header, vState->og.header_len, &wr); rv = WriteData(vState->og.body, vState->og.body_len, &wr); return NS_OK; }
void theora_comment_add_tag(theora_comment *_tc, char *_tag, char *_value){ th_comment_add_tag((th_comment *)_tc,_tag,_value); }