RESULT eServiceFactoryMP3::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
{
// check resources...
- ptr = new eServiceMP3(ref.path.c_str(),ref.getName().c_str());
+ ptr = new eServiceMP3(ref);
return 0;
}
// eServiceMP3
-eServiceMP3::eServiceMP3(const char *filename, const char *title): m_filename(filename), m_title(title), m_pump(eApp, 1)
+eServiceMP3::eServiceMP3(eServiceReference ref)
+ :m_ref(ref), m_pump(eApp, 1)
{
m_seekTimeout = eTimer::create(eApp);
m_subtitle_sync_timer = eTimer::create(eApp);
m_currentSubtitleStream = 0;
m_subtitle_widget = 0;
m_currentTrickRatio = 0;
+ m_buffer_size = 1*1024*1024;
CONNECT(m_seekTimeout->timeout, eServiceMP3::seekTimeoutCB);
CONNECT(m_subtitle_sync_timer->timeout, eServiceMP3::pushSubtitles);
CONNECT(m_pump.recv_msg, eServiceMP3::gstPoll);
m_state = stIdle;
eDebug("eServiceMP3::construct!");
-
+
+ const char *filename = m_ref.path.c_str();
const char *ext = strrchr(filename, '.');
if (!ext)
ext = filename;
}
gst_element_set_state (m_gst_playbin, GST_STATE_PLAYING);
+ setBufferSize(m_buffer_size);
}
eServiceMP3::~eServiceMP3()
ASSERT(m_state != stIdle);
if (m_state == stStopped)
return -1;
- eDebug("eServiceMP3::stop %s", m_filename.c_str());
+ eDebug("eServiceMP3::stop %s", m_ref.path.c_str());
gst_element_set_state(m_gst_playbin, GST_STATE_NULL);
m_state = stStopped;
return 0;
RESULT eServiceMP3::getName(std::string &name)
{
- if (m_title.empty())
+ std::string title = m_ref.getName();
+ if (title.empty())
{
- name = m_filename;
+ name = m_ref.path;
size_t n = name.rfind('/');
if (n != std::string::npos)
name = name.substr(n + 1);
}
else
- name = m_title;
+ name = title;
return 0;
}
switch (w)
{
+ case sServiceref: return m_ref;
case sVideoHeight: return m_height;
case sVideoWidth: return m_width;
case sFrameRate: return m_framerate;
if (!caps)
continue;
GstStructure* str = gst_caps_get_structure(caps, 0);
-gchar *g_type;
-g_type = gst_structure_get_name(str);
-eDebug("AUDIO STRUCT=%s", g_type);
+ gchar *g_type;
+ g_type = gst_structure_get_name(str);
+ eDebug("AUDIO STRUCT=%s", g_type);
audio.type = gstCheckAudioPad(str);
g_codec = g_strdup(g_type);
g_lang = g_strdup_printf ("und");
g_free(eventname);
}
}
+ break;
+ }
+ case GST_MESSAGE_BUFFERING:
+ {
+ GstBufferingMode mode;
+ gst_message_parse_buffering(msg, &(m_bufferInfo.bufferPercent));
+ gst_message_parse_buffering_stats(msg, &mode, &(m_bufferInfo.avgInRate), &(m_bufferInfo.avgOutRate), &(m_bufferInfo.bufferingLeft));
+ m_event((iPlayableService*)this, evBuffering);
}
default:
break;
PyObject *eServiceMP3::getCachedSubtitle()
{
+// eDebug("eServiceMP3::getCachedSubtitle");
Py_RETURN_NONE;
}
return l;
}
+RESULT eServiceMP3::streamed(ePtr<iStreamedService> &ptr)
+{
+ ptr = this;
+ return 0;
+}
+
+PyObject *eServiceMP3::getBufferCharge()
+{
+ ePyObject tuple = PyTuple_New(5);
+ PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(m_bufferInfo.bufferPercent));
+ PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(m_bufferInfo.avgInRate));
+ PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(m_bufferInfo.avgOutRate));
+ PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(m_bufferInfo.bufferingLeft));
+ PyTuple_SET_ITEM(tuple, 4, PyInt_FromLong(m_buffer_size));
+ return tuple;
+}
+
+int eServiceMP3::setBufferSize(int size)
+{
+ m_buffer_size = size;
+ g_object_set (G_OBJECT (m_gst_playbin), "buffer-size", m_buffer_size, NULL);
+ return 0;
+}
+
+
#else
#warning gstreamer not available, not building media player
#endif