Ejemplo n.º 1
0
unsigned int CHTSPData::GetNumTimers()
{
  SRecordings recordings = GetDVREntries(false, true);
  return recordings.size();
}
Ejemplo n.º 2
0
int cHTSPData::GetNumRecordings()
{
  SRecordings recordings = GetDVREntries(true, false);
  return recordings.size();
}
Ejemplo n.º 3
0
PVR_ERROR CHTSPData::GetRecordings(ADDON_HANDLE handle)
{
  SRecordings recordings = GetDVREntries(true, false);

  for(SRecordings::const_iterator it = recordings.begin(); it != recordings.end(); ++it)
  {
    SRecording recording = it->second;
    CStdString strStreamURL = "http://";
    CStdString strRecordingId;
    CStdString strDirectory = "/";
    std::string strChannelName = "";

    /* lock */
    {
      CLockObject lock(m_mutex);
      SChannels::const_iterator itr = m_channels.find(recording.channel);
      if (itr != m_channels.end())
        strChannelName = itr->second.name.c_str();

      /* HTSPv7+ - use HTSP */
      if (GetProtocol() >= 7) {
        strStreamURL = "";

      /* HTSPv6- - use HTTP */
      } else {
        strStreamURL = "http://";

        if (g_strUsername != "")
        {
          strStreamURL += g_strUsername;
          if (g_strPassword != "")
          {
            strStreamURL += ":";
            strStreamURL += g_strPassword;
          }
          strStreamURL += "@";
        }
        strStreamURL.Format("%s%s:%i/dvrfile/%i", strStreamURL.c_str(), g_strHostname.c_str(), g_iPortHTTP, recording.id);
      }
    }

    strRecordingId.Format("%i", recording.id);

    if (recording.path != "")
    {
      size_t i, idx = recording.path.rfind("/");
      if (idx == 0 || idx == std::string::npos) {
        strDirectory = "/";
      } else {
        i = recording.path[0] == '/' ? 1 : 0;
        strDirectory = recording.path.substr(i, idx - i);
        strDirectory.Replace("/", " - ");
        strDirectory = "/" + strDirectory;
      }
    }

    PVR_RECORDING tag;
    memset(&tag, 0, sizeof(PVR_RECORDING));

    strncpy(tag.strRecordingId, strRecordingId.c_str(), sizeof(tag.strRecordingId) - 1);
    strncpy(tag.strTitle, recording.title.c_str(), sizeof(tag.strTitle) - 1);
    strncpy(tag.strStreamURL, strStreamURL.c_str(), sizeof(tag.strStreamURL) - 1);
    strncpy(tag.strDirectory, strDirectory.c_str(), sizeof(tag.strDirectory) - 1);
    strncpy(tag.strPlot, recording.description.c_str(), sizeof(tag.strPlot) - 1);
    strncpy(tag.strChannelName, strChannelName.c_str(), sizeof(tag.strChannelName) - 1);
    tag.recordingTime  = recording.start;
    tag.iDuration      = recording.stop - recording.start;

    PVR->TransferRecordingEntry(handle, &tag);
  }

  return PVR_ERROR_NO_ERROR;
}