PipeWire  0.3.33
debug/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
29 extern "C" {
30 #endif
31 
41 #include <spa/debug/mem.h>
42 #include <spa/debug/types.h>
43 #include <spa/buffer/type-info.h>
44 
45 #ifndef spa_debug
46 #define spa_debug(...) ({ fprintf(stderr, __VA_ARGS__);fputc('\n', stderr); })
47 #endif
48 
49 /* static */ 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  }
75  case SPA_META_VideoCrop:
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_debug_buffer
int spa_debug_buffer(int indent, const struct spa_buffer *buffer)
Definition: debug/buffer.h:49
spa_meta::data
void * data
pointer to metadata
Definition: meta.h:64
spa_data::maxsize
uint32_t maxsize
max size of data
Definition: buffer/buffer.h:87
spa_rectangle::width
uint32_t width
Definition: defs.h:87
SPA_META_Cursor
@ SPA_META_Cursor
struct spa_meta_cursor
Definition: meta.h:46
spa_type_data_type
const struct spa_type_info spa_type_data_type[]
Definition: buffer/type-info.h:52
types.h
spa_meta_header::seq
uint64_t seq
sequence number, increments with a media specific frequency
Definition: meta.h:86
spa_point::x
int32_t x
Definition: defs.h:93
SPA_META_VideoCrop
@ SPA_META_VideoCrop
struct spa_meta_region with cropping data
Definition: meta.h:43
SPA_META_VideoDamage
@ SPA_META_VideoDamage
array of struct spa_meta_region with damage
Definition: meta.h:44
spa_region::size
struct spa_rectangle size
Definition: defs.h:100
spa_chunk::stride
int32_t stride
stride of valid data
Definition: buffer/buffer.h:63
type-info.h
spa_rectangle::height
uint32_t height
Definition: defs.h:88
spa_debug
#define spa_debug(...)
Definition: debug/buffer.h:46
spa_meta_header::dts_offset
int64_t dts_offset
decoding timestamp as a difference with pts
Definition: meta.h:85
spa_data::flags
uint32_t flags
data flags
Definition: buffer/buffer.h:84
spa_chunk::offset
uint32_t offset
offset of valid data.
Definition: buffer/buffer.h:58
spa_meta_region::region
struct spa_region region
Definition: meta.h:92
spa_type_meta_type
const struct spa_type_info spa_type_meta_type[]
Definition: buffer/type-info.h:73
spa_meta_for_each
#define spa_meta_for_each(pos, meta)
iterate all the items in a metadata
Definition: meta.h:98
spa_debug_mem
int spa_debug_mem(int indent, const void *data, size_t size)
Definition: build-12775836/doc/spa/debug/mem.h:43
spa_buffer
A Buffer.
Definition: buffer/buffer.h:93
spa_data::type
uint32_t type
memory type, one of enum spa_data_type, when allocating memory, the type contains a bitmask of allowe...
Definition: buffer/buffer.h:71
buffer
Definition: filter.c:59
spa_meta_header
Describes essential buffer header metadata such as flags and timestamps.
Definition: meta.h:75
spa_meta
A metadata element.
Definition: meta.h:61
spa_data::chunk
struct spa_chunk * chunk
valid chunk of memory
Definition: buffer/buffer.h:89
spa_meta::type
uint32_t type
metadata type, one of enum spa_meta_type
Definition: meta.h:62
spa_meta_region
metadata structure for Region or an array of these for RegionArray
Definition: meta.h:91
spa_meta_header::pts
int64_t pts
presentation timestamp
Definition: meta.h:84
SPA_META_Bitmap
@ SPA_META_Bitmap
struct spa_meta_bitmap
Definition: meta.h:45
spa_data::mapoffset
uint32_t mapoffset
offset to map fd at
Definition: buffer/buffer.h:86
spa_chunk::size
uint32_t size
size of valid data.
Definition: buffer/buffer.h:61
spa_data
Data for a buffer this stays constant for a buffer.
Definition: buffer/buffer.h:70
mem.h
spa_meta::size
uint32_t size
size of metadata
Definition: meta.h:63
spa_data::fd
int64_t fd
optional fd for data
Definition: buffer/buffer.h:85
spa_data::data
void * data
optional data pointer
Definition: buffer/buffer.h:88
spa_meta_header::flags
uint32_t flags
flags
Definition: meta.h:82
SPA_META_Header
@ SPA_META_Header
struct spa_meta_header
Definition: meta.h:42
spa_meta_header::offset
uint32_t offset
offset in current cycle
Definition: meta.h:83
spa_point::y
int32_t y
Definition: defs.h:94
spa_region::position
struct spa_point position
Definition: defs.h:99
spa_debug_type_find_name
const char * spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type)
Definition: types.h:68