PipeWire: buffer.h Source File

PipeWire 0.3.71

Loading...
Searching...
No Matches
debug/buffer.h
Go to the documentation of this file.
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_DEBUG_BUFFER_H
6#define SPA_DEBUG_BUFFER_H
7
8#ifdef __cplusplus
9extern "C" {
10#endif
11
21#include <spa/debug/context.h>
22#include <spa/debug/mem.h>
23#include <spa/debug/types.h>
24#include <spa/buffer/type-info.h>
25
26static inline int spa_debugc_buffer(struct spa_debug_context *ctx, int indent, const struct spa_buffer *buffer)
27{
28 uint32_t i;
29
30 spa_debugc(ctx, "%*s" "struct spa_buffer %p:", indent, "", buffer);
31 spa_debugc(ctx, "%*s" " n_metas: %u (at %p)", indent, "", buffer->n_metas, buffer->metas);
32 for (i = 0; i < buffer->n_metas; i++) {
33 struct spa_meta *m = &buffer->metas[i];
34 const char *type_name;
35
36 type_name = spa_debug_type_find_name(spa_type_meta_type, m->type);
37 spa_debugc(ctx, "%*s" " meta %d: type %d (%s), data %p, size %d:", indent, "", i, m->type,
38 type_name, m->data, m->size);
39
40 switch (m->type) {
41 case SPA_META_Header:
42 {
43 struct spa_meta_header *h = (struct spa_meta_header*)m->data;
44 spa_debugc(ctx, "%*s" " struct spa_meta_header:", indent, "");
45 spa_debugc(ctx, "%*s" " flags: %08x", indent, "", h->flags);
46 spa_debugc(ctx, "%*s" " offset: %u", indent, "", h->offset);
47 spa_debugc(ctx, "%*s" " seq: %" PRIu64, indent, "", h->seq);
48 spa_debugc(ctx, "%*s" " pts: %" PRIi64, indent, "", h->pts);
49 spa_debugc(ctx, "%*s" " dts_offset: %" PRIi64, indent, "", h->dts_offset);
50 break;
51 }
52 case SPA_META_VideoCrop:
53 {
54 struct spa_meta_region *h = (struct spa_meta_region*)m->data;
55 spa_debugc(ctx, "%*s" " struct spa_meta_region:", indent, "");
56 spa_debugc(ctx, "%*s" " x: %d", indent, "", h->region.position.x);
57 spa_debugc(ctx, "%*s" " y: %d", indent, "", h->region.position.y);
58 spa_debugc(ctx, "%*s" " width: %d", indent, "", h->region.size.width);
59 spa_debugc(ctx, "%*s" " height: %d", indent, "", h->region.size.height);
60 break;
61 }
62 case SPA_META_VideoDamage:
63 {
64 struct spa_meta_region *h;
65 spa_meta_for_each(h, m) {
66 spa_debugc(ctx, "%*s" " struct spa_meta_region:", indent, "");
67 spa_debugc(ctx, "%*s" " x: %d", indent, "", h->region.position.x);
68 spa_debugc(ctx, "%*s" " y: %d", indent, "", h->region.position.y);
69 spa_debugc(ctx, "%*s" " width: %d", indent, "", h->region.size.width);
70 spa_debugc(ctx, "%*s" " height: %d", indent, "", h->region.size.height);
71 }
72 break;
73 }
74 case SPA_META_Bitmap:
75 break;
76 case SPA_META_Cursor:
77 break;
78 default:
79 spa_debugc(ctx, "%*s" " Unknown:", indent, "");
80 spa_debugc_mem(ctx, 5, m->data, m->size);
81 }
82 }
83 spa_debugc(ctx, "%*s" " n_datas: \t%u (at %p)", indent, "", buffer->n_datas, buffer->datas);
84 for (i = 0; i < buffer->n_datas; i++) {
85 struct spa_data *d = &buffer->datas[i];
86 spa_debugc(ctx, "%*s" " type: %d (%s)", indent, "", d->type,
87 spa_debug_type_find_name(spa_type_data_type, d->type));
88 spa_debugc(ctx, "%*s" " flags: %d", indent, "", d->flags);
89 spa_debugc(ctx, "%*s" " data: %p", indent, "", d->data);
90 spa_debugc(ctx, "%*s" " fd: %" PRIi64, indent, "", d->fd);
91 spa_debugc(ctx, "%*s" " offset: %d", indent, "", d->mapoffset);
92 spa_debugc(ctx, "%*s" " maxsize: %u", indent, "", d->maxsize);
93 spa_debugc(ctx, "%*s" " chunk: %p", indent, "", d->chunk);
94 spa_debugc(ctx, "%*s" " offset: %d", indent, "", d->chunk->offset);
95 spa_debugc(ctx, "%*s" " size: %u", indent, "", d->chunk->size);
96 spa_debugc(ctx, "%*s" " stride: %d", indent, "", d->chunk->stride);
97 }
98 return 0;
99}
100
101static inline int spa_debug_buffer(int indent, const struct spa_buffer *buffer)
102{
103 return spa_debugc_buffer(NULL, indent, buffer);
104}
109#ifdef __cplusplus
110} /* extern "C" */
111#endif
112
113#endif /* SPA_DEBUG_BUFFER_H */
type-info.h
spa/buffer/type-info.h
spa_type_data_type
static const struct spa_type_info spa_type_data_type[]
Definition buffer/type-info.h:43
spa_meta_for_each
#define spa_meta_for_each(pos, meta)
iterate all the items in a metadata
Definition meta.h:99
spa_type_meta_type
static const struct spa_type_info spa_type_meta_type[]
Definition buffer/type-info.h:72
SPA_META_VideoDamage
@ 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:29
SPA_META_Bitmap
@ SPA_META_Bitmap
struct spa_meta_bitmap
Definition meta.h:30
SPA_META_Cursor
@ SPA_META_Cursor
struct spa_meta_cursor
Definition meta.h:31
SPA_META_VideoCrop
@ SPA_META_VideoCrop
struct spa_meta_region with cropping data
Definition meta.h:28
SPA_META_Header
@ SPA_META_Header
struct spa_meta_header
Definition meta.h:27
spa_debug_buffer
static int spa_debug_buffer(int indent, const struct spa_buffer *buffer)
Definition debug/buffer.h:106
spa_debugc
#define spa_debugc(_c, _fmt,...)
Definition spa/include/spa/debug/context.h:37
spa_debug_type_find_name
static const char * spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type)
Definition types.h:53
spa_debugc_buffer
static int spa_debugc_buffer(struct spa_debug_context *ctx, int indent, const struct spa_buffer *buffer)
Definition debug/buffer.h:31
spa_debugc_mem
static int spa_debugc_mem(struct spa_debug_context *ctx, int indent, const void *data, size_t size)
Definition spa/include/spa/debug/mem.h:26
context.h
spa/debug/context.h
mem.h
spa/debug/mem.h
spa_buffer
A Buffer.
Definition buffer/buffer.h:90
spa_buffer::n_metas
uint32_t n_metas
number of metadata
Definition buffer/buffer.h:91
spa_buffer::metas
struct spa_meta * metas
array of metadata
Definition buffer/buffer.h:93
spa_buffer::datas
struct spa_data * datas
array of data members
Definition buffer/buffer.h:94
spa_buffer::n_datas
uint32_t n_datas
number of data members
Definition buffer/buffer.h:92
spa_chunk::stride
int32_t stride
stride of valid data
Definition buffer/buffer.h:49
spa_chunk::size
uint32_t size
size of valid data.
Definition buffer/buffer.h:47
spa_chunk::offset
uint32_t offset
offset of valid data.
Definition buffer/buffer.h:44
spa_data
Data for a buffer this stays constant for a buffer.
Definition buffer/buffer.h:62
spa_data::chunk
struct spa_chunk * chunk
valid chunk of memory
Definition buffer/buffer.h:86
spa_data::fd
int64_t fd
optional fd for data
Definition buffer/buffer.h:82
spa_data::mapoffset
uint32_t mapoffset
offset to map fd at
Definition buffer/buffer.h:83
spa_data::flags
uint32_t flags
data flags
Definition buffer/buffer.h:81
spa_data::data
void * data
optional data pointer
Definition buffer/buffer.h:85
spa_data::maxsize
uint32_t maxsize
max size of data
Definition buffer/buffer.h:84
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:63
spa_debug_context
Definition spa/include/spa/debug/context.h:33
spa_meta_header
Describes essential buffer header metadata such as flags and timestamps.
Definition meta.h:67
spa_meta_region
metadata structure for Region or an array of these for RegionArray
Definition meta.h:89
spa_meta_region::region
struct spa_region region
Definition meta.h:90
spa_meta
A metadata element.
Definition meta.h:47
spa_meta::size
uint32_t size
size of metadata
Definition meta.h:49
spa_meta::type
uint32_t type
metadata type, one of enum spa_meta_type
Definition meta.h:48
spa_meta::data
void * data
pointer to metadata
Definition meta.h:50
spa_point::y
int32_t y
Definition defs.h:111
spa_point::x
int32_t x
Definition defs.h:110
spa_rectangle::width
uint32_t width
Definition defs.h:103
spa_rectangle::height
uint32_t height
Definition defs.h:104
spa_region::position
struct spa_point position
Definition defs.h:117
spa_region::size
struct spa_rectangle size
Definition defs.h:118
types.h
spa/debug/types.h