diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-04-12 08:46:12 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-04-12 08:46:12 +0200 |
commit | 5637664fcbe18b05a773d6db621a94de76e07817 (patch) | |
tree | 6d1891004e9d7977d02891fa22de642aac640b17 /src | |
parent | 28f95670d7f1497dc58f8820ab09475e4917d4ba (diff) | |
download | fdk-aac-5637664fcbe18b05a773d6db621a94de76e07817.tar.gz fdk-aac-5637664fcbe18b05a773d6db621a94de76e07817.tar.bz2 fdk-aac-5637664fcbe18b05a773d6db621a94de76e07817.zip |
VLC can write ICY Text into a file for mot-encoder
Diffstat (limited to 'src')
-rw-r--r-- | src/VLCInput.cpp | 13 | ||||
-rw-r--r-- | src/VLCInput.h | 6 | ||||
-rw-r--r-- | src/dabplus-enc.cpp | 26 |
3 files changed, 38 insertions, 7 deletions
diff --git a/src/VLCInput.cpp b/src/VLCInput.cpp index 687e144..82d1d14 100644 --- a/src/VLCInput.cpp +++ b/src/VLCInput.cpp @@ -216,6 +216,12 @@ ssize_t VLCInput::m_read(uint8_t* buf, size_t length) err = -1; break; } + + char* nowplaying_sz = libvlc_media_get_meta(media, libvlc_meta_NowPlaying); + if (nowplaying_sz) { + m_nowplaying = nowplaying_sz; + free(nowplaying_sz); + } } return err; } @@ -230,5 +236,12 @@ ssize_t VLCInput::read(uint8_t* buf, size_t length) return read; } +void VLCInput::write_icy_text(const std::string& filename) const +{ + FILE* fd = fopen(filename.c_str(), "wb"); + fprintf(fd, "%s", m_nowplaying.c_str()); + fclose(fd); +} + #endif // HAVE_VLC diff --git a/src/VLCInput.h b/src/VLCInput.h index f97b9d9..ec7c80e 100644 --- a/src/VLCInput.h +++ b/src/VLCInput.h @@ -63,6 +63,10 @@ class VLCInput */ ssize_t read(uint8_t* buf, size_t length); + /* Write the last received ICY-Text to the + * file. + */ + void write_icy_text(const std::string& filename) const; // Callbacks for VLC @@ -97,6 +101,8 @@ class VLCInput unsigned m_channels; int m_rate; + std::string m_nowplaying; + // VLC pointers libvlc_instance_t *m_vlc; libvlc_media_player_t *m_mp; diff --git a/src/dabplus-enc.cpp b/src/dabplus-enc.cpp index 5911ea3..3fdb852 100644 --- a/src/dabplus-enc.cpp +++ b/src/dabplus-enc.cpp @@ -1,6 +1,6 @@ /* ------------------------------------------------------------------ * Copyright (C) 2011 Martin Storsjo - * Copyright (C) 2013,2014 Matthias P. Braendli + * Copyright (C) 2013,2014,2015 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. @@ -99,6 +99,7 @@ void usage(const char* name) { " -v, --vlc-uri=uri Enable VLC input and use the URI given as source\n" " -V Increase the VLC verbosity by one (can be given \n" " multiple times)\n" + " -w, --write-icy-text=filename Write the ICY Text into the file, so that mot-encoder can read it.\n" #else " The VLC input was disabled at compile-time\n" #endif @@ -247,6 +248,7 @@ int main(int argc, char *argv[]) // For the VLC input std::string vlc_uri = ""; + std::string vlc_icytext_file = ""; unsigned verbosity = 0; // For the file output @@ -293,6 +295,7 @@ int main(int argc, char *argv[]) {"channels", required_argument, 0, 'c'}, {"device", required_argument, 0, 'd'}, {"vlc-uri", required_argument, 0, 'v'}, + {"write-icy-text", required_argument, 0, 'w'}, {"format", required_argument, 0, 'f'}, {"input", required_argument, 0, 'i'}, {"jack", required_argument, 0, 'j'}, @@ -335,7 +338,7 @@ int main(int argc, char *argv[]) int index; while(ch != -1) { - ch = getopt_long(argc, argv, "aAhDlVb:c:f:i:j:k:o:r:d:p:P:s:v:", longopts, &index); + ch = getopt_long(argc, argv, "aAhDlVb:c:f:i:j:k:o:r:d:p:P:s:v:w:", longopts, &index); switch (ch) { case 0: // AAC-LC aot = AOT_DABPLUS_AAC_LC; @@ -413,13 +416,18 @@ int main(int argc, char *argv[]) } break; +#ifdef HAVE_VLC case 'v': -#ifndef HAVE_VLC - fprintf(stderr, "VLC input not enabled at compile time!\n"); - return 1; -#else vlc_uri = optarg; break; + case 'w': + vlc_icytext_file = optarg; + break; +#else + case 'v': + case 'w': + fprintf(stderr, "VLC input not enabled at compile time!\n"); + return 1; #endif case 'V': verbosity++; @@ -721,7 +729,7 @@ int main(int argc, char *argv[]) } } #if HAVE_VLC - else if (vlc_uri != "") { + else if (not vlc_uri.empty()) { read = vlc_in.read(input_buf, input_size); if (read < 0) { fprintf(stderr, "Detected fault in VLC input!\n"); @@ -731,6 +739,10 @@ int main(int argc, char *argv[]) fprintf(stderr, "Short VLC read !\n"); break; } + + if (not vlc_icytext_file.empty()) { + vlc_in.write_icy_text(vlc_icytext_file); + } } #endif else if (drift_compensation || jack_name) { |