]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - mp4.c
mp4: Introduce mp4_is_audio_track().
[paraslash.git] / mp4.c
diff --git a/mp4.c b/mp4.c
index d9f86fc7414685c5448252f8e8048c2979935d88..be974b3c4e5c8186152f3e7a86b17ee1eaee52ed 100644 (file)
--- a/mp4.c
+++ b/mp4.c
@@ -1235,27 +1235,6 @@ static int32_t parse_atoms(struct mp4 *f, int meta_only)
        return 0;
 }
 
-void mp4_get_decoder_config(const struct mp4 *f, int track,
-               unsigned char **ppBuf, unsigned int *pBufSize)
-{
-       if (track >= f->total_tracks) {
-               *ppBuf = NULL;
-               *pBufSize = 0;
-               return;
-       }
-
-       if (f->track[track]->decoderConfig == NULL
-               || f->track[track]->decoderConfigLen == 0) {
-               *ppBuf = NULL;
-               *pBufSize = 0;
-       } else {
-               *ppBuf = para_malloc(f->track[track]->decoderConfigLen);
-               memcpy(*ppBuf, f->track[track]->decoderConfig,
-                       f->track[track]->decoderConfigLen);
-               *pBufSize = f->track[track]->decoderConfigLen;
-       }
-}
-
 struct mp4 *mp4_open_read(struct mp4_callback *f)
 {
        struct mp4 *ff = para_calloc(sizeof(struct mp4));
@@ -1425,6 +1404,20 @@ uint64_t mp4_get_duration(const struct mp4 *f, int32_t track)
        return t->duration * 1000 / t->timeScale;
 }
 
+/**
+ * Check whether the given track number corresponds to an audio track.
+ *
+ * \param f See \ref mp4_get_duration().
+ * \param track See \ref mp4_get_duration().
+ *
+ * Besides audio tracks, an mp4 file may contain video and system tracks. For
+ * those the function returns false.
+ */
+bool mp4_is_audio_track(const struct mp4 *f, int32_t track)
+{
+       return f->track[track]->type == TRACK_AUDIO;
+}
+
 void mp4_set_sample_position(struct mp4 *f, int32_t track, int32_t sample)
 {
        int32_t offset = sample_to_offset(f, track, sample);