Browse Source

redis support functions

git.mgm/mediaproxy-ng/2.2
Richard Fuchs 13 years ago
parent
commit
8d3b8e310a
2 changed files with 21 additions and 5 deletions
  1. +11
    -0
      daemon/call.c
  2. +10
    -5
      daemon/call.h

+ 11
- 0
daemon/call.c View File

@ -1153,6 +1153,17 @@ static void relays_cache_init(struct relays_cache *c) {
c->array_ptrs[1] = c->relays_B;
}
int relays_cache_want_ports(struct relays_cache *c, int portA, int portB, struct call *call) {
if (c->relays_open + 2 > ARRAY_SIZE(c->relays_A))
return -1;
if (get_consecutive_ports(&c->relays_A[c->relays_open], 2, portA, call))
return -1;
if (get_consecutive_ports(&c->relays_B[c->relays_open], 2, portB, call))
return -1;
c->relays_open += 2;
return 0;
}
static int relays_cache_get_ports(struct relays_cache *c, int num, struct call *call) {
num *= 2;
if (c->relays_open >= num)


+ 10
- 5
daemon/call.h View File

@ -166,6 +166,7 @@ struct callstream *callstream_new(struct call *ca, int num);
void callstream_init(struct callstream *s, struct relays_cache *);
void kernelize(struct callstream *c);
int call_stream_address(char *o, struct peer *p, enum stream_address_format format, int *len);
int relays_cache_want_ports(struct relays_cache *c, int portA, int portB, struct call *call);
static inline char *call_strdup(struct call *c, const char *s) {
char *r;
@ -176,19 +177,23 @@ static inline char *call_strdup(struct call *c, const char *s) {
mutex_unlock(&c->chunk_lock);
return r;
}
static inline str *call_str_cpy(struct call *c, str *out, const str *in) {
static inline str *call_str_cpy_len(struct call *c, str *out, const char *in, int len) {
if (!in) {
*out = STR_NULL;
return out;
}
*out = *in;
if (!in->s)
return out;
mutex_lock(&c->chunk_lock);
out->s = g_string_chunk_insert_len(c->chunk, in->s, in->len);
out->s = g_string_chunk_insert_len(c->chunk, in, len);
mutex_unlock(&c->chunk_lock);
out->len = len;
return out;
}
static inline str *call_str_cpy(struct call *c, str *out, const str *in) {
return call_str_cpy_len(c, out, in ? in->s : NULL, in ? in->len : 0);
}
static inline str *call_str_cpy_c(struct call *c, str *out, const char *in) {
return call_str_cpy_len(c, out, in, in ? strlen(in) : 0);
}
static inline str *call_str_dup(struct call *c, const str *in) {
str *out;
mutex_lock(&c->chunk_lock);


Loading…
Cancel
Save