Incremental commit after rearranging build a bit and moving files into
[platform/upstream/libvorbis.git] / examples / chaining_example.c
1 /********************************************************************
2  *                                                                  *
3  * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE.  *
4  * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
5  * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE.    *
6  * PLEASE READ THESE TERMS DISTRIBUTING.                            *
7  *                                                                  *
8  * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-1999             *
9  * by 1999 Monty <monty@xiph.org> and The XIPHOPHORUS Company       *
10  * http://www.xiph.org/                                             *
11  *                                                                  *
12  ********************************************************************
13
14  function: illustrate simple use of chained bitstream and vorbisfile.a
15  author: Monty <xiphmont@mit.edu>
16  modifications by: Monty
17  last modification date: Nov 02 1999
18
19  ********************************************************************/
20
21 #include "codec.h"
22 #include "vorbisfile.h"
23
24 int main(){
25   OggVorbis_File ov;
26   int i;
27
28   /* open the file/pipe on stdin */
29   if(ov_open(stdin,&ov,NULL,-1)==-1){
30     printf("Could not open input as an OggVorbis file.\n\n");
31     exit(1);
32   }
33   
34   /* print details about each logical bitstream in the input */
35   if(ov_seekable(&ov)){
36     printf("Input bitstream contained %ld logical bitstream section(s).\n",
37            ov_streams(&ov));
38     printf("Total bitstream playing time: %ld seconds\n\n",
39            (long)ov_time_total(&ov,-1));
40
41   }else{
42     printf("Standard input was not seekable.\n"
43            "First logical bitstream information:\n\n");
44   }
45
46   for(i=0;i<ov_streams(&ov);i++){
47     vorbis_info *vi=ov_info(&ov,i);
48     printf("\tlogical bitstream section %d information:\n",i+1);
49     printf("\t\t%ldHz %d channels bitrate %ldkbps serial number=%ld\n",
50            vi->rate,vi->channels,ov_bitrate(&ov,i)/1000,
51            ov_serialnumber(&ov,i));
52     printf("\t\tcompressed length: %ld bytes ",ov_raw_total(&ov,i));
53     printf(" play time: %lds\n",(long)ov_time_total(&ov,i));
54   }
55
56   ov_clear(&ov);
57   return 0;
58 }
59
60
61
62
63
64
65
66
67
68
69
70
71