int32_t mp4ff_read_sample(mp4ff_t *f, const int32_t track, const int32_t sample, uint8_t **audio_buffer, uint32_t *bytes) { int32_t result = 0; *bytes = mp4ff_audio_frame_size(f, track, sample); if (*bytes==0) return 0; *audio_buffer = (uint8_t*)malloc(*bytes); if (!(*audio_buffer)) { //fprintf (stderr, "mp4ff_read_sample: malloc failure (tried to alloc %d bytes). possible mp4ff bug or memleak! please report a bug to deadbeef developers (i'm serious).\n", *bytes); return 0; } mp4ff_set_sample_position(f, track, sample); result = mp4ff_read_data(f, *audio_buffer, *bytes); if (!result) { free(*audio_buffer); *audio_buffer = 0; return 0; } #ifdef ITUNES_DRM if (f->track[track]->p_drms != NULL) { drms_decrypt(f->track[track]->p_drms, (uint32_t*)*audio_buffer, *bytes); } #endif return *bytes; }
int32_t mp4ff_read_sample(mp4ff_t *f, const int32_t track, const int32_t sample, uint8_t **audio_buffer, uint32_t *bytes) { int32_t result = 0; *bytes = mp4ff_audio_frame_size(f, track, sample); if (*bytes==0) return 0; *audio_buffer = (uint8_t*)malloc(*bytes); mp4ff_set_sample_position(f, track, sample); result = mp4ff_read_data(f, *audio_buffer, *bytes); if (!result) { free(*audio_buffer); *audio_buffer = 0; return 0; } #ifdef ITUNES_DRM if (f->track[track]->p_drms != NULL) { drms_decrypt(f->track[track]->p_drms, (uint32_t*)*audio_buffer, *bytes); } #endif return *bytes; }
int32_t mp4ff_read_sample_v2(mp4ff_t *f, const int track, const int sample,unsigned char *buffer) { int32_t result = 0; int32_t size = mp4ff_audio_frame_size(f,track,sample); if (size<=0) return 0; mp4ff_set_sample_position(f, track, sample); result = mp4ff_read_data(f,buffer,size); #ifdef ITUNES_DRM if (f->track[track]->p_drms != NULL) { drms_decrypt(f->track[track]->p_drms, (uint32_t*)buffer, size); } #endif return result; }