Ejemplo n.º 1
0
static GstFlowReturn
gst_trm_chain (GstPad * pad, GstBuffer * buf)
{
  GstTRM *trm = GST_TRM (GST_PAD_PARENT (pad));

  if (!trm->data_available) {
    GstFormat tformat = GST_FORMAT_TIME;
    gint64 total_duration;

    /* FIXME: maybe we should only query this once we have as much data as
     * we need (30secs or so), to get a better estimation of the length in
     * the case of VBR files? */
    if (gst_pad_query_peer_duration (pad, &tformat, &total_duration)) {
      total_duration /= GST_SECOND;
      trm_SetSongLength (trm->trm, total_duration);
      trm->data_available = TRUE;
    }
  }

  if (!trm->signature_available
      && trm_GenerateSignature (trm->trm, (char *) GST_BUFFER_DATA (buf),
          GST_BUFFER_SIZE (buf))) {
    GST_DEBUG ("Signature");

    GST_OBJECT_LOCK (trm);
    if (trm->proxy_address != NULL) {
      if (!trm_SetProxy (trm->trm, trm->proxy_address, trm->proxy_port)) {
        GST_OBJECT_UNLOCK (trm);
        goto proxy_setup_error;
      }
    }
    GST_OBJECT_UNLOCK (trm);

    gst_trm_emit_signature (trm);
  }

  return gst_pad_push (trm->srcpad, buf);

/* ERRORS */
proxy_setup_error:
  {
    GST_ELEMENT_ERROR (trm, RESOURCE, SETTINGS, (NULL),
        ("Unable to set proxy server for trm lookup"));
    return GST_FLOW_ERROR;
  }
}
Ejemplo n.º 2
0
Archivo: k3btrm.cpp Proyecto: KDE/k3b
bool K3b::TRM::generate( char* data, int len )
{
    return ( trm_GenerateSignature( d->trm, data, len ) == 1 );
}