No more assertions after fixing the viewfinder stopping logic in QtCamDevice::stop()
[harmattan/cameraplus] / lib / qtcamviewfinderrenderermeego.cpp
index 8c5eeed..4ff08fe 100644 (file)
@@ -1,3 +1,23 @@
+/*!
+ * This file is part of CameraPlus.
+ *
+ * Copyright (C) 2012 Mohammed Sameer <msameer@foolab.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
 #include "qtcamviewfinderrenderermeego.h"
 #include <QDebug>
 #include <gst/video/video.h>
@@ -103,10 +123,13 @@ void QtCamViewfinderRendererMeeGo::resize(const QSizeF& size) {
   // TODO: this will destroy everything
   // but we need a way to reset the viewport and the transformation matrix only.
   m_needsInit = true;
+
+  emit renderAreaChanged();
 }
 
 void QtCamViewfinderRendererMeeGo::reset() {
-  // Nothing.
+  QMutexLocker locker(&m_frameMutex);
+  m_frame = -1;
 }
 
 GstElement *QtCamViewfinderRendererMeeGo::sinkElement() {
@@ -162,6 +185,8 @@ void QtCamViewfinderRendererMeeGo::frame_ready(GstElement *sink, int frame,
 void QtCamViewfinderRendererMeeGo::sink_notify(QtCamViewfinderRendererMeeGo *q,
                                               GObject *object, gboolean is_last_ref) {
 
+  Q_UNUSED(object);
+
   if (is_last_ref) {
     g_signal_handler_disconnect(q->m_sink, q->m_id);
     g_object_remove_toggle_ref(G_OBJECT(q->m_sink), (GToggleNotify)sink_notify, q);
@@ -175,7 +200,7 @@ void QtCamViewfinderRendererMeeGo::sink_caps_changed(GObject *obj, GParamSpec *p
   Q_UNUSED(pspec);
 
   int width, height;
-  if (obj && gst_video_get_size  (GST_PAD(obj), &width, &height)) {
+  if (obj && gst_video_get_size(GST_PAD(obj), &width, &height)) {
     QMetaObject::invokeMethod(q, "setVideoSize", Qt::QueuedConnection,
                              Q_ARG(QSizeF, QSizeF(width, height)));
   }
@@ -304,6 +329,10 @@ QRectF QtCamViewfinderRendererMeeGo::renderArea() {
   return m_renderArea;
 }
 
+QSizeF QtCamViewfinderRendererMeeGo::videoResolution() {
+  return m_videoSize;
+}
+
 void QtCamViewfinderRendererMeeGo::setVideoSize(const QSizeF& size) {
   if (size == m_videoSize) {
     return;
@@ -316,4 +345,7 @@ void QtCamViewfinderRendererMeeGo::setVideoSize(const QSizeF& size) {
   calculateCoords();
 
   m_needsInit = true;
+
+  emit renderAreaChanged();
+  emit videoResolution();
 }