PipeWire: spa/debug/buffer.h Source File

PipeWire 0.3.51

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/log.h>
42#include <spa/debug/mem.h>
43#include <spa/debug/types.h>
44#include <spa/buffer/type-info.h>
45
46static inline int spa_debug_buffer(int indent, const struct spa_buffer *buffer)
47{
48 uint32_t i;
49
50 spa_debug("%*s" "struct spa_buffer %p:", indent, "", buffer);
51 spa_debug("%*s" " n_metas: %u (at %p)", indent, "", buffer->n_metas, buffer->metas);
52 for (i = 0; i < buffer->n_metas; i++) {
53 struct spa_meta *m = &buffer->metas[i];
54 const char *type_name;
55
56 type_name = spa_debug_type_find_name(spa_type_meta_type, m->type);
57 spa_debug("%*s" " meta %d: type %d (%s), data %p, size %d:", indent, "", i, m->type,
58 type_name, m->data, m->size);
59
60 switch (m->type) {
61 case SPA_META_Header:
62 {
63 struct spa_meta_header *h = (struct spa_meta_header*)m->data;
64 spa_debug("%*s" " struct spa_meta_header:", indent, "");
65 spa_debug("%*s" " flags: %08x", indent, "", h->flags);
66 spa_debug("%*s" " offset: %u", indent, "", h->offset);
67 spa_debug("%*s" " seq: %" PRIu64, indent, "", h->seq);
68 spa_debug("%*s" " pts: %" PRIi64, indent, "", h->pts);
69 spa_debug("%*s" " dts_offset: %" PRIi64, indent, "", h->dts_offset);
70 break;
71 }
72 case SPA_META_VideoCrop:
73 {
74 struct spa_meta_region *h = (struct spa_meta_region*)m->data;
75 spa_debug("%*s" " struct spa_meta_region:", indent, "");
76 spa_debug("%*s" " x: %d", indent, "", h->region.position.x);
77 spa_debug("%*s" " y: %d", indent, "", h->region.position.y);
78 spa_debug("%*s" " width: %d", indent, "", h->region.size.width);
79 spa_debug("%*s" " height: %d", indent, "", h->region.size.height);
80 break;
81 }
82 case SPA_META_VideoDamage:
83 {
84 struct spa_meta_region *h;
85 spa_meta_for_each(h, m) {
86 spa_debug("%*s" " struct spa_meta_region:", indent, "");
87 spa_debug("%*s" " x: %d", indent, "", h->region.position.x);
88 spa_debug("%*s" " y: %d", indent, "", h->region.position.y);
89 spa_debug("%*s" " width: %d", indent, "", h->region.size.width);
90 spa_debug("%*s" " height: %d", indent, "", h->region.size.height);
91 }
92 break;
93 }
94 case SPA_META_Bitmap:
95 break;
96 case SPA_META_Cursor:
97 break;
98 default:
99 spa_debug("%*s" " Unknown:", indent, "");
100 spa_debug_mem(5, m->data, m->size);
101 }
102 }
103 spa_debug("%*s" " n_datas: \t%u (at %p)", indent, "", buffer->n_datas, buffer->datas);
104 for (i = 0; i < buffer->n_datas; i++) {
105 struct spa_data *d = &buffer->datas[i];
106 spa_debug("%*s" " type: %d (%s)", indent, "", d->type,
107 spa_debug_type_find_name(spa_type_data_type, d->type));
108 spa_debug("%*s" " flags: %d", indent, "", d->flags);
109 spa_debug("%*s" " data: %p", indent, "", d->data);
110 spa_debug("%*s" " fd: %" PRIi64, indent, "", d->fd);
111 spa_debug("%*s" " offset: %d", indent, "", d->mapoffset);
112 spa_debug("%*s" " maxsize: %u", indent, "", d->maxsize);
113 spa_debug("%*s" " chunk: %p", indent, "", d->chunk);
114 spa_debug("%*s" " offset: %d", indent, "", d->chunk->offset);
115 spa_debug("%*s" " size: %u", indent, "", d->chunk->size);
116 spa_debug("%*s" " stride: %d", indent, "", d->chunk->stride);
117 }
118 return 0;
119}
120
125#ifdef __cplusplus
126} /* extern "C" */
127#endif
128
129#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:63
spa_meta_for_each
#define spa_meta_for_each(pos, meta)
iterate all the items in a metadata
Definition: meta.h:109
spa_type_meta_type
static const struct spa_type_info spa_type_meta_type[]
Definition: type-info.h:92
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:49
SPA_META_Bitmap
@ SPA_META_Bitmap
struct spa_meta_bitmap
Definition: meta.h:50
SPA_META_Cursor
@ SPA_META_Cursor
struct spa_meta_cursor
Definition: meta.h:51
SPA_META_VideoCrop
@ SPA_META_VideoCrop
struct spa_meta_region with cropping data
Definition: meta.h:48
SPA_META_Header
@ SPA_META_Header
struct spa_meta_header
Definition: meta.h:47
spa_debug_buffer
static int spa_debug_buffer(int indent, const struct spa_buffer *buffer)
Definition: buffer.h:51
spa_debug
#define spa_debug(fmt,...)
Definition: log.h:44
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:73
spa_debug_mem
static int spa_debug_mem(int indent, const void *data, size_t size)
Definition: mem.h:46
log.h
spa/debug/log.h
mem.h
spa/debug/mem.h
spa_buffer
A Buffer.
Definition: buffer.h:105
spa_buffer::n_metas
uint32_t n_metas
number of metadata
Definition: buffer.h:106
spa_buffer::metas
struct spa_meta * metas
array of metadata
Definition: buffer.h:108
spa_buffer::datas
struct spa_data * datas
array of data members
Definition: buffer.h:109
spa_buffer::n_datas
uint32_t n_datas
number of data members
Definition: buffer.h:107
spa_chunk::stride
int32_t stride
stride of valid data
Definition: buffer.h:68
spa_chunk::size
uint32_t size
size of valid data.
Definition: buffer.h:66
spa_chunk::offset
uint32_t offset
offset of valid data.
Definition: buffer.h:63
spa_data
Data for a buffer this stays constant for a buffer.
Definition: buffer.h:77
spa_data::chunk
struct spa_chunk * chunk
valid chunk of memory
Definition: buffer.h:101
spa_data::fd
int64_t fd
optional fd for data
Definition: buffer.h:97
spa_data::mapoffset
uint32_t mapoffset
offset to map fd at
Definition: buffer.h:98
spa_data::flags
uint32_t flags
data flags
Definition: buffer.h:96
spa_data::data
void * data
optional data pointer
Definition: buffer.h:100
spa_data::maxsize
uint32_t maxsize
max size of data
Definition: buffer.h:99
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:78
spa_meta_header
Describes essential buffer header metadata such as flags and timestamps.
Definition: meta.h:80
spa_meta_header::offset
uint32_t offset
offset in current cycle
Definition: meta.h:94
spa_meta_header::flags
uint32_t flags
flags
Definition: meta.h:93
spa_meta_header::seq
uint64_t seq
sequence number, increments with a media specific frequency
Definition: meta.h:97
spa_meta_header::pts
int64_t pts
presentation timestamp in nanoseconds
Definition: meta.h:95
spa_meta_header::dts_offset
int64_t dts_offset
decoding timestamp as a difference with pts
Definition: meta.h:96
spa_meta_region
metadata structure for Region or an array of these for RegionArray
Definition: meta.h:102
spa_meta_region::region
struct spa_region region
Definition: meta.h:103
spa_meta
A metadata element.
Definition: meta.h:66
spa_meta::size
uint32_t size
size of metadata
Definition: meta.h:68
spa_meta::type
uint32_t type
metadata type, one of enum spa_meta_type
Definition: meta.h:67
spa_meta::data
void * data
pointer to metadata
Definition: meta.h:69
spa_point::y
int32_t y
Definition: defs.h:109
spa_point::x
int32_t x
Definition: defs.h:108
spa_rectangle::width
uint32_t width
Definition: defs.h:101
spa_rectangle::height
uint32_t height
Definition: defs.h:102
spa_region::position
struct spa_point position
Definition: defs.h:115
spa_region::size
struct spa_rectangle size
Definition: defs.h:116
types.h
spa/debug/types.h