Esempio n. 1
0
size_t cSatipRtsp::HeaderCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP)
{
  cSatipRtsp *obj = reinterpret_cast<cSatipRtsp *>(dataP);
  size_t len = sizeP * nmembP;
  debug16("%s len=%zu", __PRETTY_FUNCTION__, len);

  char *s, *p = (char *)ptrP;
  char *r = strtok_r(p, "\r\n", &s);

  while (obj && r) {
        debug16("%s (%zu): %s", __PRETTY_FUNCTION__, len, r);
        r = skipspace(r);
        if (strstr(r, "com.ses.streamID")) {
           int streamid = -1;
           if (sscanf(r, "com.ses.streamID:%11d", &streamid) == 1)
              obj->tunerM.SetStreamId(streamid);
           }
        else if (strstr(r, "Session:")) {
           int timeout = -1;
           char *session = NULL;
           if (sscanf(r, "Session:%m[^;];timeout=%11d", &session, &timeout) == 2)
              obj->tunerM.SetSessionTimeout(skipspace(session), timeout * 1000);
           else if (sscanf(r, "Session:%m[^;]", &session) == 1)
              obj->tunerM.SetSessionTimeout(skipspace(session), -1);
           FREE_POINTER(session);
           }
        r = strtok_r(NULL, "\r\n", &s);
        }

  return len;
}
Esempio n. 2
0
cSatipDevice *cSatipDevice::GetSatipDevice(int cardIndexP)
{
  debug16("%s (%d)", __PRETTY_FUNCTION__, cardIndexP);
  for (unsigned int i = 0; i < SATIP_MAX_DEVICES; ++i) {
      if (SatipDevicesS[i] && (SatipDevicesS[i]->CardIndex() == cardIndexP)) {
         debug16("%s (%d): Found!", __PRETTY_FUNCTION__, cardIndexP);
         return SatipDevicesS[i];
         }
      }
  return NULL;
}
Esempio n. 3
0
void cSatipSectionStatistics::AddSectionStatistic(long bytesP, long callsP)
{
  debug16("%s (%ld, %ld)", __PRETTY_FUNCTION__, bytesP, callsP);
  cMutexLock MutexLock(&mutexM);
  filteredDataM += bytesP;
  numberOfCallsM += callsP;
}
Esempio n. 4
0
void cSatipRtsp::ParseHeader(void)
{
  debug1("%s [device %d]", __PRETTY_FUNCTION__, tunerM.GetId());
  char *s, *p = headerBufferM.Data();
  char *r = strtok_r(p, "\r\n", &s);

  while (r) {
        debug16("%s (%zu): %s", __PRETTY_FUNCTION__, headerBufferM.Size(), r);
        r = skipspace(r);
        if (strstr(r, "com.ses.streamID")) {
           int streamid = -1;
           if (sscanf(r, "com.ses.streamID:%11d", &streamid) == 1)
              tunerM.SetStreamId(streamid);
           }
        else if (strstr(r, "Session:")) {
           int timeout = -1;
           char *session = NULL;
           if (sscanf(r, "Session:%m[^;];timeout=%11d", &session, &timeout) == 2)
              tunerM.SetSessionTimeout(skipspace(session), timeout * 1000);
           else if (sscanf(r, "Session:%m[^;]", &session) == 1)
              tunerM.SetSessionTimeout(skipspace(session), -1);
           FREE_POINTER(session);
           }
        r = strtok_r(NULL, "\r\n", &s);
        }
}
Esempio n. 5
0
uchar *cSatipDevice::GetData(int *availableP)
{
  debug16("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
  if (isOpenDvrM && tsBufferM) {
     int count = 0;
     if (isPacketDeliveredM)
        SkipData(TS_SIZE);
     uchar *p = tsBufferM->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) {
                  count = i;
                  break;
                  }
               }
           tsBufferM->Del(count);
           info("Skipped %d bytes to sync on TS packet", count);
           return NULL;
           }
        isPacketDeliveredM = true;
        if (availableP)
           *availableP = count;
        // Update pid statistics
        AddPidStatistic(ts_pid(p), payload(p));
        return p;
        }
     }
  return NULL;
}
Esempio n. 6
0
void cSatipDevice::SkipData(int countP)
{
  debug16("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
  tsBufferM->Del(countP);
  isPacketDeliveredM = false;
  // Update buffer statistics
  AddBufferStatistic(countP, tsBufferM->Available());
}
Esempio n. 7
0
void cSatipBufferStatistics::AddBufferStatistic(long bytesP, long usedP)
{
  debug16("%s (%ld, %ld)", __PRETTY_FUNCTION__, bytesP, usedP);
  cMutexLock MutexLock(&mutexM);
  dataBytesM += bytesP;
  if (usedP > usedSpaceM)
     usedSpaceM = usedP;
}
Esempio n. 8
0
// Section statistics class
cSatipSectionStatistics::cSatipSectionStatistics()
: filteredDataM(0),
  numberOfCallsM(0),
  timerM(),
  mutexM()
{
  debug16("%s", __PRETTY_FUNCTION__);
}
Esempio n. 9
0
cPluginSatip::cPluginSatip(void)
: deviceCountM(2),
  serversM(NULL)
{
  debug16("%s", __PRETTY_FUNCTION__);
  // Initialize any member variables here.
  // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
  // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
}
Esempio n. 10
0
int cSatipPidStatistics::SortPids(const void* data1P, const void* data2P)
{
  debug16("%s", __PRETTY_FUNCTION__);
  const pidStruct *comp1 = reinterpret_cast<const pidStruct*>(data1P);
  const pidStruct *comp2 = reinterpret_cast<const pidStruct*>(data2P);
  if (comp1->dataAmount > comp2->dataAmount)
     return -1;
  if (comp1->dataAmount < comp2->dataAmount)
     return 1;
  return 0;
}
Esempio n. 11
0
cString cSatipDevice::GetGeneralInformation(void)
{
  debug16("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
  return cString::sprintf("SAT>IP device: %d\nCardIndex: %d\nStream: %s\nSignal: %s\nStream bitrate: %s\n%sChannel: %s",
                          deviceIndexM, CardIndex(),
                          pTunerM ? *pTunerM->GetInformation() : "",
                          pTunerM ? *pTunerM->GetSignalStatus() : "",
                          pTunerM ? *pTunerM->GetTunerStatistic() : "",
                          *GetBufferStatistic(),
                          *Channels.GetByNumber(cDevice::CurrentChannel())->ToText());
}
Esempio n. 12
0
size_t cSatipRtsp::DataCallback(char *ptrP, size_t sizeP, size_t nmembP, void *dataP)
{
  cSatipRtsp *obj = reinterpret_cast<cSatipRtsp *>(dataP);
  size_t len = sizeP * nmembP;
  debug16("%s len=%zu", __PRETTY_FUNCTION__, len);

  if (obj)
     obj->dataBufferM.Add(ptrP, len);

  return len;
}
Esempio n. 13
0
size_t cSatipRtsp::WriteCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP)
{
  cSatipRtsp *obj = reinterpret_cast<cSatipRtsp *>(dataP);
  size_t len = sizeP * nmembP;
  debug16("%s len=%zu", __PRETTY_FUNCTION__, len);

  if (obj && (len > 0))
     obj->tunerM.ProcessApplicationData((u_char*)ptrP, len);

  return len;
}
Esempio n. 14
0
void cSatipDevice::WriteData(uchar *bufferP, int lengthP)
{
  debug16("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
  // Fill up TS buffer
  if (isOpenDvrM && tsBufferM) {
     int len = tsBufferM->Put(bufferP, lengthP);
     if (len != lengthP)
        tsBufferM->ReportOverflow(lengthP - len);
     }
  // Filter the sections
  if (pSectionFilterHandlerM)
     pSectionFilterHandlerM->Write(bufferP, lengthP);
}
Esempio n. 15
0
cString cSatipSectionStatistics::GetSectionStatistic()
{
  debug16("%s", __PRETTY_FUNCTION__);
  cMutexLock MutexLock(&mutexM);
  uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
  timerM.Set();
  long bitrate = elapsed ? (long)(1000.0L * filteredDataM / KILOBYTE(1) / elapsed) : 0L;
  if (!SatipConfig.GetUseBytes())
     bitrate *= 8;
  // no trailing linefeed here!
  cString s = cString::sprintf("%4ld (%4ld k%s/s)", numberOfCallsM, bitrate,
                               SatipConfig.GetUseBytes() ? "B" : "bit");
  filteredDataM = numberOfCallsM = 0;
  return s;
}
Esempio n. 16
0
cString cSatipTunerStatistics::GetTunerStatistic()
{
  debug16("%s", __PRETTY_FUNCTION__);
  mutexM.Lock();
  uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
  timerM.Set();
  long bitrate = elapsed ? (long)(1000.0L * dataBytesM / KILOBYTE(1) / elapsed) : 0L;
  dataBytesM = 0;
  mutexM.Unlock();

  if (!SatipConfig.GetUseBytes())
     bitrate *= 8;
  cString s = cString::sprintf("%ld k%s/s", bitrate, SatipConfig.GetUseBytes() ? "B" : "bit");
  return s;
}
Esempio n. 17
0
bool cSatipDevice::GetTSPacket(uchar *&dataP)
{
  debug16("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
  if (tsBufferM) {
     if (cCamSlot *cs = CamSlot()) {
        if (cs->WantsTsData()) {
           int available;
           dataP = GetData(&available);
           if (dataP) {
              dataP = cs->Decrypt(dataP, available);
              SkipData(available);
              }
           return true;
           }
        }
     dataP = GetData();
     return true;
     }
  dataP = NULL;
  return true;
}
Esempio n. 18
0
cString cSatipBufferStatistics::GetBufferStatistic()
{
  debug16("%s", __PRETTY_FUNCTION__);
  cMutexLock MutexLock(&mutexM);
  uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
  timerM.Set();
  long bitrate = elapsed ? (long)(1000.0L * dataBytesM / KILOBYTE(1) / elapsed) : 0L;
  long totalSpace = SATIP_BUFFER_SIZE;
  float percentage = (float)((float)usedSpaceM / (float)totalSpace * 100.0);
  long totalKilos = totalSpace / KILOBYTE(1);
  long usedKilos = usedSpaceM / KILOBYTE(1);
  if (!SatipConfig.GetUseBytes()) {
     bitrate *= 8;
     totalKilos *= 8;
     usedKilos *= 8;
     }
  cString s = cString::sprintf("Buffer bitrate: %ld k%s/s\nBuffer usage: %ld/%ld k%s (%2.1f%%)\n", bitrate,
                               SatipConfig.GetUseBytes() ? "B" : "bit", usedKilos, totalKilos,
                               SatipConfig.GetUseBytes() ? "B" : "bit", percentage);
  dataBytesM = 0;
  usedSpaceM = 0;
  return s;
}
Esempio n. 19
0
void cSatipPidStatistics::AddPidStatistic(int pidP, long payloadP)
{
  debug16("%s (%d, %ld)", __PRETTY_FUNCTION__, pidP, payloadP);
  cMutexLock MutexLock(&mutexM);
  const int numberOfElements = sizeof(mostActivePidsM) / sizeof(pidStruct);
  // If our statistic already is in the array, update it and quit
  for (int i = 0; i < numberOfElements; ++i) {
      if (mostActivePidsM[i].pid == pidP) {
         mostActivePidsM[i].dataAmount += payloadP;
         // Now re-sort the array and quit
         qsort(mostActivePidsM, numberOfElements, sizeof(pidStruct), SortPids);
         return;
         }
      }
  // Apparently our pid isn't in the array. Replace the last element with this
  // one if new payload is greater
  if (mostActivePidsM[numberOfElements - 1].dataAmount < payloadP) {
      mostActivePidsM[numberOfElements - 1].pid = pidP;
      mostActivePidsM[numberOfElements - 1].dataAmount = payloadP;
     // Re-sort
     qsort(mostActivePidsM, numberOfElements, sizeof(pidStruct), SortPids);
     }
}
Esempio n. 20
0
void cSatipRtsp::ParseData(void)
{
  debug1("%s [device %d]", __PRETTY_FUNCTION__, tunerM.GetId());
  char *s, *p = dataBufferM.Data();
  char *r = strtok_r(p, "\r\n", &s);

  while (r) {
        debug16("%s (%zu): %s", __PRETTY_FUNCTION__, dataBufferM.Size(), r);
        r = skipspace(r);
        if (strstr(r, "No-More:")) {
           char *tmp = NULL;
           if (sscanf(r, "No-More:%m[^;]", &tmp) == 1) {
              errorNoMoreM = skipspace(tmp);
              debug3("%s No-More: %s [device %d]", __PRETTY_FUNCTION__, *errorNoMoreM, tunerM.GetId());
              }
           FREE_POINTER(tmp);
           }
        else if (strstr(r, "Out-of-Range:")) {
           char *tmp = NULL;
           if (sscanf(r, "Out-of-Range:%m[^;]", &tmp) == 1) {
              errorOutOfRangeM = skipspace(tmp);
              debug3("%s Out-of-Range: %s [device %d]", __PRETTY_FUNCTION__, *errorOutOfRangeM, tunerM.GetId());
              }
           FREE_POINTER(tmp);
           }
        else if (strstr(r, "Check-Syntax:")) {
           char *tmp = NULL;
           if (sscanf(r, "Check-Syntax:%m[^;]", &tmp) == 1) {
              errorCheckSyntaxM = skipspace(tmp);
              debug3("%s Check-Syntax: %s [device %d]", __PRETTY_FUNCTION__, *errorCheckSyntaxM, tunerM.GetId());
              }
           FREE_POINTER(tmp);
           }
        r = strtok_r(NULL, "\r\n", &s);
        }
}
Esempio n. 21
0
cString cSatipPidStatistics::GetPidStatistic()
{
  debug16("%s", __PRETTY_FUNCTION__);
  cMutexLock MutexLock(&mutexM);
  const int numberOfElements = sizeof(mostActivePidsM) / sizeof(pidStruct);
  uint64_t elapsed = timerM.Elapsed(); /* in milliseconds */
  timerM.Set();
  cString s("Active pids:\n");
  for (int i = 0; i < numberOfElements; ++i) {
      if (mostActivePidsM[i].pid >= 0) {
         long bitrate = elapsed ? (long)(1000.0L * mostActivePidsM[i].dataAmount / KILOBYTE(1) / elapsed) : 0L;
         if (!SatipConfig.GetUseBytes())
            bitrate *= 8;
         s = cString::sprintf("%sPid %d: %4d (%4ld k%s/s)\n", *s, i,
                              mostActivePidsM[i].pid, bitrate,
                              SatipConfig.GetUseBytes() ? "B" : "bit");
         }
      }
  for (int i = 0; i < numberOfElements; ++i) {
      mostActivePidsM[i].pid = -1;
      mostActivePidsM[i].dataAmount = 0L;
      }
  return s;
}
Esempio n. 22
0
bool cSatipDevice::AvoidRecording(void) const
{
  debug16("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
  return SatipConfig.IsOperatingModeLow();
}
Esempio n. 23
0
bool cSatipDevice::Ready(void)
{
  debug16("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
  return ((cSatipDiscover::GetInstance()->GetServerCount() > 0) || (createdM.Elapsed() > eReadyTimeoutMs));
}
Esempio n. 24
0
bool cSatipDevice::HasLock(int timeoutMsP) const
{
  debug16("%s (%d) [device %d]", __PRETTY_FUNCTION__, timeoutMsP, deviceIndexM);
  return (pTunerM && pTunerM->HasLock());
}
Esempio n. 25
0
cString cSatipDevice::DeviceType(void) const
{
  debug16("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
  return "SAT>IP";
}
Esempio n. 26
0
cString cSatipDevice::DeviceName(void) const
{
  debug16("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
  return deviceNameM;
}
Esempio n. 27
0
cSatipSectionStatistics::~cSatipSectionStatistics()
{
  debug16("%s", __PRETTY_FUNCTION__);
}
Esempio n. 28
0
bool cSatipDevice::HasInternalCam(void)
{
  debug16("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
  return SatipConfig.GetCIExtension();
}
Esempio n. 29
0
void cSatipTunerStatistics::AddTunerStatistic(long bytesP)
{
  debug16("%s (%ld)", __PRETTY_FUNCTION__, bytesP);
  cMutexLock MutexLock(&mutexM);
  dataBytesM += bytesP;
}
Esempio n. 30
0
int cSatipDevice::SignalQuality(void) const
{
  debug16("%s [device %u]", __PRETTY_FUNCTION__, deviceIndexM);
  return (pTunerM ? pTunerM->SignalQuality() : -1);
}