diff --git a/src/driver/genpsi.cpp b/src/driver/genpsi.cpp index bdd3f51a3..d921b98f0 100644 --- a/src/driver/genpsi.cpp +++ b/src/driver/genpsi.cpp @@ -39,6 +39,8 @@ #define ES_TYPE_MPA 0x03 #define ES_TYPE_EAC3 0x7a #define ES_TYPE_AC3 0x81 +#define ES_TYPE_AAC 0x0f +#define ES_TYPE_AACP 0x11 static const uint32_t crc_table[256] = { 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, @@ -192,6 +194,32 @@ void CGenPsi::addPid(uint16_t pid, uint16_t pidtype, short isAC3, const char *da } neac3++; break; + case EN_TYPE_AUDIO_AAC: + aac_pid[naac] = pid; + if(data != NULL){ + aac_lang[naac][0] = data[0]; + aac_lang[naac][1] = data[1]; + aac_lang[naac][2] = data[2]; + }else{ + aac_lang[naac][0] = 'u'; + aac_lang[naac][1] = 'n'; + aac_lang[naac][2] = 'k'; + } + naac++; + break; + case EN_TYPE_AUDIO_AACP: + aacp_pid[naacp] = pid; + if(data != NULL){ + aacp_lang[naacp][0] = data[0]; + aacp_lang[naacp][1] = data[1]; + aacp_lang[naacp][2] = data[2]; + }else{ + aacp_lang[naacp][0] = 'u'; + aacp_lang[naacp][1] = 'n'; + aacp_lang[naacp][2] = 'k'; + } + naacp++; + break; default: break; } @@ -333,6 +361,52 @@ void CGenPsi::build_pmt(uint8_t* buffer) buffer[off++] = 0xc5; } + // aac audio + for (int index = 0; index < naac && off < (TS_DATA_LEN-18); index++) + { + buffer[off++] = ES_TYPE_AAC; + buffer[off++] = 0xe0 | aac_pid[index]>>8; + buffer[off++] = aac_pid[index]&0xff; + buffer[off++] = 0xf0; + buffer[off++] = 0x0d; + buffer[off++] = 0x2b; // aac descriptor + buffer[off++] = 0x02; + buffer[off++] = 0x52; + buffer[off++] = 0x00; + buffer[off++] = 0x52; + buffer[off++] = 0x01; + buffer[off++] = 0x20; + buffer[off++] = 0x0a; // iso639 descriptor tag + buffer[off++] = 0x04; // descriptor length + buffer[off++] = aac_lang[index][0]; + buffer[off++] = aac_lang[index][1]; + buffer[off++] = aac_lang[index][2]; + buffer[off++] = 0x00; // audio type + } + + // aacp audio + for (int index = 0; index < naacp && off < (TS_DATA_LEN-18); index++) + { + buffer[off++] = ES_TYPE_AACP; + buffer[off++] = 0xe0 | aacp_pid[index]>>8; + buffer[off++] = aacp_pid[index]&0xff; + buffer[off++] = 0xf0; + buffer[off++] = 0x0d; + buffer[off++] = 0x7C; // aacp descriptor + buffer[off++] = 0x02; + buffer[off++] = 0x52; + buffer[off++] = 0x00; + buffer[off++] = 0x52; + buffer[off++] = 0x01; + buffer[off++] = 0x20; + buffer[off++] = 0x0a; // iso639 descriptor tag + buffer[off++] = 0x04; // descriptor length + buffer[off++] = aacp_lang[index][0]; + buffer[off++] = aacp_lang[index][1]; + buffer[off++] = aacp_lang[index][2]; + buffer[off++] = 0x00; // audio type + } + // Subtitle streams for (int index = 0; index < nsub && off < (TS_DATA_LEN-15); index++) { diff --git a/src/driver/genpsi.h b/src/driver/genpsi.h index c52b4acb2..758a46978 100644 --- a/src/driver/genpsi.h +++ b/src/driver/genpsi.h @@ -31,12 +31,14 @@ #define EN_TYPE_DVBSUB 0x06 #define EN_TYPE_AUDIO_EAC3 0x07 #define EN_TYPE_HEVC 0x08 +#define EN_TYPE_AUDIO_AAC 0x09 +#define EN_TYPE_AUDIO_AACP 0x0a class CGenPsi { private: static const unsigned int pmt_pid = 0xcc; - short nba, nsub, neac3; + short nba, nsub, neac3, naac, naacp; uint16_t vpid; uint8_t vtype; uint16_t pcrpid; @@ -49,6 +51,10 @@ class CGenPsi char dvbsublang[10][3]; uint16_t eac3_pid[10]; char eac3_lang[10][3]; + uint16_t aac_pid[10]; + char aac_lang[10][3]; + uint16_t aacp_pid[10]; + char aacp_lang[10][3]; uint32_t calc_crc32psi(uint8_t *dst, const uint8_t *src, uint32_t len); void build_pat(uint8_t* buffer); void build_pmt(uint8_t* buffer); diff --git a/src/driver/record.cpp b/src/driver/record.cpp index b1c08a661..5f8524b8d 100644 --- a/src/driver/record.cpp +++ b/src/driver/record.cpp @@ -213,10 +213,20 @@ record_error_msg_t CRecordInstance::Start(CZapitChannel * channel) } for (unsigned int i = 0; i < recMovieInfo->audioPids.size(); i++) { apids[numpids++] = recMovieInfo->audioPids[i].AudioPid; - if(channel->getAudioChannel(i)->audioChannelType == CZapitAudioChannel::EAC3){ - psi.addPid(recMovieInfo->audioPids[i].AudioPid, EN_TYPE_AUDIO_EAC3, recMovieInfo->audioPids[i].atype, channel->getAudioChannel(i)->description.c_str()); - }else - psi.addPid(recMovieInfo->audioPids[i].AudioPid, EN_TYPE_AUDIO, recMovieInfo->audioPids[i].atype, channel->getAudioChannel(i)->description.c_str()); + switch (channel->getAudioChannel(i)->audioChannelType) { + case CZapitAudioChannel::EAC3: + psi.addPid(recMovieInfo->audioPids[i].AudioPid, EN_TYPE_AUDIO_EAC3, recMovieInfo->audioPids[i].atype, channel->getAudioChannel(i)->description.c_str()); + break; + case CZapitAudioChannel::AAC: + psi.addPid(recMovieInfo->audioPids[i].AudioPid, EN_TYPE_AUDIO_AAC, recMovieInfo->audioPids[i].atype, channel->getAudioChannel(i)->description.c_str()); + break; + case CZapitAudioChannel::AACPLUS: + psi.addPid(recMovieInfo->audioPids[i].AudioPid, EN_TYPE_AUDIO_AACP, recMovieInfo->audioPids[i].atype, channel->getAudioChannel(i)->description.c_str()); + break; + default: + psi.addPid(recMovieInfo->audioPids[i].AudioPid, EN_TYPE_AUDIO, recMovieInfo->audioPids[i].atype, channel->getAudioChannel(i)->description.c_str()); + break; + } if (numpids >= REC_MAX_APIDS) break; diff --git a/src/zapit/src/scanpmt.cpp b/src/zapit/src/scanpmt.cpp index 0184f2f38..6ecbdf400 100644 --- a/src/zapit/src/scanpmt.cpp +++ b/src/zapit/src/scanpmt.cpp @@ -296,10 +296,13 @@ bool CPmt::ParseEsInfo(ElementaryStreamInfo *esinfo, CZapitChannel * const chann audio = true; break; case 0x0F: // AAC ADTS (MPEG2) - case 0x11: // AAC LATM (MPEG4) audio_type = CZapitAudioChannel::AAC; audio = true; break; + case 0x11: // AAC LATM (MPEG4) + audio_type = CZapitAudioChannel::AACPLUS; + audio = true; + break; case 0x81: // Dolby Digital audio_type = CZapitAudioChannel::AC3; audio = true;