iods.c
上传用户:sun1608
上传日期:2007-02-02
资源大小:6116k
文件大小:3k
源码类别:

流媒体/Mpeg4/MP4

开发平台:

Visual C++

  1. /*
  2.  * The contents of this file are subject to the Mozilla Public
  3.  * License Version 1.1 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy of
  5.  * the License at http://www.mozilla.org/MPL/
  6.  * 
  7.  * Software distributed under the License is distributed on an "AS
  8.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9.  * implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  * 
  12.  * The Original Code is MPEG4IP.
  13.  * 
  14.  * The Initial Developer of the Original Code is Cisco Systems Inc.
  15.  * Portions created by Cisco Systems Inc. are
  16.  * Copyright (C) Cisco Systems Inc. 2000, 2001.  All Rights Reserved.
  17.  * 
  18.  * Contributor(s): 
  19.  * Dave Mackie dmackie@cisco.com
  20.  */
  21. #include "quicktime.h"
  22. int quicktime_iods_init(quicktime_iods_t *iods)
  23. {
  24. iods->version = 0;
  25. iods->flags = 0;
  26. iods->audioProfileId = 0xFF;
  27. iods->videoProfileId = 0xFF;
  28. return 0;
  29. }
  30. int quicktime_iods_set_audio_profile(quicktime_iods_t* iods, int id)
  31. {
  32. iods->audioProfileId = id;
  33. }
  34. int quicktime_iods_set_video_profile(quicktime_iods_t* iods, int id)
  35. {
  36. iods->videoProfileId = id;
  37. }
  38. int quicktime_iods_delete(quicktime_iods_t *iods)
  39. {
  40. return 0;
  41. }
  42. int quicktime_iods_dump(quicktime_iods_t *iods)
  43. {
  44. printf(" initial object descriptorn");
  45. printf("  version %dn", iods->version);
  46. printf("  flags %ldn", iods->flags);
  47. printf("  audioProfileId %un", iods->audioProfileId);
  48. printf("  videoProfileId %un", iods->videoProfileId);
  49. }
  50. int quicktime_read_iods(quicktime_t *file, quicktime_iods_t *iods)
  51. {
  52. iods->version = quicktime_read_char(file);
  53. iods->flags = quicktime_read_int24(file);
  54. quicktime_read_char(file); /* skip tag */
  55. quicktime_read_mp4_descr_length(file); /* skip length */
  56. /* skip ODID, ODProfile, sceneProfile */
  57. quicktime_set_position(file, quicktime_position(file) + 4);
  58. iods->audioProfileId = quicktime_read_char(file);
  59. iods->videoProfileId = quicktime_read_char(file);
  60. /* will skip the remainder of the atom */
  61. }
  62. int quicktime_write_iods(quicktime_t *file, quicktime_iods_t *iods)
  63. {
  64. quicktime_atom_t atom;
  65. int i;
  66. if (!file->use_mp4) {
  67. return 0;
  68. }
  69. quicktime_atom_write_header(file, &atom, "iods");
  70. quicktime_write_char(file, iods->version);
  71. quicktime_write_int24(file, iods->flags);
  72. quicktime_write_char(file, 0x10); /* MP4_IOD_Tag */
  73. quicktime_write_char(file, 7 + (file->moov.total_tracks * (1+1+4))); /* length */
  74. quicktime_write_int16(file, 0x004F); /* ObjectDescriptorID = 1 */
  75. quicktime_write_char(file, 0xFF); /* ODProfileLevel */
  76. quicktime_write_char(file, 0xFF); /* sceneProfileLevel */
  77. quicktime_write_char(file, iods->audioProfileId); /* audioProfileLevel */
  78. quicktime_write_char(file, iods->videoProfileId); /* videoProfileLevel */
  79. quicktime_write_char(file, 0xFF); /* graphicsProfileLevel */
  80. for (i = 0; i < file->moov.total_tracks; i++) {
  81. quicktime_write_char(file, 0x0E); /* ES_ID_IncTag */
  82. quicktime_write_char(file, 0x04); /* length */
  83. quicktime_write_int32(file, file->moov.trak[i]->tkhd.track_id);
  84. }
  85. /* no OCI_Descriptors */
  86. /* no IPMP_DescriptorPointers */
  87. /* no Extenstion_Descriptors */
  88. quicktime_atom_write_footer(file, &atom);
  89. }