static void print_ipsecstats(const struct ipsecstat *ipsecstat) { #define p(f, m) if (ipsecstat->f || sflag <= 1) \ printf(m, (uintmax_t)ipsecstat->f, plural(ipsecstat->f)) #define pes(f, m) if (ipsecstat->f || sflag <= 1) \ printf(m, (uintmax_t)ipsecstat->f, plurales(ipsecstat->f)) #define hist(f, n, t) \ ipsec_hist((f), sizeof(f)/sizeof(f[0]), (n), (t)); p(in_success, "\t%ju inbound packet%s processed successfully\n"); p(in_polvio, "\t%ju inbound packet%s violated process security " "policy\n"); p(in_nosa, "\t%ju inbound packet%s with no SA available\n"); p(in_inval, "\t%ju invalid inbound packet%s\n"); p(in_nomem, "\t%ju inbound packet%s failed due to insufficient memory\n"); p(in_badspi, "\t%ju inbound packet%s failed getting SPI\n"); p(in_ahreplay, "\t%ju inbound packet%s failed on AH replay check\n"); p(in_espreplay, "\t%ju inbound packet%s failed on ESP replay check\n"); p(in_ahauthsucc, "\t%ju inbound packet%s considered authentic\n"); p(in_ahauthfail, "\t%ju inbound packet%s failed on authentication\n"); hist(ipsecstat->in_ahhist, ipsec_ahnames, "AH input"); hist(ipsecstat->in_esphist, ipsec_espnames, "ESP input"); hist(ipsecstat->in_comphist, ipsec_compnames, "IPComp input"); p(out_success, "\t%ju outbound packet%s processed successfully\n"); p(out_polvio, "\t%ju outbound packet%s violated process security " "policy\n"); p(out_nosa, "\t%ju outbound packet%s with no SA available\n"); p(out_inval, "\t%ju invalid outbound packet%s\n"); p(out_nomem, "\t%ju outbound packet%s failed due to insufficient memory\n"); p(out_noroute, "\t%ju outbound packet%s with no route\n"); hist(ipsecstat->out_ahhist, ipsec_ahnames, "AH output"); hist(ipsecstat->out_esphist, ipsec_espnames, "ESP output"); hist(ipsecstat->out_comphist, ipsec_compnames, "IPComp output"); p(spdcachelookup, "\t%ju SPD cache lookup%s\n"); pes(spdcachemiss, "\t%ju SPD cache miss%s\n"); #undef pes #undef hist p(ips_in_polvio, "\t%ju inbound packet%s violated process " "security policy\n"); p(ips_out_polvio, "\t%ju outbound packet%s violated process " "security policy\n"); p(ips_out_nosa, "\t%ju outbound packet%s with no SA available\n"); p(ips_out_nomem, "\t%ju outbound packet%s failed due to " "insufficient memory\n"); p(ips_out_noroute, "\t%ju outbound packet%s with no route " "available\n"); p(ips_out_inval, "\t%ju invalid outbound packet%s\n"); p(ips_out_bundlesa, "\t%ju outbound packet%s with bundled SAs\n"); p(ips_mbcoalesced, "\t%ju mbuf%s coalesced during clone\n"); p(ips_clcoalesced, "\t%ju cluster%s coalesced during clone\n"); p(ips_clcopied, "\t%ju cluster%s copied during clone\n"); p(ips_mbinserted, "\t%ju mbuf%s inserted during makespace\n"); #undef p }
/** \fn addAudioTrack \brief gather information about audio & add audio track to the list */ bool tsGetAudioInfo(tsPacketLinear *p,tsAudioTrackInfo *trackInfo) { #define PROBE_ANALYZE_SIZE 6000 // Should be enough in all cases (need ~ 2 blocks) uint8_t audioBuffer[PROBE_ANALYZE_SIZE]; uint64_t pts,dts,startAt; trackInfo->extraDataLen=0; // dont even try if it is not audio switch(trackInfo->trackType) { case ADM_TS_MPEG_AUDIO: case ADM_TS_AC3: case ADM_TS_EAC3: case ADM_TS_AAC_ADTS: case ADM_TS_AAC_LATM: break; default: ADM_warning("Unsupported audio track (%d)\n",trackInfo->trackType); return false; } // Go back where we were p->changePid(trackInfo->esId); //Realign p->seek(0,0); // This is a special case... // For ADTS, we read one packet and ask ffmpeg to extract // Extra data, frequency etc... ADM_TS_TRACK_TYPE trackType=trackInfo->trackType; //--------------------- AAC ------------------------- if(trackType==ADM_TS_AAC_ADTS || trackType==ADM_TS_AAC_LATM) { // Step 1, try to get a packet... TS_PESpacket pes(trackInfo->esId); int retries=5; int offset; uint32_t eLen=0; uint8_t *eData=NULL; trackInfo->wav.encoding=WAV_AAC; again: if(!retries) { ADM_error("Cannot get info from audio\n"); return false; } if(false==p->getNextPES(&pes)) { ADM_warning("Cannot get pes packet for AAC track\n"); return false; } retries--; // try to decode header.. uint8_t *ptr=pes.payload+pes.offset; int size=pes.payloadSize-pes.offset; switch(trackType) { default: case ADM_TS_AAC_LATM: { ADM_latm2aac latm; ADM_info("Looking up LATM info"); retries=20; while(retries) { ptr=pes.payload+pes.offset; size=pes.payloadSize-pes.offset; latm.flush(); latm.pushData(size,ptr,0); if(latm.getFrequency()) { ADM_assert(latm.getExtraData(&eLen,&eData)); trackInfo->wav.frequency=latm.getFrequency(); trackInfo->wav.channels=latm.getChannels(); trackInfo->wav.byterate=128000>>3; trackInfo->extraDataLen=eLen; trackInfo->extraData[0]=eData[0]; trackInfo->extraData[1]=eData[1]; trackInfo->mux=ADM_TS_MUX_LATM; ADM_info("AAC extra data : %02x %02x\n",eData[0],eData[1]); return true; } // next packet retries--; if(false==p->getNextPES(&pes)) { ADM_error("Cannot get next PES packet for LATM extradata\n"); return false; } } ADM_error("LATM : Cannot get codec extra data\n"); return false; // break; } case ADM_TS_AAC_ADTS: { ADM_adts2aac adts; trackInfo->mux=ADM_TS_MUX_ADTS; int dummySize=0; if(false==adts.convert(size,ptr,&dummySize,NULL)) // We dont need the output hence the null goto again; adts.getExtraData(&eLen,&eData); if( eLen!=2) { ADM_error("%d bytes of extradata, expecting 2"); return false; } trackInfo->extraDataLen=eLen; trackInfo->extraData[0]=eData[0]; trackInfo->extraData[1]=eData[1]; ADM_info("AAC extra data : %02x %02x\n",eData[0],eData[1]); trackInfo->wav.frequency=adts.getFrequency(); trackInfo->wav.channels=adts.getChannels(); trackInfo->wav.byterate=128000>>3; return true; } break; }