PipeWire: spa/debug/buffer.h Source File

PipeWire 1.4.2 |

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