MT#56374 add convenience macros for string creation

... and use them in a few places where it makes sense

Change-Id: I849f2841990808de6f697c92e2760645286dacca
pull/1701/head
Richard Fuchs 2 years ago
parent 1de9aee92d
commit d9e682b7db

@ -171,13 +171,12 @@ static str *call_update_lookup_udp(char **out, enum call_opmode opmode, const ch
struct call_subscription *dialogue[2]; struct call_subscription *dialogue[2];
GQueue q = G_QUEUE_INIT; GQueue q = G_QUEUE_INIT;
struct stream_params sp; struct stream_params sp;
str *ret, callid, viabranch, fromtag, totag = STR_NULL; str *ret;
int i; int i;
str_init(&callid, out[RE_UDP_UL_CALLID]); str callid = STR_INIT(out[RE_UDP_UL_CALLID]);
str_init(&viabranch, out[RE_UDP_UL_VIABRANCH]); str fromtag = STR_INIT(out[RE_UDP_UL_FROMTAG]);
str_init(&fromtag, out[RE_UDP_UL_FROMTAG]); str totag = STR_INIT(out[RE_UDP_UL_TOTAG]);
str_init(&totag, out[RE_UDP_UL_TOTAG]);
if (opmode == OP_ANSWER) if (opmode == OP_ANSWER)
str_swap(&fromtag, &totag); str_swap(&fromtag, &totag);
@ -320,10 +319,10 @@ static str *call_request_lookup_tcp(char **out, enum call_opmode opmode) {
struct call *c; struct call *c;
struct call_subscription *dialogue[2]; struct call_subscription *dialogue[2];
AUTO_CLEANUP(GQueue s, sdp_streams_free) = G_QUEUE_INIT; AUTO_CLEANUP(GQueue s, sdp_streams_free) = G_QUEUE_INIT;
str *ret = NULL, callid, fromtag, totag = STR_NULL; str *ret = NULL;
GHashTable *infohash; GHashTable *infohash;
str_init(&callid, out[RE_TCP_RL_CALLID]); str callid = STR_INIT(out[RE_TCP_RL_CALLID]);
infohash = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); infohash = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
c = call_get_opmode(&callid, opmode); c = call_get_opmode(&callid, opmode);
if (!c) { if (!c) {
@ -333,12 +332,12 @@ static str *call_request_lookup_tcp(char **out, enum call_opmode opmode) {
info_parse(out[RE_TCP_RL_INFO], infohash); info_parse(out[RE_TCP_RL_INFO], infohash);
streams_parse(out[RE_TCP_RL_STREAMS], &s); streams_parse(out[RE_TCP_RL_STREAMS], &s);
str_init(&fromtag, g_hash_table_lookup(infohash, "fromtag")); str fromtag = STR_INIT(g_hash_table_lookup(infohash, "fromtag"));
if (!fromtag.s) { if (!fromtag.s) {
ilog(LOG_WARNING, "No from-tag in message"); ilog(LOG_WARNING, "No from-tag in message");
goto out2; goto out2;
} }
str_init(&totag, g_hash_table_lookup(infohash, "totag")); str totag = STR_INIT(g_hash_table_lookup(infohash, "totag"));
if (opmode == OP_ANSWER) { if (opmode == OP_ANSWER) {
if (!totag.s) { if (!totag.s) {
ilog(LOG_WARNING, "No to-tag in message"); ilog(LOG_WARNING, "No to-tag in message");
@ -373,15 +372,13 @@ str *call_lookup_tcp(char **out) {
} }
str *call_delete_udp(char **out) { str *call_delete_udp(char **out) {
str callid, branch, fromtag, totag;
__C_DBG("got delete for callid '%s' and viabranch '%s'", __C_DBG("got delete for callid '%s' and viabranch '%s'",
out[RE_UDP_DQ_CALLID], out[RE_UDP_DQ_VIABRANCH]); out[RE_UDP_DQ_CALLID], out[RE_UDP_DQ_VIABRANCH]);
str_init(&callid, out[RE_UDP_DQ_CALLID]); str callid = STR_INIT(out[RE_UDP_DQ_CALLID]);
str_init(&branch, out[RE_UDP_DQ_VIABRANCH]); str branch = STR_INIT(out[RE_UDP_DQ_VIABRANCH]);
str_init(&fromtag, out[RE_UDP_DQ_FROMTAG]); str fromtag = STR_INIT(out[RE_UDP_DQ_FROMTAG]);
str_init(&totag, out[RE_UDP_DQ_TOTAG]); str totag = STR_INIT(out[RE_UDP_DQ_TOTAG]);
if (call_delete_branch_by_id(&callid, &branch, &fromtag, &totag, NULL, -1)) if (call_delete_branch_by_id(&callid, &branch, &fromtag, &totag, NULL, -1))
return str_sprintf("%s E8\n", out[RE_UDP_COOKIE]); return str_sprintf("%s E8\n", out[RE_UDP_COOKIE]);
@ -390,14 +387,14 @@ str *call_delete_udp(char **out) {
} }
str *call_query_udp(char **out) { str *call_query_udp(char **out) {
AUTO_CLEANUP_NULL(struct call *c, call_unlock_release); AUTO_CLEANUP_NULL(struct call *c, call_unlock_release);
str *ret, callid, fromtag, totag; str *ret;
struct call_stats stats; struct call_stats stats;
__C_DBG("got query for callid '%s'", out[RE_UDP_DQ_CALLID]); __C_DBG("got query for callid '%s'", out[RE_UDP_DQ_CALLID]);
str_init(&callid, out[RE_UDP_DQ_CALLID]); str callid = STR_INIT(out[RE_UDP_DQ_CALLID]);
str_init(&fromtag, out[RE_UDP_DQ_FROMTAG]); str fromtag = STR_INIT(out[RE_UDP_DQ_FROMTAG]);
str_init(&totag, out[RE_UDP_DQ_TOTAG]); str totag = STR_INIT(out[RE_UDP_DQ_TOTAG]);
c = call_get_opmode(&callid, OP_OTHER); c = call_get_opmode(&callid, OP_OTHER);
if (!c) { if (!c) {
@ -424,9 +421,7 @@ out:
} }
void call_delete_tcp(char **out) { void call_delete_tcp(char **out) {
str callid; str callid = STR_INIT(out[RE_TCP_D_CALLID]);
str_init(&callid, out[RE_TCP_D_CALLID]);
call_delete_branch_by_id(&callid, NULL, NULL, NULL, NULL, -1); call_delete_branch_by_id(&callid, NULL, NULL, NULL, NULL, -1);
} }

@ -2204,8 +2204,7 @@ static int packet_dtmf(struct codec_ssrc_handler *ch, struct codec_ssrc_handler
// provide an uninitialised buffer as potential output storage for DTMF // provide an uninitialised buffer as potential output storage for DTMF
char buf[sizeof(struct telephone_event_payload)]; char buf[sizeof(struct telephone_event_payload)];
str ev_pl; str ev_pl = STR_INIT_LEN(buf, sizeof(buf));
str_init_len(&ev_pl, buf, sizeof(buf));
int is_dtmf = dtmf_event_payload(&ev_pl, &ts, duration, int is_dtmf = dtmf_event_payload(&ev_pl, &ts, duration,
&input_ch->dtmf_event, &input_ch->dtmf_events); &input_ch->dtmf_event, &input_ch->dtmf_events);
@ -3865,8 +3864,7 @@ void packet_encoded_packetize(AVPacket *pkt, struct codec_ssrc_handler *ch, stru
char *buf = malloc(pkt_len); char *buf = malloc(pkt_len);
char *payload = buf + sizeof(struct rtp_header); char *payload = buf + sizeof(struct rtp_header);
// tell our packetizer how much we want // tell our packetizer how much we want
str inout; str inout = STR_INIT_LEN(payload, payload_len);
str_init_len(&inout, payload, payload_len);
// and request a packet // and request a packet
if (in_pkt) if (in_pkt)
ilogs(transcoding, LOG_DEBUG, "Adding %i bytes to packetizer", in_pkt->size); ilogs(transcoding, LOG_DEBUG, "Adding %i bytes to packetizer", in_pkt->size);
@ -4643,8 +4641,7 @@ void codec_tracker_update(struct codec_store *cs) {
ilogs(codec, LOG_DEBUG, "Adding supplemental codec " STR_FORMAT " for clock rate %u", STR_FMT(supp_codec), clockrate); ilogs(codec, LOG_DEBUG, "Adding supplemental codec " STR_FORMAT " for clock rate %u", STR_FMT(supp_codec), clockrate);
char *pt_s = g_strdup_printf(STR_FORMAT "/%u", STR_FMT(supp_codec), clockrate); char *pt_s = g_strdup_printf(STR_FORMAT "/%u", STR_FMT(supp_codec), clockrate);
str pt_str; str pt_str = STR_INIT(pt_s);
str_init(&pt_str, pt_s);
struct rtp_payload_type *pt = codec_add_payload_type(&pt_str, cs->media, NULL, NULL); struct rtp_payload_type *pt = codec_add_payload_type(&pt_str, cs->media, NULL, NULL);
if (!pt) if (!pt)

@ -99,8 +99,7 @@ static struct call_monologue *janus_get_monologue(uint64_t handle_id, struct cal
{ {
AUTO_CLEANUP_GBUF(handle_buf); AUTO_CLEANUP_GBUF(handle_buf);
handle_buf = g_strdup_printf("%" PRIu64, handle_id); handle_buf = g_strdup_printf("%" PRIu64, handle_id);
str handle_str; str handle_str = STR_INIT(handle_buf);
str_init(&handle_str, handle_buf);
return fn(call, &handle_str); return fn(call, &handle_str);
} }
@ -844,8 +843,7 @@ static const char *janus_videoroom_configure(struct websocket_message *wm, struc
if (strcmp(jsep_type, "offer")) if (strcmp(jsep_type, "offer"))
return "Not an offer"; return "Not an offer";
AUTO_CLEANUP(str sdp_in, str_free_dup) = STR_NULL; AUTO_CLEANUP(str sdp_in, str_free_dup) = STR_INIT_DUP(jsep_sdp);
str_init_dup(&sdp_in, jsep_sdp);
AUTO_CLEANUP(struct sdp_ng_flags flags, call_ng_free_flags); AUTO_CLEANUP(struct sdp_ng_flags flags, call_ng_free_flags);
AUTO_CLEANUP(GQueue parsed, sdp_free) = G_QUEUE_INIT; AUTO_CLEANUP(GQueue parsed, sdp_free) = G_QUEUE_INIT;
@ -949,8 +947,7 @@ static const char *janus_videoroom_start(struct websocket_message *wm, struct ja
if (strcmp(jsep_type, "answer")) if (strcmp(jsep_type, "answer"))
return "Not an answer"; return "Not an answer";
AUTO_CLEANUP(str sdp_in, str_free_dup) = STR_NULL; AUTO_CLEANUP(str sdp_in, str_free_dup) = STR_INIT_DUP(jsep_sdp);
str_init_dup(&sdp_in, jsep_sdp);
AUTO_CLEANUP(struct sdp_ng_flags flags, call_ng_free_flags); AUTO_CLEANUP(struct sdp_ng_flags flags, call_ng_free_flags);
AUTO_CLEANUP(GQueue parsed, sdp_free) = G_QUEUE_INIT; AUTO_CLEANUP(GQueue parsed, sdp_free) = G_QUEUE_INIT;
@ -1080,8 +1077,7 @@ static const char *janus_videoroom(struct websocket_message *wm, struct janus_se
const char *req = json_reader_get_string_value(reader); const char *req = json_reader_get_string_value(reader);
if (!req) if (!req)
goto err; goto err;
str req_str; str req_str = STR_INIT((char*) req);
str_init(&req_str, (char *) req);
json_reader_end_member(reader); json_reader_end_member(reader);
switch (__csh_lookup(&req_str)) { switch (__csh_lookup(&req_str)) {
@ -1786,8 +1782,7 @@ static const char *websocket_janus_process_json(struct websocket_message *wm,
ilog(LOG_DEBUG, "Processing '%s' type Janus message", janus_cmd); ilog(LOG_DEBUG, "Processing '%s' type Janus message", janus_cmd);
str janus_cmd_str; str janus_cmd_str = STR_INIT((char*) janus_cmd);
str_init(&janus_cmd_str, (char *) janus_cmd);
err = NULL; err = NULL;
@ -1900,8 +1895,7 @@ const char *websocket_janus_process(struct websocket_message *wm) {
const char *websocket_janus_get(struct websocket_message *wm) { const char *websocket_janus_get(struct websocket_message *wm) {
str uri; str uri = STR_INIT(wm->uri);
str_init(&uri, wm->uri);
ilog(LOG_DEBUG, "Processing Janus GET: '%s'", wm->uri); ilog(LOG_DEBUG, "Processing Janus GET: '%s'", wm->uri);
@ -1934,8 +1928,7 @@ const char *websocket_janus_get(struct websocket_message *wm) {
const char *websocket_janus_post(struct websocket_message *wm) { const char *websocket_janus_post(struct websocket_message *wm) {
str uri; str uri = STR_INIT(wm->uri);
str_init(&uri, wm->uri);
ilog(LOG_DEBUG, "Processing Janus POST: '%s'", wm->uri); ilog(LOG_DEBUG, "Processing Janus POST: '%s'", wm->uri);

@ -1172,8 +1172,7 @@ success:;
goto err; goto err;
} }
str blob; str blob = STR_INIT_LEN(row[0], lengths[0]);
str_init_len(&blob, row[0], lengths[0]);
int ret = media_player_play_blob_id(mp, &blob, repeat, start_pos, id); int ret = media_player_play_blob_id(mp, &blob, repeat, start_pos, id);
mysql_free_result(res); mysql_free_result(res);

@ -2155,8 +2155,7 @@ static void restore_thread(void *call_p, void *ctx_p) {
struct thread_ctx *ctx = ctx_p; struct thread_ctx *ctx = ctx_p;
redisReply *call = call_p; redisReply *call = call_p;
struct redis *r; struct redis *r;
str callid; str callid = STR_INIT_LEN(call->str, call->len);
str_init_len(&callid, call->str, call->len);
rlog(LOG_DEBUG, "Processing call ID '%s%.*s%s' from Redis", FMT_M(REDIS_FMT(call))); rlog(LOG_DEBUG, "Processing call ID '%s%.*s%s' from Redis", FMT_M(REDIS_FMT(call)));

@ -556,11 +556,9 @@ static int rtcp_rr(struct rtcp_chain_element *el, struct rtcp_process_ctx *log_c
} }
static int rtcp_sdes(struct rtcp_chain_element *el, struct rtcp_process_ctx *log_ctx) { static int rtcp_sdes(struct rtcp_chain_element *el, struct rtcp_process_ctx *log_ctx) {
str comp_s;
CAH(sdes_list_start, el->u.sdes); CAH(sdes_list_start, el->u.sdes);
str_init_len(&comp_s, (void *) el->u.sdes->chunks, el->len - sizeof(el->u.sdes->header)); str comp_s = STR_INIT_LEN((void *) el->u.sdes->chunks, el->len - sizeof(el->u.sdes->header));
int i = 0; int i = 0;
while (1) { while (1) {
struct sdes_chunk *sdes_chunk = (struct sdes_chunk *) comp_s.s; struct sdes_chunk *sdes_chunk = (struct sdes_chunk *) comp_s.s;
@ -618,8 +616,7 @@ static void xr_voip_metrics(struct xr_rb_voip_metrics *rb, struct rtcp_process_c
static int rtcp_xr(struct rtcp_chain_element *el, struct rtcp_process_ctx *log_ctx) { static int rtcp_xr(struct rtcp_chain_element *el, struct rtcp_process_ctx *log_ctx) {
CAH(common, el->u.rtcp_packet); CAH(common, el->u.rtcp_packet);
str comp_s; str comp_s = STR_INIT_LEN(el->u.buf + sizeof(el->u.xr->rtcp), el->len - sizeof(el->u.xr->rtcp));
str_init_len(&comp_s, el->u.buf + sizeof(el->u.xr->rtcp), el->len - sizeof(el->u.xr->rtcp));
while (1) { while (1) {
struct xr_report_block *rb = (void *) comp_s.s; struct xr_report_block *rb = (void *) comp_s.s;
if (comp_s.len < sizeof(*rb)) if (comp_s.len < sizeof(*rb))
@ -1600,14 +1597,14 @@ void rtcp_send_report(struct call_media *media, struct ssrc_ctx *ssrc_out) {
// handle crypto // handle crypto
str rtcp_packet = STR_CONST_INIT_LEN(sr->str, sr->len); str rtcp_packet = STR_INIT_LEN(sr->str, sr->len);
const struct streamhandler *crypt_handler = determine_handler(&transport_protocols[PROTO_RTP_AVP], const struct streamhandler *crypt_handler = determine_handler(&transport_protocols[PROTO_RTP_AVP],
media, true); media, true);
if (crypt_handler && crypt_handler->out->rtcp_crypt) { if (crypt_handler && crypt_handler->out->rtcp_crypt) {
g_string_set_size(sr, sr->len + RTP_BUFFER_TAIL_ROOM); g_string_set_size(sr, sr->len + RTP_BUFFER_TAIL_ROOM);
rtcp_packet = STR_CONST_INIT_LEN(sr->str, sr->len - RTP_BUFFER_TAIL_ROOM); rtcp_packet = STR_INIT_LEN(sr->str, sr->len - RTP_BUFFER_TAIL_ROOM);
crypt_handler->out->rtcp_crypt(&rtcp_packet, ps, ssrc_out); crypt_handler->out->rtcp_crypt(&rtcp_packet, ps, ssrc_out);
} }

@ -1216,8 +1216,7 @@ int sdp_parse(str *body, GQueue *sessions, const struct sdp_ng_flags *flags) {
goto new_session; // allowed for trickle ICE SDP fragments goto new_session; // allowed for trickle ICE SDP fragments
} }
str value_str; str value_str = STR_INIT_LEN(value, line_end - value);
str_init_len(&value_str, value, line_end - value);
switch (b[0]) { switch (b[0]) {
case 'v': case 'v':
@ -2818,8 +2817,7 @@ const char *sdp_get_sendrecv(struct call_media *media) {
static void append_attr_to_gstring(GString *s, char * name, const str * value, static void append_attr_to_gstring(GString *s, char * name, const str * value,
struct sdp_ng_flags *flags, enum media_type media_type) struct sdp_ng_flags *flags, enum media_type media_type)
{ {
str attr; str attr = STR_INIT(name);
str_init(&attr, name);
struct sdp_manipulations *sdp_manipulations = sdp_manipulations_get_by_id(flags, media_type); struct sdp_manipulations *sdp_manipulations = sdp_manipulations_get_by_id(flags, media_type);
/* take into account SDP arbitrary manipulations */ /* take into account SDP arbitrary manipulations */
if (sdp_manipulate_remove(sdp_manipulations, &attr)) { if (sdp_manipulate_remove(sdp_manipulations, &attr)) {
@ -2842,8 +2840,7 @@ static void append_attr_to_gstring(GString *s, char * name, const str * value,
static void append_attr_int_to_gstring(GString *s, char * name, const int * value, static void append_attr_int_to_gstring(GString *s, char * name, const int * value,
struct sdp_ng_flags *flags, enum media_type media_type) struct sdp_ng_flags *flags, enum media_type media_type)
{ {
str attr; str attr = STR_INIT(name);
str_init(&attr, name);
struct sdp_manipulations *sdp_manipulations = sdp_manipulations_get_by_id(flags, media_type); struct sdp_manipulations *sdp_manipulations = sdp_manipulations_get_by_id(flags, media_type);
/* take into account SDP arbitrary manipulations */ /* take into account SDP arbitrary manipulations */
if (sdp_manipulate_remove(sdp_manipulations, &attr)) { if (sdp_manipulate_remove(sdp_manipulations, &attr)) {

@ -108,7 +108,7 @@ static int t38_gateway_handler(t38_core_state_t *stat, void *user_data, const ui
g_string_append_len(s, (void *) &seq, 2); g_string_append_len(s, (void *) &seq, 2);
// add primary IFP packet // add primary IFP packet
str buf = STR_CONST_INIT_LEN((char *) b, len); str buf = STR_INIT_LEN((char *) b, len);
__add_udptl(s, &buf); __add_udptl(s, &buf);
// add error correction packets // add error correction packets
@ -717,7 +717,7 @@ int t38_gateway_input_udptl(struct t38_gateway *tg, const str *buf) {
"packet with seq %i from FEC", "packet with seq %i from FEC",
seq_fec); seq_fec);
str rec_str = STR_CONST_INIT_LEN(rec_s->str, rec_s->len); str rec_str = STR_INIT_LEN(rec_s->str, rec_s->len);
__fec_save(tg, &rec_str, seq_fec); __fec_save(tg, &rec_str, seq_fec);
up = __make_udptl_packet(&rec_str, seq_fec); up = __make_udptl_packet(&rec_str, seq_fec);
packet_sequencer_insert(&tg->sequencer, &up->p); packet_sequencer_insert(&tg->sequencer, &up->p);

@ -432,8 +432,7 @@ static const char *websocket_http_cli(struct websocket_message *wm) {
ilogs(http, LOG_DEBUG, "Respoding to GET /cli/%s", uri); ilogs(http, LOG_DEBUG, "Respoding to GET /cli/%s", uri);
str uri_cmd; str uri_cmd = STR_INIT(uri);
str_init(&uri_cmd, uri);
struct cli_writer cw = { struct cli_writer cw = {
.cw_printf = websocket_queue_printf, .cw_printf = websocket_queue_printf,
@ -451,8 +450,7 @@ static const char *websocket_http_cli(struct websocket_message *wm) {
static const char *websocket_cli_process(struct websocket_message *wm) { static const char *websocket_cli_process(struct websocket_message *wm) {
ilogs(http, LOG_DEBUG, "Processing websocket CLI req '%s'", wm->body->str); ilogs(http, LOG_DEBUG, "Processing websocket CLI req '%s'", wm->body->str);
str uri_cmd; str uri_cmd = STR_INIT_LEN(wm->body->str, wm->body->len);
str_init_len(&uri_cmd, wm->body->str, wm->body->len);
struct cli_writer cw = { struct cli_writer cw = {
.cw_printf = websocket_queue_printf, .cw_printf = websocket_queue_printf,

@ -34,7 +34,9 @@ typedef struct _str str;
#define STR_NULL ((str) { NULL, 0 }) #define STR_NULL ((str) { NULL, 0 })
#define STR_EMPTY ((str) { "", 0 }) #define STR_EMPTY ((str) { "", 0 })
#define STR_CONST_INIT(s) ((str) { s, sizeof(s)-1 }) #define STR_CONST_INIT(s) ((str) { s, sizeof(s)-1 })
#define STR_CONST_INIT_LEN(s, len) ((str) { s, len }) #define STR_INIT(s) ((str) { s, (s) ? strlen(s) : 0 })
#define STR_INIT_LEN(s, len) ((str) { s, len })
#define STR_INIT_DUP(s) ((str) { g_strdup(s), strlen(s) })
#define STR_CONST_INIT_BUF(buf) ((str) { (char *) &buf, sizeof(buf) }) #define STR_CONST_INIT_BUF(buf) ((str) { (char *) &buf, sizeof(buf) })

@ -272,8 +272,7 @@ static void db_do_call_metadata(metafile_t *mf) {
my_ull(&b[0], &mf->db_id); // stays persistent my_ull(&b[0], &mf->db_id); // stays persistent
// XXX offload this parsing to proxy module -> bencode list/dictionary // XXX offload this parsing to proxy module -> bencode list/dictionary
str all_meta; str all_meta = STR_INIT(mf->metadata_db);
str_init(&all_meta, mf->metadata_db);
while (all_meta.len > 1) { while (all_meta.len > 1) {
str token; str token;
if (str_token_sep(&token, &all_meta, '|')) if (str_token_sep(&token, &all_meta, '|'))

@ -26,14 +26,13 @@ int resample_audio;
decode_t *decoder_new(const char *payload_str, const char *format, int ptime, output_t *outp) { decode_t *decoder_new(const char *payload_str, const char *format, int ptime, output_t *outp) {
str name;
char *slash = strchr(payload_str, '/'); char *slash = strchr(payload_str, '/');
if (!slash) { if (!slash) {
ilog(LOG_WARN, "Invalid payload format: %s", payload_str); ilog(LOG_WARN, "Invalid payload format: %s", payload_str);
return NULL; return NULL;
} }
str_init_len(&name, (char *) payload_str, slash - payload_str); str name = STR_INIT_LEN((char *) payload_str, slash - payload_str);
int clockrate = atoi(slash + 1); int clockrate = atoi(slash + 1);
if (clockrate <= 0) { if (clockrate <= 0) {
ilog(LOG_ERR, "Invalid clock rate %i (parsed from '%.20s'/'%.20s')", ilog(LOG_ERR, "Invalid clock rate %i (parsed from '%.20s'/'%.20s')",
@ -83,8 +82,7 @@ decode_t *decoder_new(const char *payload_str, const char *format, int ptime, ou
else else
out_format.format = AV_SAMPLE_FMT_S16; // needed for TLS-only scenarios out_format.format = AV_SAMPLE_FMT_S16; // needed for TLS-only scenarios
str fmtp; str fmtp = STR_INIT((char*) format);
str_init(&fmtp, (char *) format);
decoder_t *dec = decoder_new_fmtp(def, rtp_clockrate, channels, ptime, &out_format, NULL, &fmtp, NULL); decoder_t *dec = decoder_new_fmtp(def, rtp_clockrate, channels, ptime, &out_format, NULL, &fmtp, NULL);
if (!dec) if (!dec)

@ -366,8 +366,7 @@ void packet_process(stream_t *stream, unsigned char *buf, unsigned len) {
packet->buffer = buf; // handing it over packet->buffer = buf; // handing it over
// XXX more checking here // XXX more checking here
str bufstr; str bufstr = STR_INIT_LEN(packet->buffer, len);
str_init_len(&bufstr, packet->buffer, len);
packet->ip = (void *) bufstr.s; packet->ip = (void *) bufstr.s;
// XXX kernel already does this - add metadata? // XXX kernel already does this - add metadata?
if (packet->ip->version == 4) { if (packet->ip->version == 4) {

@ -37,8 +37,7 @@ static void do_test_amr_xx(const char *file, int line,
char *codec, int clockrate) char *codec, int clockrate)
{ {
printf("running test %s:%i\n", file, line); printf("running test %s:%i\n", file, line);
str codec_name; str codec_name = STR_INIT(codec);
str_init(&codec_name, codec);
codec_def_t *def = codec_find(&codec_name, MT_AUDIO); codec_def_t *def = codec_find(&codec_name, MT_AUDIO);
assert(def); assert(def);
if (!def->support_encoding || !def->support_decoding) { if (!def->support_encoding || !def->support_decoding) {

@ -47,8 +47,7 @@ static void do_test_amr_xx(const char *file, int line,
int bitrate, char *codec, int clockrate) int bitrate, char *codec, int clockrate)
{ {
printf("running test %s:%i\n", file, line); printf("running test %s:%i\n", file, line);
str codec_name; str codec_name = STR_INIT(codec);
str_init(&codec_name, codec);
codec_def_t *def = codec_find(&codec_name, MT_AUDIO); codec_def_t *def = codec_find(&codec_name, MT_AUDIO);
assert(def); assert(def);
if (!def->support_encoding || !def->support_decoding) { if (!def->support_encoding || !def->support_decoding) {

@ -39,8 +39,7 @@ int do_test(const char *input, unsigned int input_len,
{ {
char in_buf[input_len]; char in_buf[input_len];
memcpy(in_buf, input, input_len); memcpy(in_buf, input, input_len);
str inp; str inp = STR_INIT_LEN(in_buf, input_len);
str_init_len(&inp, in_buf, input_len);
bitstr inp_bs; bitstr inp_bs;
bitstr_init(&inp_bs, &inp); bitstr_init(&inp_bs, &inp);

@ -17,8 +17,7 @@ GString *dtmf_logs;
struct control_ng *rtpe_control_ng[2]; struct control_ng *rtpe_control_ng[2];
static str *sdup(char *s) { static str *sdup(char *s) {
str r; str r = STR_INIT(s);
str_init(&r, s);
return str_dup(&r); return str_dup(&r);
} }
static void queue_dump(GString *s, GQueue *q) { static void queue_dump(GString *s, GQueue *q) {
@ -117,8 +116,7 @@ static void __start(const char *file, int line) {
static void codec_set(char *c) { static void codec_set(char *c) {
// from call_ng_flags_str_ht_split // from call_ng_flags_str_ht_split
c = strdup(c); c = strdup(c);
str s; str s = STR_INIT(c);
str_init(&s, c);
str splitter = s; str splitter = s;
while (1) { while (1) {

Loading…
Cancel
Save