mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
videotestsrc: add pattern property and snow pattern
This commit is contained in:
parent
5c56fbdfc2
commit
bc4893057b
2 changed files with 48 additions and 2 deletions
|
|
@ -249,11 +249,33 @@ draw_smpte_snow (DrawingData *dd)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_snow (DrawingData *dd)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
for (y = 0; y < dd->height; y++) {
|
||||
for (x = 0; x < dd->width; x++) {
|
||||
Pixel p;
|
||||
unsigned char r = rand ();
|
||||
|
||||
p.R = r;
|
||||
p.G = r;
|
||||
p.B = r;
|
||||
update_yuv (&p);
|
||||
dd->draw_pixel (dd, x, &p);
|
||||
}
|
||||
|
||||
next_line (dd);
|
||||
}
|
||||
}
|
||||
|
||||
static SpaResult
|
||||
draw (SpaVideoTestSrc *this, char *data)
|
||||
{
|
||||
DrawingData dd;
|
||||
SpaResult res;
|
||||
uint32_t pattern;
|
||||
|
||||
init_colors ();
|
||||
|
||||
|
|
@ -261,7 +283,13 @@ draw (SpaVideoTestSrc *this, char *data)
|
|||
if (res != SPA_RESULT_OK)
|
||||
return res;
|
||||
|
||||
draw_smpte_snow (&dd);
|
||||
pattern = this->props[1].pattern;
|
||||
if (pattern == pattern_val_smpte_snow)
|
||||
draw_smpte_snow (&dd);
|
||||
else if (pattern == pattern_val_snow)
|
||||
draw_snow (&dd);
|
||||
else
|
||||
return SPA_RESULT_NOT_IMPLEMENTED;
|
||||
|
||||
return res;
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ typedef struct _SpaVideoTestSrc SpaVideoTestSrc;
|
|||
typedef struct {
|
||||
SpaProps props;
|
||||
bool live;
|
||||
uint32_t pattern;
|
||||
} SpaVideoTestSrcProps;
|
||||
|
||||
#define MAX_BUFFERS 16
|
||||
|
|
@ -105,9 +106,19 @@ struct _SpaVideoTestSrc {
|
|||
#define CHECK_PORT(this,d,p) ((d) == SPA_DIRECTION_OUTPUT && (p) == 0)
|
||||
|
||||
#define DEFAULT_LIVE true
|
||||
#define DEFAULT_PATTERN 0
|
||||
|
||||
static const uint32_t pattern_val_smpte_snow = 0;
|
||||
static const uint32_t pattern_val_snow = 1;
|
||||
|
||||
static const SpaPropRangeInfo pattern_range[] = {
|
||||
{ "smpte-snow", { sizeof (uint32_t), &pattern_val_smpte_snow } },
|
||||
{ "snow", { sizeof (uint32_t), &pattern_val_snow } },
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_ID_LIVE,
|
||||
PROP_ID_PATTERN,
|
||||
PROP_ID_LAST,
|
||||
};
|
||||
|
||||
|
|
@ -119,12 +130,19 @@ static const SpaPropInfo prop_info[] =
|
|||
SPA_PROP_TYPE_BOOL, sizeof (bool),
|
||||
SPA_PROP_RANGE_TYPE_NONE, 0, NULL,
|
||||
NULL },
|
||||
{ PROP_ID_PATTERN, offsetof (SpaVideoTestSrcProps, pattern),
|
||||
"pattern",
|
||||
SPA_PROP_FLAG_READWRITE,
|
||||
SPA_PROP_TYPE_UINT32, sizeof (uint32_t),
|
||||
SPA_PROP_RANGE_TYPE_ENUM, SPA_N_ELEMENTS (pattern_range), pattern_range,
|
||||
NULL },
|
||||
};
|
||||
|
||||
static SpaResult
|
||||
reset_videotestsrc_props (SpaVideoTestSrcProps *props)
|
||||
{
|
||||
props->live = DEFAULT_LIVE;
|
||||
props->pattern = DEFAULT_PATTERN;
|
||||
|
||||
return SPA_RESULT_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue