diff --git a/src/daemonc/remotecontrol.cpp b/src/daemonc/remotecontrol.cpp index b238151fb..be5bc8c8c 100644 --- a/src/daemonc/remotecontrol.cpp +++ b/src/daemonc/remotecontrol.cpp @@ -427,13 +427,23 @@ void CRemoteControl::processAPIDnames() int pref_idx = -1; int pref_ac3_idx = -1; int ac3_found = -1; + const char *desc; + char lang[4]; if(g_settings.auto_lang) { /* first we check prefs to find pid according to pref index */ for(int i = 0; i < 3; i++) { for(int j = 0; j < (int) current_PIDs.APIDs.size(); j++) { + desc = current_PIDs.APIDs[j].desc; + // In some cases AAC is the only audio system used + // so accept it here as a 'normal' sound track + if(strstr(desc, "(AAC)")) { + strncpy(lang, desc, 3); + lang[3] = 0; + desc = lang; + } /* processAPIDnames called 2 times, TODO find better way to detect second call */ - if(strlen( current_PIDs.APIDs[j].desc ) != 3) + if(strlen( desc ) != 3) continue; if(strlen(g_settings.pref_lang[i]) == 0) continue; @@ -441,7 +451,7 @@ void CRemoteControl::processAPIDnames() std::string temp(g_settings.pref_lang[i]); std::map::const_iterator it; for(it = iso639.begin(); it != iso639.end(); it++) { - if(temp == it->second && strcasecmp(current_PIDs.APIDs[j].desc, it->first.c_str()) == 0) { + if(temp == it->second && strcasecmp(desc, it->first.c_str()) == 0) { /* remember first pref found index and pid*/ if(pref_found < 0) { pref_found = j; @@ -507,37 +517,14 @@ void CRemoteControl::processAPIDnames() strncpy(current_PIDs.APIDs[j].desc, tags[i].component.c_str(), 25); if (current_PIDs.APIDs[j].is_ac3) strncat(current_PIDs.APIDs[j].desc, " (AC3)", 25); + else if (current_PIDs.APIDs[j].is_aac) + strncat(current_PIDs.APIDs[j].desc, " (AAC)", 25); } current_PIDs.APIDs[j].component_tag = -1; break; } } } -#if 0 // old - CZapitClient::APIDList::iterator e = current_PIDs.APIDs.begin(); - while ( e != current_PIDs.APIDs.end() ) - { - if ( e->is_ac3 ) - { - has_ac3 = true; - } - e++; - } - - if ( /*( g_settings.audio_english == 0) &&*/ (g_settings.audio_DolbyDigital == 1)) - { - for (unsigned int j=0; j< current_PIDs.APIDs.size(); j++) - if ( current_PIDs.APIDs[j].is_ac3 ) - { - setAPID( j ); - break; - } - } - if ( current_PIDs.PIDs.selected_apid >= current_PIDs.APIDs.size() ) - { - setAPID( 0 ); - } -#endif } } } diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 9fc7217f4..3bed511d4 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -2415,7 +2415,7 @@ int CNeutrinoApp::run(int argc, char **argv) videoDecoder->SetCECAutoStandby(g_settings.hdmi_cec_standby == 1); videoDecoder->SetCECAutoView(g_settings.hdmi_cec_view_on == 1); videoDecoder->SetCECMode((VIDEO_HDMI_CEC_MODE)g_settings.hdmi_cec_mode); - + // trigger a change audioSetupNotifier->changeNotify(LOCALE_AUDIOMENU_AVSYNC, NULL); if(display_language_selection) diff --git a/src/zapit/include/zapit/channel.h b/src/zapit/include/zapit/channel.h index 4c1d376fd..569f9615f 100644 --- a/src/zapit/include/zapit/channel.h +++ b/src/zapit/include/zapit/channel.h @@ -92,9 +92,18 @@ class CZapitAudioChannel { public: unsigned short pid; - bool isAc3; std::string description; unsigned char componentTag; + + enum ZapitAudioChannelType { + MPEG, + AC3, + AAC, + AACPLUS, //? + DTS, + UNKNOWN, + }; + ZapitAudioChannelType audioChannelType; }; class CChannelList; @@ -186,7 +195,7 @@ class CZapitChannel unsigned short getAudioPid(unsigned char index = 0xFF); unsigned char getAudioChannelIndex(void) { return currentAudioChannel; } - int addAudioChannel(const unsigned short pid, const bool isAc3, const std::string & description, const unsigned char componentTag); + int addAudioChannel(const unsigned short pid, const CZapitAudioChannel::ZapitAudioChannelType audioChannelType, const std::string & description, const unsigned char componentTag); /* set methods */ void setServiceType(const unsigned char pserviceType) { serviceType = pserviceType; } diff --git a/src/zapit/include/zapit/client/zapitclient.h b/src/zapit/include/zapit/client/zapitclient.h index 619b23989..3c90b4904 100644 --- a/src/zapit/include/zapit/client/zapitclient.h +++ b/src/zapit/include/zapit/client/zapitclient.h @@ -180,6 +180,7 @@ class CZapitClient:public CBasicClient uint32_t pid; char desc[25]; int is_ac3; + int is_aac; int component_tag; }; diff --git a/src/zapit/src/channel.cpp b/src/zapit/src/channel.cpp index ad4f6ba8f..6ed1ae3cf 100644 --- a/src/zapit/src/channel.cpp +++ b/src/zapit/src/channel.cpp @@ -80,20 +80,20 @@ unsigned short CZapitChannel::getAudioPid(unsigned char index) return retval; } -int CZapitChannel::addAudioChannel(const unsigned short pid, const bool isAc3, const std::string & description, const unsigned char componentTag) +int CZapitChannel::addAudioChannel(const unsigned short pid, const CZapitAudioChannel::ZapitAudioChannelType audioChannelType, const std::string & description, const unsigned char componentTag) { std::vector ::iterator aI; for (aI = audioChannels.begin(); aI != audioChannels.end(); aI++) if ((* aI)->pid == pid) { (* aI)->description = description; - (* aI)->isAc3 = isAc3; + (* aI)->audioChannelType = audioChannelType; (* aI)->componentTag = componentTag; return -1; } CZapitAudioChannel *tmp = new CZapitAudioChannel(); tmp->pid = pid; - tmp->isAc3 = isAc3; + tmp->audioChannelType = audioChannelType; tmp->description = description; tmp->componentTag = componentTag; audioChannels.push_back(tmp); diff --git a/src/zapit/src/pmt.cpp b/src/zapit/src/pmt.cpp index b974dcd11..06238bb79 100644 --- a/src/zapit/src/pmt.cpp +++ b/src/zapit/src/pmt.cpp @@ -66,6 +66,7 @@ unsigned short parse_ES_info(const unsigned char * const buffer, CZapitChannel * bool isAc3 = false; bool isDts = false; + bool isAac = false; bool descramble = false; std::string description = ""; unsigned char componentTag = 0xFF; @@ -208,6 +209,7 @@ printf("[pmt] teletext type %d mag %d page %d lang %s\n", teletext_type, teletex break; case 0x7C: //FIXME AAC + isAac = true; break; case 0x90: /* unknown, Astra 19.2E */ @@ -280,7 +282,7 @@ printf("[pmt] name %s\n", description.c_str()); if(channel->getPreAudioPid() == 0) channel->setAudioPid(esInfo->elementary_PID); } else - channel->addAudioChannel(esInfo->elementary_PID, false, description, componentTag); + channel->addAudioChannel(esInfo->elementary_PID, CZapitAudioChannel::MPEG, description, componentTag); descramble = true; printf("[pmt] apid %x: %s\n", esInfo->elementary_PID, description.c_str()); break; @@ -323,23 +325,47 @@ printf("[pmt] name %s\n", description.c_str()); isAc3 = true; descramble = true; if(!scan_runs) - channel->addAudioChannel(esInfo->elementary_PID, true, description, componentTag); + channel->addAudioChannel(esInfo->elementary_PID, CZapitAudioChannel::AC3, description, componentTag); break; case 0x06: - if ((isAc3) || (isDts)) { + if ((isAc3) || (isDts) || (isAac)) { if (description == "") { description = esInfo->elementary_PID; if (isAc3) description += " (AC3)"; else if (isDts) description += " (DTS)"; + else if (isAac) + description += " (AAC)"; } - if(!scan_runs) - channel->addAudioChannel(esInfo->elementary_PID, true, description, componentTag); + + if(!scan_runs) { + CZapitAudioChannel::ZapitAudioChannelType Type; + if (isAc3) + Type = CZapitAudioChannel::AC3; + else if (isDts) + Type = CZapitAudioChannel::DTS; + else if (isAac) + Type = CZapitAudioChannel::AAC; + else + Type = CZapitAudioChannel::UNKNOWN; + channel->addAudioChannel(esInfo->elementary_PID, Type, description, componentTag); + } + descramble = true; } break; + case 0x0F: // AAC ADTS + case 0x11: // AAC LATM + if (description == "") + description = esInfo->elementary_PID; + description += " (AAC)"; + isAac = true; + descramble = true; + if(!scan_runs) + channel->addAudioChannel(esInfo->elementary_PID, CZapitAudioChannel::AAC, description, componentTag); + break; case 0x0B: break; diff --git a/src/zapit/src/pzapit.cpp b/src/zapit/src/pzapit.cpp index 845458776..4ac72c5b4 100644 --- a/src/zapit/src/pzapit.cpp +++ b/src/zapit/src/pzapit.cpp @@ -689,6 +689,11 @@ channel_found: std::cout << " audio " << std::dec << count + 1 << ": 0x" << std::hex << pids.APIDs[count].pid << " (" << pids.APIDs[count].desc; if (pids.APIDs[count].is_ac3) std::cout << ", ac3"; + else if (pids.APIDs[count].is_aac) + std::cout << ", aac"; + else + std::cout << ", unknown"; + std::cout << ")" << std::endl; } } diff --git a/src/zapit/src/zapit.cpp b/src/zapit/src/zapit.cpp index 059d78522..22c369a38 100644 --- a/src/zapit/src/zapit.cpp +++ b/src/zapit/src/zapit.cpp @@ -450,7 +450,7 @@ printf("[zapit] saving channel, apid %x sub pid %x mode %d volume %d\n", channel printf("[zapit] channel have pids: vpid %X apid %X pcr %X\n", channel->getVideoPid(), channel->getPreAudioPid(), channel->getPcrPid());fflush(stdout); if((channel->getAudioChannelCount() <= 0) && channel->getPreAudioPid() > 0) { std::string desc = "Preset"; - channel->addAudioChannel(channel->getPreAudioPid(), false, desc, 0xFF); + channel->addAudioChannel(channel->getPreAudioPid(), CZapitAudioChannel::MPEG, desc, 0xFF); } startPlayBack(channel); } @@ -502,7 +502,7 @@ printf("[zapit] saving channel, apid %x sub pid %x mode %d volume %d\n", channel if (channel->getAudioChannel(i)->pid == audio_map_it->second.apid ) { DBG("***** Setting audio!\n"); channel->setAudioChannel(i); - if(we_playing && channel->getAudioChannel(i)->isAc3) change_audio_pid(i); + if(we_playing && (channel->getAudioChannel(i)->audioChannelType != CZapitAudioChannel::MPEG)) change_audio_pid(i); } } } @@ -605,10 +605,26 @@ int change_audio_pid(uint8_t index) return -1; } - if (currentAudioChannel->isAc3) - audioDecoder->SetStreamType(AUDIO_FMT_DOLBY_DIGITAL); - else - audioDecoder->SetStreamType(AUDIO_FMT_MPEG); + switch (currentAudioChannel->audioChannelType) { + case CZapitAudioChannel::AC3: + audioDecoder->SetStreamType(AUDIO_FMT_DOLBY_DIGITAL); + break; + case CZapitAudioChannel::MPEG: + audioDecoder->SetStreamType(AUDIO_FMT_MPEG); + break; + case CZapitAudioChannel::AAC: + audioDecoder->SetStreamType(AUDIO_FMT_AAC); + break; + case CZapitAudioChannel::AACPLUS: + audioDecoder->SetStreamType(AUDIO_FMT_AAC_PLUS); + break; + case CZapitAudioChannel::DTS: + audioDecoder->SetStreamType(AUDIO_FMT_DTS); + break; + default: + printf("[zapit] unknown audio channel type 0x%x\n", currentAudioChannel->audioChannelType); + break; + } printf("[zapit] change apid to 0x%x\n", channel->getAudioPid()); /* set demux filter */ @@ -1669,7 +1685,13 @@ void sendAPIDs(int connfd) CZapitClient::responseGetAPIDs response; response.pid = channel->getAudioPid(i); strncpy(response.desc, channel->getAudioChannel(i)->description.c_str(), 25); - response.is_ac3 = channel->getAudioChannel(i)->isAc3; + if (channel->getAudioChannel(i)->audioChannelType == CZapitAudioChannel::AC3) { + response.is_ac3 = 1; + response.is_aac = 0; + } else if (channel->getAudioChannel(i)->audioChannelType == CZapitAudioChannel::AAC) { + response.is_ac3 = 0; + response.is_aac = 1; + } response.component_tag = channel->getAudioChannel(i)->componentTag; if (CBasicServer::send_data(connfd, &response, sizeof(response)) == false) { @@ -1882,12 +1904,34 @@ int startPlayBack(CZapitChannel *thisChannel) /* select audio output and start audio */ if (have_audio) { - if (thisChannel->getAudioChannel()->isAc3) - audioDecoder->SetStreamType(AUDIO_FMT_DOLBY_DIGITAL); - else - audioDecoder->SetStreamType(AUDIO_FMT_MPEG); + const char *audioStr = "UNKNOWN"; + switch (thisChannel->getAudioChannel()->audioChannelType) { + case CZapitAudioChannel::AC3: + audioStr = "AC3"; + audioDecoder->SetStreamType(AUDIO_FMT_DOLBY_DIGITAL); + break; + case CZapitAudioChannel::MPEG: + audioStr = "MPEG2"; + audioDecoder->SetStreamType(AUDIO_FMT_MPEG); + break; + case CZapitAudioChannel::AAC: + audioStr = "AAC"; + audioDecoder->SetStreamType(AUDIO_FMT_AAC); + break; + case CZapitAudioChannel::AACPLUS: + audioStr = "AAC-PLUS"; + audioDecoder->SetStreamType(AUDIO_FMT_AAC_PLUS); + break; + case CZapitAudioChannel::DTS: + audioStr = "DTS"; + audioDecoder->SetStreamType(AUDIO_FMT_DTS); + break; + default: + printf("[zapit] unknown audio channel type 0x%x\n", thisChannel->getAudioChannel()->audioChannelType); + break; + } - printf("[zapit] starting %s audio\n", thisChannel->getAudioChannel()->isAc3 ? "AC3" : "MPEG2"); + printf("[zapit] starting %s audio\n", audioStr); audioDemux->Start(); audioDecoder->Start(); }