Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions include/upipe/uref_attr.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012-2016 OpenHeadend S.A.R.L.
* Copyright (C) 2026 EasyTools
*
* Authors: Christophe Massiot
*
Expand Down Expand Up @@ -2187,6 +2188,24 @@ static inline int uref_##group##_copy_##attr(struct uref *uref, \
{ \
return uref_attr_copy_rational(uref, uref_src, UDICT_TYPE_RATIONAL, \
name); \
} \
/** @This compares the desc attribute in two urefs. \
* \
* @param uref1 pointer to the first uref \
* @param uref2 pointer to the second uref \
* @return 0 if both attributes are absent or identical \
*/ \
static inline int \
uref_##group##_cmp_##attr(struct uref *uref1, struct uref *uref2) \
{ \
struct urational v1, v2; \
int err1 = uref_##group##_get_##attr(uref1, &v1); \
int err2 = uref_##group##_get_##attr(uref2, &v2); \
if (!ubase_check(err1) && !ubase_check(err2)) \
return 0; \
if (!ubase_check(err1) || !ubase_check(err2)) \
return -1; \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should'nt that be INT64_MIN like in urational_cmp()? And should'nt the function returns int64_t instead?

return urational_cmp(&v1, &v2); \
}

/* @This allows to define accessors for a shorthand rational attribute.
Expand Down Expand Up @@ -2238,6 +2257,24 @@ static inline int uref_##group##_copy_##attr(struct uref *uref, \
struct uref *uref_src) \
{ \
return uref_attr_copy_rational(uref, uref_src, type, NULL); \
} \
/** @This compares the desc attribute in two urefs. \
* \
* @param uref1 pointer to the first uref \
* @param uref2 pointer to the second uref \
* @return 0 if both attributes are absent or identical \
*/ \
static inline int \
uref_##group##_cmp_##attr(struct uref *uref1, struct uref *uref2) \
{ \
struct urational v1, v2; \
int err1 = uref_##group##_get_##attr(uref1, &v1); \
int err2 = uref_##group##_get_##attr(uref2, &v2); \
if (!ubase_check(err1) && !ubase_check(err2)) \
return 0; \
if (!ubase_check(err1) || !ubase_check(err2)) \
return -1; \
return urational_cmp(&v1, &v2); \
}

/* @This allows to define accessors for a rational attribute, with a name
Expand Down
Loading