QtGStreamer  0.10.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
buffer.cpp
1 /*
2  Copyright (C) 2010 Collabora Multimedia.
3  @author Mauricio Piacentini <mauricio.piacentini@collabora.co.uk>
4 
5  This library is free software; you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published
7  by the Free Software Foundation; either version 2.1 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include "buffer.h"
19 #include "caps.h"
20 #include <QtCore/QDebug>
21 #include <gst/gst.h>
22 
23 namespace QGst {
24 
25 BufferPtr Buffer::create(uint size)
26 {
27  return BufferPtr::wrap(gst_buffer_try_new_and_alloc(size), false);
28 }
29 
30 quint8 * Buffer::data() const
31 {
32  return GST_BUFFER_DATA(object<GstBuffer>());
33 }
34 
35 quint32 Buffer::size() const
36 {
37  return GST_BUFFER_SIZE(object<GstBuffer>());
38 }
39 
40 ClockTime Buffer::timeStamp() const
41 {
42  return GST_BUFFER_TIMESTAMP(object<GstBuffer>());
43 }
44 
45 ClockTime Buffer::duration() const
46 {
47  return GST_BUFFER_DURATION(object<GstBuffer>());
48 }
49 
50 CapsPtr Buffer::caps() const
51 {
52  //wrap increasing the refcount
53  return QGst::CapsPtr::wrap(GST_BUFFER_CAPS(object<GstBuffer>()));
54 }
55 
56 void Buffer::setCaps(const CapsPtr & caps)
57 {
58  gst_buffer_set_caps(object<GstBuffer>(), caps);
59 }
60 
61 quint64 Buffer::offset() const
62 {
63  return GST_BUFFER_OFFSET(object<GstBuffer>());
64 }
65 
66 quint64 Buffer::offsetEnd() const
67 {
68  return GST_BUFFER_OFFSET_END(object<GstBuffer>());
69 }
70 
71 BufferFlags Buffer::flags() const
72 {
73  return BufferFlags(GST_BUFFER_FLAGS(object<GstBuffer>()));
74 }
75 
76 void Buffer::setFlags(const BufferFlags flags)
77 {
78  GST_BUFFER_FLAGS(object<GstBuffer>()) = flags;
79 }
80 
81 BufferPtr Buffer::copy() const
82 {
83  return BufferPtr::wrap(gst_buffer_copy(object<GstBuffer>()), false);
84 }
85 
86 } //namespace QGst