examples/SFExamples/oggvorbiscodec/src/libvorbis/examples/chaining_example.c

00001 /********************************************************************
00002  *                                                                  *
00003  * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
00004  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
00005  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
00006  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
00007  *                                                                  *
00008  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002             *
00009  * by the XIPHOPHORUS Company http://www.xiph.org/                  *
00010  *                                                                  *
00011  ********************************************************************
00012 
00013  function: illustrate simple use of chained bitstream and vorbisfile.a
00014  last mod: $Id: chaining_example.c 7187 2004-07-20 07:24:27Z xiphmont $
00015 
00016  ********************************************************************/
00017 
00018 #include <stdlib.h>
00019 #include <vorbis/codec.h>
00020 #include <vorbis/vorbisfile.h>
00021 
00022 #if defined(_WIN32) && !defined(__SYMBIAN32__) /* We need the following two to set stdin/stdout to binary */
00023 #include <io.h>
00024 #include <fcntl.h>
00025 #endif
00026 
00027 int main(){
00028   OggVorbis_File ov;
00029   int i;
00030 
00031 #if defined(_WIN32) && !defined(__SYMBIAN32__) /* We need to set stdin/stdout to binary mode. Damn windows. */
00032   /* Beware the evil ifdef. We avoid these where we can, but this one we 
00033      cannot. Don't add any more, you'll probably go to hell if you do. */
00034   _setmode( _fileno( stdin ), _O_BINARY );
00035   _setmode( _fileno( stdout ), _O_BINARY );
00036 #endif
00037 
00038   /* open the file/pipe on stdin */
00039   if(ov_open(stdin,&ov,NULL,-1)<0){
00040     printf("Could not open input as an OggVorbis file.\n\n");
00041     exit(1);
00042   }
00043   
00044   /* print details about each logical bitstream in the input */
00045   if(ov_seekable(&ov)){
00046     printf("Input bitstream contained %ld logical bitstream section(s).\n",
00047            ov_streams(&ov));
00048     printf("Total bitstream samples: %ld\n\n",
00049            (long)ov_pcm_total(&ov,-1));
00050     printf("Total bitstream playing time: %ld seconds\n\n",
00051            (long)ov_time_total(&ov,-1));
00052 
00053   }else{
00054     printf("Standard input was not seekable.\n"
00055            "First logical bitstream information:\n\n");
00056   }
00057 
00058   for(i=0;i<ov_streams(&ov);i++){
00059     vorbis_info *vi=ov_info(&ov,i);
00060     printf("\tlogical bitstream section %d information:\n",i+1);
00061     printf("\t\t%ldHz %d channels bitrate %ldkbps serial number=%ld\n",
00062            vi->rate,vi->channels,ov_bitrate(&ov,i)/1000,
00063            ov_serialnumber(&ov,i));
00064     printf("\t\theader length: %ld bytes\n",(long)
00065            (ov.dataoffsets[i]-ov.offsets[i]));
00066     printf("\t\tcompressed length: %ld bytes\n",(long)(ov_raw_total(&ov,i)));
00067     printf("\t\tplay time: %lds\n",(long)ov_time_total(&ov,i));
00068   }
00069 
00070   ov_clear(&ov);
00071   return 0;
00072 }
00073 

Generated by  doxygen 1.6.2