mp4parse.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // This Source Code Form is subject to the terms of the Mozilla Public
  2. // License, v. 2.0. If a copy of the MPL was not distributed with this
  3. // file, You can obtain one at https://mozilla.org/MPL/2.0/.
  4. #ifndef _MP4PARSE_RUST_H
  5. #define _MP4PARSE_RUST_H
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. struct mp4parse_state;
  10. #define MP4PARSE_OK 0
  11. #define MP4PARSE_ERROR_BADARG 1 // Argument validation failure
  12. #define MP4PARSE_ERROR_INVALID 2 // Error::InvalidData
  13. #define MP4PARSE_ERROR_UNSUPPORTED 3 // Error::Unsupported
  14. #define MP4PARSE_ERROR_EOF 4 // Error::UnexpectedEOF
  15. #define MP4PARSE_ASSERT 5 // Error::AssertCaught
  16. #define MP4PARSE_ERROR_IO 6 // Error::Io(_)
  17. #define MP4PARSE_TRACK_TYPE_H264 0 // "video/avc"
  18. #define MP4PARSE_TRACK_TYPE_AAC 1 // "audio/mp4a-latm"
  19. struct mp4parse_track_audio_info {
  20. uint16_t channels;
  21. uint16_t bit_depth;
  22. uint32_t sample_rate;
  23. };
  24. struct mp4parse_track_video_info {
  25. uint32_t display_width;
  26. uint32_t display_height;
  27. uint16_t image_width;
  28. uint16_t image_height;
  29. };
  30. struct mp4parse_track_info {
  31. uint32_t track_type;
  32. uint32_t track_id;
  33. uint64_t duration;
  34. int64_t media_time;
  35. };
  36. struct mp4parse_state* mp4parse_new(void);
  37. void mp4parse_free(struct mp4parse_state* state);
  38. int32_t mp4parse_read(struct mp4parse_state* state, uint8_t *buffer, size_t size);
  39. uint32_t mp4parse_get_track_count(struct mp4parse_state* state);
  40. int32_t mp4parse_get_track_info(struct mp4parse_state* state, uint32_t track, struct mp4parse_track_info* track_info);
  41. int32_t mp4parse_get_track_audio_info(struct mp4parse_state* state, uint32_t track, struct mp4parse_track_audio_info* track_info);
  42. int32_t mp4parse_get_track_video_info(struct mp4parse_state* state, uint32_t track, struct mp4parse_track_video_info* track_info);
  43. #ifdef __cplusplus
  44. }
  45. #endif
  46. #endif