/* note: this requires gstreamer 0.10.x and a big list of plugins. */
/* it's currently hardcoded to use a big-endian alsasink as sink. */
+#include <lib/base/ebase.h>
#include <lib/base/eerror.h>
+#include <lib/base/init_num.h>
+#include <lib/base/init.h>
+#include <lib/base/nconfig.h>
#include <lib/base/object.h>
-#include <lib/base/ebase.h>
-#include <string>
+#include <lib/dvb/decoder.h>
+#include <lib/components/file_eraser.h>
+#include <lib/gui/esubtitle.h>
#include <lib/service/servicemp3.h>
#include <lib/service/service.h>
-#include <lib/components/file_eraser.h>
-#include <lib/base/init_num.h>
-#include <lib/base/init.h>
+
+#include <string>
+
#include <gst/gst.h>
#include <gst/pbutils/missing-plugins.h>
#include <sys/stat.h>
-/* for subtitles */
-#include <lib/gui/esubtitle.h>
// eServiceFactoryMP3
extensions.push_back("vob");
extensions.push_back("wav");
extensions.push_back("wave");
+ extensions.push_back("m4v");
extensions.push_back("mkv");
extensions.push_back("avi");
extensions.push_back("divx");
}
// eServiceMP3
+int eServiceMP3::ac3_delay,
+ eServiceMP3::pcm_delay;
eServiceMP3::eServiceMP3(eServiceReference ref)
:m_ref(ref), m_pump(eApp, 1)
sourceinfo.containertype = ctAVI;
sourceinfo.is_video = TRUE;
}
- else if ( strcasecmp(ext, ".mp4") == 0 || strcasecmp(ext, ".mov") == 0)
+ else if ( strcasecmp(ext, ".mp4") == 0 || strcasecmp(ext, ".mov") == 0 || strcasecmp(ext, ".m4v") == 0)
{
sourceinfo.containertype = ctMP4;
sourceinfo.is_video = TRUE;
RESULT eServiceMP3::isCurrentlySeekable()
{
- return 1;
+ int ret = 3; // seeking and fast/slow winding possible
+ GstElement *sink;
+
+ if (!m_gst_playbin)
+ return 0;
+ if (m_state != stRunning)
+ return 0;
+
+ g_object_get (G_OBJECT (m_gst_playbin), "video-sink", &sink, NULL);
+
+ // disable fast winding yet when a dvbvideosink or dvbaudiosink is used
+ // for this we must do some changes on different places.. (gstreamer.. our sinks.. enigma2)
+ if (sink) {
+ ret &= ~2; // only seeking possible
+ gst_object_unref(sink);
+ }
+ else {
+ g_object_get (G_OBJECT (m_gst_playbin), "audio-sink", &sink, NULL);
+ if (sink) {
+ ret &= ~2; // only seeking possible
+ gst_object_unref(sink);
+ }
+ }
+
+ return ret;
}
RESULT eServiceMP3::info(ePtr<iServiceInformation>&i)
return 0;
}
-
int eServiceMP3::getInfo(int w)
{
const gchar *tag = 0;
return 0;
}
+RESULT eServiceMP3::audioDelay(ePtr<iAudioDelay> &ptr)
+{
+ ptr = this;
+ return 0;
+}
+
int eServiceMP3::getNumberOfTracks()
{
return m_audioStreams.size();
g_object_set (G_OBJECT (sink), "emit-signals", TRUE, NULL);
gst_object_unref(sink);
}
+ setAC3Delay(ac3_delay);
+ setPCMDelay(pcm_delay);
} break;
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
{
return 0;
}
+int eServiceMP3::getAC3Delay()
+{
+ return ac3_delay;
+}
+
+int eServiceMP3::getPCMDelay()
+{
+ return pcm_delay;
+}
+
+void eServiceMP3::setAC3Delay(int delay)
+{
+ ac3_delay = delay;
+ if (!m_gst_playbin || m_state != stRunning)
+ return;
+ else
+ {
+ GstElement *sink;
+ int config_delay_int = delay;
+ g_object_get (G_OBJECT (m_gst_playbin), "video-sink", &sink, NULL);
+
+ if (sink)
+ {
+ std::string config_delay;
+ if(ePythonConfigQuery::getConfigValue("config.av.generalAC3delay", config_delay) == 0)
+ config_delay_int += atoi(config_delay.c_str());
+ gst_object_unref(sink);
+ }
+ else
+ {
+ eDebug("dont apply ac3 delay when no video is running!");
+ config_delay_int = 0;
+ }
+
+ g_object_get (G_OBJECT (m_gst_playbin), "audio-sink", &sink, NULL);
+
+ if (sink)
+ {
+ gchar *name = gst_element_get_name(sink);
+ if (strstr(name, "dvbaudiosink"))
+ eTSMPEGDecoder::setHwAC3Delay(config_delay_int);
+ g_free(name);
+ gst_object_unref(sink);
+ }
+ }
+}
+
+void eServiceMP3::setPCMDelay(int delay)
+{
+ pcm_delay = delay;
+ if (!m_gst_playbin || m_state != stRunning)
+ return;
+ else
+ {
+ GstElement *sink;
+ int config_delay_int = delay;
+ g_object_get (G_OBJECT (m_gst_playbin), "video-sink", &sink, NULL);
+
+ if (sink)
+ {
+ std::string config_delay;
+ if(ePythonConfigQuery::getConfigValue("config.av.generalPCMdelay", config_delay) == 0)
+ config_delay_int += atoi(config_delay.c_str());
+ gst_object_unref(sink);
+ }
+ else
+ {
+ eDebug("dont apply pcm delay when no video is running!");
+ config_delay_int = 0;
+ }
+
+ g_object_get (G_OBJECT (m_gst_playbin), "audio-sink", &sink, NULL);
+
+ if (sink)
+ {
+ gchar *name = gst_element_get_name(sink);
+ if (strstr(name, "dvbaudiosink"))
+ eTSMPEGDecoder::setHwPCMDelay(config_delay_int);
+ else
+ {
+ // this is realy untested..and not used yet
+ gint64 offset = config_delay_int;
+ offset *= 1000000; // milli to nano
+ g_object_set (G_OBJECT (m_gst_playbin), "ts-offset", offset, NULL);
+ }
+ g_free(name);
+ gst_object_unref(sink);
+ }
+ }
+}
#else
#warning gstreamer not available, not building media player