PipeWire  0.3.61
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/log.h>
42 #include <spa/debug/mem.h>
43 #include <spa/debug/types.h>
44 #include <spa/buffer/type-info.h>
45 
46 static 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 
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  }
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,
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 */
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:119
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:51
#define spa_debug(fmt,...)
Definition: log.h:44
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:46
spa/debug/log.h
spa/debug/mem.h
A Buffer.
Definition: buffer.h:109
uint32_t n_metas
number of metadata
Definition: buffer.h:110
struct spa_meta * metas
array of metadata
Definition: buffer.h:112
struct spa_data * datas
array of data members
Definition: buffer.h:113
uint32_t n_datas
number of data members
Definition: buffer.h:111
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:81
struct spa_chunk * chunk
valid chunk of memory
Definition: buffer.h:105
int64_t fd
optional fd for data
Definition: buffer.h:101
uint32_t mapoffset
offset to map fd at
Definition: buffer.h:102
uint32_t flags
data flags
Definition: buffer.h:100
void * data
optional data pointer
Definition: buffer.h:104
uint32_t maxsize
max size of data
Definition: buffer.h:103
uint32_t type
memory type, one of enum spa_data_type, when allocating memory, the type contains a bitmask of allowe...
Definition: buffer.h:82
Describes essential buffer header metadata such as flags and timestamps.
Definition: meta.h:87
uint32_t offset
offset in current cycle
Definition: meta.h:101
uint32_t flags
flags
Definition: meta.h:100
uint64_t seq
sequence number, increments with a media specific frequency
Definition: meta.h:104
int64_t pts
presentation timestamp in nanoseconds
Definition: meta.h:102
int64_t dts_offset
decoding timestamp as a difference with pts
Definition: meta.h:103
metadata structure for Region or an array of these for RegionArray
Definition: meta.h:109
struct spa_region region
Definition: meta.h:110
A metadata element.
Definition: meta.h:67
uint32_t size
size of metadata
Definition: meta.h:69
uint32_t type
metadata type, one of enum spa_meta_type
Definition: meta.h:68
void * data
pointer to metadata
Definition: meta.h:70
int32_t y
Definition: defs.h:127
int32_t x
Definition: defs.h:126
uint32_t width
Definition: defs.h:119
uint32_t height
Definition: defs.h:120
struct spa_point position
Definition: defs.h:133
struct spa_rectangle size
Definition: defs.h:134
spa/debug/types.h