mdia.c
上传用户:luping1608
上传日期:2007-01-06
资源大小:38k
文件大小:2k
源码类别:

多媒体

开发平台:

Unix_Linux

  1. #include "quicktime.h"
  2. int quicktime_mdia_init(quicktime_mdia_t *mdia)
  3. {
  4. quicktime_mdhd_init(&(mdia->mdhd));
  5. quicktime_hdlr_init(&(mdia->hdlr));
  6. quicktime_minf_init(&(mdia->minf));
  7. }
  8. int quicktime_mdia_init_video(quicktime_t *file, 
  9. quicktime_mdia_t *mdia,
  10. int frame_w,
  11. int frame_h, 
  12. float frame_rate,
  13. char *compressor)
  14. {
  15. quicktime_mdhd_init_video(file, &(mdia->mdhd), frame_w, frame_h, frame_rate);
  16. quicktime_minf_init_video(file, &(mdia->minf), frame_w, frame_h, frame_rate, compressor);
  17. quicktime_hdlr_init_video(&(mdia->hdlr));
  18. }
  19. int quicktime_mdia_init_audio(quicktime_t *file, 
  20. quicktime_mdia_t *mdia, 
  21. int channels,
  22. int sample_rate, 
  23. int bits, 
  24. char *compressor)
  25. {
  26. quicktime_mdhd_init_audio(file, &(mdia->mdhd), channels, sample_rate, bits, compressor);
  27. quicktime_minf_init_audio(file, &(mdia->minf), channels, sample_rate, bits, compressor);
  28. quicktime_hdlr_init_audio(&(mdia->hdlr));
  29. }
  30. int quicktime_mdia_delete(quicktime_mdia_t *mdia)
  31. {
  32. quicktime_mdhd_delete(&(mdia->mdhd));
  33. quicktime_hdlr_delete(&(mdia->hdlr));
  34. quicktime_minf_delete(&(mdia->minf));
  35. }
  36. int quicktime_mdia_dump(quicktime_mdia_t *mdia)
  37. {
  38. printf("  median");
  39. quicktime_mdhd_dump(&(mdia->mdhd));
  40. quicktime_hdlr_dump(&(mdia->hdlr));
  41. quicktime_minf_dump(&(mdia->minf));
  42. }
  43. int quicktime_read_mdia(quicktime_t *file, quicktime_mdia_t *mdia, quicktime_atom_t *trak_atom)
  44. {
  45. quicktime_atom_t leaf_atom;
  46. do
  47. {
  48. quicktime_atom_read_header(file->stream, &leaf_atom);
  49. // mandatory
  50. if(quicktime_atom_is(&leaf_atom, "mdhd"))
  51. { quicktime_read_mdhd(file, &(mdia->mdhd)); }
  52. else
  53. if(quicktime_atom_is(&leaf_atom, "hdlr"))
  54. { quicktime_read_hdlr(file, &(mdia->hdlr)); }
  55. else
  56. if(quicktime_atom_is(&leaf_atom, "minf"))
  57. { quicktime_read_minf(file, &(mdia->minf), &leaf_atom); }
  58. else
  59. quicktime_atom_skip(file, &leaf_atom);
  60. }while(quicktime_position(file) < trak_atom->end);
  61. return 0;
  62. }
  63. int quicktime_write_mdia(quicktime_t *file, quicktime_mdia_t *mdia)
  64. {
  65. quicktime_atom_t atom;
  66. quicktime_atom_write_header(file, &atom, "mdia");
  67. quicktime_write_mdhd(file, &(mdia->mdhd));
  68. quicktime_write_hdlr(file, &(mdia->hdlr));
  69. quicktime_write_minf(file, &(mdia->minf));
  70. quicktime_atom_write_footer(file, &atom);
  71. }