mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-03-22 09:40:30 +00:00
Use C++ compiler for files using audio_frame2
This commit is contained in:
@@ -45,7 +45,7 @@ uv_datadir = @datadir@/ultragrid/
|
||||
# autogenerated headers
|
||||
GENERATED_HEADERS = @GENERATED_HEADERS@
|
||||
|
||||
ALL_INCLUDES = $(wildcard src/*.h) $(wildcard src/*/*.h)
|
||||
ALL_INCLUDES = $(wildcard src/*.h src/*/*.h src/*/*/*.h)
|
||||
|
||||
OBJS = @OBJS@ \
|
||||
src/blackmagic_common.o \
|
||||
|
||||
@@ -243,7 +243,7 @@ struct state_audio * audio_cfg_init(struct module *parent, const char *addrs, in
|
||||
return NULL;
|
||||
}
|
||||
|
||||
s = calloc(1, sizeof(struct state_audio));
|
||||
s = (struct state_audio *) calloc(1, sizeof(struct state_audio));
|
||||
|
||||
module_init_default(&s->mod);
|
||||
s->mod.priv_data = s;
|
||||
@@ -495,7 +495,7 @@ static struct rtp *initialize_audio_network(struct audio_network_parameters *par
|
||||
r = rtp_init_if(params->addr, params->mcast_if, params->recv_port,
|
||||
params->send_port, 255, rtcp_bw,
|
||||
FALSE, rtp_recv_callback,
|
||||
(void *) params->participants,
|
||||
(uint8_t *) params->participants,
|
||||
params->use_ipv6, false);
|
||||
if (r != NULL) {
|
||||
pdb_add(params->participants, rtp_my_ssrc(r));
|
||||
@@ -509,7 +509,7 @@ static struct rtp *initialize_audio_network(struct audio_network_parameters *par
|
||||
|
||||
static void *audio_receiver_thread(void *arg)
|
||||
{
|
||||
struct state_audio *s = arg;
|
||||
struct state_audio *s = (struct state_audio *) arg;
|
||||
// rtp variables
|
||||
struct timeval timeout, curr_time;
|
||||
uint32_t ts;
|
||||
@@ -520,7 +520,7 @@ static void *audio_receiver_thread(void *arg)
|
||||
memset(&pbuf_data.buffer, 0, sizeof(struct audio_frame));
|
||||
memset(&device_desc, 0, sizeof(struct audio_desc));
|
||||
|
||||
pbuf_data.decoder = audio_decoder_init(s->audio_channel_map, s->audio_scale, s->requested_encryption);
|
||||
pbuf_data.decoder = (struct state_audio_decoder *) audio_decoder_init(s->audio_channel_map, s->audio_scale, s->requested_encryption);
|
||||
assert(pbuf_data.decoder != NULL);
|
||||
|
||||
printf("Audio receiving started.\n");
|
||||
@@ -686,7 +686,7 @@ static void resample(struct state_resample *s, struct audio_frame *buffer)
|
||||
|
||||
if(buffer->sample_rate == s->resample_to && s->codec_supported_bytes_per_sample == NULL) {
|
||||
memcpy(&s->resampled, buffer, sizeof(s->resampled));
|
||||
s->resampled.data = malloc(buffer->data_len);
|
||||
s->resampled.data = (char *) malloc(buffer->data_len);
|
||||
memcpy(s->resampled.data, buffer->data, buffer->data_len);
|
||||
} else {
|
||||
/**
|
||||
@@ -695,7 +695,7 @@ static void resample(struct state_resample *s, struct audio_frame *buffer)
|
||||
assert(set_contains(s->codec_supported_bytes_per_sample, 2));
|
||||
// expect that we may got as much as 12-times more data (eg 8 kHz to 96 kHz
|
||||
uint32_t write_frames = 12 * (buffer->data_len / buffer->ch_count / buffer->bps);
|
||||
s->resampled.data = malloc(write_frames * 2 * buffer->ch_count);
|
||||
s->resampled.data = (char *) malloc(write_frames * 2 * buffer->ch_count);
|
||||
if(s->resample_from != buffer->sample_rate || s->resample_ch_count != buffer->ch_count) {
|
||||
s->resample_from = buffer->sample_rate;
|
||||
s->resample_ch_count = buffer->ch_count;
|
||||
@@ -806,7 +806,7 @@ static void *audio_sender_thread(void *arg)
|
||||
|
||||
memset(&resample_state, 0, sizeof(resample_state));
|
||||
resample_state.resample_to = s->resample_to;
|
||||
resample_state.resample_buffer = malloc(1024 * 1024);
|
||||
resample_state.resample_buffer = (char *) malloc(1024 * 1024);
|
||||
resample_state.codec_supported_bytes_per_sample =
|
||||
audio_codec_get_supported_bps(s->audio_coder);
|
||||
|
||||
@@ -894,7 +894,7 @@ void audio_register_put_callback(struct state_audio *s, void (*callback)(void *,
|
||||
if(!audio_playback_get_display_flags(s->audio_playback_device))
|
||||
return;
|
||||
|
||||
sdi_playback = audio_playback_get_state_pointer(s->audio_playback_device);
|
||||
sdi_playback = (struct state_sdi_playback *) audio_playback_get_state_pointer(s->audio_playback_device);
|
||||
sdi_register_put_callback(sdi_playback, callback, udata);
|
||||
}
|
||||
|
||||
@@ -906,7 +906,7 @@ void audio_register_reconfigure_callback(struct state_audio *s, int (*callback)(
|
||||
if(!audio_playback_get_display_flags(s->audio_playback_device))
|
||||
return;
|
||||
|
||||
sdi_playback = audio_playback_get_state_pointer(s->audio_playback_device);
|
||||
sdi_playback = (struct state_sdi_playback *) audio_playback_get_state_pointer(s->audio_playback_device);
|
||||
sdi_register_reconfigure_callback(sdi_playback, callback, udata);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct state_audio_playback;
|
||||
|
||||
@@ -78,5 +81,9 @@ void audio_register_reconfigure_callback(struct state_audio *s, int (*callback)(
|
||||
*/
|
||||
void *audio_playback_get_state_pointer(struct state_audio_playback *s);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab: sw=8 */
|
||||
|
||||
|
||||
@@ -46,6 +46,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//void audio_sdi_send(struct state_audio *s, struct audio_frame *frame);
|
||||
//int audio_does_send_sdi(struct state_audio *s);
|
||||
struct audio_frame;
|
||||
@@ -60,6 +64,9 @@ struct audio_frame * sdi_read(void *state);
|
||||
/* SDI specific API */
|
||||
void sdi_capture_new_incoming_frame(void *state, struct audio_frame *frame);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab: sw=8 */
|
||||
|
||||
|
||||
@@ -89,11 +89,8 @@ static struct audio_codec *audio_codecs[MAX_AUDIO_CODECS] = {
|
||||
};
|
||||
static struct audio_codec_state *audio_codec_init_real(const char *audio_codec_cfg,
|
||||
audio_codec_direction_t direction, bool try_init);
|
||||
static void register_audio_codec_real(struct audio_codec *);
|
||||
|
||||
void (*register_audio_codec)(struct audio_codec *) = register_audio_codec_real;
|
||||
|
||||
static void register_audio_codec_real(struct audio_codec *codec)
|
||||
void register_audio_codec(struct audio_codec *codec)
|
||||
{
|
||||
for(int i = 0; i < MAX_AUDIO_CODECS; ++i) {
|
||||
if(audio_codecs[i] == 0) {
|
||||
@@ -69,8 +69,7 @@ struct audio_codec {
|
||||
void (*done)(void *);
|
||||
};
|
||||
|
||||
extern void (*register_audio_codec)(struct audio_codec *);
|
||||
|
||||
void register_audio_codec(struct audio_codec *);
|
||||
typedef struct {
|
||||
const char *name;
|
||||
/** @var tag
|
||||
|
||||
@@ -54,11 +54,13 @@
|
||||
|
||||
#include "audio/codec/libavcodec.h"
|
||||
|
||||
extern "C" {
|
||||
#include <libavcodec/avcodec.h>
|
||||
#if LIBAVCODEC_VERSION_MAJOR >= 54
|
||||
#include <libavutil/channel_layout.h>
|
||||
#endif
|
||||
#include <libavutil/mem.h>
|
||||
}
|
||||
|
||||
#include "audio/audio.h"
|
||||
#include "audio/codec.h"
|
||||
@@ -92,7 +94,7 @@ static void register_module(void)
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int codec_id;
|
||||
enum AVCodecID codec_id;
|
||||
} audio_codec_t_to_codec_id_mapping_t;
|
||||
|
||||
static const audio_codec_t_to_codec_id_mapping_t mapping[] =
|
||||
@@ -140,7 +142,7 @@ struct libavcodec_codec_state {
|
||||
static void *libavcodec_init(audio_codec_t audio_codec, audio_codec_direction_t direction, bool try_init,
|
||||
int bitrate)
|
||||
{
|
||||
int codec_id = 0;
|
||||
enum AVCodecID codec_id = AV_CODEC_ID_NONE;
|
||||
|
||||
if(audio_codec <= sizeof(mapping) / sizeof(audio_codec_t_to_codec_id_mapping_t)) {
|
||||
codec_id = mapping[audio_codec].codec_id;
|
||||
@@ -155,7 +157,8 @@ static void *libavcodec_init(audio_codec_t audio_codec, audio_codec_direction_t
|
||||
|
||||
avcodec_register_all();
|
||||
|
||||
struct libavcodec_codec_state *s = calloc(1, sizeof(struct libavcodec_codec_state));
|
||||
struct libavcodec_codec_state *s = (struct libavcodec_codec_state *)
|
||||
calloc(1, sizeof(struct libavcodec_codec_state));
|
||||
if(direction == AUDIO_CODER) {
|
||||
s->codec = avcodec_find_encoder(codec_id);
|
||||
} else {
|
||||
@@ -191,8 +194,8 @@ static void *libavcodec_init(audio_codec_t audio_codec, audio_codec_direction_t
|
||||
|
||||
memset(&s->tmp, 0, sizeof(audio_channel));
|
||||
memset(&s->output_channel, 0, sizeof(audio_channel));
|
||||
s->tmp.data = malloc(1024*1024);
|
||||
s->output_channel.data = malloc(1024*1024);
|
||||
s->tmp.data = (char *) malloc(1024*1024);
|
||||
s->output_channel.data = (char *) malloc(1024*1024);
|
||||
|
||||
if(direction == AUDIO_CODER) {
|
||||
s->output_channel.codec = audio_codec;
|
||||
@@ -51,6 +51,10 @@
|
||||
|
||||
#include "audio/audio.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct echo_cancellation;
|
||||
|
||||
typedef struct echo_cancellation echo_cancellation_t;
|
||||
@@ -61,5 +65,8 @@ void echo_play(struct echo_cancellation *state, struct audio_frame *frame);
|
||||
|
||||
struct audio_frame * echo_cancel(struct echo_cancellation *state, struct audio_frame *frame);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _ECHO_H_ */
|
||||
|
||||
@@ -49,6 +49,10 @@
|
||||
#ifndef _EXPORT_H_
|
||||
#define _EXPORT_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct audio_export;
|
||||
struct audio_frame;
|
||||
|
||||
@@ -56,4 +60,9 @@ struct audio_export * audio_export_init(char *filename);
|
||||
void audio_export_destroy(struct audio_export *state);
|
||||
void audio_export(struct audio_export *state, struct audio_frame *frame);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* _EXPORT_H_ */
|
||||
|
||||
@@ -48,6 +48,10 @@
|
||||
|
||||
struct audio_frame;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void sdi_playback_help(const char *driver_name);
|
||||
void *sdi_playback_init(char *cfg);
|
||||
void sdi_put_frame(void *state, struct audio_frame *frame);
|
||||
@@ -61,6 +65,9 @@ void sdi_register_reconfigure_callback(void *s, int (*callback)(void *, int, int
|
||||
int),
|
||||
void *udata);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab: sw=8 */
|
||||
|
||||
|
||||
@@ -16,10 +16,10 @@ struct resampler
|
||||
|
||||
struct resampler *resampler_init(int dst_sample_rate)
|
||||
{
|
||||
struct resampler *s = calloc(1, sizeof(struct resampler));
|
||||
struct resampler *s = (struct resampler *) calloc(1, sizeof(struct resampler));
|
||||
|
||||
s->resample_buffer = malloc(1024 * 1024);
|
||||
s->muxed = malloc(1024 * 1024);
|
||||
s->resample_buffer = (char *) malloc(1024 * 1024);
|
||||
s->muxed = (char *) malloc(1024 * 1024);
|
||||
s->resampled = audio_frame2_init();
|
||||
s->resample_to = dst_sample_rate;
|
||||
|
||||
@@ -6,9 +6,17 @@
|
||||
|
||||
#include "audio/audio.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct resampler;
|
||||
|
||||
struct resampler *resampler_init(int dst_sample_rate);
|
||||
void resampler_done(struct resampler *);
|
||||
audio_frame2 *resampler_resample(struct resampler *, audio_frame2 *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ void audio_frame2_allocate(audio_frame2 *frame, int nr_channels, int max_size)
|
||||
frame->ch_count = nr_channels;
|
||||
|
||||
for(int i = 0; i < nr_channels; ++i) {
|
||||
frame->data[i] = malloc(max_size);
|
||||
frame->data[i] = (char *) malloc(max_size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ void audio_frame2_append(audio_frame2 *dest, audio_frame2 *src)
|
||||
dest->max_size = new_max_size;
|
||||
dest->ch_count = src->ch_count;
|
||||
for (int i = 0; i < src->ch_count; ++i) {
|
||||
dest->data[i] = realloc(dest->data[i], new_max_size);
|
||||
dest->data[i] = (char *) realloc(dest->data[i], new_max_size);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user