- char srt_filename[strlen(filename)+1];
- strncpy(srt_filename,filename,strlen(filename)-3);
- srt_filename[strlen(filename)-3]='\0';
- strcat(srt_filename, "srt");
- struct stat buffer;
- if (stat(srt_filename, &buffer) == 0)
- {
- eDebug("subtitle file found: %s",srt_filename);
- GstElement *subsource = gst_element_factory_make ("filesrc", "srt_source");
- g_object_set (G_OBJECT (subsource), "location", srt_filename, NULL);
- GstElement *parser = gst_element_factory_make("subparse", "parse_subtitles");
- GstElement *switch_subtitles = gst_element_factory_make ("input-selector", "switch_subtitles");
- GstElement *sink = gst_element_factory_make("fakesink", "sink_subtitles");
- gst_bin_add_many(GST_BIN (m_gst_pipeline), subsource, switch_subtitles, parser, sink, NULL);
- gst_element_link(subsource, switch_subtitles);
- gst_element_link(switch_subtitles, parser);
- gst_element_link(parser, sink);
- g_object_set (G_OBJECT(switch_subtitles), "select-all", TRUE, NULL);
- g_object_set (G_OBJECT(sink), "signal-handoffs", TRUE, NULL);
- g_object_set (G_OBJECT(sink), "sync", TRUE, NULL);
- g_object_set (G_OBJECT(parser), "subtitle-encoding", "ISO-8859-15", NULL);
- g_signal_connect(sink, "handoff", G_CALLBACK(gstCBsubtitleAvail), this);
- subtitleStream subs;
- subs.language_code = std::string(".srt file");
- m_subtitleStreams.push_back(subs);
- }
- gst_bin_add_many(GST_BIN(m_gst_pipeline), source, videodemux, audio, queue_audio, video, queue_video, NULL);
- switch_audio = gst_element_factory_make ("input-selector", "switch_audio");
- if (switch_audio)
- {
- g_object_set (G_OBJECT (switch_audio), "select-all", TRUE, NULL);
- gst_bin_add(GST_BIN(m_gst_pipeline), switch_audio);
- gst_element_link(switch_audio, queue_audio);
- }
- gst_element_link(source, videodemux);
- gst_element_link(queue_audio, audio);
- gst_element_link(queue_video, video);
- g_signal_connect(videodemux, "pad-added", G_CALLBACK (gstCBpadAdded), this);