Skip to content

Commit

Permalink
Do not set VLC sout option in libvlc_new
Browse files Browse the repository at this point in the history
  • Loading branch information
mpbraendli committed Mar 11, 2018
1 parent c0e7df7 commit 2285fef
Showing 1 changed file with 30 additions and 27 deletions.
57 changes: 30 additions & 27 deletions src/VLCInput.cpp
@@ -1,5 +1,5 @@
/* ------------------------------------------------------------------
* Copyright (C) 2017 Matthias P. Braendli
* Copyright (C) 2018 Matthias P. Braendli
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -159,29 +159,6 @@ void VLCInput::prepare()
}

// VLC options
std::stringstream transcode_options_ss;
transcode_options_ss << "acodec=fl32";
transcode_options_ss << ",samplerate=" << m_rate;
if (not m_gain.empty()) {
transcode_options_ss << ",afilter=compressor";
}
string transcode_options = transcode_options_ss.str();

char smem_options[512];
snprintf(smem_options, sizeof(smem_options),
"#transcode{%s}:"
// We are using transcode because smem only support raw audio and
// video formats
"smem{"
"audio-postrender-callback=%lld,"
"audio-prerender-callback=%lld,"
"audio-data=%lld"
"}",
transcode_options.c_str(),
handleStream_address,
prepareRender_address,
(long long int)(intptr_t)this);

vector<string> vlc_args;
vlc_args.push_back("--verbose=" + to_string(m_verbosity));

Expand All @@ -193,9 +170,6 @@ void VLCInput::prepare()
vlc_args.push_back("--compressor-makeup=" + m_gain);
}

vlc_args.push_back("--sout");
vlc_args.push_back(smem_options); // Stream to memory

copy(m_additional_opts.begin(), m_additional_opts.end(),
back_inserter(vlc_args));

Expand Down Expand Up @@ -223,6 +197,35 @@ void VLCInput::prepare()
// Load the media
libvlc_media_t *m;
m = libvlc_media_new_location(m_vlc, m_uri.c_str());

std::stringstream transcode_options_ss;
transcode_options_ss << "acodec=fl32";
transcode_options_ss << ",samplerate=" << m_rate;
if (not m_gain.empty()) {
transcode_options_ss << ",afilter=compressor";
}
string transcode_options = transcode_options_ss.str();

char smem_options[512];
snprintf(smem_options, 511,
":sout=#transcode{%s}:"
// We are using transcode because smem only support raw audio and
// video formats
"smem{"
"audio-postrender-callback=%lld,"
"audio-prerender-callback=%lld,"
"audio-data=%lld"
"}",
transcode_options.c_str(),
handleStream_address,
prepareRender_address,
(long long int)(intptr_t)this);

if (m_verbosity) {
fprintf(stderr, "Setting VLC media option: %s\n", smem_options);
}

libvlc_media_add_option(m, smem_options);
m_mp = libvlc_media_player_new_from_media(m);
libvlc_media_release(m);

Expand Down

0 comments on commit 2285fef

Please sign in to comment.