void GstEnginePipeline::SourceSetupCallback(GstURIDecodeBin* bin, GParamSpec* pspec, gpointer self) { GstEnginePipeline* instance = reinterpret_cast<GstEnginePipeline*>(self); GstElement* element; g_object_get(bin, "source", &element, nullptr); if (!element) { return; } if (g_object_class_find_property(G_OBJECT_GET_CLASS(element), "device") && !instance->source_device().isEmpty()) { // Gstreamer is not able to handle device in URL (refering to Gstreamer // documentation, this might be added in the future). Despite that, for now // we include device inside URL: we decompose it during Init and set device // here, when this callback is called. g_object_set(element, "device", instance->source_device().toLocal8Bit().constData(), nullptr); } if (g_object_class_find_property(G_OBJECT_GET_CLASS(element), "user-agent")) { QString user_agent = QString("%1 %2").arg(QCoreApplication::applicationName(), QCoreApplication::applicationVersion()); g_object_set(element, "user-agent", user_agent.toUtf8().constData(), nullptr); #ifdef Q_OS_DARWIN g_object_set(element, "tls-database", instance->engine_->tls_database(), nullptr); g_object_set(element, "ssl-use-system-ca-file", false, nullptr); g_object_set(element, "ssl-strict", TRUE, nullptr); #endif } }
void GstEnginePipeline::SourceSetupCallback(GstURIDecodeBin* bin, GParamSpec* pspec, gpointer self) { GstEnginePipeline* instance = reinterpret_cast<GstEnginePipeline*>(self); GstElement* element; g_object_get(bin, "source", &element, nullptr); if (!element) { return; } if (g_object_class_find_property(G_OBJECT_GET_CLASS(element), "device") && !instance->source_device().isEmpty()) { // Gstreamer is not able to handle device in URL (refering to Gstreamer // documentation, this might be added in the future). Despite that, for now // we include device inside URL: we decompose it during Init and set device // here, when this callback is called. g_object_set(element, "device", instance->source_device().toLocal8Bit().constData(), nullptr); } if (g_object_class_find_property(G_OBJECT_GET_CLASS(element), "extra-headers") && instance->url().host().contains("grooveshark")) { // Grooveshark streaming servers will answer with a 400 error 'Bad request' // if we don't specify 'Range' field in HTTP header. // Maybe it could be usefull in some other cases, but for now, I prefer to // keep this grooveshark specific. GstStructure* headers; headers = gst_structure_new("extra-headers", "Range", G_TYPE_STRING, "bytes=0-", nullptr); g_object_set(element, "extra-headers", headers, nullptr); gst_structure_free(headers); } if (g_object_class_find_property(G_OBJECT_GET_CLASS(element), "extra-headers") && instance->url().host().contains("files.one.ubuntu.com")) { GstStructure* headers; headers = gst_structure_new("extra-headers", "Authorization", G_TYPE_STRING, instance->url().fragment().toAscii().data(), nullptr); g_object_set(element, "extra-headers", headers, nullptr); gst_structure_free(headers); } if (g_object_class_find_property(G_OBJECT_GET_CLASS(element), "user-agent")) { QString user_agent = QString("%1 %2").arg(QCoreApplication::applicationName(), QCoreApplication::applicationVersion()); g_object_set(element, "user-agent", user_agent.toUtf8().constData(), nullptr); } }