Skip to content

Commit

Permalink
Merge OpenViX
Browse files Browse the repository at this point in the history
  • Loading branch information
Ev0-BH committed Jun 27, 2022
2 parents 45daeb4 + 33550c2 commit 33717d8
Show file tree
Hide file tree
Showing 11 changed files with 163 additions and 78 deletions.
1 change: 1 addition & 0 deletions data/setup.xml
Expand Up @@ -206,6 +206,7 @@
<item level="0" text="Default movie location" description="Set the default location for your recordings. Press OK to add new locations, LEFT/RIGHT to select from any existing locations.">config.usage.default_path</item>
<item level="2" text="Timer recording location" description="Set the default location for your timers. Press OK to add new locations, LEFT/RIGHT to select from any existing locations.">config.usage.timer_path</item>
<item level="2" text="Instant recording location" description="Set the default location for your instant recordings. Press OK to add new locations, LEFT/RIGHT to select from any existing locations.">config.usage.instantrec_path</item>
<item level="2" text="Recordings - convert IPTV servicetypes to 1" description="Recording 4097, 5001 and 5002 streams not possible with external players, so convert recordings to servicetype 1.">config.recording.setstreamto1</item>
<!-- <item level="2" text="Preferred tuner for recordings" description="Configure which tuner will be preferred for recordings, when more than one tuner is available. 'Disabled' would select a tuner based on preferred tuner in customise screen. 'Auto' would choose based on E2's default rules, ignoring preferred tuner in customise screen.">config.usage.recording_frontend_priority</item>-->
<item level="1" text="Recordings always have priority" description="When enabled, a recording is allowed to interrupt live TV, when there are no free tuners.">config.recording.asktozap</item>
<item level="0" text="Margin before recording (minutes)" description="When nonzero, a recording will start earlier than the starting time indicated by the EPG.">config.recording.margin_before</item>
Expand Down
57 changes: 52 additions & 5 deletions lib/dvb_ci/dvbci.cpp
Expand Up @@ -1027,6 +1027,14 @@ PyObject *eDVBCIInterfaces::readCICaIds(int slotid)
return 0;
}

int eDVBCIInterfaces::setCIEnabled(int slotid, bool enabled)
{
eDVBCISlot *slot = getSlot(slotid);
if (slot)
return slot->setEnabled(enabled);
return -1;
}

int eDVBCIInterfaces::setCIClockRate(int slotid, int rate)
{
singleLock s(m_slot_lock);
Expand Down Expand Up @@ -1231,6 +1239,20 @@ void eDVBCISlot::data(int what)
DEFINE_REF(eDVBCISlot);

eDVBCISlot::eDVBCISlot(eMainloop *context, int nr)
{
char configStr[255];
slotid = nr;
m_context = context;
state = stateDisabled;
snprintf(configStr, 255, "config.ci.%d.enabled", slotid);
bool enabled = eConfigManager::getConfigBoolValue(configStr, true);
if (enabled)
openDevice();
else
/* emit */ eDVBCI_UI::getInstance()->m_messagepump.send(eDVBCIInterfaces::Message(eDVBCIInterfaces::Message::slotStateChanged, getSlotID(), 3)); // state disabled
}

void eDVBCISlot::openDevice()
{
char filename[128];

Expand All @@ -1244,9 +1266,7 @@ eDVBCISlot::eDVBCISlot(eMainloop *context, int nr)
plugged = true;
m_ci_version = versionUnknown;

slotid = nr;

sprintf(filename, "/dev/ci%d", nr);
sprintf(filename, "/dev/ci%d", slotid);

// possible_caids.insert(0x1702);
// possible_providers.insert(providerPair("PREMIERE", 0xC00000));
Expand All @@ -1259,7 +1279,7 @@ eDVBCISlot::eDVBCISlot(eMainloop *context, int nr)

if (fd >= 0)
{
notifier = eSocketNotifier::create(context, fd, eSocketNotifier::Read | eSocketNotifier::Priority | eSocketNotifier::Write);
notifier = eSocketNotifier::create(m_context, fd, eSocketNotifier::Read | eSocketNotifier::Priority | eSocketNotifier::Write);
CONNECT(notifier->activated, eDVBCISlot::data);
} else
{
Expand All @@ -1273,7 +1293,16 @@ eDVBCISlot::~eDVBCISlot()
close(fd);
}

void eDVBCISlot::setAppManager( eDVBCIApplicationManagerSession *session )
void eDVBCISlot::closeDevice()
{
close(fd);
fd = -1;
notifier->stop();
data(eSocketNotifier::Priority);
state = stateDisabled;
}

void eDVBCISlot::setAppManager(eDVBCIApplicationManagerSession *session)
{
singleLock s(eDVBCIInterfaces::m_slot_lock);
application_manager=session;
Expand Down Expand Up @@ -1607,4 +1636,22 @@ int eDVBCISlot::setClockRate(int rate)
return 0;
}

int eDVBCISlot::setEnabled(bool enabled)
{
eDebug("[CI] Slot: %d Enabled: %d, state %d", getSlotID(), enabled, state);
if (enabled && state != stateDisabled)
return 0;

if (!enabled && state == stateDisabled)
return 0;

if(enabled)
openDevice();
else {
closeDevice();
/* emit */ eDVBCI_UI::getInstance()->m_messagepump.send(eDVBCIInterfaces::Message(eDVBCIInterfaces::Message::slotStateChanged, getSlotID(), 3)); // state disabled
}
return 0;
}

eAutoInitP0<eDVBCIInterfaces> init_eDVBCIInterfaces(eAutoInitNumbers::dvb, "CI Slots");
7 changes: 6 additions & 1 deletion lib/dvb_ci/dvbci.h
Expand Up @@ -66,6 +66,7 @@ class eDVBCISlot: public iObject, public sigc::trackable
bool user_mapped;
void data(int);
bool plugged;
eMainloop *m_context;

eDVBCIApplicationManagerSession *getAppManager() { return application_manager; }
eDVBCIMMISession *getMMIManager() { return mmi_session; }
Expand All @@ -85,12 +86,15 @@ class eDVBCISlot: public iObject, public sigc::trackable
int setSource(const std::string &source);
int setClockRate(int);
void determineCIVersion();
int setEnabled(bool);
static std::string getTunerLetter(int tuner_no) { return std::string(1, char(65 + tuner_no)); }
public:
enum {stateRemoved, stateInserted, stateInvalid, stateResetted};
enum {stateRemoved, stateInserted, stateInvalid, stateResetted, stateDisabled};
enum {versionUnknown = -1, versionCI = 0, versionCIPlus1 = 1, versionCIPlus2 = 2};
eDVBCISlot(eMainloop *context, int nr);
~eDVBCISlot();
void closeDevice();
void openDevice();

int send(const unsigned char *data, size_t len);

Expand Down Expand Up @@ -183,6 +187,7 @@ class eDVBCIInterfaces: public eMainloop, private eThread
void ciRemoved(eDVBCISlot *slot);
int getSlotState(int slot);

int setCIEnabled(int slot, bool enabled);
int reset(int slot);
int initialize(int slot);
int startMMI(int slot);
Expand Down
5 changes: 5 additions & 0 deletions lib/dvb_ci/dvbci_ui.cpp
Expand Up @@ -96,5 +96,10 @@ int eDVBCI_UI::setClockRate(int slot, int rate)
return eDVBCIInterfaces::getInstance()->setCIClockRate(slot, rate);
}

int eDVBCI_UI::setEnabled(int slot, bool enabled)
{
return eDVBCIInterfaces::getInstance()->setCIEnabled(slot, enabled);
}

//FIXME: correct "run/startlevel"
eAutoInitP0<eDVBCI_UI> init_dvbciui(eAutoInitNumbers::rc, "DVB-CI UI");
1 change: 1 addition & 0 deletions lib/dvb_ci/dvbci_ui.h
Expand Up @@ -34,6 +34,7 @@ class eDVBCI_UI: public eMMI_UI
int answerEnq(int slot, char *val);
int cancelEnq(int slot);
int setClockRate(int slot, int rate);
int setEnabled(int slot, bool enabled);
};

#endif
4 changes: 3 additions & 1 deletion lib/python/Components/EpgListGrid.py
Expand Up @@ -527,7 +527,8 @@ def buildEntry(self, service, serviceName, events, picon, channel):
duration = ev[3]

xpos, ewidth = self.calcEventPosAndWidthHelper(stime, duration, start, end, width)
serviceTimers = self.filteredTimerList.get(':'.join(service.split(':')[:11]))
serviceref = "1" + service[4:] if service[:4] in config.recording.setstreamto1.value else service # converts 4097, 5001, 5002 to 1
serviceTimers = self.filteredTimerList.get(':'.join(serviceref.split(':')[:11]))
if serviceTimers is not None:
timer, matchType = RecordTimer.isInTimerOnService(serviceTimers, stime, duration)
timerIcon, autoTimerIcon = self.getPixmapsForTimer(timer, matchType, selected)
Expand Down Expand Up @@ -821,6 +822,7 @@ def snapshotTimers(self, startTime, endTime):
# repeat timers represent all their future repetitions, so always include them
if (startTime <= timer.end or timer.repeated) and timer.begin < endTime:
serviceref = timer.service_ref.ref.toCompareString()
serviceref = "1" + serviceref[4:] if serviceref[:4] in config.recording.setstreamto1.value else serviceref # converts 4097, 5001, 5002 to 1
l = self.filteredTimerList.get(serviceref)
if l is None:
self.filteredTimerList[serviceref] = l = [timer]
Expand Down
9 changes: 9 additions & 0 deletions lib/python/Components/RecordingConfig.py
Expand Up @@ -5,6 +5,15 @@ def InitRecordingConfig():
config.recording = ConfigSubsection()
# actually this is "recordings always have priority". "Yes" does mean: don't ask. The RecordTimer will ask when value is 0.
config.recording.asktozap = ConfigYesNo(default=True)
config.recording.setstreamto1 = ConfigSelection(default=(), choices=[
((), _("don't convert")),
(("4097",), _("4097 only")),
(("4097", "5001"), _("4097 + 5001")),
(("4097", "5001", "5002"), _("4097 + 5001 + 5002")),
(("4097", "5002"), _("4097 + 5002")),
(("5001",), _("5001 only")),
(("5001", "5002"), _("5001 + 5002")),
(("5002",), _("5002 only"))])
config.recording.margin_before = ConfigSelectionNumber(min=0, max=120, stepwidth=1, default=3, wraparound=True)
config.recording.margin_after = ConfigSelectionNumber(min=0, max=120, stepwidth=1, default=5, wraparound=True)
config.recording.split_programme_minutes = ConfigSelectionNumber(min=0, max=30, stepwidth=1, default=15, wraparound=True)
Expand Down
21 changes: 10 additions & 11 deletions lib/python/Components/config.py
Expand Up @@ -7,7 +7,7 @@
from Components.Harddisk import harddiskmanager
from Tools.LoadPixmap import LoadPixmap
from copy import copy as copy_copy
from os import path as os_path
from os import fsync, path as os_path, rename, sep
from time import localtime, strftime, mktime

ACTIONKEY_LEFT = 0
Expand Down Expand Up @@ -1908,7 +1908,7 @@ def removedMount(self, mp):
x[2] = False

def refreshMountpoints(self):
self.mountpoints = [p.mountpoint for p in harddiskmanager.getMountedPartitions() if p.mountpoint != "/"]
self.mountpoints = [p.mountpoint for p in harddiskmanager.getMountedPartitions() if p.mountpoint != sep]
self.mountpoints.sort(key=lambda x: -len(x))

def checkChangedMountpoints(self):
Expand All @@ -1925,7 +1925,7 @@ def checkChangedMountpoints(self):
self.addedMount(x)

def getMountpoint(self, file):
file = os_path.realpath(file) + "/"
file = os_path.realpath(file) + sep
for m in self.mountpoints:
if file.startswith(m):
return m
Expand Down Expand Up @@ -2231,18 +2231,17 @@ def unpickle(self, lines, base_file=True):
def saveToFile(self, filename):
text = self.pickle()
try:
import os
f = open(filename + ".writing", "w")
f.write(text)
f.flush()
os.fsync(f.fileno())
f.close()
os.rename(filename + ".writing", filename)
with open(filename + ".writing", "w", encoding="UTF-8") as f:
f.write(text)
f.flush()
fsync(f.fileno())
rename(filename + ".writing", filename)
except IOError:
print("[Config] Couldn't write %s" % filename)

def loadFromFile(self, filename, base_file=True):
self.unpickle(open(filename, "r"), base_file)
with open(filename, "r", encoding="UTF-8") as f:
self.unpickle(f, base_file)


config = Config()
Expand Down

0 comments on commit 33717d8

Please sign in to comment.