static gboolean
gst_id3demux_identify_tag (GstTagDemux * demux, GstBuffer * buf,
    gboolean start_tag, guint * tag_size)
{
  const guint8 *data = GST_BUFFER_DATA (buf);

  if (start_tag) {
    if (data[0] != 'I' || data[1] != 'D' || data[2] != '3')
      goto no_marker;

    *tag_size = id3demux_calc_id3v2_tag_size (buf);
  } else {
    if (data[0] != 'T' || data[1] != 'A' || data[2] != 'G')
      goto no_marker;

    *tag_size = ID3V1_TAG_SIZE;
  }

  GST_INFO_OBJECT (demux, "Found ID3v%u marker, tag_size = %u",
      (start_tag) ? 2 : 1, *tag_size);

  return TRUE;

no_marker:
  {
    GST_DEBUG_OBJECT (demux, "No ID3v%u marker found", (start_tag) ? 2 : 1);
    return FALSE;
  }
}
Exemple #2
0
/* caller must pass buffer with full ID3 tag */
ID3TagsResult
id3demux_read_id3v2_tag (GstBuffer * buffer, guint * id3v2_size,
    GstTagList ** tags)
{
  guint8 *data, *uu_data = NULL;
  guint read_size;
  ID3TagsWorking work;
  guint8 flags;
  ID3TagsResult result;
  guint16 version;

  read_size = id3demux_calc_id3v2_tag_size (buffer);

  if (id3v2_size)
    *id3v2_size = read_size;

  /* Ignore tag if it has no frames attached, but skip the header then */
  if (read_size <= ID3V2_HDR_SIZE)
    return ID3TAGS_BROKEN_TAG;

  data = GST_BUFFER_DATA (buffer);

  /* Read the version */
  version = GST_READ_UINT16_BE (data + 3);

  /* Read the flags */
  flags = data[5];

  /* Validate the version. At the moment, we only support up to 2.4.0 */
  if (ID3V2_VER_MAJOR (version) > 4 || ID3V2_VER_MINOR (version) > 0) {
    GST_WARNING ("ID3v2 tag is from revision 2.%d.%d, "
        "but decoder only supports 2.%d.%d. Ignoring as per spec.",
        version >> 8, version & 0xff, ID3V2_VERSION >> 8, ID3V2_VERSION & 0xff);
    return ID3TAGS_READ_TAG;
  }