aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/AACDecoder.h2
-rw-r--r--src/Outputs.cpp23
-rw-r--r--src/Outputs.h10
-rw-r--r--src/StatsPublish.cpp7
-rw-r--r--src/StatsPublish.h3
-rw-r--r--src/VLCInput.cpp15
-rw-r--r--src/odr-audioenc.cpp35
7 files changed, 70 insertions, 25 deletions
diff --git a/src/AACDecoder.h b/src/AACDecoder.h
index 2c09548..28713c1 100644
--- a/src/AACDecoder.h
+++ b/src/AACDecoder.h
@@ -24,7 +24,7 @@
#pragma once
-#include <fdk-aac/aacdecoder_lib.h>
+#include <aacdecoder_lib.h>
#include <cstdint>
#include <vector>
#include "wavfile.h"
diff --git a/src/Outputs.cpp b/src/Outputs.cpp
index d0d3ca4..27ab365 100644
--- a/src/Outputs.cpp
+++ b/src/Outputs.cpp
@@ -1,6 +1,6 @@
/* ------------------------------------------------------------------
* Copyright (C) 2011 Martin Storsjo
- * Copyright (C) 2019 Matthias P. Braendli
+ * Copyright (C) 2020 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.
@@ -108,10 +108,10 @@ bool ZMQ::write_frame(const uint8_t *buf, size_t len)
try {
switch (m_encoder) {
case encoder_selection_t::fdk_dabplus:
- zmq_frame_header->encoder = ZMQ_ENCODER_FDK;
+ zmq_frame_header->encoder = ZMQ_ENCODER_AACPLUS;
break;
case encoder_selection_t::toolame_dab:
- zmq_frame_header->encoder = ZMQ_ENCODER_TOOLAME;
+ zmq_frame_header->encoder = ZMQ_ENCODER_MPEG_L2;
break;
}
@@ -141,6 +141,11 @@ EDI::EDI() :
EDI::~EDI() { }
+void EDI::set_odr_version_tag(const std::string& odr_version_tag)
+{
+ m_odr_version_tag = odr_version_tag;
+}
+
void EDI::add_udp_destination(const std::string& host, unsigned int port)
{
auto dest = make_shared<edi::udp_destination_t>();
@@ -164,7 +169,7 @@ void EDI::add_tcp_destination(const std::string& host, unsigned int port)
dest->dest_port = port;
m_edi_conf.destinations.push_back(dest);
- m_edi_conf.dump = true;
+ m_edi_conf.dump = false;
}
bool EDI::enabled() const
@@ -224,15 +229,7 @@ bool EDI::write_frame(const uint8_t *buf, size_t len)
edi::TagODRAudioLevels edi_tagAudioLevels(m_audio_left, m_audio_right);
- stringstream ss;
- ss << PACKAGE_NAME << " " <<
-#if defined(GITVERSION)
- GITVERSION;
-#else
- PACKAGE_VERSION;
-#endif
- edi::TagODRVersion edi_tagVersion(ss.str(), m_num_seconds_sent);
-
+ edi::TagODRVersion edi_tagVersion(m_odr_version_tag, m_num_seconds_sent);
// The above Tag Items will be assembled into a TAG Packet
edi::TagPacket edi_tagpacket(m_edi_conf.tagpacket_alignment);
diff --git a/src/Outputs.h b/src/Outputs.h
index 0f1f34f..1211841 100644
--- a/src/Outputs.h
+++ b/src/Outputs.h
@@ -1,6 +1,6 @@
/* ------------------------------------------------------------------
* Copyright (C) 2011 Martin Storsjo
- * Copyright (C) 2019 Matthias P. Braendli
+ * Copyright (C) 2020 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.
@@ -91,8 +91,8 @@ struct zmq_frame_header_t
/* Data follows this header */
} __attribute__ ((packed));
-#define ZMQ_ENCODER_FDK 1
-#define ZMQ_ENCODER_TOOLAME 2
+#define ZMQ_ENCODER_AACPLUS 1
+#define ZMQ_ENCODER_MPEG_L2 2
#define ZMQ_HEADER_SIZE sizeof(struct zmq_frame_header_t)
@@ -133,6 +133,8 @@ class EDI: public Base {
EDI& operator=(const EDI&) = delete;
virtual ~EDI() override;
+ void set_odr_version_tag(const std::string& odr_version_tag);
+
void add_udp_destination(const std::string& host, unsigned int port);
void add_tcp_destination(const std::string& host, unsigned int port);
@@ -143,6 +145,8 @@ class EDI: public Base {
virtual bool write_frame(const uint8_t *buf, size_t len) override;
private:
+ std::string m_odr_version_tag;
+
edi::configuration_t m_edi_conf;
std::shared_ptr<edi::Sender> m_edi_sender;
diff --git a/src/StatsPublish.cpp b/src/StatsPublish.cpp
index 0bad833..cdb32cb 100644
--- a/src/StatsPublish.cpp
+++ b/src/StatsPublish.cpp
@@ -51,6 +51,13 @@ StatsPublisher::StatsPublisher(const string& socket_path) :
}
}
+StatsPublisher::~StatsPublisher()
+{
+ if (m_sock != -1) {
+ close(m_sock);
+ }
+}
+
void StatsPublisher::update_audio_levels(int16_t audiolevel_left, int16_t audiolevel_right)
{
m_audio_left = audiolevel_left;
diff --git a/src/StatsPublish.h b/src/StatsPublish.h
index f593c7c..7ff7da4 100644
--- a/src/StatsPublish.h
+++ b/src/StatsPublish.h
@@ -34,6 +34,9 @@
class StatsPublisher {
public:
StatsPublisher(const std::string& socket_path);
+ StatsPublisher(const StatsPublisher& other) = delete;
+ StatsPublisher& operator=(const StatsPublisher& other) = delete;
+ ~StatsPublisher();
/*! Update peak audio level information */
void update_audio_levels(int16_t audiolevel_left, int16_t audiolevel_right);
diff --git a/src/VLCInput.cpp b/src/VLCInput.cpp
index 80e85be..d2ae4f0 100644
--- a/src/VLCInput.cpp
+++ b/src/VLCInput.cpp
@@ -291,13 +291,18 @@ void VLCInput::preRender_cb(uint8_t** pp_pcm_buffer, size_t size)
void VLCInput::exit_cb()
{
- std::lock_guard<std::mutex> lock(m_queue_mutex);
+ if (m_running) {
+ std::lock_guard<std::mutex> lock(m_queue_mutex);
- fprintf(stderr, "VLC exit, restarting...\n");
+ fprintf(stderr, "VLC exit, restarting...\n");
- cleanup();
- m_current_buf.clear();
- prepare();
+ cleanup();
+ m_current_buf.clear();
+ prepare();
+ }
+ else {
+ fprintf(stderr, "VLC exit.\n");
+ }
}
void VLCInput::cleanup()
diff --git a/src/odr-audioenc.cpp b/src/odr-audioenc.cpp
index 45aacf2..aab76b2 100644
--- a/src/odr-audioenc.cpp
+++ b/src/odr-audioenc.cpp
@@ -1,6 +1,6 @@
/* ------------------------------------------------------------------
* Copyright (C) 2011 Martin Storsjo
- * Copyright (C) 2019 Matthias P. Braendli
+ * Copyright (C) 2020 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.
@@ -83,7 +83,7 @@ extern "C" {
#include <sys/ioctl.h>
#include <fcntl.h>
-#include "fdk-aac/aacenc_lib.h"
+#include "aacenc_lib.h"
extern "C" {
#include "fec/fec.h"
@@ -191,6 +191,7 @@ void usage(const char* name)
" -B, --bandwidth=VALUE Set the AAC encoder bandwidth to VALUE [Hz].\n"
" --decode=FILE Decode the AAC back to a wav file (loopback test).\n"
" Output and PAD parameters:\n"
+ " --identifier=ID An identifier string that is sent in the ODRv EDI TAG. Max 32 characters length.\n"
" -o, --output=URI Output ZMQ uri. (e.g. 'tcp://localhost:9000')\n"
" -or- Output file uri. (e.g. 'file.dabp')\n"
" -or- a single dash '-' to denote stdout\n"
@@ -444,6 +445,7 @@ public:
shared_ptr<Output::File> file_output;
shared_ptr<Output::ZMQ> zmq_output;
Output::EDI edi_output;
+ string identifier;
bool tist_enabled = false;
uint32_t tist_delay_ms = 0;
@@ -625,6 +627,16 @@ int AudioEnc::run()
if (not edi_output_uris.empty()) {
edi_output.set_tist(tist_enabled, tist_delay_ms);
+
+ stringstream ss;
+ ss << PACKAGE_NAME << " " <<
+#if defined(GITVERSION)
+ GITVERSION <<
+#else
+ PACKAGE_VERSION <<
+#endif
+ " " << identifier;
+ edi_output.set_odr_version_tag(ss.str());
}
if (padlen != 0) {
@@ -1342,6 +1354,7 @@ int main(int argc, char *argv[])
{"decode", required_argument, 0, 6 },
{"format", required_argument, 0, 'f'},
{"gst-uri", required_argument, 0, 'G'},
+ {"identifier", required_argument, 0, 7 },
{"input", required_argument, 0, 'i'},
{"jack", required_argument, 0, 'j'},
{"output", required_argument, 0, 'o'},
@@ -1425,6 +1438,16 @@ int main(int argc, char *argv[])
case 6: // Enable loopback decoder for AAC
audio_enc.decode_wavfilename = optarg;
break;
+ case 7: // Identifier for in-band version information
+ audio_enc.identifier = optarg;
+ /* The 32 character length restriction is arbitrary, but guarantees
+ * that the EDI packet will not grow too large */
+ if (audio_enc.identifier.size() > 32) {
+ fprintf(stderr, "Output Identifier too long!\n");
+ usage(argv[0]);
+ return 1;
+ }
+ break;
case 'a':
audio_enc.selected_encoder = encoder_selection_t::toolame_dab;
break;
@@ -1548,6 +1571,12 @@ int main(int argc, char *argv[])
}
}
- return audio_enc.run();
+ try {
+ return audio_enc.run();
+ }
+ catch (const std::runtime_error& e) {
+ fprintf(stderr, "ODR-AudioEnc failed to start: %s\n", e.what());
+ return 1;
+ }
}