bool __RDRenderLogLine::GetCutFile(const QString &cutname,int start_pt, int end_pt,QString *dest_filename) const { bool ret=false; RDAudioConvert::ErrorCode conv_err; RDAudioExport::ErrorCode export_err; char tempdir[PATH_MAX]; strncpy(tempdir,RDTempDirectory::basePath()+"/rdrenderXXXXXX",PATH_MAX); *dest_filename=QString(mkdtemp(tempdir))+"/"+cutname+".wav"; RDAudioExport *conv=new RDAudioExport(); conv->setDestinationFile(*dest_filename); conv->setCartNumber(RDCut::cartNumber(cutname)); conv->setCutNumber(RDCut::cutNumber(cutname)); RDSettings s; s.setFormat(RDSettings::Pcm16); s.setSampleRate(rda->system()->sampleRate()); s.setChannels(ll_channels); s.setNormalizationLevel(0); conv->setDestinationSettings(&s); conv->setRange(start_pt,end_pt); conv->setEnableMetadata(false); switch(export_err=conv->runExport(rda->user()->name(), rda->user()->password(),&conv_err)) { case RDAudioExport::ErrorOk: ret=true; break; default: ret=false; printf("export err %d [%s]\n",export_err, (const char *)RDAudioExport::errorText(export_err,conv_err).toUtf8()); break; } delete conv; return ret; }
QString RDFeed::GetExportCommand(RDStation *station,const QString &srcfile, QString *destfile,RDFeed::Error *err) const { int format_in=0; int len; RDSettings settings; QString custom_cmd; *destfile=GetTempFilename(); QFile file(srcfile); if(!file.exists()) { *err=RDFeed::ErrorCannotOpenFile; return QString(); } RDWaveFile *wave=new RDWaveFile(srcfile); if(!wave->openWave()) { *err=RDFeed::ErrorUnsupportedType; delete wave; return QString(); } int samplerate=wave->getSamplesPerSec(); switch(wave->getFormatTag()) { case WAVE_FORMAT_PCM: format_in=0; len=wave->getSampleLength()*wave->getChannels()* (wave->getBitsPerSample()/8); break; case WAVE_FORMAT_MPEG: format_in=wave->getHeadLayer(); len=wave->getSampleLength()*wave->getChannels()*2; break; } wave->closeWave(); delete wave; QString cmd; float normal=0.0; RDLibraryConf *rdlibrary=new RDLibraryConf(station->name(),0); if(normalizeLevel()<=0) { normal=pow(10.0,(double)(normalizeLevel()/20000.0)); cmd=QString(). sprintf("rd_export_file %6.4f %d %d %s %d %d %d %d %d %s %s.dat %s.%s %d", normal, format_in, samplerate, (const char *)srcfile, uploadFormat(), uploadChannels(), uploadSampleRate(), uploadBitRate()/1000, uploadQuality(), (const char *)RDEscapeString(*destfile), (const char *)(*destfile), (const char *)(*destfile), RDConfiguration()->audioExtension().ascii(), rdlibrary->srcConverter()); } else { cmd=QString(). sprintf("rd_export_file 0 %d %d %s %d %d %d %d %d %s %s.dat %s.%s %d", format_in, samplerate, (const char *)srcfile, uploadFormat(), uploadChannels(), uploadSampleRate(), uploadBitRate()/1000, uploadQuality(), (const char *)RDEscapeString(*destfile), (const char *)(*destfile), (const char *)(*destfile), RDConfiguration()->audioExtension().ascii(), rdlibrary->srcConverter()); } delete rdlibrary; switch(uploadFormat()) { // Custom format? case RDSettings::Pcm16: case RDSettings::MpegL1: case RDSettings::MpegL2: case RDSettings::MpegL3: case RDSettings::Flac: case RDSettings::OggVorbis: break; default: settings.setFormat(uploadFormat()); settings.setChannels(uploadChannels()); settings.setSampleRate(uploadSampleRate()); settings.setBitRate(uploadBitRate()); custom_cmd=settings.resolvedCustomCommandLine(*destfile); if(custom_cmd.isEmpty()) { return QString(); } cmd+=" \""+custom_cmd+"\""; break; } // printf("CMD: %s",(const char *)cmd); *err=RDFeed::ErrorOk; return cmd; }