Example #1
0
int srvlisten_startrtsplive(SRV_LISTENER_CFG_T *pListenCfg) {
  pthread_t ptdRtspLive;
  pthread_attr_t attrRtspLive;
  const char *s;
  int rc = 0;

  if(!pListenCfg || !pListenCfg->pConnPool || pListenCfg->max <= 0 || 
     !pListenCfg->pCfg || !pListenCfg->pCfg->cfgShared.pRtspSessions || 
     pListenCfg->pCfg->cfgShared.pRtspSessions->max <= 0) {
    return -1;
  }

  if((pListenCfg->netflags & NETIO_FLAG_SSL_TLS) && !netio_ssl_enabled(1)) {
    LOG(X_ERROR("SSL not enabled"));
    return -1;
  }

  if((s = logutil_tid_lookup(pthread_self(), 0)) && s[0] != '\0') {
    snprintf(pListenCfg->tid_tag, sizeof(pListenCfg->tid_tag), "%s-rtsp", s);
  }
  pthread_attr_init(&attrRtspLive);
  pthread_attr_setdetachstate(&attrRtspLive, PTHREAD_CREATE_DETACHED);

  if(pthread_create(&ptdRtspLive,
                    &attrRtspLive,
                  (void *) srvlisten_rtsplive_proc,
                  (void *) pListenCfg) != 0) {

    LOG(X_ERROR("Unable to create rtsp listener thread"));
    return -1;
  }

  return rc;
}
Example #2
0
int srvlisten_startmediasrv(SRV_LISTENER_CFG_T *pListenCfg, int async) {
  pthread_t ptdTsLive;
  pthread_attr_t attrTsLive;
  const char *s;
  int rc = 0;

  if(!pListenCfg || !pListenCfg->pConnPool || pListenCfg->max <= 0 || !pListenCfg->pCfg) { 
    return -1;
  }

  if((pListenCfg->netflags & NETIO_FLAG_SSL_TLS) && !netio_ssl_enabled(1)) {
    LOG(X_ERROR("SSL not enabled"));
    return -1;
  }

  if(async) {

    if((s = logutil_tid_lookup(pthread_self(), 0)) && s[0] != '\0') {
      snprintf(pListenCfg->tid_tag, sizeof(pListenCfg->tid_tag), "%s-media", s);
    }

    PHTREAD_INIT_ATTR(&attrTsLive);

    if(pthread_create(&ptdTsLive,
                      &attrTsLive,
                    (void *) srvlisten_media_proc,
                    (void *) pListenCfg) != 0) {

      LOG(X_ERROR("Unable to create live listener thread"));
      return -1;
    }

  } else {
    srvlisten_media_proc(pListenCfg);
    rc = 0;
  }

  return rc;
}