Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions config_example
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
mix_room MixRoom
mix_url /
mix_token_host TOKENHOST # can start record
mix_token_download TOKENDOWNLOAD # protected download folder
mix_token_guests TOKENGUEST # invite url
mix_token_download TOKENDOWNLOAD # protected download folder
mix_token_guests TOKENGUEST # invite url
mix_token_api TOKENAPI # api token
#mix_path /opt/slmix/
#mix_stream_url rtmp://example.net/stream
1 change: 1 addition & 0 deletions include/mix.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct mix {
char token_guests[TOKEN_SZ];
char token_listeners[TOKEN_SZ];
char token_download[TOKEN_SZ];
char stream_url[URL_SZ];
struct rtc_configuration pc_config;
mix_rec_h *audio_rec_h;
mix_rec_h *video_rec_h;
Expand Down
22 changes: 14 additions & 8 deletions modules/vmix/record.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@
#include <libavutil/rational.h>
#include <libswresample/swresample.h>

#include <string.h>
#include <time.h>
#include <sys/stat.h>
#include <re_atomic.h>
#include <re.h>
#include <rem.h>
#include <baresip.h>
#include <re_atomic.h>
#include "vmix.h"
#include <mix.h>

#define STREAM 0
#define STREAM 1

static struct {
RE_ATOMIC bool run;
Expand Down Expand Up @@ -51,7 +50,6 @@ struct record_entry {
};

#if STREAM
static const char *stream_url = "rtmp://example.net/stream";
static AVRational timebase_audio = {1, 48000};
#endif
static AVRational timebase_video = {1, 1000000};
Expand Down Expand Up @@ -88,8 +86,16 @@ static int init_stream(void)

/* av_log_set_level(AV_LOG_DEBUG); */

if (str_isset(slmix()->stream_url)) {
info("streaming enabled: %s\n", slmix()->stream_url);
}
else {
info("streaming disabled\n");
return 0;
}

ret = avformat_alloc_output_context2(&rec.streamFormatContext, NULL,
"flv", stream_url);
"flv", slmix()->stream_url);
if (ret < 0)
return EINVAL;

Expand Down Expand Up @@ -117,14 +123,14 @@ static int init_stream(void)
avcodec_parameters_from_context(audioStream->codecpar,
rec.audioCodecCtx);

ret = avio_open(&rec.streamFormatContext->pb, stream_url,
ret = avio_open(&rec.streamFormatContext->pb, slmix()->stream_url,
AVIO_FLAG_WRITE);
if (ret < 0) {
warning("avio_open stream error\n");
return EINVAL;
}

av_dump_format(rec.streamFormatContext, 0, stream_url, 1);
av_dump_format(rec.streamFormatContext, 0, slmix()->stream_url, 1);

AVDictionary *opts = NULL;
av_dict_set(&opts, "flvflags", "no_duration_filesize", 0);
Expand Down Expand Up @@ -164,7 +170,7 @@ static int write_stream(AVPacket *pkt, AVRational *time_base_src,
if (!re_atomic_rlx(&rec.run_stream))
return 0;

int err = 0;
int err = 0;
AVPacket *packet = av_packet_clone(pkt);

packet->pts =
Expand Down
6 changes: 5 additions & 1 deletion src/mix.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ static struct mix mix = {.room = "main",
.token_host = "",
.token_guests = "",
.token_listeners = "",
.token_download = ""};
.token_download = "",
.stream_url = ""};

static struct tmr tmr_room_update;
static uint64_t last_room_update = 0;
Expand Down Expand Up @@ -213,6 +214,9 @@ int slmix_config(char *file)
conf_get_str(conf, "mix_token_download", mix.token_download,
sizeof(mix.token_download));

conf_get_str(conf, "mix_stream_url", mix.stream_url,
sizeof(mix.stream_url));

err = conf_get_str(conf, "mix_path", mix.path, sizeof(mix.path));
if (err) {
if (!getcwd(mix.path, sizeof(mix.path))) {
Expand Down