From: <jpg...@us...> - 2008-04-15 22:17:42
|
Revision: 1405 http://iaxclient.svn.sourceforge.net/iaxclient/?rev=1405&view=rev Author: jpgrayson Date: 2008-04-15 15:17:47 -0700 (Tue, 15 Apr 2008) Log Message: ----------- Cleanup public versus static interfaces in file module. Other syntactic tidiness. Modified Paths: -------------- trunk/simpleclient/stresstest/file.c trunk/simpleclient/stresstest/file.h Modified: trunk/simpleclient/stresstest/file.c =================================================================== --- trunk/simpleclient/stresstest/file.c 2008-04-15 22:16:27 UTC (rev 1404) +++ trunk/simpleclient/stresstest/file.c 2008-04-15 22:17:47 UTC (rev 1405) @@ -3,16 +3,51 @@ #include <stdio.h> #include "file.h" +#include <oggz/oggz.h> +#include <theora/theora.h> + #ifdef __GNUC__ void mylog(const char * fmt, ...) __attribute__ ((format (printf, 1, 2))); #else void mylog(const char * fmt, ...); #endif +#define THEORA_FRAME_DURATION 1000 / 15 + +struct op_node +{ + ogg_packet *op; + long serialno; + long timestamp; + struct op_node *next; +}; + +struct theora_headers +{ + theora_info ti; + theora_comment tc; + theora_state ts; + int header_count; + int have_headers; +}; + +struct ogg_stream +{ + struct op_node *first; + struct op_node *last; + struct op_node *current; + long serialno; + long page_ts; + long page_count; + long base_ts; + void *data; +}; + static struct ogg_stream *audio_stream; static struct ogg_stream *video_stream; -struct op_node * create_node(ogg_packet *op, long serialno, long timestamp) +static struct op_node * +create_node(ogg_packet *op, long serialno, long timestamp) { struct op_node *node; @@ -27,7 +62,8 @@ return node; } -void append_node(struct ogg_stream *os, struct op_node *node) +static void +append_node(struct ogg_stream *os, struct op_node *node) { if ( os->first == NULL ) { @@ -65,15 +101,13 @@ * * To whoever came up with this convoluted scheme: please consider a change of careers. */ -int read_theora_cb(OGGZ *oggz, ogg_packet *op, long serialno, void *data) +static int +read_theora_cb(OGGZ *oggz, ogg_packet *op, long serialno, void *data) { struct op_node *node; struct theora_headers *th; long timestamp = 0; - //mylog("Got theora packet, serialno=%d, size=%d, packetno=%lld, granulepos=%lld\n", - // serialno, op->bytes, op->packetno, op->granulepos); - th = (struct theora_headers *)video_stream->data; if ( theora_packet_isheader(op) ) @@ -98,7 +132,8 @@ if ( timestamp < 0 ) { - timestamp = video_stream->page_ts + video_stream->page_count * THEORA_FRAME_DURATION; + timestamp = video_stream->page_ts + + video_stream->page_count * THEORA_FRAME_DURATION; video_stream->page_count++; } else { @@ -115,30 +150,29 @@ return 0; } -int read_speex_cb(OGGZ *oggz, ogg_packet *op, long serialno, void *data) +static int +read_speex_cb(OGGZ *oggz, ogg_packet *op, long serialno, void *data) { - struct op_node *node; - long timestamp; - static int cnt = 0; + static int cnt = 0; + const long timestamp = audio_stream->page_ts + + audio_stream->page_count * SPEEX_FRAME_DURATION; - timestamp = audio_stream->page_ts + audio_stream->page_count * SPEEX_FRAME_DURATION; audio_stream->page_count++; cnt++; - //mylog("Got speex packet, serialno=%ld, size=%ld, packetno=%lld, granulepos=%lld, timestamp=%ld\n", - // serialno, op->bytes, op->packetno, op->granulepos, timestamp); // Ignore the first two packets, they are headers if ( cnt > 2 ) { - node = create_node(op, serialno, timestamp); + struct op_node *node = create_node(op, serialno, timestamp); append_node(audio_stream, node); } return 0; } -int read_cb(OGGZ *oggz, ogg_packet *op, long serialno, void *data) +static int +read_cb(OGGZ *oggz, ogg_packet *op, long serialno, void *data) { struct theora_headers *th; @@ -147,12 +181,11 @@ if ( memcmp(op->packet, theoraId, strlen(theoraId)) == 0 ) { - //mylog("Detected a Theora stream with serialno=%d\n", serialno); oggz_set_read_callback(oggz, serialno, read_theora_cb, NULL); video_stream->serialno = serialno; // Initialize theora specific data fields - th = (struct theora_headers *)calloc(1, sizeof(struct theora_headers)); + th = calloc(1, sizeof(struct theora_headers)); theora_info_init(&(th->ti)); theora_comment_init(&(th->tc)); video_stream->data = th; @@ -160,48 +193,37 @@ read_theora_cb(oggz, op, serialno, data); } else if ( memcmp(op->packet, speexId, strlen(speexId)) == 0 ) { - //mylog("Detected a Speex stream with serialno=%d\n", serialno); oggz_set_read_callback(oggz, serialno, read_speex_cb, NULL); audio_stream->serialno = serialno; read_speex_cb(oggz, op, serialno, data); } else { - mylog("Got unknown ogg packet, serialno=%d, size=%d, packetno=%d, granulepos=%d\n", - serialno, op->bytes, op->packetno, op->granulepos); + mylog("Got unknown ogg packet, serialno=%d, size=%d, " + "packetno=%d, granulepos=%d\n", + serialno, op->bytes, + op->packetno, op->granulepos); } return 0; } -int read_page_cb(OGGZ *oggz, const ogg_page *og, long serialno, void *data) +static int +read_page_cb(OGGZ *oggz, const ogg_page *og, long serialno, void *data) { if ( serialno == audio_stream->serialno ) { - audio_stream->page_ts = ogg_page_granulepos(og) * 1000 / SPEEX_SAMPLING_RATE; + audio_stream->page_ts = ogg_page_granulepos(og) * 1000 / + SPEEX_SAMPLING_RATE; audio_stream->page_count = 0; - } else if ( serialno == video_stream->serialno ) + } + else if ( serialno == video_stream->serialno ) { - //mylog("Got theora page serialno=%d, header_len=%d, body_len=%d, granulepos=%lld\n", - // serialno, og->header_len, og->body_len, ogg_page_granulepos(og)); } return 0; } -void dump_stream(struct ogg_stream *os) +void +load_ogg_file(const char *filename) { - struct op_node *node; - - node = os->first; - while ( node != NULL ) - { - mylog("Size=%ld, Stream=%ld, packetno=%lld, timestamp=%ld\n", - node->op->bytes, node->serialno, - node->op->packetno, node->timestamp); - node = node->next; - } -} - -void load_ogg_file(const char *filename) -{ OGGZ *oggz; oggz = oggz_open(filename, OGGZ_READ | OGGZ_AUTO); @@ -220,15 +242,10 @@ oggz_run(oggz); - //mylog("Audio stream, serialno=%d\n", audio_stream->serialno); - //dump_stream(audio_stream); - //mylog("Video stream, serialno=%d\n", video_stream->serialno); - //dump_stream(video_stream); - oggz_close(oggz); } -ogg_packet * get_next_op(struct ogg_stream *os) +static ogg_packet * get_next_op(struct ogg_stream *os) { ogg_packet *op; struct timeval tv; Modified: trunk/simpleclient/stresstest/file.h =================================================================== --- trunk/simpleclient/stresstest/file.h 2008-04-15 22:16:27 UTC (rev 1404) +++ trunk/simpleclient/stresstest/file.h 2008-04-15 22:17:47 UTC (rev 1405) @@ -1,48 +1,11 @@ #ifndef __FILE_H__ #define __FILE_H__ -#include <oggz/oggz.h> -#include <theora/theora.h> +#include <ogg/ogg.h> #define SPEEX_FRAME_DURATION 20 #define SPEEX_SAMPLING_RATE 8000 -#define THEORA_FRAME_DURATION 1000 / 15 - -// Struct used to build chains of packets for delivery -struct op_node -{ - ogg_packet *op; - long serialno; - long timestamp; - struct op_node *next; -}; - -struct ogg_stream -{ - struct op_node *first; - struct op_node *last; - struct op_node *current; - long serialno; - long page_ts; - long page_count; - long base_ts; - void *data; -}; - -struct theora_headers -{ - theora_info ti; - theora_comment tc; - theora_state ts; - int header_count; - int have_headers; -}; - -int read_theora_cb(OGGZ *oggz, ogg_packet *op, long serialno, void *data); -int read_speex_cb(OGGZ *oggz, ogg_packet *op, long serialno, void *data); -int read_cb(OGGZ *oggz, ogg_packet *op, long serialno, void *data); -int read_page_cb(OGGZ *oggz, const ogg_page *og, long serialno, void *data); void load_ogg_file(const char *filename); ogg_packet * get_next_audio_op(); @@ -51,4 +14,4 @@ int audio_is_eos(); int video_is_eos(); -#endif // __FILE_H__ +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |