annotate src/libvorbis-1.3.3/examples/chaining_example.c @ 83:ae30d91d2ffe

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