chaining_example.c 2.1 KB

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