annotate src/libvorbis-1.3.3/examples/chaining_example.c @ 168:ceec0dd9ec9c

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 07 Feb 2020 11:51:13 +0000
parents 98c1576536ae
children
rev   line source
cannam@86 1 /********************************************************************
cannam@86 2 * *
cannam@86 3 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
cannam@86 4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
cannam@86 5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
cannam@86 6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
cannam@86 7 * *
cannam@86 8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
cannam@86 9 * by the Xiph.Org Foundation http://www.xiph.org/ *
cannam@86 10 * *
cannam@86 11 ********************************************************************
cannam@86 12
cannam@86 13 function: illustrate simple use of chained bitstream and vorbisfile.a
cannam@86 14 last mod: $Id: chaining_example.c 16243 2009-07-10 02:49:31Z xiphmont $
cannam@86 15
cannam@86 16 ********************************************************************/
cannam@86 17
cannam@86 18 #include <stdlib.h>
cannam@86 19 #include <vorbis/codec.h>
cannam@86 20 #include <vorbis/vorbisfile.h>
cannam@86 21
cannam@86 22 #ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */
cannam@86 23 #include <io.h>
cannam@86 24 #include <fcntl.h>
cannam@86 25 #endif
cannam@86 26
cannam@86 27 int main(){
cannam@86 28 OggVorbis_File ov;
cannam@86 29 int i;
cannam@86 30
cannam@86 31 #ifdef _WIN32 /* We need to set stdin to binary mode. Damn windows. */
cannam@86 32 /* Beware the evil ifdef. We avoid these where we can, but this one we
cannam@86 33 cannot. Don't add any more, you'll probably go to hell if you do. */
cannam@86 34 _setmode( _fileno( stdin ), _O_BINARY );
cannam@86 35 #endif
cannam@86 36
cannam@86 37 /* open the file/pipe on stdin */
cannam@86 38 if(ov_open_callbacks(stdin,&ov,NULL,-1,OV_CALLBACKS_NOCLOSE)<0){
cannam@86 39 printf("Could not open input as an OggVorbis file.\n\n");
cannam@86 40 exit(1);
cannam@86 41 }
cannam@86 42
cannam@86 43 /* print details about each logical bitstream in the input */
cannam@86 44 if(ov_seekable(&ov)){
cannam@86 45 printf("Input bitstream contained %ld logical bitstream section(s).\n",
cannam@86 46 ov_streams(&ov));
cannam@86 47 printf("Total bitstream samples: %ld\n\n",
cannam@86 48 (long)ov_pcm_total(&ov,-1));
cannam@86 49 printf("Total bitstream playing time: %ld seconds\n\n",
cannam@86 50 (long)ov_time_total(&ov,-1));
cannam@86 51
cannam@86 52 }else{
cannam@86 53 printf("Standard input was not seekable.\n"
cannam@86 54 "First logical bitstream information:\n\n");
cannam@86 55 }
cannam@86 56
cannam@86 57 for(i=0;i<ov_streams(&ov);i++){
cannam@86 58 vorbis_info *vi=ov_info(&ov,i);
cannam@86 59 printf("\tlogical bitstream section %d information:\n",i+1);
cannam@86 60 printf("\t\t%ldHz %d channels bitrate %ldkbps serial number=%ld\n",
cannam@86 61 vi->rate,vi->channels,ov_bitrate(&ov,i)/1000,
cannam@86 62 ov_serialnumber(&ov,i));
cannam@86 63 printf("\t\theader length: %ld bytes\n",(long)
cannam@86 64 (ov.dataoffsets[i]-ov.offsets[i]));
cannam@86 65 printf("\t\tcompressed length: %ld bytes\n",(long)(ov_raw_total(&ov,i)));
cannam@86 66 printf("\t\tplay time: %lds\n",(long)ov_time_total(&ov,i));
cannam@86 67 }
cannam@86 68
cannam@86 69 ov_clear(&ov);
cannam@86 70 return 0;
cannam@86 71 }
cannam@86 72