Bringing rc2 (minus the modes it needs) onto mainline.
[platform/upstream/libvorbis.git] / examples / chaining_example.c
1 /********************************************************************
2  *                                                                  *
3  * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
4  * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
5  * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6  * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
7  *                                                                  *
8  * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001             *
9  * by the XIPHOPHORUS Company http://www.xiph.org/                  *
10
11  ********************************************************************
12
13  function: illustrate simple use of chained bitstream and vorbisfile.a
14  last mod: $Id: chaining_example.c,v 1.10 2001/08/13 01:36:55 xiphmont Exp $
15
16  ********************************************************************/
17
18 #include <vorbis/codec.h>
19 #include <vorbis/vorbisfile.h>
20
21 int main(){
22   OggVorbis_File ov;
23   int i;
24
25   /* open the file/pipe on stdin */
26   if(ov_open(stdin,&ov,NULL,-1)<0){
27     printf("Could not open input as an OggVorbis file.\n\n");
28     exit(1);
29   }
30   
31   /* print details about each logical bitstream in the input */
32   if(ov_seekable(&ov)){
33     printf("Input bitstream contained %ld logical bitstream section(s).\n",
34            ov_streams(&ov));
35     printf("Total bitstream playing time: %ld seconds\n\n",
36            (long)ov_time_total(&ov,-1));
37
38   }else{
39     printf("Standard input was not seekable.\n"
40            "First logical bitstream information:\n\n");
41   }
42
43   for(i=0;i<ov_streams(&ov);i++){
44     vorbis_info *vi=ov_info(&ov,i);
45     printf("\tlogical bitstream section %d information:\n",i+1);
46     printf("\t\t%ldHz %d channels bitrate %ldkbps serial number=%ld\n",
47            vi->rate,vi->channels,ov_bitrate(&ov,i)/1000,
48            ov_serialnumber(&ov,i));
49     printf("\t\theader length: %ld bytes\n",(long)
50            (ov.dataoffsets[i]-ov.offsets[i]));
51     printf("\t\tcompressed length: %ld bytes ",(long)(ov_raw_total(&ov,i)));
52     printf(" play time: %lds\n",(long)ov_time_total(&ov,i));
53   }
54
55   ov_clear(&ov);
56   return 0;
57 }
58
59
60
61
62
63
64
65
66
67
68
69
70