Merging the postbeta2 branch onto the mainline.
[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-2000             *
9  * by 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  last mod: $Id: chaining_example.c,v 1.6 2000/10/12 03:12:39 xiphmont Exp $
16
17  ********************************************************************/
18
19 #include <vorbis/codec.h>
20 #include <vorbis/vorbisfile.h>
21
22 int main(){
23   OggVorbis_File ov;
24   int i;
25
26   /* open the file/pipe on stdin */
27   if(ov_open(stdin,&ov,NULL,-1)==-1){
28     printf("Could not open input as an OggVorbis file.\n\n");
29     exit(1);
30   }
31   
32   /* print details about each logical bitstream in the input */
33   if(ov_seekable(&ov)){
34     printf("Input bitstream contained %ld logical bitstream section(s).\n",
35            ov_streams(&ov));
36     printf("Total bitstream playing time: %ld seconds\n\n",
37            (long)ov_time_total(&ov,-1));
38
39   }else{
40     printf("Standard input was not seekable.\n"
41            "First logical bitstream information:\n\n");
42   }
43
44   for(i=0;i<ov_streams(&ov);i++){
45     vorbis_info *vi=ov_info(&ov,i);
46     printf("\tlogical bitstream section %d information:\n",i+1);
47     printf("\t\t%ldHz %d channels bitrate %ldkbps serial number=%ld\n",
48            vi->rate,vi->channels,ov_bitrate(&ov,i)/1000,
49            ov_serialnumber(&ov,i));
50     printf("\t\tcompressed length: %ld bytes ",(long)(ov_raw_total(&ov,i)));
51     printf(" play time: %lds\n",(long)ov_time_total(&ov,i));
52   }
53
54   ov_clear(&ov);
55   return 0;
56 }
57
58
59
60
61
62
63
64
65
66
67
68
69