bool PlayerGst::open(QUrl fname, long start, long length) { sync_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); if(fname.toString().toLower().startsWith("file://")/*fname.toLocalFile().size()*/) { //g_object_set (G_OBJECT (l_src), "location", (const char*)fname.toLocalFile().toLocal8Bit(), NULL); setLink(1, fname); } else if(fname.toString().toLower().startsWith("http://")) { //g_object_set (G_OBJECT (http_src), "location", (const char*)fname.toString().toLocal8Bit(), NULL); setLink(2, fname); } else if(fname.toString().toLower().startsWith("mms://")) { QMessageBox::warning(0, "Error", "The mms protocol not supported now"); return false; } //g_object_set (player, "uri", (const char*)fname.toString().toLocal8Bit(), NULL); sync_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED); //gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED); Gstart = start; Gstart *= 1000000000 / 75; Glength = length; Glength *= 1000000000 / 75; gint64 all=0; GstFormat fmt = GST_FORMAT_TIME; //while(!gst_element_query_duration(pipeline, &fmt, &all)) {} // don't do that again, bad boy if(gst_element_query_duration(pipeline, &fmt, &all)) { if(!Glength) Glength = all - Gstart; } else { Gstart = Glength = 0; } //QMessageBox::information(0, "", QString("start = %1, length = %2, stream = %3").arg(QString::number((qlonglong)Gstart), QString::number((qlonglong)Glength), QString::number((qlonglong)all))); return true; }
void Player::asyncOpen(QUrl url) { p->mutex.lock(); m_length = 0; m_position = 0; p->isLoaded=false; p->error=""; lastError=""; sync_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); GstElement *l_src = gst_bin_get_by_name(GST_BIN(pipeline), "localsrc"); g_object_set (G_OBJECT (l_src), "location", (const char*)url.toLocalFile().toUtf8(), NULL); sync_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED); setPosition(QTime(0,0)); gst_object_unref(l_src); p->mutex.unlock(); }
void TrackAnalyser::asyncOpen(QUrl url) { p->mutex.lock(); QString filename = url.toLocalFile().toUtf8(); m_GainDB = GAIN_INVALID; m_StartPosition = QTime(0,0); sync_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); GstElement *l_src = gst_bin_get_by_name(GST_BIN(pipeline), "localsrc"); g_object_set (G_OBJECT (l_src), "location", filename.toLatin1().data(), NULL); sync_set_state (GST_ELEMENT (pipeline), GST_STATE_PAUSED); m_MaxPosition=length(); m_EndPosition=m_MaxPosition; m_finished=false; gst_object_unref(l_src); p->mutex.unlock(); }
void Player::cleanup() { if(pipeline) sync_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL); if(bus) gst_object_unref (bus); if(pipeline) gst_object_unref(G_OBJECT(pipeline)); }