chaining_example.c 2.13 KB
Newer Older
Monty's avatar
 
Monty committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
/********************************************************************
 *                                                                  *
 * THIS FILE IS PART OF THE Ogg Vorbis SOFTWARE CODEC SOURCE CODE.  *
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS SOURCE IS GOVERNED BY *
 * THE GNU PUBLIC LICENSE 2, WHICH IS INCLUDED WITH THIS SOURCE.    *
 * PLEASE READ THESE TERMS DISTRIBUTING.                            *
 *                                                                  *
 * THE OggSQUISH SOURCE CODE IS (C) COPYRIGHT 1994-1999             *
 * by 1999 Monty <monty@xiph.org> and The XIPHOPHORUS Company       *
 * http://www.xiph.org/                                             *
 *                                                                  *
 ********************************************************************

 function: illustrate simple use of chained bitstream and vorbisfile.a
 author: Monty <xiphmont@mit.edu>
 modifications by: Monty
 last modification date: Nov 02 1999

 ********************************************************************/

#include "codec.h"
#include "vorbisfile.h"

int main(){
  OggVorbis_File ov;
  int i;

  /* open the file/pipe on stdin */
  if(ov_open(stdin,&ov,NULL,-1)==-1){
    printf("Could not open input as an OggVorbis file.\n\n");
    exit(1);
  }
  
  /* print details about each logical bitstream in the input */
Monty's avatar
 
Monty committed
35
  if(ov_seekable(&ov)){
Monty's avatar
 
Monty committed
36
    printf("Input bitstream contained %d logical bitstream section(s).\n",
Monty's avatar
 
Monty committed
37
	   ov_streams(&ov));
Monty's avatar
 
Monty committed
38
    printf("Total bitstream playing time: %ld seconds\n\n",
Monty's avatar
 
Monty committed
39
	   (long)ov_time_total(&ov,-1));
Monty's avatar
 
Monty committed
40 41 42 43 44 45

  }else{
    printf("Standard input was not seekable.\n"
	   "First logical bitstream information:\n\n");
  }

Monty's avatar
 
Monty committed
46 47
  for(i=0;i<ov_streams(&ov);i++){
    vorbis_info *vi=ov_info(&ov,i);
Monty's avatar
 
Monty committed
48
    printf("\tlogical bitstream section %d information:\n",i+1);
Monty's avatar
 
Monty committed
49 50 51
    printf("\t\t%ldHz %d channels bitrate %dkbps serial number=%ld\n",
	   vi->rate,vi->channels,ov_bitrate(&ov,i)/1000,
	   ov_serialnumber(&ov,i));
Monty's avatar
 
Monty committed
52
    printf("\t\tcompressed length: %ld bytes ",ov_raw_total(&ov,i));
Monty's avatar
 
Monty committed
53
    printf(" play time: %lds\n",(long)ov_time_total(&ov,i));
Monty's avatar
 
Monty committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
  }
  
  ov_clear(&ov);
  return 0;
}