ifc_mp4file.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #pragma once
  2. #include "foundation/dispatch.h"
  3. static const uint32_t mp4file_invalid_track_id=0;
  4. class ifc_mp4file : public Wasabi2::Dispatchable
  5. {
  6. protected:
  7. ifc_mp4file() : Dispatchable(DISPATCHABLE_VERSION) {}
  8. ~ifc_mp4file() {}
  9. public:
  10. typedef uint32_t TrackID;
  11. typedef uint32_t SampleID;
  12. typedef uint64_t Timestamp;
  13. typedef uint64_t Duration;
  14. typedef struct metadata_itunes_atom_s {} *metadata_itunes_atom_t;
  15. int Free(void *buffer) { return MP4File_Free(buffer); }
  16. int Track_GetESConfiguration(TrackID track_number, uint8_t **buffer, uint32_t *buffer_size) { return MP4File_Track_GetESConfiguration(track_number, buffer, buffer_size); }
  17. int Track_GetMaxSampleSize(TrackID track_number, uint32_t *max_sample_size) { return MP4File_Track_GetMaxSampleSize(track_number, max_sample_size); }
  18. int Track_ConvertFromTimestamp(TrackID track_number, Timestamp timestamp, double *seconds) { return MP4File_Track_ConvertFromTimestamp(track_number, timestamp, seconds); }
  19. int Track_ConvertToDuration(TrackID track_number, double seconds, Duration *duration) { return MP4File_Track_ConvertToDuration(track_number, seconds, duration); }
  20. int Track_GetMediaDataName(TrackID track_number, const char **name) { return MP4File_Track_GetMediaDataName(track_number, name); }
  21. int Track_GetESDSObjectTypeID(TrackID track_number, uint8_t *type) { return MP4File_Track_GetESDSObjectTypeID(track_number, type); }
  22. int Track_GetAudioMPEG4Type(TrackID track_number, uint8_t *type) { return MP4File_Track_GetAudioMPEG4Type(track_number, type); }
  23. int Track_GetBytesProperty(TrackID track_number, const char *property_name, uint8_t **buffer, uint32_t *buffer_size) { return MP4File_Track_GetBytesProperty(track_number, property_name, buffer, buffer_size); }
  24. int Metadata_iTunes_FindFreeform(const char *name, const char *mean, metadata_itunes_atom_t *atom) { return MP4File_Metadata_iTunes_FindFreeform(name, mean, atom); }
  25. int Metadata_iTunes_GetBinary(metadata_itunes_atom_t atom, const uint8_t **value, size_t *value_length) { return MP4File_Metadata_iTunes_GetBinary(atom, value, value_length); }
  26. int Sample_Read(TrackID track_number, SampleID sample_number, uint8_t **bytes, uint32_t *bytes_length, Timestamp *start_time=0, Duration *duration=0, Duration *offset=0, int *is_sync=0) { return MP4File_Sample_Read(track_number, sample_number, bytes, bytes_length, start_time, duration, offset, is_sync); }
  27. int Sample_GetFromDuration(TrackID track_number, Duration duration, SampleID *sample_id) { return MP4File_Sample_GetFromDuration(track_number, duration, sample_id); }
  28. enum
  29. {
  30. esds_object_type_mpeg4_audio = 0x40,
  31. esds_object_type_mpeg2_aac_lc_audio = 0x67,
  32. esds_object_type_mpeg2_audio = 0x69,
  33. esds_object_type_mpeg1_audio = 0x6B,
  34. mpeg4_audio_type_aac_lc = 2,
  35. mpeg4_audio_type_he_aac = 5,
  36. mpeg4_audio_type_layer1 = 32,
  37. mpeg4_audio_type_layer2 = 33,
  38. mpeg4_audio_type_layer3 = 34,
  39. };
  40. enum
  41. {
  42. DISPATCHABLE_VERSION,
  43. };
  44. private:
  45. virtual int WASABICALL MP4File_Free(void *buffer)=0;
  46. virtual int WASABICALL MP4File_Track_GetESConfiguration(TrackID track_number, uint8_t **buffer, uint32_t *buffer_size)=0;
  47. virtual int WASABICALL MP4File_Track_GetMaxSampleSize(TrackID track_number, uint32_t *max_sample_size)=0;
  48. virtual int WASABICALL MP4File_Track_ConvertFromTimestamp(TrackID track_number, Timestamp timestamp, double *seconds)=0;
  49. virtual int WASABICALL MP4File_Track_ConvertToDuration(TrackID track_number, double seconds, Duration *duration)=0;
  50. virtual int WASABICALL MP4File_Track_GetMediaDataName(TrackID track_number, const char **name)=0;
  51. virtual int WASABICALL MP4File_Track_GetESDSObjectTypeID(TrackID track_number, uint8_t *type)=0;
  52. virtual int WASABICALL MP4File_Track_GetAudioMPEG4Type(TrackID track_number, uint8_t *type)=0;
  53. virtual int WASABICALL MP4File_Track_GetBytesProperty(TrackID track_number, const char *property_name, uint8_t **buffer, uint32_t *buffer_size)=0;
  54. virtual int WASABICALL MP4File_Metadata_iTunes_FindFreeform(const char *name, const char *mean, metadata_itunes_atom_t *atom)=0;
  55. virtual int WASABICALL MP4File_Metadata_iTunes_GetBinary(metadata_itunes_atom_t atom, const uint8_t **value, size_t *value_length)=0;
  56. virtual int WASABICALL MP4File_Sample_Read(TrackID track_number, SampleID sample_number, uint8_t **bytes, uint32_t *bytes_length, Timestamp *start_time, Duration *duration, Duration *offset, int *is_sync)=0;
  57. virtual int WASABICALL MP4File_Sample_GetFromDuration(TrackID track_number, Duration duration, SampleID *sample_id)=0;
  58. };