Commit 58605b8c authored by Trever Fischer's avatar Trever Fischer
Browse files

Minor porting changes.

According to porting-to-0.11.txt in gstreamer sources.
parent 6434cab1
......@@ -111,7 +111,7 @@ inline void AudioDataOutput::convertAndEmit()
emit dataReady(map);
}
void AudioDataOutput::processBuffer(GstElement*, GstBuffer* buffer, GstPad*, gpointer gThat)
void AudioDataOutput::processBuffer(GstElement*, GstBuffer* buffer, GstPad* pad, gpointer gThat)
{
// TODO emit endOfMedia
AudioDataOutput *that = static_cast<AudioDataOutput *>(gThat);
......@@ -122,12 +122,15 @@ void AudioDataOutput::processBuffer(GstElement*, GstBuffer* buffer, GstPad*, gpo
return;
// determine the number of channels
GstStructure *structure = gst_caps_get_structure(GST_BUFFER_CAPS(buffer), 0);
GstCaps *caps = gst_pad_get_caps(pad, NULL);
GstStructure *structure = gst_caps_get_structure(caps, 0);
gst_caps_unref(caps);
gst_structure_get_int(structure, "channels", &that->m_channels);
// Let's get the buffers
gint16 *gstBufferData = reinterpret_cast<gint16 *>(GST_BUFFER_DATA(buffer));
guint gstBufferSize = GST_BUFFER_SIZE(buffer) / sizeof(gint16);
gsize bufferSize;
gint16 *gstBufferData = reinterpret_cast<gint16 *>(gst_buffer_map(buffer, &bufferSize, NULL, GST_MAP_READ));
guint gstBufferSize = bufferSize / sizeof(gint16);
if (gstBufferSize == 0) {
qWarning() << Q_FUNC_INFO << ": received a buffer of 0 size ... doing nothing";
......
......@@ -51,7 +51,7 @@ EffectManager::EffectManager(Backend *backend)
GstPluginFeature *feature = GST_PLUGIN_FEATURE(iter->data);
klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(feature));
if (klass == QLatin1String("Filter/Effect/Audio")) {
name = GST_PLUGIN_FEATURE_NAME(feature);
name = GST_OBJECT_NAME(feature);
// These plugins simply make no sense to the frontend:
// "audiorate" Should be internal
......
......@@ -373,7 +373,7 @@ void MediaObject::getStreamInfo()
if (m_source.discType() == Phonon::Cd) {
gint64 titleCount;
GstFormat format = gst_format_get_by_nick("track");
if (m_pipeline->queryDuration(&format, &titleCount)) {
if (m_pipeline->queryDuration(format, &titleCount)) {
//check if returned format is still "track",
//gstreamer sometimes returns the total time, if tracks information is not available.
if (qstrcmp(gst_format_get_name(format), "track") == 0) {
......
......@@ -232,7 +232,7 @@ void Pipeline::writeToDot(MediaObject *media, const QString &type)
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(bin, GST_DEBUG_GRAPH_SHOW_ALL, QString("phonon-%0").arg(type).toUtf8().constData());
}
bool Pipeline::queryDuration(GstFormat *format, gint64 *duration) const
bool Pipeline::queryDuration(GstFormat format, gint64 *duration) const
{
return gst_element_query_duration(GST_ELEMENT(m_pipeline), format, duration);
}
......@@ -284,9 +284,8 @@ gboolean Pipeline::cb_duration(GstBus *bus, GstMessage *gstMessage, gpointer dat
qint64 Pipeline::totalDuration() const
{
GstFormat format = GST_FORMAT_TIME;
gint64 duration = 0;
if (queryDuration(&format, &duration)) {
if (queryDuration(GST_FORMAT_TIME, &duration)) {
return duration/GST_MSECOND;
}
return -1;
......@@ -297,7 +296,7 @@ gboolean Pipeline::cb_buffering(GstBus *bus, GstMessage *gstMessage, gpointer da
Q_UNUSED(bus)
Pipeline *that = static_cast<Pipeline*>(data);
gint percent = 0;
gst_structure_get_int (gstMessage->structure, "buffer-percent", &percent); //gst_message_parse_buffering was introduced in 0.10.11
gst_structure_get_int (gst_message_get_structure(gstMessage), "buffer-percent", &percent); //gst_message_parse_buffering was introduced in 0.10.11
if (that->m_bufferPercent != percent) {
emit that->buffering(percent);
......@@ -761,7 +760,8 @@ static void cb_feedAppSrc(GstAppSrc *appSrc, guint buffsize, gpointer data)
{
StreamReader *reader = static_cast<StreamReader*>(data);
GstBuffer *buf = gst_buffer_new_and_alloc(buffsize);
reader->read(reader->currentPos(), buffsize, (char*)GST_BUFFER_DATA(buf));
gpointer bufData = gst_buffer_map(buf, NULL, NULL, GST_MAP_WRITE);
reader->read(reader->currentPos(), buffsize, (char*)bufData);
gst_app_src_push_buffer(appSrc, buf);
}
......@@ -810,10 +810,9 @@ Phonon::MediaSource Pipeline::currentSource() const
qint64 Pipeline::position() const
{
gint64 pos = 0;
GstFormat format = GST_FORMAT_TIME;
if (m_resetting)
return m_posAtReset;
gst_element_query_position (GST_ELEMENT(m_pipeline), &format, &pos);
gst_element_query_position (GST_ELEMENT(m_pipeline), GST_FORMAT_TIME, &pos);
return (pos / GST_MSECOND);
}
......
......@@ -51,7 +51,7 @@ class Pipeline : public QObject
GstState state() const;
Phonon::MediaSource currentSource() const;
void writeToDot(MediaObject *media, const QString &type);
bool queryDuration(GstFormat *format, gint64 *duration) const;
bool queryDuration(GstFormat format, gint64 *duration) const;
qint64 totalDuration() const;
static gboolean cb_eos(GstBus *bus, GstMessage *msg, gpointer data);
......
......@@ -82,8 +82,10 @@ GstFlowReturn QWidgetVideoSink<FMT>::render(GstBaseSink* sink, GstBuffer* buf)
{
QWidgetVideoSink<FMT> *self = G_TYPE_CHECK_INSTANCE_CAST(sink, QWidgetVideoSinkClass<FMT>::get_type(), QWidgetVideoSink<FMT>);
QByteArray frame;
frame.resize(buf->size);
memcpy(frame.data(), buf->data, buf->size);
gsize bufSize;
gpointer bufData = gst_buffer_map(buf, &bufSize, NULL, GST_MAP_READ);
frame.resize(bufSize);
memcpy(frame.data(), bufData, bufSize);
NewFrameEvent *frameEvent = new NewFrameEvent(frame, self->width, self->height);
QApplication::postEvent(self->renderWidget, frameEvent);
}
......
......@@ -83,11 +83,13 @@ VideoDataOutput::~VideoDataOutput()
gst_object_unref(m_queue);
}
void VideoDataOutput::processBuffer(GstElement*, GstBuffer* buffer, GstPad*, gpointer gThat)
void VideoDataOutput::processBuffer(GstElement*, GstBuffer* buffer, GstPad* pad, gpointer gThat)
{
VideoDataOutput *that = reinterpret_cast<VideoDataOutput*>(gThat);
GstStructure* structure = gst_caps_get_structure(GST_BUFFER_CAPS(buffer), 0);
GstCaps *caps = gst_pad_get_caps(pad, NULL);
GstStructure* structure = gst_caps_get_structure(caps, 0);
gst_caps_unref(caps);
int width;
int height;
double aspect;
......@@ -95,13 +97,14 @@ void VideoDataOutput::processBuffer(GstElement*, GstBuffer* buffer, GstPad*, gpo
gst_structure_get_int(structure, "width", &width);
gst_structure_get_int(structure, "height", &height);
aspect = (double)width/height;
const char *bufferData = reinterpret_cast<const char*>(gst_buffer_map(buffer, NULL, NULL, GST_MAP_READ));
const Experimental::VideoFrame2 f = {
width,
height,
aspect,
Experimental::VideoFrame2::Format_RGB888,
// RGB888 Means the data is 8 bits o' red, 8 bits o' green, and 8 bits o' blue per pixel.
QByteArray::fromRawData(reinterpret_cast<const char*>(GST_BUFFER_DATA(buffer)), 3*width*height),
QByteArray::fromRawData(bufferData, 3*width*height),
0,
0
};
......
......@@ -515,11 +515,14 @@ void VideoWidget::cb_capsChanged(GstPad *pad, GParamSpec *spec, gpointer data)
gint width;
gint height;
//FIXME: This sometimes gives a gstreamer warning. Feels like GStreamer shouldn't, and instead
//just quietly return false, probably a bug.
if (gst_video_get_size(pad, &width, &height)) {
QMetaObject::invokeMethod(that, "setMovieSize", Q_ARG(QSize, QSize(width, height)));
}
GstCaps *caps = gst_pad_get_caps(pad, NULL);
GstStructure *structure = gst_caps_get_structure(caps, 0);
gst_caps_unref(caps);
gst_structure_get_int(structure, "width", &width);
gst_structure_get_int(structure, "height", &height);
gst_structure_free(structure);
QMetaObject::invokeMethod(that, "setMovieSize", Q_ARG(QSize, QSize(width, height)));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment