Chris@1: /******************************************************************** Chris@1: * * Chris@1: * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * Chris@1: * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * Chris@1: * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * Chris@1: * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * Chris@1: * * Chris@1: * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * Chris@1: * by the Xiph.Org Foundation http://www.xiph.org/ * Chris@1: * * Chris@1: ******************************************************************** Chris@1: Chris@1: function: illustrate simple use of chained bitstream and vorbisfile.a Chris@1: last mod: $Id: chaining_example.c 16243 2009-07-10 02:49:31Z xiphmont $ Chris@1: Chris@1: ********************************************************************/ Chris@1: Chris@1: #include Chris@1: #include Chris@1: #include Chris@1: Chris@1: #ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */ Chris@1: #include Chris@1: #include Chris@1: #endif Chris@1: Chris@1: int main(){ Chris@1: OggVorbis_File ov; Chris@1: int i; Chris@1: Chris@1: #ifdef _WIN32 /* We need to set stdin to binary mode. Damn windows. */ Chris@1: /* Beware the evil ifdef. We avoid these where we can, but this one we Chris@1: cannot. Don't add any more, you'll probably go to hell if you do. */ Chris@1: _setmode( _fileno( stdin ), _O_BINARY ); Chris@1: #endif Chris@1: Chris@1: /* open the file/pipe on stdin */ Chris@1: if(ov_open_callbacks(stdin,&ov,NULL,-1,OV_CALLBACKS_NOCLOSE)<0){ Chris@1: printf("Could not open input as an OggVorbis file.\n\n"); Chris@1: exit(1); Chris@1: } Chris@1: Chris@1: /* print details about each logical bitstream in the input */ Chris@1: if(ov_seekable(&ov)){ Chris@1: printf("Input bitstream contained %ld logical bitstream section(s).\n", Chris@1: ov_streams(&ov)); Chris@1: printf("Total bitstream samples: %ld\n\n", Chris@1: (long)ov_pcm_total(&ov,-1)); Chris@1: printf("Total bitstream playing time: %ld seconds\n\n", Chris@1: (long)ov_time_total(&ov,-1)); Chris@1: Chris@1: }else{ Chris@1: printf("Standard input was not seekable.\n" Chris@1: "First logical bitstream information:\n\n"); Chris@1: } Chris@1: Chris@1: for(i=0;irate,vi->channels,ov_bitrate(&ov,i)/1000, Chris@1: ov_serialnumber(&ov,i)); Chris@1: printf("\t\theader length: %ld bytes\n",(long) Chris@1: (ov.dataoffsets[i]-ov.offsets[i])); Chris@1: printf("\t\tcompressed length: %ld bytes\n",(long)(ov_raw_total(&ov,i))); Chris@1: printf("\t\tplay time: %lds\n",(long)ov_time_total(&ov,i)); Chris@1: } Chris@1: Chris@1: ov_clear(&ov); Chris@1: return 0; Chris@1: } Chris@1: