audiodec: unify cover handling

Origin commit data
------------------
Branch: ni/coolstream
Commit: ae0f735d99
Author: vanhofen <vanhofen@gmx.de>
Date: 2017-06-27 (Tue, 27 Jun 2017)

Origin message was:
------------------
- audiodec: unify cover handling

------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
vanhofen
2017-06-27 23:45:57 +02:00
parent f97a29a785
commit c5dbede1d3
3 changed files with 10 additions and 5 deletions

View File

@@ -33,15 +33,19 @@
#include <cstring> #include <cstring>
#include <errno.h> #include <errno.h>
#include <sstream> #include <sstream>
#include <global.h>
#include <driver/audioplay.h> #include <driver/audioplay.h>
#include <zapit/include/audio.h> #include <zapit/include/audio.h>
#include <eitd/edvbstring.h> // UTF8 #include <eitd/edvbstring.h> // UTF8
#include "ffmpegdec.h" #include "ffmpegdec.h"
extern "C" { extern "C" {
#include <libavutil/opt.h> #include <libavutil/opt.h>
#include <libavutil/samplefmt.h> #include <libavutil/samplefmt.h>
#include <libswresample/swresample.h> #include <libswresample/swresample.h>
} }
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55, 28, 1) #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55, 28, 1)
#define av_frame_alloc avcodec_alloc_frame #define av_frame_alloc avcodec_alloc_frame
#define av_frame_unref avcodec_get_frame_defaults #define av_frame_unref avcodec_get_frame_defaults
@@ -63,8 +67,6 @@ extern cAudio * audioDecoder;
#define ProgName "FfmpegDec" #define ProgName "FfmpegDec"
#define COVERDIR "/tmp/cover"
static OpenThreads::Mutex mutex; static OpenThreads::Mutex mutex;
static int cover_count = 0; static int cover_count = 0;
@@ -521,7 +523,7 @@ bool CFfmpegDec::SetMetaData(FILE *_in, CAudioMetaData* m, bool save_cover)
if (save_cover && (avc->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC)) { if (save_cover && (avc->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC)) {
mkdir(COVERDIR, 0755); mkdir(COVERDIR, 0755);
std::string cover(COVERDIR); std::string cover(COVERDIR);
cover += "/" + to_string(cover_count++) + ".jpg"; cover += "/cover_" + to_string(cover_count++) + ".jpg";
FILE *f = fopen(cover.c_str(), "wb"); FILE *f = fopen(cover.c_str(), "wb");
if (f) { if (f) {
AVPacket *pkt = &avc->streams[i]->attached_pic; AVPacket *pkt = &avc->streams[i]->attached_pic;

View File

@@ -1388,9 +1388,10 @@ bool CMP3Dec::SaveCover(FILE * in, CAudioMetaData * const m)
data = id3_field_getbinarydata(field, &size); data = id3_field_getbinarydata(field, &size);
if ( data ) if ( data )
{ {
mkdir(COVERDIR, 0755);
std::ostringstream cover; std::ostringstream cover;
cover.str(""); cover.str(COVERDIR);
cover << "/tmp/cover_" << cover_count++ << ".jpg"; cover << "/cover_" << cover_count++ << ".jpg";
FILE * pFile; FILE * pFile;
pFile = fopen ( cover.str().c_str() , "wb" ); pFile = fopen ( cover.str().c_str() , "wb" );
if (pFile) if (pFile)

View File

@@ -49,6 +49,8 @@
#define NEUTRINO_SCAN_SETTINGS_FILE CONFIGDIR "/scan.conf" #define NEUTRINO_SCAN_SETTINGS_FILE CONFIGDIR "/scan.conf"
#define NEUTRINO_PARENTALLOCKED_FILE DATADIR "/neutrino/.plocked" #define NEUTRINO_PARENTALLOCKED_FILE DATADIR "/neutrino/.plocked"
#define COVERDIR "/tmp/cover"
#define LOGODIR ICONSDIR "/logo" #define LOGODIR ICONSDIR "/logo"
#define LOGODIR_VAR ICONSDIR_VAR "/logo" #define LOGODIR_VAR ICONSDIR_VAR "/logo"