You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.4KB

  1. #include "mov-internal.h"
  2. #include <string.h>
  3. #include <assert.h>
  4. // 8.4.3 Handler Reference Box (p36)
  5. // Box Type: 'hdlr'
  6. // Container: Media Box ('mdia') or Meta Box ('meta')
  7. // Mandatory: Yes
  8. // Quantity: Exactly one
  9. int mov_read_hdlr(struct mov_t* mov, const struct mov_box_t* box)
  10. {
  11. struct mov_track_t* track = mov->track;
  12. mov_buffer_r8(&mov->io); /* version */
  13. mov_buffer_r24(&mov->io); /* flags */
  14. //uint32_t pre_defined = mov_buffer_r32(&mov->io);
  15. mov_buffer_skip(&mov->io, 4);
  16. track->handler_type = mov_buffer_r32(&mov->io);
  17. // const unsigned int(32)[3] reserved = 0;
  18. mov_buffer_skip(&mov->io, 12);
  19. // string name;
  20. mov_buffer_skip(&mov->io, box->size - 24); // String name
  21. return 0;
  22. }
  23. size_t mov_write_hdlr(const struct mov_t* mov)
  24. {
  25. const struct mov_track_t* track = mov->track;
  26. mov_buffer_w32(&mov->io, 33 + (uint32_t)strlen(track->handler_descr)); /* size */
  27. mov_buffer_write(&mov->io, "hdlr", 4);
  28. mov_buffer_w32(&mov->io, 0); /* Version & flags */
  29. mov_buffer_w32(&mov->io, 0); /* pre_defined */
  30. mov_buffer_w32(&mov->io, track->handler_type); /* handler_type */
  31. mov_buffer_w32(&mov->io, 0); /* reserved */
  32. mov_buffer_w32(&mov->io, 0); /* reserved */
  33. mov_buffer_w32(&mov->io, 0); /* reserved */
  34. mov_buffer_write(&mov->io, track->handler_descr, (uint64_t)strlen(track->handler_descr)+1); /* name */
  35. return 33 + strlen(track->handler_descr);
  36. }