chaining_example.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. function: illustrate simple use of chained bitstream and vorbisfile.a
  14. last mod: $Id: chaining_example.c,v 1.5.8.1 2000/09/03 08:34:51 jack Exp $
  15. ********************************************************************/
  16. #include <vorbis/codec.h>
  17. #include <vorbis/vorbisfile.h>
  18. int main(){
  19. OggVorbis_File ov;
  20. int i;
  21. /* open the file/pipe on stdin */
  22. if(ov_open(stdin,&ov,NULL,-1)==-1){
  23. printf("Could not open input as an OggVorbis file.\n\n");
  24. exit(1);
  25. }
  26. /* print details about each logical bitstream in the input */
  27. if(ov_seekable(&ov)){
  28. printf("Input bitstream contained %ld logical bitstream section(s).\n",
  29. ov_streams(&ov));
  30. printf("Total bitstream playing time: %ld seconds\n\n",
  31. (long)ov_time_total(&ov,-1));
  32. }else{
  33. printf("Standard input was not seekable.\n"
  34. "First logical bitstream information:\n\n");
  35. }
  36. for(i=0;i<ov_streams(&ov);i++){
  37. vorbis_info *vi=ov_info(&ov,i);
  38. printf("\tlogical bitstream section %d information:\n",i+1);
  39. printf("\t\t%ldHz %d channels bitrate %ldkbps serial number=%ld\n",
  40. vi->rate,vi->channels,ov_bitrate(&ov,i)/1000,
  41. ov_serialnumber(&ov,i));
  42. printf("\t\tcompressed length: %ld bytes ",(long)(ov_raw_total(&ov,i)));
  43. printf(" play time: %lds\n",(long)ov_time_total(&ov,i));
  44. }
  45. ov_clear(&ov);
  46. return 0;
  47. }