boxstack->update(crash);
}
+int Command::getLangPref(bool subtitle,const char* langcode)
+{
+ vector<struct ASLPref>::iterator itty=langcodes.begin();
+ char templangcode[4];
+ templangcode[0]=langcode[0];
+ templangcode[1]=langcode[1];
+ templangcode[2]=langcode[2];
+ templangcode[3]='\0';
+ int langpos =0;
+ while (itty != langcodes.end()) {
+ size_t pos=(*itty).langcode.find(templangcode);
+ if (pos != string::npos) {
+ vector<struct ASLPref>::iterator itty2=langcodes.begin();
+ for (int i=0; i<langcodes.size();i++) {
+ int pref=-1;
+ if (subtitle) {
+ pref=langcodes[i].subtitlepref;
+ } else {
+ pref=langcodes[i].audiopref;
+ }
+ if (pref < -1) break;
+
+ if (langcodes[i].audiopref==langpos) {
+ return i;
+ }
+ }
+ break;
+ }
+ itty++;
+ langpos++;
+ }
+ return langcodes.size(); //neutral
+}
+
void Command::doJustConnected(VConnect* vconnect)
{
I18n::initialize();
#include "defines.h"
#include "messagequeue.h"
#include "udp.h"
+#include <vector>
+#include <string>
class VConnect;
class Message;
class VInfo;
class WJpeg;
+struct ASLPref {
+ std::string langcode;
+ int audiopref;
+ int subtitlepref;
+};
+
+typedef vector<struct ASLPref> ASLPrefList;
+
class Command : public MessageQueue
{
public:
void setAdvMenues(bool adv) {advmenues=adv;};
bool advMenues() { return advmenues;};
+ int getLangPref(bool subtitle,const char* langcode);
+ void setSubDefault(int subon) {subdefault=subon;};
+ int getSubDefault() { return subdefault;};
+ ASLPrefList &getASLList(){return langcodes;};
private:
void handleCommand(int);
char* server;
bool advmenues;
+ ASLPrefList langcodes;
+ int subdefault;
UDP udp;
new_channelinfo.apids.push_back(newapid);
new_channelinfo.numAPids++;
- if (getAID() == 0 && Audio::getInstance()->streamTypeSupported(streamtype)) { //set unset AID to first audio pid that reports itself
- setAID(foundpid,0,streamtype,false);
- Log::getInstance()->log("ProcessTS", Log::DEBUG, "Set audio PID to %x", foundpid);
- }
+
} break;
case 5:
case 6: { //Private Data
}
+
bool audioPIDpresent=false; //Check if pids chnages
ULONG i;
for (i=0;i<channelinfo.numAPids;i++) {
audioPIDpresent=true;
}
}
- if (! audioPIDpresent) {
- bool found=false;
- if (channelinfo.numAPids>0) {
- int j=0;
- while (j<channelinfo.numAPids && !found) {
- if (Audio::getInstance()->streamTypeSupported(channelinfo.apids[j].type)) {
- found =true;
- setAID(channelinfo.apids[j].pid,0,channelinfo.apids[j].type,false);
+ if (! audioPIDpresent || getAID() == 0) {
+
+ bool dolby=false;
+ int selected=-1;
+ int prefered=-1;
+ Command* command = Command::getInstance();
+
+ if (channelinfo.numDPids > 0 && Audio::getInstance()->maysupportAc3())
+ {
+ ULONG j = 0;
+ while (j < channelinfo.numDPids)
+ {
+ int newpref = command->getLangPref(false, channelinfo.dpids[j].desc);
+ if (Audio::getInstance()->streamTypeSupported(channelinfo.dpids[j].type)
+ && (prefered < 0 || newpref < prefered))
+ {
+ selected = j;
+ dolby=true;
+ prefered = newpref;
}
j++;
}
+ }
+ if (channelinfo.numAPids > 0)
+ {
+ ULONG j = 0;
+ while (j < channelinfo.numAPids)
+ {
+ int newpref = command->getLangPref(false, channelinfo.apids[j].desc);
+ if (Audio::getInstance()->streamTypeSupported(channelinfo.apids[j].type)
+ && (prefered < 0 || newpref < prefered))
+ {
+ selected = j;
+ dolby=false;
+ prefered = newpref;
+ }
+ j++;
+ }
+ }
+ if (selected >= 0) {
+ if (dolby) {
+ setAID(channelinfo.dpids[selected].pid,1,channelinfo.dpids[selected].type,false);
+ Audio::getInstance()->setStreamType(Audio::MPEG2_PES);
+ } else {
+ setAID(channelinfo.dpids[selected].pid,0,channelinfo.apids[selected].type,false);
+ Audio::getInstance()->setStreamType(Audio::MPEG2_PES);
+ }
}
- if (channelinfo.numDPids>0 && !found) {
- int j=0;
- while (j<channelinfo.numDPids && !found) {
- if (Audio::getInstance()->streamTypeSupported(channelinfo.dpids[j].type)) {
- found =true;
- setAID(channelinfo.dpids[j].pid,1,channelinfo.dpids[j].type,false);
+
+
+ selected = -1;
+ prefered=-1;
+ if (channelinfo.numSPids) {
+ ULONG j = 0;
+ while (j < channelinfo.numSPids)
+ {
+ int newpref = command->getLangPref(true, channelinfo.spids[j].desc);
+ if ( (prefered < 0 || newpref < prefered))
+ {
+ selected = j;
+ prefered = newpref;
}
- i++;
+ j++;
}
}
+
+ if (selected >= 0) {
+ setSubID(channelinfo.spids[selected].pid);
+
+ }
}
channelinfo=new_channelinfo;
video->blank();
audio->stop();
+ if (Command::getInstance()->getSubDefault()) {
+ turnSubtitlesOn(true);
+ } else {
+ turnSubtitlesOn(false);
+ }
+
initted = true;
return 1;
}
if (!checkError())
{
- Channel* chan = (*chanList)[i.channelIndex];
- chan->loadPids();
- h264=chan->vstreamtype==0x1b;
- demuxer->seth264(h264);
- video->seth264mode(chan->vstreamtype==0x1b);
- demuxer->setVID(chan->vpid);
- video->seth264mode(chan->vstreamtype==0x1b);
-
- bool found=false;
-
- if (chan->numAPids > 0)
- {
- ULONG j = 0;
- while (j < chan->numAPids && !found)
- {
- if (Audio::getInstance()->streamTypeSupported(chan->apids[j].type))
- {
- demuxer->setAID(chan->apids[j].pid, 0, chan->apids[j].type, true);
- audio->setStreamType(Audio::MPEG2_PES);
- logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer pids: %u %u %u", chan->vpid, chan->apids[j].pid, chan->apids[j].type);
- found = true;
- }
- j++;
- }
- }
-
- if (!found)
- {
- if (chan->numDPids > 0 && audio->maysupportAc3())
- {
- ULONG j = 0;
- while (j < chan->numDPids && !found)
- {
- if (Audio::getInstance()->streamTypeSupported(chan->dpids[j].type))
- {
- demuxer->setAID(chan->dpids[j].pid, 1, chan->dpids[j].type, true);
- audio->setStreamType(Audio::MPEG2_PES);
- logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer pids: %u %u (ac3) %u", chan->vpid, chan->dpids[j].pid, chan->dpids[j].type);
- found = true;
- }
- j++;
- }
- }
- else
- {
- logger->log("PlayerLiveTV", Log::WARN, "Demuxer video pid only: %u", chan->vpid);
- }
- }
-
- if (chan->numSPids > 0)
- demuxer->setSubID(chan->spids[0].pid);
-
- demuxer->setTID(chan->tpid);
- teletext->ResetDecoder();
- int streamSuccess = vdr->streamChannel(chan->number, this);
- if (!checkError() && !streamSuccess)
- {
- Message* m = new Message();
- m->from = this;
- m->to = messageReceiver;
- m->message = Message::PLAYER_EVENT;
- m->parameter = PlayerLiveTV::STREAM_END;
- messageQueue->postMessageFromOuterSpace(m);
- }
+ Channel* chan = (*chanList)[i.channelIndex];
+ chan->loadPids();
+ h264=chan->vstreamtype==0x1b;
+ demuxer->seth264(h264);
+ video->seth264mode(chan->vstreamtype==0x1b);
+ demuxer->setVID(chan->vpid);
+ video->seth264mode(chan->vstreamtype==0x1b);
+
+ bool dolby=false;
+ int selected=-1;
+ int prefered=-1;
+ Command* command = Command::getInstance();
+
+ if (chan->numDPids > 0 && audio->maysupportAc3())
+ {
+ ULONG j = 0;
+ while (j < chan->numDPids)
+ {
+ int newpref = command->getLangPref(false, chan->dpids[j].desc);
+ if (Audio::getInstance()->streamTypeSupported(chan->dpids[j].type)
+ && (prefered < 0 || newpref < prefered))
+ {
+ selected = j;
+ dolby=true;
+ prefered = newpref;
+ }
+ j++;
+ }
+ }
+
+
+
+ if (chan->numAPids > 0)
+ {
+ ULONG j = 0;
+ while (j < chan->numAPids)
+ {
+ int newpref = command->getLangPref(false, chan->apids[j].desc);
+ if (Audio::getInstance()->streamTypeSupported(chan->apids[j].type)
+ && (prefered < 0 || newpref < prefered))
+ {
+ selected = j;
+ dolby=false;
+ prefered = newpref;
+ }
+ j++;
+ }
+ }
+
+
+ if (selected >= 0) {
+ if (dolby) {
+ demuxer->setAID(chan->dpids[selected].pid, 1, chan->dpids[selected].type, true);
+ audio->setStreamType(Audio::MPEG2_PES);
+ logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer pids: %u %u (ac3) %u",
+ chan->vpid, chan->dpids[selected].pid, chan->dpids[selected].type);
+ } else {
+ demuxer->setAID(chan->apids[selected].pid, 0, chan->apids[selected].type, true);
+ audio->setStreamType(Audio::MPEG2_PES);
+ logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer pids: %u %u %u", chan->vpid, chan->apids[selected].pid,
+ chan->apids[selected].type);
+ }
+
+ } else {
+ logger->log("PlayerLiveTV", Log::WARN, "Demuxer video pid only: %u", chan->vpid);
+ }
+
+
+ selected = -1;
+ prefered=-1;
+ if (chan->numSPids) {
+ ULONG j = 0;
+ while (j < chan->numSPids)
+ {
+ int newpref = command->getLangPref(true, chan->spids[j].desc);
+ if ( (prefered < 0 || newpref < prefered))
+ {
+ selected = j;
+ prefered = newpref;
+ }
+ j++;
+ }
+ }
+
+ if (selected >= 0) {
+ demuxer->setSubID(chan->spids[selected].pid);
+ if (command->getSubDefault()) {
+ turnSubtitlesOn(true);
+ } else {
+ turnSubtitlesOn(false);
+ }
+ }
+
+ demuxer->setTID(chan->tpid);
+ teletext->ResetDecoder();
+ int streamSuccess = vdr->streamChannel(chan->number, this);
+ if (!checkError() && !streamSuccess)
+ {
+ Message* m = new Message();
+ m->from = this;
+ m->to = messageReceiver;
+ m->message = Message::PLAYER_EVENT;
+ m->parameter = PlayerLiveTV::STREAM_END;
+ messageQueue->postMessageFromOuterSpace(m);
+ }
}
}
else if (i.instruction == I_STOP)
{
- logger->log("PlayerLiveTV", Log::DEBUG, "Stopping");
- switchState(S_STOP);
- checkError();
+ logger->log("PlayerLiveTV", Log::DEBUG, "Stopping");
+ switchState(S_STOP);
+ checkError();
- stopNow = true;
- break;
+ stopNow = true;
+ break;
}
}
{
logger->log("VConnect", Log::DEBUG, "Connected ok, doing login");
unsigned int version_server_min,version_server_max,version_client;
- success = vdr->doLogin(&version_server_min,&version_server_max,&version_client);
+ int subtitles;
+ success = vdr->doLogin(&version_server_min,&version_server_max,&version_client, Command::getInstance()->getASLList(), subtitles);
+ Command::getInstance()->setSubDefault(subtitles);
if (!success)
{
/////////////////////////////////////////////////////////////////////////////
-int VDR::doLogin(unsigned int* v_server_min, unsigned int* v_server_max, unsigned int* v_client)
+int VDR::doLogin(unsigned int* v_server_min, unsigned int* v_server_max, unsigned int* v_client,
+ ASLPrefList& list, int &subtitles)
{
VDR_RequestPacket vrp;
if (!vrp.init(VDR_LOGIN, true, 6)) return 0;
*v_server_max=version_max;
*v_client=VOMP_PROTOCOLL_VERSION;
+ unsigned int numlangcodes = vresp->extractULONG();
+ subtitles = vresp->extractULONG();
+ list.clear();
+ for (int i=0; i<numlangcodes; i++) {
+ ASLPref newpref;
+ newpref.audiopref = vresp->extractLONG();
+ newpref.subtitlepref = vresp->extractLONG();
+ newpref.langcode = vresp->extractStdString();
+ //logger->log("VDR", Log::DEBUG, "Langpref %s %d %d", newpref.langcode.c_str(), newpref.audiopref, newpref.subtitlepref);
+ list.push_back(newpref);
+ }
+
+
delete vresp;
if ((version_min > VOMP_PROTOCOLL_VERSION)
#include "eventdispatcher.h"
#include "i18n.h"
#include "log.h"
+#include "command.h"
class TCP;
class Log;
// configSave
// setEventTimer
- int doLogin(unsigned int* v_server_min, unsigned int* v_server_max, unsigned int* v_client);
+ int doLogin(unsigned int* v_server_min, unsigned int* v_server_max, unsigned int* v_client, ASLPrefList& list, int &subtitles);
bool getRecordingsList(RecMan* recman);
RecInfo* getRecInfo(char* fileName);
int deleteRecording(char* fileName);
{
UINT newChannel = 0;
if (streamType ==VDR::VIDEO) {
- VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
- if (vtxt ) {
- BoxStack::getInstance()->remove(vtxt);
+ VTeletextView *vtxt=((PlayerLiveTV*)player)->getTeletextDecoder()->getTeletxtView();
+ if (vtxt ) {
+ BoxStack::getInstance()->remove(vtxt);
- }
+ }
}
if (changeType == INDEX)
{