diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/odr-padenc.cpp | 7 | ||||
| -rw-r--r-- | src/pad_common.cpp | 12 | ||||
| -rw-r--r-- | src/pad_interface.cpp | 24 | ||||
| -rw-r--r-- | src/pad_interface.h | 6 | ||||
| -rw-r--r-- | src/sls.cpp | 13 | ||||
| -rw-r--r-- | src/sls.h | 2 |
6 files changed, 51 insertions, 13 deletions
diff --git a/src/odr-padenc.cpp b/src/odr-padenc.cpp index 49f48b2..5862d17 100644 --- a/src/odr-padenc.cpp +++ b/src/odr-padenc.cpp @@ -58,9 +58,12 @@ static void usage(const char* name) { fprintf(stderr, " -d, --dir=DIRNAME Directory to read images from.\n" " -e, --erase Erase slides from DIRNAME once they have\n" " been encoded.\n" - " -s, --sleep=DUR Wait DUR seconds between each slide\n" + " -s, --sleep=DUR Wait DUR seconds between each slide. If set to 0, the next slide is inserted just after the previous one\n" + " has been transmitted. This is useful e.g. for stations that transmit just a logo slide.\n" " Default: %d\n" - " -o, --output=IDENTIFIER Socket to communicate with audio encoder\n" + " -o, --output=IDENTIFIER Socket to communicate with audio encoder.\n" + " If IDENTIFIER contains '/', it's used as a full path.\n" + " Otherwise, /tmp/ is prepended for backward compatibility\n" " --dump-current-slide=F1 Write the slide currently being transmitted to the file F1\n" " --dump-completed-slide=F2 Once the slide is transmitted, move the file from F1 to F2\n" " -t, --dls=FILENAME FIFO or file to read DLS text from.\n" diff --git a/src/pad_common.cpp b/src/pad_common.cpp index 8ee2cd8..f8e769a 100644 --- a/src/pad_common.cpp +++ b/src/pad_common.cpp @@ -143,7 +143,9 @@ std::vector<uint8_t> PADPacketizer::GetNextPAD(bool output_xpad) { pad_t* pad = output_xpad ? GetPAD() : FlushPAD(); if (verbose >= 2) { - fprintf(stderr, "ODR-PadEnc writing PAD (%zu bytes):", pad->size()); + fprintf(stderr, "ODR-PadEnc writing %cPAD (%zu bytes):", + output_xpad ? 'X' : 'F', + pad->size()); for (size_t j = 0; j < pad->size(); j++) { const char sep = (j == (pad->size() - 1) || j == (pad->size() - 1 - FPAD_LEN)) ? '|' : ' '; fprintf(stderr, "%c%02X", sep , (*pad)[j]); @@ -227,6 +229,14 @@ bool PADPacketizer::AppendDG(DATA_GROUP* dg) { } else { AppendDGWithCI(dg); + /* + fprintf(stderr, "flush? %d %zu == %zu or %d: %zu + %zu > (%zu - %zu)\n", + used_cis == max_cis, + used_cis, max_cis, + SUBFIELD_LENS[0] + AddCINeededBytes() > (xpad_size_max - xpad_size), + SUBFIELD_LENS[0], AddCINeededBytes(), xpad_size_max, xpad_size); + */ + // if no further sub-fields could be added, PAD must be flushed if (used_cis == max_cis || SUBFIELD_LENS[0] + AddCINeededBytes() > (xpad_size_max - xpad_size)) return true; diff --git a/src/pad_interface.cpp b/src/pad_interface.cpp index 3db5308..26a04ab 100644 --- a/src/pad_interface.cpp +++ b/src/pad_interface.cpp @@ -47,7 +47,17 @@ void PadInterface::open(const std::string &pad_ident) struct sockaddr_un claddr; memset(&claddr, 0, sizeof(struct sockaddr_un)); claddr.sun_family = AF_UNIX; - snprintf(claddr.sun_path, sizeof(claddr.sun_path), "/tmp/%s.padenc", m_pad_ident.c_str()); + + size_t last_slash = m_pad_ident.find_last_of('/'); + if (last_slash != std::string::npos) { + // Full path provided, use as-is with .padenc suffix + std::string socket_dir = m_pad_ident.substr(0, last_slash); + std::string socket_base = m_pad_ident.substr(last_slash + 1); + snprintf(claddr.sun_path, sizeof(claddr.sun_path), "%s/%s.padenc", socket_dir.c_str(), socket_base.c_str()); + } else { + // Identifier only, use /tmp/ for backward compatibility + snprintf(claddr.sun_path, sizeof(claddr.sun_path), "/tmp/%s.padenc", m_pad_ident.c_str()); + } if (unlink(claddr.sun_path) == -1 and errno != ENOENT) { fprintf(stderr, "Unlinking of socket %s failed: %s\n", claddr.sun_path, strerror(errno)); } @@ -110,7 +120,17 @@ void PadInterface::send_pad_data(const uint8_t *data, size_t len) struct sockaddr_un claddr; memset(&claddr, 0, sizeof(struct sockaddr_un)); claddr.sun_family = AF_UNIX; - snprintf(claddr.sun_path, sizeof(claddr.sun_path), "/tmp/%s.audioenc", m_pad_ident.c_str()); + + size_t last_slash = m_pad_ident.find_last_of('/'); + if (last_slash != std::string::npos) { + // Full path provided, use as-is with .audioenc suffix + std::string socket_dir = m_pad_ident.substr(0, last_slash); + std::string socket_base = m_pad_ident.substr(last_slash + 1); + snprintf(claddr.sun_path, sizeof(claddr.sun_path), "%s/%s.audioenc", socket_dir.c_str(), socket_base.c_str()); + } else { + // Identifier only, use /tmp/ for backward compatibility + snprintf(claddr.sun_path, sizeof(claddr.sun_path), "/tmp/%s.audioenc", m_pad_ident.c_str()); + } vector<uint8_t> message(len + 1); message[0] = MESSAGE_PAD_DATA; diff --git a/src/pad_interface.h b/src/pad_interface.h index f0307bd..2803b5e 100644 --- a/src/pad_interface.h +++ b/src/pad_interface.h @@ -33,8 +33,10 @@ class PadInterface { public: - /*! Create a new PAD data interface that binds to /tmp/pad_ident.padenc and - * communicates with ODR-AudioEnc at /tmp/pad_ident.audioenc + /*! Create a new PAD data interface that binds to a socket and + * communicates with ODR-AudioEnc. If pad_ident contains '/', it's used as a full path. + * Otherwise, /tmp/ is prepended for backward compatibility. + * Sockets: pad_ident.padenc (this) and pad_ident.audioenc (ODR-AudioEnc) */ void open(const std::string &pad_ident); diff --git a/src/sls.cpp b/src/sls.cpp index f6cfb6f..8a0c0da 100644 --- a/src/sls.cpp +++ b/src/sls.cpp @@ -261,9 +261,12 @@ const int SLSEncoder::APPTYPE_MOT_CONT = 13; const std::string SLSEncoder::REQUEST_REREAD_FILENAME = "REQUEST_SLIDES_DIR_REREAD"; -void SLSEncoder::warnOnSmallerImage(size_t height, size_t width, const std::string& fname) { - if (height < 240 || width < 320) - fprintf(stderr, "ODR-PadEnc Warning: Image '%s' smaller than recommended size (%zu x %zu < 320 x 240 px)\n", fname.c_str(), width, height); +void SLSEncoder::warnOnSmallerImage(size_t height, size_t width, const std::string& fname, bool resized) { + if (height < 240 || width < 320) { + fprintf(stderr, "ODR-PadEnc Warning: %s '%s' smaller than recommended size (%zu x %zu < 320 x 240 px)%s\n", + resized ? "Resized image" : "Image", fname.c_str(), width, height, + resized ? "; please use 4:3 aspect ratio" : ""); + } } @@ -345,7 +348,7 @@ size_t SLSEncoder::resizeImage(MagickWand* m_wand, unsigned char** blob, const s } // warn if resized image smaller than default dimension - warnOnSmallerImage(height, width, fname); + warnOnSmallerImage(height, width, fname, true); MagickRelinquishMemory(*jfif_not_png ? blob_png : blob_jpg); *blob = *jfif_not_png ? blob_jpg : blob_png; @@ -485,7 +488,7 @@ bool SLSEncoder::encodeSlide(const std::string& fname, int fidx, bool raw_slides blobsize = resizeImage(m_wand, &magick_blob, fname, &jfif_not_png, max_slide_size); } else { // warn if unresized image smaller than default dimension - warnOnSmallerImage(height, width, fname); + warnOnSmallerImage(height, width, fname, false); } #else @@ -227,7 +227,7 @@ private: static const int MINQUALITY; static const std::string SLS_PARAMS_SUFFIX; - void warnOnSmallerImage(size_t height, size_t width, const std::string& fname); + void warnOnSmallerImage(size_t height, size_t width, const std::string& fname, bool resized); #if HAVE_MAGICKWAND size_t resizeImage(MagickWand* m_wand, unsigned char** blob, const std::string& fname, bool* jfif_not_png, size_t max_slide_size); #endif |
