From 35a05922216ecc680972cab1ffebdfe192bf05e9 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Mon, 24 Feb 2014 13:48:51 +0100 Subject: [PATCH] main.c -> main.cpp --- configure.ac | 2 +- src/audio/audio.h | 17 +++++++---------- src/audio/audio_capture.h | 9 +++++++++ src/ihdtv.h | 8 ++++++++ src/{main.c => main.cpp} | 17 ++++++++--------- src/pdb.h | 8 ++++++++ src/rtp/pbuf.h | 7 +++++++ src/rtp/rtp.h | 9 +++++++++ src/rtp/rtp_callback.h | 8 ++++++++ src/sender.h | 8 ++++++++ src/stats.cpp | 2 +- src/stats.h | 2 +- src/tfrc.h | 8 ++++++++ src/transmit.h | 8 ++++++++ src/utils/misc.h | 8 ++++++++ 15 files changed, 99 insertions(+), 22 deletions(-) rename src/{main.c => main.cpp} (99%) diff --git a/configure.ac b/configure.ac index 1b9096e7b..c712a70d4 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT([UltraGrid], [1.2], [ultragrid-dev@cesnet.cz]) AM_INIT_AUTOMAKE([1.10]) AC_PREREQ(2.61) -AC_CONFIG_SRCDIR([src/main.c]) +AC_CONFIG_SRCDIR([src/main.cpp]) AC_CONFIG_MACRO_DIR([m4]) PARENT=`echo $PWD | sed -e 's%/[[^/]]*$%%'` diff --git a/src/audio/audio.h b/src/audio/audio.h index 0fdeb76d4..aac5c585c 100644 --- a/src/audio/audio.h +++ b/src/audio/audio.h @@ -55,6 +55,10 @@ #include "config_win32.h" #endif // HAVE_CONFIG_H +#ifdef __cplusplus +extern "C" { +#endif + #define PORT_AUDIO 5006 #define MAX_AUDIO_CHANNELS 8 @@ -142,16 +146,9 @@ int audio_reconfigure(struct state_audio *s, int quant_samples, int channels, unsigned int audio_get_display_flags(struct state_audio *s); -/** - * Changes bps for everey sample. - * - * The memory areas shouldn't (supposedly) overlap. - */ -void change_bps(char *out, int out_bps, const char *in, int in_bps, int in_len /* bytes */); +#ifdef __cplusplus +} +#endif -/** - * Makes n copies of first channel (interleaved). - */ -void audio_frame_multiply_channel(struct audio_frame *frame, int new_channel_count); #endif diff --git a/src/audio/audio_capture.h b/src/audio/audio_capture.h index 68fe8d26d..2afe16de4 100644 --- a/src/audio/audio_capture.h +++ b/src/audio/audio_capture.h @@ -44,6 +44,10 @@ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef __cplusplus +extern "C" { +#endif + struct state_audio_capture; struct audio_frame; @@ -69,5 +73,10 @@ const char *audio_capture_get_driver_name(struct state_audio_cap * SDI (embedded sound). */ void *audio_capture_get_state_pointer(struct state_audio_capture *s); + +#ifdef __cplusplus +} +#endif + /* vim: set expandtab: sw=4 */ diff --git a/src/ihdtv.h b/src/ihdtv.h index 98775a2c8..6a2c50e4e 100644 --- a/src/ihdtv.h +++ b/src/ihdtv.h @@ -62,6 +62,10 @@ #include "video_capture.h" #include "video_display.h" +#ifdef __cplusplus +extern "C" { +#endif + struct ihdtv_state; struct video_frame; struct rx_tx; @@ -71,5 +75,9 @@ extern struct rx_tx ihdtv_rxtx; struct ihdtv_state *initialize_ihdtv(struct vidcap *capture_device, struct display *display_device, int requested_mtu, int argc, char **argv); +#ifdef __cplusplus +} +#endif + #endif // IHDTV_H_ diff --git a/src/main.c b/src/main.cpp similarity index 99% rename from src/main.c rename to src/main.cpp index 103ce181a..f0c2c1efa 100644 --- a/src/main.c +++ b/src/main.cpp @@ -409,7 +409,7 @@ static struct rtp **initialize_network(const char *addrs, int recv_port_base, devices[index] = rtp_init_if(addr, mcast_if, recv_port, send_port, ttl, rtcp_bw, FALSE, - rtp_recv_callback, (void *)participants, + rtp_recv_callback, (uint8_t *)participants, use_ipv6); if (devices[index] != NULL) { rtp_set_option(devices[index], RTP_OPT_WEAK_VALIDATION, @@ -455,7 +455,7 @@ void destroy_rtp_devices(struct rtp ** network_devices) } static struct vcodec_state *new_video_decoder(struct state_uv *uv) { - struct vcodec_state *state = calloc(1, sizeof(struct vcodec_state)); + struct vcodec_state *state = (struct vcodec_state *) calloc(1, sizeof(struct vcodec_state)); if(state) { state->decoder = video_decoder_init(&uv->receiver_mod, uv->decoder_mode, @@ -476,7 +476,7 @@ static struct vcodec_state *new_video_decoder(struct state_uv *uv) { } static void destroy_video_decoder(void *state) { - struct vcodec_state *video_decoder_state = state; + struct vcodec_state *video_decoder_state = (struct vcodec_state *) state; if(!video_decoder_state) { return; @@ -650,7 +650,7 @@ void *ultragrid_rtp_receiver_thread(void *arg) ((struct vcodec_state*) cp->decoder_state)->display = uv->display_device; } - struct vcodec_state *vdecoder_state = cp->decoder_state; + struct vcodec_state *vdecoder_state = (struct vcodec_state *) cp->decoder_state; /* Decode and render video... */ if (pbuf_decode @@ -749,6 +749,7 @@ static void *capture_thread(void *arg) struct module *uv_mod = (struct module *)arg; struct state_uv *uv = (struct state_uv *) uv_mod->priv_data; struct sender_data sender_data; + struct wait_obj *wait_obj; memset(&sender_data, 0, sizeof(sender_data)); struct compress_state *compression = NULL; @@ -772,10 +773,7 @@ static void *capture_thread(void *arg) sender_data.video_exporter = uv->video_exporter; sender_data.compression = compression; - // The magic here with wait_objs is a workaround until all capture - // drivers implement a dispose function. Until that, it is supposed - // that every vidcap_grab call invalidates previous captured frame. - struct wait_obj *wait_obj = wait_obj_init(); + wait_obj = wait_obj_init(); if(!sender_init(&sender_data)) { fprintf(stderr, "Error initializing sender.\n"); @@ -922,6 +920,7 @@ int main(int argc, char *argv[]) unsigned display_flags = 0; int compressed_audio_sample_rate = 48000; int ret; + struct vidcap_params *audio_cap_dev; #if defined DEBUG && defined HAVE_LINUX mtrace(); @@ -1347,7 +1346,7 @@ int main(int argc, char *argv[]) /* Pass embedded/analog/AESEBU flags to selected vidcap * device. */ - struct vidcap_params *audio_cap_dev = vidcap_params_get_nth( + audio_cap_dev = vidcap_params_get_nth( vidcap_params_head, audio_capture_get_vidcap_index(audio_send)); if (audio_cap_dev != NULL) { diff --git a/src/pdb.h b/src/pdb.h index 79b25999a..771ffd920 100644 --- a/src/pdb.h +++ b/src/pdb.h @@ -51,6 +51,10 @@ * $Date: 2009/12/11 15:29:39 $ * */ + +#ifdef __cplusplus +extern "C" { +#endif /* * A participant database entry. This holds (pointers to) all the @@ -100,3 +104,7 @@ struct pdb_e *pdb_iter_init(struct pdb *db, pdb_iter_t *it); struct pdb_e *pdb_iter_next(pdb_iter_t *it); void pdb_iter_done(pdb_iter_t *it); +#ifdef __cplusplus +} +#endif + diff --git a/src/rtp/pbuf.h b/src/rtp/pbuf.h index 89c861ecc..e1dd37a48 100644 --- a/src/rtp/pbuf.h +++ b/src/rtp/pbuf.h @@ -68,6 +68,10 @@ #include "audio/audio.h" #include "utils/list.h" +#ifdef __cplusplus +extern "C" { +#endif + /* The coded representation of a single frame */ struct coded_data { struct coded_data *nxt; @@ -116,4 +120,7 @@ void pbuf_remove(struct pbuf *playout_buf, struct timeval curr_time); void pbuf_set_playout_delay(struct pbuf *playout_buf, double playout_delay, double deletion_delay); +#ifdef __cplusplus +} +#endif diff --git a/src/rtp/rtp.h b/src/rtp/rtp.h index fd94f6499..9bc05e6d7 100644 --- a/src/rtp/rtp.h +++ b/src/rtp/rtp.h @@ -46,6 +46,10 @@ #include "config_win32.h" #endif // HAVE_CONFIG_H +#ifdef __cplusplus +extern "C" { +#endif + #define RTP_VERSION 2 #define RTP_PACKET_HEADER_SIZE ((sizeof(char *) * 2) + sizeof(uint32_t *) + (2 * sizeof(int))) #define RTP_MAX_PACKET_LEN 9000 @@ -286,4 +290,9 @@ void rtp_flush_recv_buf(struct rtp *session); int rtp_change_dest(struct rtp *session, const char *addr); uint64_t rtp_get_bytes_sent(struct rtp *session); int rtp_compute_fract_lost(struct rtp *session, uint32_t ssrc); + +#ifdef __cplusplus +} +#endif + #endif /* __RTP_H__ */ diff --git a/src/rtp/rtp_callback.h b/src/rtp/rtp_callback.h index 10147a2d5..3b65d7abb 100644 --- a/src/rtp/rtp_callback.h +++ b/src/rtp/rtp_callback.h @@ -40,6 +40,10 @@ * */ +#ifdef __cplusplus +extern "C" { +#endif + /** @page av_pkt_description UltraGrid packet format * Packet formats are described in papers referenced here:
* https://www.sitola.cz/igrid/index.php/Developer_Documentation#Packet_formats @@ -143,3 +147,7 @@ int check_for_frame_completion(struct rtp *); void process_packet_for_display(char *); void call_display_frame(void); +#ifdef __cplusplus +} +#endif + diff --git a/src/sender.h b/src/sender.h index bc8e5ebe4..fba7e2116 100644 --- a/src/sender.h +++ b/src/sender.h @@ -66,6 +66,10 @@ #include "video.h" +#ifdef __cplusplus +extern "C" { +#endif + struct tx; struct rtp; struct display; @@ -128,5 +132,9 @@ struct h264_rtp_state { bool sender_init(struct sender_data *data); void sender_done(struct sender_data *data); +#ifdef __cplusplus +} +#endif + #endif // SENDER_H_ diff --git a/src/stats.cpp b/src/stats.cpp index 4a50469b4..99f47418f 100644 --- a/src/stats.cpp +++ b/src/stats.cpp @@ -47,7 +47,7 @@ struct stats { platform_spin_t m_spin; }; -struct stats *stats_new_statistics(struct control_state *control, char * name) +struct stats *stats_new_statistics(struct control_state *control, const char * name) { return new stats(string(name), control); } diff --git a/src/stats.h b/src/stats.h index 59566650c..6953cfa1b 100644 --- a/src/stats.h +++ b/src/stats.h @@ -14,7 +14,7 @@ extern "C" { struct control_state; struct stats; -struct stats *stats_new_statistics(struct control_state *control, char * name); +struct stats *stats_new_statistics(struct control_state *control, const char * name); void stats_update_int(struct stats *, int64_t); void stats_format(struct stats *s, char *buffer, int buffer_len); void stats_destroy(struct stats *); diff --git a/src/tfrc.h b/src/tfrc.h index 7489530e3..885a8a9a8 100644 --- a/src/tfrc.h +++ b/src/tfrc.h @@ -43,6 +43,10 @@ * */ +#ifdef __cplusplus +extern "C" { +#endif + struct tfrc; struct tfrc *tfrc_init(struct timeval curr_time); @@ -53,3 +57,7 @@ void tfrc_recv_rtt (struct tfrc *state, struct timeval curr_time, double tfrc_feedback_txrate(struct tfrc *state, struct timeval curr_time); int tfrc_feedback_is_due(struct tfrc *state, struct timeval curr_time); +#ifdef __cplusplus +} +#endif + diff --git a/src/transmit.h b/src/transmit.h index 798675e40..d2015679a 100644 --- a/src/transmit.h +++ b/src/transmit.h @@ -60,6 +60,10 @@ #include "audio/audio.h" #include "types.h" +#ifdef __cplusplus +extern "C" { +#endif + struct module; struct rtp; struct tx; @@ -78,5 +82,9 @@ struct tx *tx_init_h264(struct module *parent, unsigned mtu, enum tx_media_type void tx_send_h264(struct tx *tx_session, struct video_frame *frame, struct rtp *rtp_session); +#ifdef __cplusplus +} +#endif + #endif // TRANSMIT_H_ diff --git a/src/utils/misc.h b/src/utils/misc.h index 3db13461b..904e7238c 100644 --- a/src/utils/misc.h +++ b/src/utils/misc.h @@ -38,7 +38,15 @@ #ifndef UTILS_MISC_H_ #define UTILS_MISC_H_ +#ifdef __cplusplus +extern "C" { +#endif + int64_t unit_evaluate(const char *str); +#ifdef __cplusplus +} +#endif + #endif// UTILS_MISC_H_