eDynamicDeviceReturnCode cDynamicDevice::DetachDevice(const char *DevPath, bool Force)
{
  if (!DevPath)
     return ddrcNotSupported;

  cMutexLock lock(&arrayMutex);
  int freeIndex = -1;
  int index = -1;
  if (isnumber(DevPath))
     index = strtol(DevPath, NULL, 10) - 1;
  else
     index = IndexOf(DevPath, freeIndex, -1);

  if ((index < 0) || (index >= numDynamicDevices)) {
     esyslog("dynamite: device %s not found", DevPath);
     return ddrcNotFound;
     }

  cString realDevPath(dynamicdevice[index]->GetDevPath());
  if (!Force) {
     if (!dynamicdevice[index]->isDetachable) {
        esyslog("dynamite: detaching of device %s is not allowed", *realDevPath);
        return ddrcNotAllowed;
        }

     if (dynamicdevice[index] == PrimaryDevice()) {
        esyslog("dynamite: detaching of primary device %s is not supported", *realDevPath);
        return ddrcIsPrimaryDevice;
        }

     if (dynamicdevice[index]->Receiving(false)) {
        esyslog("dynamite: can't detach device %s, it's receiving something important", *realDevPath);
        return ddrcIsReceiving;
        }
     }

  dynamicdevice[index]->DeleteSubDevice();
  isyslog("dynamite: detached device %s%s", *realDevPath, (Force ? " (forced)" : ""));
  if (enableOsdMessages) {
     cString osdMsg = cString::sprintf(tr("detached %s"), *realDevPath);
     Skins.QueueMessage(mtInfo, *osdMsg);
     }
  if (attachHook != NULL) {
     cString hookCmd = cString::sprintf("%s --action=detach --device=%s", **attachHook, *realDevPath);
     isyslog("dynamite: calling hook %s", *hookCmd);
     int status = SystemExec(*hookCmd, true);
     if (!WIFEXITED(status) || WEXITSTATUS(status))
        esyslog("SystemExec() failed with status %d", status);
     }
  return ddrcSuccess;
}
Esempio n. 2
0
static int GetClippedNumProvidedSystems(int AvailableBits, cDevice *Device)
{
  int MaxNumProvidedSystems = (1 << AvailableBits) - 1;
  int NumProvidedSystems = Device->NumProvidedSystems();
  if (NumProvidedSystems > MaxNumProvidedSystems) {
     esyslog("ERROR: device %d supports %d modulation systems but cDevice::GetDevice() currently only supports %d delivery systems which should be fixed", Device->CardIndex() + 1, NumProvidedSystems, MaxNumProvidedSystems);
     NumProvidedSystems = MaxNumProvidedSystems;
     }
  else if (NumProvidedSystems <= 0) {
     esyslog("ERROR: device %d reported an invalid number (%d) of supported delivery systems - assuming 1", Device->CardIndex() + 1, NumProvidedSystems);
     NumProvidedSystems = 1;
     }
  return NumProvidedSystems;
}
Esempio n. 3
0
std::istream& PlexServer::MakeRequest(Poco::Net::HTTPResponse& response, bool& ok, std::string path, const std::map<std::string, std::string>& queryParameters)
{
	Poco::URI uri(path);
	// Create a request with an optional query
	if(queryParameters.size()) {
		for (auto const& pair : queryParameters) {
			// addQueryParameter does the encode already
			uri.addQueryParameter(pair.first, pair.second);
		}
	}
	Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, uri.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);

	request.add("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17");
	request.add("X-Plex-Client-Identifier", Config::GetInstance().GetUUID());
	request.add("X-Plex-Device", "PC");
	request.add("X-Plex-Device-Name", Config::GetInstance().GetHostname());
	request.add("X-Plex-Language", Config::GetInstance().GetLanguage());
	request.add("X-Plex-Model", "Linux");
	request.add("X-Plex-Platform", "VDR");
	request.add("X-Plex-Product", "plex for vdr");
	request.add("X-Plex-Provides", "player");
	request.add("X-Plex-Version", VERSION);

	if(Config::GetInstance().UsePlexAccount && !GetAuthToken().empty()) {
		// Add PlexToken to Header
		request.add("X-Plex-Token", GetAuthToken());
	}
	bool excep = false;
	try {
		GetClientSession()->sendRequest(request);
	} catch (Poco::TimeoutException &exc) {
		esyslog("[plex] Timeout: %s", path.c_str());
		ok = false;
		excep = true;
	} catch (Poco::Exception &exc) {
		esyslog("[plex] Oops Exception: %s", exc.displayText().c_str());
		ok = false;
		excep = true;
	}
	if(!excep) { 
		std::istream& stream = GetClientSession()->receiveResponse(response);
		ok = response.getStatus() == 200;
		return stream;
	}
	static std::stringstream* ss;
	return *ss;
	
}
bool cDynamicDevice::GetTSPacket(uchar *&Data)
{
  if (subDeviceIsReady && subDevice) {
     bool r = subDevice->GetTSPacket(Data);
     if (getTSTimeout > 0) {
        if (Data == NULL) {
           if (getTSWatchdog == 0)
              getTSWatchdog = time(NULL);
           else if ((time(NULL) - getTSWatchdog) > getTSTimeout) {
              const char *d = NULL;
              if (devpath)
                 d = **devpath;
              esyslog("dynamite: device %s hasn't delivered any data for %d seconds, detaching all receivers", d, getTSTimeout);
              subDevice->DetachAllReceivers();
              cDynamicDeviceProbe::QueueDynamicDeviceCommand(ddpcDetach, *devpath);
              const char *timeoutHandlerArg = *devpath;
              if (getTSTimeoutHandlerArg)
                 timeoutHandlerArg = **getTSTimeoutHandlerArg;
              cDynamicDeviceProbe::QueueDynamicDeviceCommand(ddpcService, *cString::sprintf("dynamite-CallGetTSTimeoutHandler-v0.1 %s", timeoutHandlerArg));
              return false;
              }
           }
        else
           getTSWatchdog = 0;
        }
     return r;
     }
  return cDevice::GetTSPacket(Data);
}
Esempio n. 5
0
bool cChannel::SetTransponderData(int Source, int Frequency, int Srate, const char *Parameters, bool Quiet)
{
  if (strchr(Parameters, ':')) {
     esyslog("ERROR: parameter string '%s' contains ':'", Parameters);
     return false;
     }
  // Workarounds for broadcaster stupidity:
  // Some providers broadcast the transponder frequency of their channels with two different
  // values (like 12551 and 12552), so we need to allow for a little tolerance here
  if (abs(frequency - Frequency) <= 1)
     Frequency = frequency;
  // Sometimes the transponder frequency is set to 0, which is just wrong
  if (Frequency == 0)
     return false;
  // Sometimes the symbol rate is off by one
  if (abs(srate - Srate) <= 1)
     Srate = srate;

  if (source != Source || frequency != Frequency || srate != Srate || strcmp(parameters, Parameters)) {
     cString OldTransponderData = TransponderDataToString();
     source = Source;
     frequency = Frequency;
     srate = Srate;
     parameters = Parameters;
     schedule = NULL;
     if (Number() && !Quiet) {
        dsyslog("changing transponder data of channel %d from %s to %s", Number(), *OldTransponderData, *TransponderDataToString());
        modification |= CHANNELMOD_TRANSP;
        Channels.SetModified();
        }
     }
  return true;
}
Esempio n. 6
0
cTDT::cTDT(const u_char *Data)
:SI::TDT(Data, false)
{
  CheckParse();

  time_t sattim = getTime();
  time_t loctim = time(NULL);

  int diff = abs(sattim - loctim);
  if (diff > 2) {
     mutex.Lock();
     if (abs(diff - lastDiff) < 3) {
        isyslog("System Time = %s (%ld)", *TimeToString(loctim), loctim);
        isyslog("Local Time  = %s (%ld)", *TimeToString(sattim), sattim);
        if (stime(&sattim) < 0){
				char __errorstr[256];
				strerror_r(errno,__errorstr,256);
				__errorstr[255]=0;
           esyslog("ERROR while setting system time: %s",__errorstr);
			  }
        }
     lastDiff = diff;
     mutex.Unlock();
     }
}
Esempio n. 7
0
File: epg.c Progetto: piotrasd/vdr
void cSchedule::Dump(FILE *f, const char *Prefix, eDumpMode DumpMode, time_t AtTime) const
{
  cChannel *channel = Channels.GetByChannelID(channelID, true);
  if (channel) {
     fprintf(f, "%sC %s %s\n", Prefix, *channel->GetChannelID().ToString(), channel->Name());
     const cEvent *p;
     switch (DumpMode) {
       case dmAll: {
            for (p = events.First(); p; p = events.Next(p))
                p->Dump(f, Prefix);
            }
            break;
       case dmPresent: {
            if ((p = GetPresentEvent()) != NULL)
               p->Dump(f, Prefix);
            }
            break;
       case dmFollowing: {
            if ((p = GetFollowingEvent()) != NULL)
               p->Dump(f, Prefix);
            }
            break;
       case dmAtTime: {
            if ((p = GetEventAround(AtTime)) != NULL)
               p->Dump(f, Prefix);
            }
            break;
       default: esyslog("ERROR: unknown DumpMode %d (%s %d)", DumpMode, __FUNCTION__, __LINE__);
       }
     fprintf(f, "%sc\n", Prefix);
     }
}
Esempio n. 8
0
cSourceParam::cSourceParam(char Source, const char *Description)
{
  source = Source;
  if ('A' <= source && source <= 'Z') {
     if (SourceParams.Get(source)) {
        esyslog("ERROR: source parameters for '%c' already defined", source);
        return;
        }
     SourceParams.Add(this);
     if (!strchr("ACST", Source)) // no, it's not "ATSC" ;-)
        Sources.Add(new cSource(Source, Description));
     dsyslog("registered source parameters for '%c - %s'", source, Description);
     }
  else
     esyslog("ERROR: invalid source '%c'", source);
}
Esempio n. 9
0
bool cPluginMhp::Initialize(void)
{
   // Initialize any background activities the plugin shall perform.
   
/*
   //VDR loads plugins without the RTDL_GLOBAL flag in dlopen.
   //Dynamic modules dlopen'ed by the plugin, however, will link against symbols from
   //the plugin itself, so it is necessary to reload its symbols globally.
   //Needed by the MHPOutput module and Java native libraries.
   char *buffer = NULL;
   //from vdr/plugin.c
   asprintf(&buffer, "%s/%s%s%s%s", VDRPluginPath, LIBVDR_PREFIX, "mhp", SO_INDICATOR, VDRVERSION);
   if (!ownPlugin.Load(buffer)) {
      esyslog("MHP: Failed to re-open own dynamic object (this plugin)."
              "Remember to give the plugin the same \"-L\" option as VDR!");
      printf("MHP: Failed to re-dlopen the dynamic object of this plugin.\n"
             "You have to give the plugin the same \"-L\" option as you specified on the command line for VDR!\n");
      return false;
   }
   free(buffer);
*/

   InitializeLocalApps();
   
   if (Mhp::ConfigPath==0) {
      char *c;
      asprintf(&c, "%s%s", VideoDirectory, "/mhp");
      Mhp::ConfigPath=c;
   }
   MakeDirs(Mhp::ConfigPath, true);
   if (!DirectoryOk(Mhp::ConfigPath, true))
      esyslog("MHP: Config directory is not accessible. Settings will not be stored.");
   
   return true;
}
Esempio n. 10
0
uchar *cDeCsaTSBuffer::Get(void)
{
  int Count=0;
  if(delivered) { ringBuffer->Del(TS_SIZE); delivered=false; }
  uchar *p=ringBuffer->Get(Count);
  if(p && Count>=TS_SIZE) {
    if(*p!=TS_SYNC_BYTE) {
      for(int i=1; i<Count; i++)
        if(p[i]==TS_SYNC_BYTE &&
           (i+TS_SIZE==Count || (i+TS_SIZE>Count && p[i+TS_SIZE]==TS_SYNC_BYTE)) ) { Count=i; break; }
      ringBuffer->Del(Count);
      esyslog("ERROR: skipped %d bytes to sync on TS packet on device %d",Count,cardIndex);
      return NULL;
      }

    if(scActive && (p[3]&0xC0)) {
      if(decsa) {
        if(!decsa->Decrypt(p,Count,false)) {
          cCondWait::SleepMs(20);
          return NULL;
          }
        }
      else p[3]&=~0xC0; // FF hack
      }

    delivered=true;
    return p;
    }
  return NULL;
}
Esempio n. 11
0
eOSState cMenuCreateFavouritesFolder::ProcessKey(eKeys Key)
{
    eOSState state = cOsdMenu::ProcessKey(Key);

    printf("state = %d key = %d\n", state, Key);
    if (state == osUnknown) {
        switch (Key) {
        case kOk:
            state = osContinue;

            if(strlen(folderName) > 0) {
                if (IsBouquetInFavourites(folderName)) {
                    Skins.Message(mtError, tr("Duplicate folder name. Please try another name."), 2);
                } else if (AddNewFavFolder(folderName))
                    state = osBack;
                else
                    esyslog("%s:%d '%s' not added to fav.", __FILE__, __LINE__, folderName);
            }
            else // name not set, empty string
                Skins.Message(mtError, tr("Invalid folder name"));

            break;

        default:
            break;
        } // switch
    } //if

    return state;
}
Esempio n. 12
0
bool SwitchToFavChannel(cChannel *favCh)
{
    if (!favCh) return false;

#if 0 // does not work as expected
    return favourites.SwitchTo(favCh->Number());
#endif

    /**
      switch to channel
        find selected channel (in fav) in global vdr-channellist
     **/

    bool success = false; /* switched to channel? */

    /* find the channel in vdr's channel list */
    cChannel *ch = Channels.GetByChannelID(favCh->GetChannelID());

    // try to switch to channel
    if (ch)
        success = Channels.SwitchTo(ch->Number());
    else
        esyslog("fav channel '%d %s' not found in vdr's list", favCh->Number(),
                favCh->Name());

    return success;
}
Esempio n. 13
0
bool UpdateFavChannelNames()
{
    bool success = false;
    cChannel *ch = favourites.First();
    cChannel *vdrCh = NULL;

    while (ch) {
        if (!ch->GroupSep()) {
            vdrCh = Channels.GetByChannelID(ch->GetChannelID());
            if (vdrCh) {
                if (strcmp(vdrCh->Name(), ch->Name()) != 0) {
                    isyslog("changing name of '%s' fav. channel", ch->Name());
                    ch->SetName(vdrCh->Name(),
                                vdrCh->ShortName()?vdrCh->ShortName():"",
                                vdrCh->Provider()?vdrCh->Provider():"");
                }

                // update Caids if they differ
                ch->ForceCaIds(vdrCh->Caids());
            } else
                esyslog("fav. channel '%s' not found in vdr's channel list!", ch->Name());
        }
        ch = favourites.Next(ch);
    } //while

    return success;
}
Esempio n. 14
0
 virtual bool Probe(int Adapter, int Frontend)
 {
   if (firstProbe) {
      firstProbe = false;
      isyslog("dynamite: preparing %d dynamic device slots for dvb devices", MAXDVBDEVICES);
      while (cDevice::NumDevices() < MAXDVBDEVICES)
            new cDynamicDevice;
      }
   cString devpath = cString::sprintf("/dev/dvb/adapter%d/frontend%d", Adapter, Frontend);
   int freeIndex = -1;
   if (cDynamicDevice::IndexOf(*devpath, freeIndex, -1) >= 0) // already attached - should not happen
      return true;
   if (freeIndex < 0) {
      if ((cDevice::NumDevices() >= MAXDEVICES) || (cDynamicDevice::NumDynamicDevices() >= MAXDEVICES)) {
         esyslog("dynamite: too many dvb-devices, vdr supports only %d devices - increase MAXDEVICES and recompile vdr", MAXDEVICES);
         return false;
         }
      new cDynamicDevice;
      }
   isyslog("dynamite: grab dvb device %d/%d", Adapter, Frontend);
   //cDynamicDevice::AttachDevice(*devpath);
   // or better attach later when all plugins are started?
   cDynamicDeviceProbe::QueueDynamicDeviceCommand(ddpcAttach, *devpath);
   return true; // grab all dvbdevices
 }
Esempio n. 15
0
void cStreamdevFilters::CarbageCollect(void) {
	LOCK_THREAD;
	for (cStreamdevFilter *fi = First(); fi;) {
		if (fi->IsClosed()) {
			if (errno == ECONNREFUSED ||
					errno == ECONNRESET ||
					errno == EPIPE) {
				ClientSocket.SetFilter(fi->Pid(), fi->Tid(), fi->Mask(), false);
				Dprintf("cStreamdevFilters::CarbageCollector: filter closed: Pid %4d, Tid %3d, Mask %2x (%d filters left)",
						(int)fi->Pid(), (int)fi->Tid(), fi->Mask(), Count()-1);

				cStreamdevFilter *next = Prev(fi);
				Del(fi);
				fi = next ? Next(next) : First();
			} else {
				esyslog("cStreamdevFilters::CarbageCollector() error: "
						"Pid %4d, Tid %3d, Mask %2x (%d filters left) failed",
						(int)fi->Pid(), (int)fi->Tid(), fi->Mask(), Count()-1);
				LOG_ERROR;
				fi = Next(fi);
			}
		} else {
			fi = Next(fi);
		}
	}
}
Esempio n. 16
0
File: pin.c Progetto: suborb/reelvdr
bool cPinPlugin::Initialize(void)
{
   char* path;

   asprintf(&path, "%s/%s", cPlugin::ConfigDirectory(), "pin");

   if (!DirectoryOk(path, no))
   {
      if (mkdir(path, 0770))
      {
         // cannot create the directory

         esyslog("Creating of directory '%s' failed, errno was (%d) - '%s'", 
                 path, errno, strerror(errno)); 
         free(path);

         return true; // anyhow let vdr start
      }
   }

   free(path);

   lockedChannels.Load(AddDirectory(cPlugin::ConfigDirectory(), 
                                    "pin/channellocks.conf"), true, false);
   lockedBroadcasts.Load(AddDirectory(cPlugin::ConfigDirectory(),
                                      "pin/broadcastlocks.conf"), true, false);
   lockedPlugins.Load(AddDirectory(cPlugin::ConfigDirectory(),
                                   "pin/pluginlocks.conf"), true, false);

   return true;
}
Esempio n. 17
0
void cTransfer::Activate(bool On)
{
  if (!On) {

     if (cReceiver::device){
        cReceiver::device->DelPid(cReceiver::device->pidHandles[cDevice::ptAudio].pid, cDevice::ptAudio);
        cReceiver::device->DelPid(cReceiver::device->pidHandles[cDevice::ptVideo].pid, cDevice::ptVideo);
        cReceiver::device->DelPid(cReceiver::device->pidHandles[cDevice::ptPcr].pid, cDevice::ptPcr);
        cReceiver::device->DelPid(cReceiver::device->pidHandles[cDevice::ptTeletext].pid, cDevice::ptTeletext);
        cReceiver::device->DelPid(cReceiver::device->pidHandles[cDevice::ptDolby].pid, cDevice::ptDolby);
        }
    if (cPlayer::device){
        cPlayer::device->StartLiveView(false,false);
        }
     }
  else if (cPlayer::device && cReceiver::device) {
     //cPlayer::device->SetAudioBypass(false);
     if (!(cReceiver::device->AddPid(pPid, cDevice::ptPcr) && cReceiver::device->AddPid(vPid, cDevice::ptVideo) && cReceiver::device->AddPid(aPid, cDevice::ptAudio))) {
        esyslog("ERROR: failed to set PIDs while activate Transferer");
        return;
        }
     cReceiver::device->AddPid(tPid, cDevice::ptTeletext);
     cPlayer::device->StartLiveView(true,false);
     cPlayer::device->EnsureAudioTrack(false);
     }
}
Esempio n. 18
0
void Artwork::createDb() {
    std::string schema =
        "CREATE TABLE IF NOT EXISTS artwork (\n"
        "  id INTEGER PRIMARY KEY AUTOINCREMENT,\n"
        "  contenttype INTEGER NOT NULL,\n"
        "  title TEXT NOT NULL,\n"
        "  externalid INTEGER,\n"
        "  posterurl TEXT,\n"
        "  backgroundurl TEXT\n,"
        "  timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL\n"
        ");\n"

        "CREATE INDEX IF NOT EXISTS artwork_externalid on artwork(externalid);\n"
        "CREATE UNIQUE INDEX IF NOT EXISTS artwork_content on artwork(contenttype, title);\n"

        "DROP TABLE IF EXISTS epgsearch;\n"
        "DROP TABLE IF EXISTS epgindex;\n"

        "CREATE TABLE IF NOT EXISTS epgartwork (\n"
        "  eventid INTEGER NOT NULL,\n"
        "  channeluid INTEGER NOT NULL,\n"
        "  contentid INTEGER NOT NULL,\n"
        "  timestamp INTEGER NOT NULL,\n"
        "  url TEXT,\n"
        "  posterurl TEXT,\n"
        "  PRIMARY KEY(channeluid, eventid)\n"
        ");\n";

    if(exec(schema) != SQLITE_OK) {
        esyslog("Unable to create database schema for artwork");
    }
}
Esempio n. 19
0
bool cConnectionIGMP::SetChannel(cChannel *Channel, in_addr_t Dst)
{
	if (Channel) {
		m_Channel = Channel;
		struct in_addr ip;
		ip.s_addr = Dst;
		if (Connect(inet_ntoa(ip), m_ClientPort))
			return true;
		else
			esyslog("streamdev-server IGMP: Connect failed: %m");
		return false;
	}
	else
		esyslog("streamdev-server IGMP: Channel not found");
	return false;
}
Esempio n. 20
0
eKeys cSkins::Message(eMessageType Type, const char *s, int Seconds)
{
  switch (Type) {
    case mtInfo:    isyslog("info: %s", s); break;
    case mtWarning: isyslog("warning: %s", s); break;
    case mtError:   esyslog("ERROR: %s", s); break;
    default: ;
    }
  if (!Current())
     return kNone;
  if (!cSkinDisplay::Current() && !displayMessage)
     displayMessage = Current()->DisplayMessage();
  cSkinDisplay::Current()->SetMessage(Type, s);
  cSkinDisplay::Current()->Flush();
  cStatus::MsgOsdStatusMessage(s);
  eKeys k = kNone;
  if (Type != mtStatus) {
     k = Interface->Wait(Seconds);
     if (displayMessage) {
        delete displayMessage;
        displayMessage = NULL;
        cStatus::MsgOsdClear();
        }
     else {
        cSkinDisplay::Current()->SetMessage(Type, NULL);
        cStatus::MsgOsdStatusMessage(NULL);
        }
     }
  else if (!s && displayMessage) {
     delete displayMessage;
     displayMessage = NULL;
     cStatus::MsgOsdClear();
     }
  return k;
}
Esempio n. 21
0
void I18nInitialize(const char *LocaleDir)
{
  I18nLocaleDir = LocaleDir;
  LanguageLocales.Append(strdup(I18N_DEFAULT_LOCALE));
  LanguageNames.Append(strdup(SkipContext(LanguageName)));
  LanguageCodes.Append(strdup(LanguageCodeList[0]));
  textdomain("vdr");
  bindtextdomain("vdr", I18nLocaleDir);
  cFileNameList Locales(I18nLocaleDir, true);
  if (Locales.Size() > 0) {
     char *OldLocale = strdup(setlocale(LC_MESSAGES, NULL));
     for (int i = 0; i < Locales.Size(); i++) {
         cString FileName = cString::sprintf("%s/%s/LC_MESSAGES/vdr.mo", *I18nLocaleDir, Locales[i]);
         if (access(FileName, F_OK) == 0) { // found a locale with VDR texts
            if (NumLocales < I18N_MAX_LANGUAGES - 1) {
               SetEnvLanguage(Locales[i]);
               const char *TranslatedLanguageName = gettext(LanguageName);
               if (TranslatedLanguageName != LanguageName) {
                  NumLocales++;
                  if (strstr(OldLocale, Locales[i]) == OldLocale)
                     CurrentLanguage = LanguageLocales.Size();
                  LanguageLocales.Append(strdup(Locales[i]));
                  LanguageNames.Append(strdup(TranslatedLanguageName));
                  const char *Code = gettext(LanguageCode);
                  for (const char **lc = LanguageCodeList; *lc; lc++) {
                      if (ContainsCode(*lc, Code)) {
                         Code = *lc;
                         break;
                         }
                      }
                  LanguageCodes.Append(strdup(Code));
                  }
               }
            else {
               esyslog("ERROR: too many locales - increase I18N_MAX_LANGUAGES!");
               break;
               }
            }
         }
     SetEnvLanguage(LanguageLocales[CurrentLanguage]);
     free(OldLocale);
     dsyslog("found %d locales in %s", NumLocales - 1, *I18nLocaleDir);
     }
  // Prepare any known language codes for which there was no locale:
  for (const char **lc = LanguageCodeList; *lc; lc++) {
      bool Found = false;
      for (int i = 0; i < LanguageCodes.Size(); i++) {
          if (strcmp(*lc, LanguageCodes[i]) == 0) {
             Found = true;
             break;
             }
          }
      if (!Found) {
         dsyslog("no locale for language code '%s'", *lc);
         LanguageLocales.Append(strdup(I18N_DEFAULT_LOCALE));
         LanguageNames.Append(strdup(*lc));
         LanguageCodes.Append(strdup(*lc));
         }
      }
}
Esempio n. 22
0
void cExternalAudio::Play(const uchar *Data, int Length, uchar Id)
{
  if (command && !mute) {
     if (pipe || pipe.Open(command, "w")) {
        if (0x80 <= Id && Id <= 0x87 || Id == 0xBD) { // AC3
           cDvbDevice::SetTransferModeForDolbyDigital(2);
           int written = Data[8] + 9; // skips the PES header
           if (Id != 0xBD)
              written += 4; // skips AC3 bytes
           Length -= written;
           while (Length > 0) {
                 int w = fwrite(Data + written, 1, Length, pipe);
                 if (w < 0) {
                    LOG_ERROR;
                    break;
                    }
                 Length -= w;
                 written += w;
                 }
           }
        }
     else {
        esyslog("ERROR: can't open pipe to audio command '%s'", command);
        free(command);
        command = NULL;
        }
     }
}
Esempio n. 23
0
  static void List(cDBusObject *Object, GVariant *Parameters, GDBusMethodInvocation *Invocation)
  {
    if (g_strcmp0(g_dbus_method_invocation_get_interface_name(Invocation), DBUS_VDR_PLUGIN_INTERFACE) == 0)
       esyslog("dbus2vdr: use of deprecated interface: 'List' should be called with the interface '%s'!", DBUS_VDR_PLUGINMANAGER_INTERFACE);

#define EMPTY(s) (s == NULL ? "" : s)
    GVariantBuilder *array = g_variant_builder_new(G_VARIANT_TYPE("a(ss)"));
    int index = 0;
    do
    {
      cPlugin *plugin = cPluginManager::GetPlugin(index);
      if (plugin == NULL)
         break;
      const char *name = plugin->Name();
      const char *version = plugin->Version();
      g_variant_builder_add(array, "(ss)", EMPTY(name), EMPTY(version));
      index++;
    } while (true);
#undef EMPTY

    GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("(a(ss))"));
    g_variant_builder_add_value(builder, g_variant_builder_end(array));
    g_dbus_method_invocation_return_value(Invocation, g_variant_builder_end(builder));
    g_variant_builder_unref(array);
    g_variant_builder_unref(builder);
  }
Esempio n. 24
0
cStateKey::~cStateKey()
{
    if (stateLock) {
        esyslog("ERROR: cStateKey::~cStateKey() called without releasing the lock first (tid=%d, lock=%s, key=%p)", stateLock->threadId, stateLock->name, this);
        ABORT;
    }
}
Esempio n. 25
0
void cKeys::PutSetup(const char *Remote, const char *Setup)
{
  if (!GetSetup(Remote))
     Add(new cKey(Remote, Setup, k_Setup));
  else
     esyslog("ERROR: called PutSetup() for %s, but setup has already been defined!", Remote);
}
Esempio n. 26
0
bool cStateLock::Lock(cStateKey &StateKey, bool Write, int TimeoutMs)
{
    dbglocking("%5d %-10s %10p   lock state = %d/%d write = %d timeout = %d\n", cThread::ThreadId(), name, &StateKey, state, StateKey.state, Write, TimeoutMs);
    StateKey.timedOut = false;
    if (StateKey.stateLock) {
        esyslog("ERROR: StateKey already in use in call to cStateLock::Lock() (tid=%d, lock=%s)", StateKey.stateLock->threadId, name);
        ABORT;
        return false;
    }
    if (rwLock.Lock(Write, TimeoutMs)) {
        StateKey.stateLock = this;
        if (Write) {
            dbglocking("%5d %-10s %10p   locked write\n", cThread::ThreadId(), name, &StateKey);
            threadId = cThread::ThreadId();
            StateKey.write = true;
            return true;
        }
        else if (state != StateKey.state) {
            dbglocking("%5d %-10s %10p   locked read\n", cThread::ThreadId(), name, &StateKey);
            return true;
        }
        else {
            dbglocking("%5d %-10s %10p   state unchanged\n", cThread::ThreadId(), name, &StateKey);
            StateKey.stateLock = NULL;
            rwLock.Unlock();
        }
    }
    else if (TimeoutMs) {
        dbglocking("%5d %-10s %10p   timeout\n", cThread::ThreadId(), name, &StateKey);
        StateKey.timedOut = true;
    }
    return false;
}
Esempio n. 27
0
void cThread::SetMainThreadId(void)
{
    if (mainThreadId == 0)
        mainThreadId = ThreadId();
    else
        esyslog("ERROR: attempt to set main thread id to %d while it already is %d", ThreadId(), mainThreadId);
}
Esempio n. 28
0
cSourceParam::cSourceParam(char Source, const char *Description)
{
  source = Source;
  if ('A' <= source && source <= 'Z') {
     if (SourceParams.Get(source)) {
        esyslog("ERROR: source parameters for '%c' already defined", source);
        return;
        }
     SourceParams.Add(this);
     if (!Sources.ContainsSourceType(source))
        Sources.Add(new cSource(source, Description));
     dsyslog("registered source parameters for '%c - %s'", source, Description);
     }
  else
     esyslog("ERROR: invalid source '%c'", source);
}
Esempio n. 29
0
int cPlayer::PlayPes(const uchar *Data, int Length, bool VideoOnly)
{
  if (device)
     return device->PlayPes(Data, Length, VideoOnly);
  esyslog("ERROR: attempt to use cPlayer::PlayPes() without attaching to a cDevice!");
  return -1;
}
Esempio n. 30
0
bool cDvbDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
{
  bool DoTune = !dvbTuner->IsTunedTo(Channel);

  bool TurnOffLivePIDs = HasDecoder()
                         && (DoTune
                            || !IsPrimaryDevice()
                            || LiveView // for a new live view the old PIDs need to be turned off
                            || pidHandles[ptVideo].pid == Channel->Vpid() // for recording the PIDs must be shifted from DMX_PES_AUDIO/VIDEO to DMX_PES_OTHER
                            );

  bool StartTransferMode = IsPrimaryDevice() && !DoTune
                           && (LiveView && HasPid(Channel->Vpid() ? Channel->Vpid() : Channel->Apid(0)) && (pidHandles[ptVideo].pid != Channel->Vpid() || (pidHandles[ptAudio].pid != Channel->Apid(0) && (Channel->Dpid(0) ? pidHandles[ptAudio].pid != Channel->Dpid(0) : true)))// the PID is already set as DMX_PES_OTHER
                              || !LiveView && (pidHandles[ptVideo].pid == Channel->Vpid() || pidHandles[ptAudio].pid == Channel->Apid(0)) // a recording is going to shift the PIDs from DMX_PES_AUDIO/VIDEO to DMX_PES_OTHER
                              );

  bool TurnOnLivePIDs = HasDecoder() && !StartTransferMode && LiveView;

#ifndef DO_MULTIPLE_RECORDINGS
  TurnOffLivePIDs = TurnOnLivePIDs = true;
  StartTransferMode = false;
#endif

  // Turn off live PIDs if necessary:

  if (TurnOffLivePIDs)
     TurnOffLiveMode(LiveView);

  // Set the tuner:

  dvbTuner->Set(Channel, DoTune);

  // If this channel switch was requested by the EITScanner we don't wait for
  // a lock and don't set any live PIDs (the EITScanner will wait for the lock
  // by itself before setting any filters):

  if (EITScanner.UsesDevice(this)) //XXX
     return true;

  // PID settings:

  if (TurnOnLivePIDs) {
     SetAudioBypass(false);
     if (!(AddPid(Channel->Ppid(), ptPcr) && AddPid(Channel->Vpid(), ptVideo) && AddPid(Channel->Apid(0), ptAudio))) {
        esyslog("ERROR: failed to set PIDs for channel %d on device %d", Channel->Number(), CardIndex() + 1);
        return false;
        }
     if (IsPrimaryDevice())
        AddPid(Channel->Tpid(), ptTeletext);
     CHECK(ioctl(fd_audio, AUDIO_SET_MUTE, true)); // actually one would expect 'false' here, but according to Marco Schlüßler <*****@*****.**> this works
                                                   // to avoid missing audio after replaying a DVD; with 'false' there is an audio disturbance when switching
                                                   // between two channels on the same transponder on DVB-S
     CHECK(ioctl(fd_audio, AUDIO_SET_AV_SYNC, true));
     }
  else if (StartTransferMode)
     cControl::Launch(new cTransferControl(this, Channel->Vpid(), Channel->Apids(), Channel->Dpids(), Channel->Spids()));

  return true;
}