Exemplo n.º 1
0
void CHTSPDemux::ParseSubscriptionStart(htsmsg_t *m)
{
  vector<PVR_STREAM_PROPERTIES::PVR_STREAM> newStreams;

  htsmsg_t       *streams;
  htsmsg_field_t *f;
  uint32_t        subs;

  if(htsmsg_get_u32(m, "subscriptionId", &subs))
  {
    XBMC->Log(LOG_ERROR, "%s - invalid subscription id", __FUNCTION__);
    return;
  }
  m_subs = subs;

  if((streams = htsmsg_get_list(m, "streams")) == NULL)
  {
    XBMC->Log(LOG_ERROR, "%s - malformed message", __FUNCTION__);
    return;
  }

  HTSMSG_FOREACH(f, streams)
  {
    uint32_t    index;
    const char* type;
    htsmsg_t*   sub;

    if (newStreams.size() >= PVR_STREAM_MAX_STREAMS)
    {
      XBMC->Log(LOG_ERROR, "%s - max amount of streams reached", __FUNCTION__);
      break;
    }

    if (f->hmf_type != HMF_MAP)
      continue;

    sub = &f->hmf_msg;

    if ((type = htsmsg_get_str(sub, "type")) == NULL)
      continue;

    if (htsmsg_get_u32(sub, "index", &index))
      continue;

    bool bValidStream(true);
    PVR_STREAM_PROPERTIES::PVR_STREAM newStream;
    m_streams.GetStreamData(index, &newStream);

    CodecDescriptor codecId = CodecDescriptor::GetCodecByName(type);
    if (codecId.Codec().codec_type != XBMC_CODEC_TYPE_UNKNOWN)
    {
      newStream.iCodecType = codecId.Codec().codec_type;
      newStream.iCodecId   = codecId.Codec().codec_id;

      if (codecId.Codec().codec_type == XBMC_CODEC_TYPE_SUBTITLE)
      {
        uint32_t composition_id = 0, ancillary_id = 0;
        htsmsg_get_u32(sub, "composition_id", &composition_id);
        htsmsg_get_u32(sub, "ancillary_id"  , &ancillary_id);
        newStream.iIdentifier = (composition_id & 0xffff) | ((ancillary_id & 0xffff) << 16);
        HTSPSetDemuxStreamInfoLanguage(newStream, sub);
      }
    }
    else
    {
      bValidStream = false;
    }

    if (bValidStream)
    {
      XBMC->Log(LOG_DEBUG, "%s - id: %d, type: %s, codec: %u", __FUNCTION__, index, codecId.Name().c_str(), codecId.Codec().codec_id);

      newStream.iPhysicalId  = index;
      if (codecId.Codec().codec_type == XBMC_CODEC_TYPE_AUDIO)
      {
        HTSPSetDemuxStreamInfoAudio(newStream, sub);
        HTSPSetDemuxStreamInfoLanguage(newStream, sub);
      }
      else if (codecId.Codec().codec_type == XBMC_CODEC_TYPE_VIDEO)
        HTSPSetDemuxStreamInfoVideo(newStream, sub);

      newStreams.push_back(newStream);
    }
    else
    {
      XBMC->Log(LOG_DEBUG, "%s - id: %d, type: %s, ignored", __FUNCTION__, index, type);
    }
  }
Exemplo n.º 2
0
ADDON_STATUS ADDON_SetSetting(const char *settingName, const void *settingValue)
{
  string str = settingName;
  if (str == "host")
  {
    string tmp_sHostname;
    XBMC->Log(LOG_INFO, "%s - Changed Setting 'host' from %s to %s", __FUNCTION__, g_strHostname.c_str(), (const char*) settingValue);
    tmp_sHostname = g_strHostname;
    g_strHostname = (const char*) settingValue;
    if (tmp_sHostname != g_strHostname)
      return ADDON_STATUS_NEED_RESTART;
  }
  else if (str == "user")
  {
    string tmp_sUsername = g_strUsername;
    g_strUsername = (const char*) settingValue;
    if (tmp_sUsername != g_strUsername)
    {
      XBMC->Log(LOG_INFO, "%s - Changed Setting 'user'", __FUNCTION__);
      return ADDON_STATUS_NEED_RESTART;
    }
  }
  else if (str == "pass")
  {
    string tmp_sPassword = g_strPassword;
    g_strPassword = (const char*) settingValue;
    if (tmp_sPassword != g_strPassword)
    {
      XBMC->Log(LOG_INFO, "%s - Changed Setting 'pass'", __FUNCTION__);
      return ADDON_STATUS_NEED_RESTART;
    }
  }
  else if (str == "htsp_port")
  {
    if (g_iPortHTSP != *(int*) settingValue)
    {
      XBMC->Log(LOG_INFO, "%s - Changed Setting 'htsp_port' from %u to %u", __FUNCTION__, g_iPortHTSP, *(int*) settingValue);
      g_iPortHTSP = *(int*) settingValue;
      return ADDON_STATUS_NEED_RESTART;
    }
  }
  else if (str == "http_port")
  {
    if (g_iPortHTTP != *(int*) settingValue)
    {
      XBMC->Log(LOG_INFO, "%s - Changed Setting 'port' from %u to %u", __FUNCTION__, g_iPortHTTP, *(int*) settingValue);
      g_iPortHTTP = *(int*) settingValue;
      return ADDON_STATUS_NEED_RESTART;
    }
  }
  else if (str == "connect_timeout")
  {
    int iNewValue = *(int*) settingValue + 1;
    if (g_iConnectTimeout != iNewValue)
    {
      XBMC->Log(LOG_INFO, "%s - Changed Setting 'connect_timeout' from %u to %u", __FUNCTION__, g_iConnectTimeout, iNewValue);
      g_iConnectTimeout = iNewValue;
      return ADDON_STATUS_OK;
    }
  }
  else if (str == "response_timeout")
  {
    int iNewValue = *(int*) settingValue + 1;
    if (g_iResponseTimeout != iNewValue)
    {
      XBMC->Log(LOG_INFO, "%s - Changed Setting 'response_timeout' from %u to %u", __FUNCTION__, g_iResponseTimeout, iNewValue);
      g_iResponseTimeout = iNewValue;
      return ADDON_STATUS_OK;
    }
  }
  else if (str == "transcode")
  {
    int bNewValue = *(bool*) settingValue;
    XBMC->Log(LOG_INFO, "%s - Changed Setting 'transcode' from %u to %u", __FUNCTION__, g_bTranscode, bNewValue);
    g_bTranscode = (bNewValue == 1);
  }
  else if (str == "resolution")
  {
    int iNewValue = *(int*) settingValue + 1;
    if (g_iResolution != iNewValue)
    {
      XBMC->Log(LOG_INFO, "%s - Changed Setting 'resolution' from %u to %u", __FUNCTION__, g_iResolution, iNewValue);
      g_iResolution = iNewValue;
      return ADDON_STATUS_OK;
    }
  }
  else if (str == "video_codec_name")
  {
    string tmp_strCodecname = g_videoCodec.Name();
    if (tmp_strCodecname != (const char*) settingValue)
    {
      XBMC->Log(LOG_INFO, "%s - Changed Setting 'video_codec' from %s to %s", __FUNCTION__, tmp_strCodecname.c_str(), (const char*) settingValue);
      g_videoCodec = CodecDescriptor::GetCodecByName((const char*) settingValue);
      return ADDON_STATUS_OK;
    }
  }
  else if (str == "audio_codec_name")
  {
    string tmp_strCodecname = g_audioCodec.Name();
    if (tmp_strCodecname != (const char*) settingValue)
    {
      XBMC->Log(LOG_INFO, "%s - Changed Setting 'audio_codec' from %s to %s", __FUNCTION__, tmp_strCodecname.c_str(), (const char*) settingValue);
      g_audioCodec = CodecDescriptor::GetCodecByName((const char*) settingValue);
      return ADDON_STATUS_OK;
    }
  }

  return ADDON_STATUS_OK;
}