예제 #1
0
파일: procdb.c 프로젝트: flybird119/openvcx
static int check_status(SYS_PROC_T *pProc) {
  HTTP_STATUS_T httpStatus;
  unsigned char buf[2048];
  unsigned int szdata = sizeof(buf);
  const char *page = NULL;
  char host[256];
  char tmp[64];
  PROC_STATUS_RESP_DATA_T status;

  snprintf(host, sizeof(host), "http://127.0.0.1:%d", MGR_GET_PORT_STATUS(pProc->startPort));

  VSX_DEBUG_MGR( LOG(X_DEBUG("MGR - Sending local status command: '%s' to: %s"), VSX_STATUS_URL, host); );
예제 #2
0
파일: procdb.c 프로젝트: mmashimaro/openvcx
static char *get_methods_str(int methodBits, 
                             int ssl,
                             char *buf, 
                             unsigned int szbuf, 
                             int startPort, 
                             const char *userpass) {
  unsigned int idxMethod;
  unsigned int idxbuf = 0;
  int lastHttpPort = -1;
  int rc;

  if(userpass && userpass[0] == '\0') {
    userpass = NULL;
  }

  if(methodBits == 0) {
    methodBits = (1 << STREAM_METHOD_HTTPLIVE) |
                 (1 << STREAM_METHOD_FLVLIVE) |
                 (1 << STREAM_METHOD_MKVLIVE) |
                 (1 << STREAM_METHOD_TSLIVE) |
                 (1 << STREAM_METHOD_RTSP);
                 //(1 << STREAM_METHOD_RTMP);
  }

  buf[0] = '\0';

#define HTTP_PROTO_STR "http"
#define RTMP_PROTO_STR "rtmp"
#define RTSP_PROTO_STR "rtsp"

  for(idxMethod = 0; idxMethod < STREAM_METHOD_MAX; idxMethod++) {

    switch(methodBits & (1 << idxMethod)) {
      case (1 << STREAM_METHOD_DASH):
        if((rc = write_listener(&lastHttpPort, MGR_GET_PORT_HTTP(startPort), ssl, "dash", HTTP_PROTO_STR,
                        userpass, NULL, idxbuf > 0 ? 1 : 0, &buf[idxbuf], szbuf - idxbuf)) > 0) {
          idxbuf += rc;
        }
        break;
      case (1 << STREAM_METHOD_HTTPLIVE):
        if((rc = write_listener(&lastHttpPort, MGR_GET_PORT_HTTP(startPort), ssl, "httplive", HTTP_PROTO_STR, 
                        userpass, NULL, idxbuf > 0 ? 1 : 0, &buf[idxbuf], szbuf - idxbuf)) > 0) {
          idxbuf += rc;
        }
        break;
      case (1 << STREAM_METHOD_FLVLIVE):
        if((rc = write_listener(&lastHttpPort, MGR_GET_PORT_HTTP(startPort), ssl, "flvlive", HTTP_PROTO_STR, 
                        userpass, NULL, idxbuf > 0 ? 1 : 0, &buf[idxbuf], szbuf - idxbuf)) > 0) {
          idxbuf += rc;
        }
        break;
      case (1 << STREAM_METHOD_MKVLIVE):
        if((rc = write_listener(&lastHttpPort, MGR_GET_PORT_HTTP(startPort), ssl, "mkvlive", HTTP_PROTO_STR, 
                        userpass, NULL, idxbuf > 0 ? 1 : 0, &buf[idxbuf], szbuf - idxbuf)) > 0) {
          idxbuf += rc;
        }
        break;
      case (1 << STREAM_METHOD_TSLIVE):
        if((rc = write_listener(&lastHttpPort, MGR_GET_PORT_HTTP(startPort), ssl, "tslive", HTTP_PROTO_STR, 
                        userpass, NULL, idxbuf > 0 ? 1 : 0, &buf[idxbuf], szbuf - idxbuf)) > 0) {
          idxbuf += rc;
        }
        break;
      case (1 << STREAM_METHOD_RTMP):
        if((rc = write_listener(NULL, MGR_GET_PORT_RTMP(startPort), ssl, "rtmp", RTMP_PROTO_STR, 
                            userpass, NULL, idxbuf > 0 ? 1 : 0, &buf[idxbuf], szbuf - idxbuf)) > 0) {
          idxbuf += rc;
        }
        break;
      case (1 << STREAM_METHOD_RTSP):
        if((rc = write_listener(NULL, MGR_GET_PORT_RTSP(startPort), ssl, "rtsp", RTSP_PROTO_STR, 
                            userpass, NULL, idxbuf > 0 ? 1 : 0, &buf[idxbuf], szbuf - idxbuf)) > 0) {
          idxbuf += rc;
        }
        break;

      default:
        break;

    } // end of switch

  } // end of for(idxMethod...

  if(idxbuf > 0) {
    //
    // If we are using a streaming output method then include the '/live' URL which also allows for loading
    // various rsrc/*.js and img/ files required by rsrc/xxx_embed.html files
    //
    if((rc = write_listener(&lastHttpPort, MGR_GET_PORT_HTTP(startPort), ssl, "live", HTTP_PROTO_STR, 
                        userpass, NULL, idxbuf > 0 ? 1 : 0, &buf[idxbuf], szbuf - idxbuf)) > 0) {
      idxbuf += rc;
    }
  }

  //
  // Include a /status URL listener bound to localhost without any credentials
  //
  if((rc = write_listener(NULL, MGR_GET_PORT_STATUS(startPort), 0, "status", HTTP_PROTO_STR, 
                      NULL, "127.0.0.1", idxbuf > 0 ? 1 : 0, &buf[idxbuf], szbuf - idxbuf)) > 0) {
    idxbuf += rc;
  }

  return buf;
}
예제 #3
0
파일: procdb.c 프로젝트: mmashimaro/openvcx
static int check_status(SYS_PROC_T *pProc) {
  int rc;
  char *p, *p2;
  KEYVAL_PAIR_T kv;
  char buf[1024];
  int numActiveRtmp = -1;
  int numActiveRtsp = -1;
  int numActiveRtspInterleaved = -1;
  int numActiveTsLive = -1;
  int numActiveFlvLive = -1;
  const char *host = "127.0.0.1";

  pProc->numActive = 0;

  if((rc = http_getpage(host, MGR_GET_PORT_STATUS(pProc->startPort), VSX_STATUS_URL, buf, sizeof(buf), 2000)) < 0) {
    LOG(X_ERROR("Failed to load "VSX_STATUS_URL" for %s:%d"), host, MGR_GET_PORT_STATUS(pProc->startPort));
    return rc;
  }

  p = buf;
  while(p - buf < rc) {
    p2 = p;
    while(p2 - buf < rc && *p2 != '&') {
      p2++;
    }
    //fprintf(stderr, "--%c%c%c len:%d, rc:%d\n", p[0], p[1], p[2], p2 - p, rc);
    if(conf_parse_keyval(&kv, p, p2 - p, '=', 0) == 2) {
      if(!strncasecmp(kv.key, "rtmp", 4)) {
        numActiveRtmp = atoi(kv.val);
      } else if(!strncasecmp(kv.key, "rtspi", 5)) {
        numActiveRtspInterleaved = atoi(kv.val);
      } else if(!strncasecmp(kv.key, "rtsp", 4)) {
        numActiveRtsp = atoi(kv.val);
      } else if(!strncasecmp(kv.key, "tslive", 6)) {
        numActiveTsLive = atoi(kv.val);
      } else if(!strncasecmp(kv.key, "flvlive", 7)) {
        numActiveFlvLive = atoi(kv.val);
      }

      //fprintf(stderr, "key:'%s' val:'%s'\n", kv.key , kv.val);
    }
    p = p2;
    while(p - buf < rc && *p == '&') {
      p++;
    }
  }


  if(numActiveRtmp >= 0) {
    pProc->numActive += numActiveRtmp;
  }
  if(numActiveRtsp >= 0) {
    pProc->numActive += numActiveRtsp;
  }
  if(numActiveTsLive >= 0) {
    pProc->numActive += numActiveTsLive;
  }
  if(numActiveTsLive >= 0) {
    pProc->numActive += numActiveFlvLive;
  }
 
  VSX_DEBUGLOG("Status for %s (%s, profile:%s) %s:%d rtmp:%d rtsp:%d (interleaved:%d) ts:%d flv: %d"
                " (rc:%d '%s')\n", 
     pProc->name, pProc->instanceId, pProc->id, host, MGR_GET_PORT_STATUS(pProc->startPort), 
     numActiveRtmp, numActiveRtsp, numActiveRtspInterleaved, numActiveTsLive, numActiveFlvLive, rc, buf);

  return rc;
}