Debian Codegraph @

gstreamer/src/buffer.ccg

raw
1 /* gstreamermm - a C++ wrapper for gstreamer
2 *
3 * Copyright 2008-2015 The gstreamermm Development Team
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library 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 GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 _PINCLUDE(gstreamermm/private/miniobject_p.h)
21
22 namespace Gst
23 {
24 Glib::RefPtr<Gst::Buffer> Buffer::create(guint size)
25 {
26 return Glib::wrap(gst_buffer_new_allocate(nullptr, size, nullptr));
27 }
28
29 Glib::RefPtr<Buffer> Buffer::create_writable()
30 {
31 return Glib::RefPtr<Buffer>::cast_static(MiniObject::create_writable());
32 }
33
34 guint64 Buffer::offset_none()
35 {
36 return GST_BUFFER_OFFSET_NONE;
37 }
38
39 Glib::RefPtr<Gst::Buffer> Buffer::append_region(Glib::RefPtr<Gst::Buffer>&& buf, gssize offset, gssize size)
40 {
41 if (is_writable())
42 {
43 return Glib::wrap(gst_buffer_append_region(gobj(), buf.release()->gobj(), offset, size), true);
44 }
45 else
46 {
47 reference();
48 return Glib::wrap(gst_buffer_append_region(gobj(), buf.release()->gobj(), offset, size), false);
49 }
50 }
51
52 Glib::RefPtr<Gst::Buffer> Buffer::append(Glib::RefPtr<Gst::Buffer>&& buf)
53 {
54 return append_region(std::move(buf), 0, -1);
55 }
56
57 } // namespace Gst