QtGStreamer 0.10.1
|
00001 /* 00002 Copyright (C) 2009-2010 George Kiagiadakis <kiagiadakis.george@gmail.com> 00003 00004 This library is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU Lesser General Public License as published 00006 by the Free Software Foundation; either version 2.1 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU General Public License for more details. 00013 00014 You should have received a copy of the GNU Lesser General Public License 00015 along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 #include "miniobject.h" 00018 #include "objectstore_p.h" 00019 #include <gst/gst.h> 00020 00021 namespace QGst { 00022 00023 MiniObjectPtr MiniObject::copy() const 00024 { 00025 return MiniObjectPtr::wrap(gst_mini_object_copy(object<GstMiniObject>()), false); 00026 } 00027 00028 bool MiniObject::isWritable() const 00029 { 00030 return gst_mini_object_is_writable(object<GstMiniObject>()); 00031 } 00032 00033 void MiniObject::ref(bool increaseRef) 00034 { 00035 if (Private::ObjectStore::put(this)) { 00036 if (increaseRef) { 00037 gst_mini_object_ref(GST_MINI_OBJECT(m_object)); 00038 } 00039 } 00040 } 00041 00042 void MiniObject::unref() 00043 { 00044 if (Private::ObjectStore::take(this)) { 00045 gst_mini_object_unref(GST_MINI_OBJECT(m_object)); 00046 delete this; 00047 } 00048 } 00049 00050 MiniObjectPtr MiniObject::makeWritable() const 00051 { 00052 /* 00053 * Calling gst_*_make_writable() below is tempting but wrong. 00054 * Since MiniObjects and Caps do not share the same C++ instance in various wrappings, calling 00055 * gst_*_make_writable() on an already writable object and wrapping the result is wrong, 00056 * since it would just return the same pointer and we would wrap it in a new C++ instance. 00057 */ 00058 if (!isWritable()) { 00059 return copy(); 00060 } else { 00061 return MiniObjectPtr(const_cast<MiniObject*>(this)); 00062 } 00063 } 00064 00065 00066 namespace Private { 00067 00068 QGlib::RefCountedObject *wrapMiniObject(void *miniObject) 00069 { 00070 return QGlib::constructWrapper(QGlib::Type::fromInstance(miniObject), miniObject); 00071 } 00072 00073 } //namespace Private 00074 } //namespace QGst