QtGStreamer  0.10.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
bufferlist.cpp
00001 /*
00002     Copyright (C) 2011 Collabora Ltd. <info@collabora.co.uk>
00003       @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
00004 
00005     This library is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU Lesser General Public License as published
00007     by the Free Software Foundation; either version 2.1 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU Lesser General Public License for more details.
00014 
00015     You should have received a copy of the GNU Lesser General Public License
00016     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 #include "bufferlist.h"
00019 #include <gst/gstbufferlist.h>
00020 
00021 namespace QGst {
00022 
00023 BufferListPtr BufferList::create()
00024 {
00025     return BufferListPtr::wrap(gst_buffer_list_new(), false);
00026 }
00027 
00028 uint BufferList::groupsCount() const
00029 {
00030     return gst_buffer_list_n_groups(object<GstBufferList>());
00031 }
00032 
00033 BufferPtr BufferList::bufferAt(uint group, uint index) const
00034 {
00035     return BufferPtr::wrap(gst_buffer_list_get(object<GstBufferList>(), group, index));
00036 }
00037 
00038 
00039 BufferListIterator::BufferListIterator(const BufferListPtr & list)
00040 {
00041     m_it = gst_buffer_list_iterate(list);
00042 }
00043 
00044 BufferListIterator::~BufferListIterator()
00045 {
00046     gst_buffer_list_iterator_free(m_it);
00047 }
00048 
00049 uint BufferListIterator::buffersInCurrentGroup() const
00050 {
00051     return gst_buffer_list_iterator_n_buffers(m_it);
00052 }
00053 
00054 BufferPtr BufferListIterator::next()
00055 {
00056     return BufferPtr::wrap(gst_buffer_list_iterator_next(m_it));
00057 }
00058 
00059 void BufferListIterator::insert(const BufferPtr & buffer)
00060 {
00061     gst_buffer_list_iterator_add(m_it, gst_buffer_ref(buffer));
00062 }
00063 
00064 void BufferListIterator::remove()
00065 {
00066     gst_buffer_list_iterator_remove(m_it);
00067 }
00068 
00069 BufferPtr BufferListIterator::take()
00070 {
00071     BufferPtr buf = BufferPtr::wrap(gst_buffer_list_iterator_steal(m_it), false);
00072     gst_buffer_list_iterator_remove(m_it);
00073     return buf;
00074 }
00075 
00076 void BufferListIterator::replace(const BufferPtr & other)
00077 {
00078     gst_buffer_list_iterator_take(m_it, gst_buffer_ref(other));
00079 }
00080 
00081 void BufferListIterator::addGroup()
00082 {
00083     gst_buffer_list_iterator_add_group(m_it);
00084 }
00085 
00086 bool BufferListIterator::nextGroup()
00087 {
00088     return gst_buffer_list_iterator_next_group(m_it);
00089 }
00090 
00091 BufferPtr BufferListIterator::mergeGroup() const
00092 {
00093     return BufferPtr::wrap(gst_buffer_list_iterator_merge_group(m_it), false);
00094 }
00095 
00096 } //namespace QGst
00097