Update header copyright dates, update copyright assignemnt
[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 SOURCE IS GOVERNED BY *
5  * THE GNU LESSER/LIBRARY PUBLIC LICENSE, WHICH IS INCLUDED WITH    *
6  * THIS SOURCE. 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.8 2001/02/02 03:51:53 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\tcompressed length: %ld bytes ",(long)(ov_raw_total(&ov,i)));
50     printf(" play time: %lds\n",(long)ov_time_total(&ov,i));
51   }
52
53   ov_clear(&ov);
54   return 0;
55 }
56
57
58
59
60
61
62
63
64
65
66
67
68