aacparse: parse codec_data to determine number of samples per frame
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Tue, 6 Sep 2011 13:59:49 +0000 (15:59 +0200)
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Wed, 7 Sep 2011 09:20:03 +0000 (11:20 +0200)
Fixes #656734.

gst/audioparsers/gstaacparse.c
gst/audioparsers/gstaacparse.h

index 5c50da8..e42983d 100644 (file)
@@ -262,9 +262,11 @@ gst_aac_parse_sink_setcaps (GstBaseParse * parse, GstCaps * caps)
       aacparse->channels = (buffer[1] & 0x78) >> 3;
       aacparse->header_type = DSPAAC_HEADER_NONE;
       aacparse->mpegversion = 4;
+      aacparse->frame_samples = (buffer[1] & 4) ? 960 : 1024;
 
-      GST_DEBUG ("codec_data: object_type=%d, sample_rate=%d, channels=%d",
-          aacparse->object_type, aacparse->sample_rate, aacparse->channels);
+      GST_DEBUG ("codec_data: object_type=%d, sample_rate=%d, channels=%d, "
+          "samples=%d", aacparse->object_type, aacparse->sample_rate,
+          aacparse->channels, aacparse->frame_samples);
 
       /* arrange for metadata and get out of the way */
       gst_aac_parse_set_src_caps (aacparse, caps);
@@ -460,7 +462,8 @@ gst_aac_parse_detect_stream (GstAacParse * aacparse,
     gst_aac_parse_parse_adts_header (aacparse, data, &rate, &channels,
         &aacparse->object_type, &aacparse->mpegversion);
 
-    gst_base_parse_set_frame_rate (GST_BASE_PARSE (aacparse), rate, 1024, 2, 2);
+    gst_base_parse_set_frame_rate (GST_BASE_PARSE (aacparse), rate,
+        aacparse->frame_samples, 2, 2);
 
     GST_DEBUG ("ADTS: samplerate %d, channels %d, objtype %d, version %d",
         rate, channels, aacparse->object_type, aacparse->mpegversion);
@@ -679,7 +682,7 @@ gst_aac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
     }
 
     gst_base_parse_set_frame_rate (GST_BASE_PARSE (aacparse),
-        aacparse->sample_rate, 1024, 2, 2);
+        aacparse->sample_rate, aacparse->frame_samples, 2, 2);
   }
 
   return ret;
@@ -701,6 +704,7 @@ gst_aac_parse_start (GstBaseParse * parse)
 
   aacparse = GST_AAC_PARSE (parse);
   GST_DEBUG ("start");
+  aacparse->frame_samples = 1024;
   gst_base_parse_set_min_frame_size (GST_BASE_PARSE (aacparse), ADTS_MAX_SIZE);
   return TRUE;
 }
index 4020d8f..1907c2e 100644 (file)
@@ -63,19 +63,6 @@ typedef struct _GstAacParseClass GstAacParseClass;
 
 /**
  * GstAacParse:
- * @element: the parent element.
- * @object_type: AAC object type of the stream.
- * @bitrate:  Current media bitrate.
- * @sample_rate: Current media samplerate.
- * @channels: Current media channel count.
- * @frames_per_sec: FPS value of the current stream.
- * @header_type: #GstAacHeaderType indicating the current stream type.
- * @framecount: The amount of frames that has been processed this far.
- * @bytecount: The amount of bytes that has been processed this far.
- * @sync: Tells whether the parser is in sync (a.k.a. not searching for header)
- * @eos: End-of-Stream indicator. Set when EOS event arrives.
- * @duration: Duration of the current stream.
- * @ts: Current stream timestamp.
  *
  * The opaque GstAacParse data structure.
  */
@@ -88,6 +75,7 @@ struct _GstAacParse {
   gint           sample_rate;
   gint           channels;
   gint           mpegversion;
+  gint           frame_samples;
 
   GstAacHeaderType header_type;
 };