+ /* Some broken senders send ADTS headers (e.g. some Sony cameras).
+ * Try to detect those and skip them (still needs config set), but
+ * don't check every frame, only the first (unless we detect ADTS) */
+ if (rtpmp4gdepay->check_adts && avail >= 7) {
+ if (gst_adapter_masked_scan_uint32_peek (rtpmp4gdepay->adapter,
+ 0xfffe0000, 0xfff00000, 0, 4, &v) == 0) {
+ guint adts_hdr_len = (((v >> 16) & 0x1) == 0) ? 9 : 7;
+ if (avail > adts_hdr_len) {
+ if (rtpmp4gdepay->warn_adts) {
+ GST_WARNING_OBJECT (rtpmp4gdepay, "Detected ADTS header of "
+ "%u bytes, skipping", adts_hdr_len);
+ rtpmp4gdepay->warn_adts = FALSE;
+ }
+ gst_adapter_flush (rtpmp4gdepay->adapter, adts_hdr_len);
+ avail -= adts_hdr_len;
+ }
+ } else {
+ rtpmp4gdepay->check_adts = FALSE;
+ rtpmp4gdepay->warn_adts = TRUE;
+ }
+ }
+