PipeWire 0.3.43
buffer.h
Go to the documentation of this file.
1/* Simple Plugin API
2 *
3 * Copyright © 2018 Wim Taymans
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25#ifndef SPA_DEBUG_BUFFER_H
26#define SPA_DEBUG_BUFFER_H
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
41#include <spa/debug/mem.h>
42#include <spa/debug/types.h>
44
45#ifndef spa_debug
46#define spa_debug(...) ({ fprintf(stderr, __VA_ARGS__);fputc('\n', stderr); })
47#endif
48
49static inline int spa_debug_buffer(int indent, const struct spa_buffer *buffer)
50{
51 uint32_t i;
52
53 spa_debug("%*s" "struct spa_buffer %p:", indent, "", buffer);
54 spa_debug("%*s" " n_metas: %u (at %p)", indent, "", buffer->n_metas, buffer->metas);
55 for (i = 0; i < buffer->n_metas; i++) {
56 struct spa_meta *m = &buffer->metas[i];
57 const char *type_name;
58
60 spa_debug("%*s" " meta %d: type %d (%s), data %p, size %d:", indent, "", i, m->type,
61 type_name, m->data, m->size);
62
63 switch (m->type) {
64 case SPA_META_Header:
65 {
66 struct spa_meta_header *h = (struct spa_meta_header*)m->data;
67 spa_debug("%*s" " struct spa_meta_header:", indent, "");
68 spa_debug("%*s" " flags: %08x", indent, "", h->flags);
69 spa_debug("%*s" " offset: %u", indent, "", h->offset);
70 spa_debug("%*s" " seq: %" PRIu64, indent, "", h->seq);
71 spa_debug("%*s" " pts: %" PRIi64, indent, "", h->pts);
72 spa_debug("%*s" " dts_offset: %" PRIi64, indent, "", h->dts_offset);
73 break;
74 }
76 {
77 struct spa_meta_region *h = (struct spa_meta_region*)m->data;
78 spa_debug("%*s" " struct spa_meta_region:", indent, "");
79 spa_debug("%*s" " x: %d", indent, "", h->region.position.x);
80 spa_debug("%*s" " y: %d", indent, "", h->region.position.y);
81 spa_debug("%*s" " width: %d", indent, "", h->region.size.width);
82 spa_debug("%*s" " height: %d", indent, "", h->region.size.height);
83 break;
84 }
86 {
87 struct spa_meta_region *h;
88 spa_meta_for_each(h, m) {
89 spa_debug("%*s" " struct spa_meta_region:", indent, "");
90 spa_debug("%*s" " x: %d", indent, "", h->region.position.x);
91 spa_debug("%*s" " y: %d", indent, "", h->region.position.y);
92 spa_debug("%*s" " width: %d", indent, "", h->region.size.width);
93 spa_debug("%*s" " height: %d", indent, "", h->region.size.height);
94 }
95 break;
96 }
97 case SPA_META_Bitmap:
98 break;
99 case SPA_META_Cursor:
100 break;
101 default:
102 spa_debug("%*s" " Unknown:", indent, "");
103 spa_debug_mem(5, m->data, m->size);
104 }
105 }
106 spa_debug("%*s" " n_datas: \t%u (at %p)", indent, "", buffer->n_datas, buffer->datas);
107 for (i = 0; i < buffer->n_datas; i++) {
108 struct spa_data *d = &buffer->datas[i];
109 spa_debug("%*s" " type: %d (%s)", indent, "", d->type,
111 spa_debug("%*s" " flags: %d", indent, "", d->flags);
112 spa_debug("%*s" " data: %p", indent, "", d->data);
113 spa_debug("%*s" " fd: %" PRIi64, indent, "", d->fd);
114 spa_debug("%*s" " offset: %d", indent, "", d->mapoffset);
115 spa_debug("%*s" " maxsize: %u", indent, "", d->maxsize);
116 spa_debug("%*s" " chunk: %p", indent, "", d->chunk);
117 spa_debug("%*s" " offset: %d", indent, "", d->chunk->offset);
118 spa_debug("%*s" " size: %u", indent, "", d->chunk->size);
119 spa_debug("%*s" " stride: %d", indent, "", d->chunk->stride);
120 }
121 return 0;
122}
123
128#ifdef __cplusplus
129} /* extern "C" */
130#endif
131
132#endif /* SPA_DEBUG_BUFFER_H */
spa/buffer/type-info.h
static const struct spa_type_info spa_type_data_type[]
Definition: type-info.h:63
#define spa_meta_for_each(pos, meta)
iterate all the items in a metadata
Definition: meta.h:109
static const struct spa_type_info spa_type_meta_type[]
Definition: type-info.h:92
@ SPA_META_VideoDamage
array of struct spa_meta_region with damage, where an invalid entry or end-of-array marks the end.
Definition: meta.h:49
@ SPA_META_Bitmap
struct spa_meta_bitmap
Definition: meta.h:50
@ SPA_META_Cursor
struct spa_meta_cursor
Definition: meta.h:51
@ SPA_META_VideoCrop
struct spa_meta_region with cropping data
Definition: meta.h:48
@ SPA_META_Header
struct spa_meta_header
Definition: meta.h:47
static int spa_debug_buffer(int indent, const struct spa_buffer *buffer)
Definition: buffer.h:54
#define spa_debug(...)
Definition: buffer.h:51
static const char * spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type)
Definition: types.h:73
static int spa_debug_mem(int indent, const void *data, size_t size)
Definition: mem.h:48
spa/debug/mem.h
A Buffer.
Definition: buffer.h:105
uint32_t n_metas
number of metadata
Definition: buffer.h:106
struct spa_meta * metas
array of metadata
Definition: buffer.h:108
struct spa_data * datas
array of data members
Definition: buffer.h:109
uint32_t n_datas
number of data members
Definition: buffer.h:107
int32_t stride
stride of valid data
Definition: buffer.h:68
uint32_t size
size of valid data.
Definition: buffer.h:66
uint32_t offset
offset of valid data.
Definition: buffer.h:63
Data for a buffer this stays constant for a buffer.
Definition: buffer.h:77
struct spa_chunk * chunk
valid chunk of memory
Definition: buffer.h:101
int64_t fd
optional fd for data
Definition: buffer.h:97
uint32_t mapoffset
offset to map fd at
Definition: buffer.h:98
uint32_t flags
data flags
Definition: buffer.h:96
void * data
optional data pointer
Definition: buffer.h:100
uint32_t maxsize
max size of data
Definition: buffer.h:99
uint32_t type
memory type, one of enum spa_data_type, when allocating memory, the type contains a bitmask of allowe...
Definition: buffer.h:78
Describes essential buffer header metadata such as flags and timestamps.
Definition: meta.h:80
uint32_t offset
offset in current cycle
Definition: meta.h:94
uint32_t flags
flags
Definition: meta.h:93
uint64_t seq
sequence number, increments with a media specific frequency
Definition: meta.h:97
int64_t pts
presentation timestamp
Definition: meta.h:95
int64_t dts_offset
decoding timestamp as a difference with pts
Definition: meta.h:96
metadata structure for Region or an array of these for RegionArray
Definition: meta.h:102
struct spa_region region
Definition: meta.h:103
A metadata element.
Definition: meta.h:66
uint32_t size
size of metadata
Definition: meta.h:68
uint32_t type
metadata type, one of enum spa_meta_type
Definition: meta.h:67
void * data
pointer to metadata
Definition: meta.h:69
int32_t y
Definition: defs.h:109
int32_t x
Definition: defs.h:108
uint32_t width
Definition: defs.h:101
uint32_t height
Definition: defs.h:102
struct spa_point position
Definition: defs.h:115
struct spa_rectangle size
Definition: defs.h:116
spa/debug/types.h