Esempio n. 1
0
File: k3btrm.cpp Progetto: KDE/k3b
void K3b::TRM::start( const K3b::Msf& length )
{
    if( KProtocolManager::useProxy() ) {
        QUrl proxy( KProtocolManager::proxyFor("http") );
        trm_SetProxy( d->trm, const_cast<char*>(proxy.host().toLatin1().constData()), short(proxy.port()) );
    }

    trm_SetPCMDataInfo( d->trm, 44100, 2, 16 );
    trm_SetSongLength( d->trm, length.totalFrames()/75 );
}
Esempio n. 2
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;
  }
}