[misc] Add media_quality struct for storing sample rate, bps and channels

This commit is contained in:
ejurgensen 2019-02-08 18:58:46 +01:00
parent ad77a42dbb
commit 462d787fab
2 changed files with 17 additions and 2 deletions

View File

@ -1039,6 +1039,11 @@ murmur_hash64(const void *key, int len, uint32_t seed)
# error Platform not supported
#endif
bool
quality_is_equal(struct media_quality *a, struct media_quality *b)
{
return (a->sample_rate == b->sample_rate && a->bits_per_sample == b->bits_per_sample && a->channels == b->channels);
}
bool
peer_address_is_trusted(const char *addr)

View File

@ -12,11 +12,18 @@
#include <pthread.h>
/* Samples to bytes, bytes to samples */
#define STOB(s) ((s) * 4)
#define BTOS(b) ((b) / 4)
#define STOB(s, bits, c) ((s) * (c) * (bits) / 8)
#define BTOS(b, bits, c) ((b) / ((c) * (bits) / 8))
#define ARRAY_SIZE(x) ((unsigned int)(sizeof(x) / sizeof((x)[0])))
// Remember to adjust quality_is_equal() if adding elements
struct media_quality {
int sample_rate;
int bits_per_sample;
int channels;
};
struct onekeyval {
char *name;
char *value;
@ -114,6 +121,9 @@ b64_encode(const uint8_t *in, size_t len);
uint64_t
murmur_hash64(const void *key, int len, uint32_t seed);
bool
quality_is_equal(struct media_quality *a, struct media_quality *b);
// Checks if the address is in a network that is configured as trusted
bool
peer_address_is_trusted(const char *addr);