Skip to content

Commit e26a87c

Browse files
authored
rtpext: add rtpext_find (#1282)
Finds an RTP extension by its ID within an array of RTP extensions
1 parent 3314393 commit e26a87c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

include/re_rtpext.h

+2
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,5 @@ int rtpext_encode_long(struct mbuf *mb, uint8_t id, uint8_t len,
4141
const uint8_t *data);
4242
int rtpext_decode(struct rtpext *ext, struct mbuf *mb);
4343
int rtpext_decode_long(struct rtpext *ext, struct mbuf *mb);
44+
const struct rtpext *rtpext_find(const struct rtpext *extv, size_t extc,
45+
uint8_t id);

src/rtpext/rtpext.c

+23
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,26 @@ int rtpext_decode_long(struct rtpext *ext, struct mbuf *mb)
248248

249249
return 0;
250250
}
251+
252+
253+
/**
254+
* Finds an RTP extension by its ID
255+
*
256+
* @param extv Pointer to an array of RTP extensions
257+
* @param extc Number of elements in the RTP extension array
258+
* @param id The ID of the RTP extension to find
259+
*
260+
* @return Pointer to the matching RTP extension on success, otherwise NULL
261+
*/
262+
const struct rtpext *rtpext_find(const struct rtpext *extv, size_t extc,
263+
uint8_t id)
264+
{
265+
for (size_t i = 0; i < extc; i++) {
266+
const struct rtpext *rtpext = &extv[i];
267+
268+
if (rtpext->id == id)
269+
return rtpext;
270+
}
271+
272+
return NULL;
273+
}

0 commit comments

Comments
 (0)