context->header_written = 1 ;
context->header_handled = 1 ;
static int ogg_write_packet(AVFormatContext *avfcontext,			    int stream_index,			    unsigned char *buf, int size, int force_pts){    OggContext *context = avfcontext->priv_data ;    ogg_packet *op ;    ogg_page og ;    int l = 0 ;        /* flush header packets so audio starts on a new page */    if(!context->header_written) {	while(ogg_stream_flush(&context->os, &og)) {	    put_buffer(&avfcontext->pb, og.header, og.header_len) ;	    put_buffer(&avfcontext->pb, og.body, og.body_len) ;	    put_flush_packet(&avfcontext->pb);	}	context->header_written = 1 ;    }    while(l < size) {	op = (ogg_packet*)(buf + l) ;	op->packet = buf + l + sizeof(ogg_packet) ; /* fix data pointer */	if(!context->base_packet_no) { /* this is the first packet */	    context->base_packet_no = op->packetno ; 	    context->base_granule_pos = op->granulepos ;	}	/* correct the fields in the packet -- essential for streaming */	op->packetno -= context->base_packet_no ;	op->granulepos -= context->base_granule_pos ;	ogg_stream_packetin(&context->os, op) ;	l += sizeof(ogg_packet) + op->bytes ;	while(ogg_stream_pageout(&context->os, &og)) {	    put_buffer(&avfcontext->pb, og.header, og.header_len) ;	    put_buffer(&avfcontext->pb, og.body, og.body_len) ;	    put_flush_packet(&avfcontext->pb);	}    }    return 0;}