QtGStreamer  1.2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
memory.cpp
1 /*
2  Copyright (C) 2013 Diane Trout <diane@ghic.org>
3 
4  This library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License as published
6  by the Free Software Foundation; either version 2.1 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 #include "allocator.h"
18 #include "memory.h"
19 #include "buffer.h"
20 #include <gst/gst.h>
21 
22 namespace QGst {
23 
24 MapInfo::MapInfo()
25 {
26  m_object = g_slice_new0(GstMapInfo);
27 }
28 
29 MapInfo::~MapInfo()
30 {
31  g_slice_free(GstMapInfo, m_object);
32 }
33 
34 MapFlags MapInfo::flags() const
35 {
36  return static_cast<MapFlag>(static_cast<GstMapInfo*>(m_object)->flags);
37 }
38 
39 quint8 *MapInfo::data() const
40 {
41  return static_cast<GstMapInfo*>(m_object)->data;
42 }
43 
44 size_t MapInfo::size() const
45 {
46  return static_cast<GstMapInfo*>(m_object)->size;
47 }
48 
49 size_t MapInfo::maxSize() const
50 {
51  return static_cast<GstMapInfo*>(m_object)->maxsize;
52 }
53 
54 //-----------------------
55 
56 AllocatorPtr Memory::allocator() const
57 {
58  return AllocatorPtr::wrap(object<GstMemory>()->allocator);
59 }
60 
61 size_t Memory::size() const
62 {
63  return object<GstMemory>()->size;
64 }
65 
66 size_t Memory::offset() const
67 {
68  return object<GstMemory>()->offset;
69 }
70 
71 size_t Memory::maxSize() const
72 {
73  return object<GstMemory>()->maxsize;
74 }
75 
76 bool Memory::isType(const char *type) const
77 {
78  return gst_memory_is_type(object<GstMemory>(), type);
79 }
80 
81 bool Memory::map(MapInfo &info, MapFlags flags)
82 {
83  return gst_memory_map(object<GstMemory>(), static_cast<GstMapInfo*>(info.m_object),
84  static_cast<GstMapFlags>(static_cast<int>(flags)));
85 }
86 
87 void Memory::unmap(MapInfo &info)
88 {
89  gst_memory_unmap(object<GstMemory>(), static_cast<GstMapInfo*>(info.m_object));
90 }
91 
92 } // namespace QGst
93 
static RefPointer< T > wrap(typename T::CType *nativePtr, bool increaseRef=true)
Definition: refpointer.h:326