SAT-IP-NAT-port-support.diff

Patch - Mono Polimorph, 2017-09-21 13:27

Download (4.83 KB)

View differences:

src/satip/rtsp.c
81 81
static char *rtsp_ip = NULL;
82 82
static char *rtsp_nat_ip = NULL;
83 83
static int rtsp_port = -1;
84
static int rtsp_nat_port = -1;
84 85
static int rtsp_descramble = 1;
85 86
static int rtsp_rewrite_pmt = 0;
86 87
static int rtsp_muxcnf = MUXCNF_AUTO;
......
252 253
rtsp_check_urlbase(char *u)
253 254
{
254 255
  char *p, *s;
256
  int t;
255 257

  
256 258
  if (*u == '/' || strncmp(u, "stream=", 7) == 0)
257 259
    return u;
......
264 266
    *p = '\0';
265 267
  if ((s = strchr(u, ':')) != NULL) {
266 268
    *s = '\0';
267
    if (atoi(s + 1) != rtsp_port)
269
    t = rtsp_nat_port ?: rtsp_port;
270
    if (atoi(s + 1) != t)
268 271
      return NULL;
269 272
  } else {
270 273
#if 0 /* VLC is broken */
......
1393 1396
rtsp_process_play(http_connection_t *hc, int cmd)
1394 1397
{
1395 1398
  session_t *rs;
1396
  int errcode = HTTP_STATUS_BAD_REQUEST, valid = 0, i, stream;
1399
  int errcode = HTTP_STATUS_BAD_REQUEST, valid = 0, i, p, stream;
1397 1400
  char buf[256], *u = tvh_strdupa(hc->hc_url);
1398 1401
  http_arg_list_t args;
1399 1402

  
......
1452 1455
    snprintf(buf, sizeof(buf), "%d", rs->stream);
1453 1456
    http_arg_set(&args, "com.ses.streamID", buf);
1454 1457
  } else {
1455
    if (rtsp_port != 554)
1456
      snprintf(buf, sizeof(buf), "url=rtsp://%s:%d/stream=%d", rtsp_ip, rtsp_port, rs->stream);
1458
    p = rtsp_nat_port ?: rtsp_port;
1459
    if (p != 554)
1460
      snprintf(buf, sizeof(buf), "url=rtsp://%s:%d/stream=%d", rtsp_ip, p, rs->stream);
1457 1461
    else
1458 1462
      snprintf(buf, sizeof(buf), "url=rtsp://%s/stream=%d", rtsp_ip, rs->stream);
1459 1463
    http_arg_set(&args, "RTP-Info", buf);
......
1683 1687
 */
1684 1688
void satip_server_rtsp_init
1685 1689
  (const char *bindaddr, int port, int descramble, int rewrite_pmt, int muxcnf,
1686
   const char *nat_ip)
1690
   const char *nat_ip, int nat_port)
1687 1691
{
1688 1692
  static tcp_server_ops_t ops = {
1689 1693
    .start  = rtsp_serve,
......
1716 1720
  s = rtsp_nat_ip;
1717 1721
  rtsp_nat_ip = nat_ip ? strdup(nat_ip) : NULL;
1718 1722
  free(s);
1723
  rtsp_nat_port = nat_port;
1719 1724
  if (!rtsp_server)
1720 1725
    rtsp_server = tcp_server_create(LS_SATIPS, "SAT>IP RTSP", bindaddr, port, &ops, NULL);
1721 1726
  if (reg)
......
1738 1743
  pthread_mutex_lock(&global_lock);
1739 1744
  rtsp_server = NULL;
1740 1745
  rtsp_port = -1;
1746
  rtsp_nat_port = -1;
1741 1747
  free(rtsp_ip);
1742 1748
  free(rtsp_nat_ip);
1743 1749
  rtsp_ip = rtsp_nat_ip = NULL;
src/satip/server.c
754 754
      .group  = 1,
755 755
    },
756 756
    {
757
      .type   = PT_INT,
758
      .id     = "satip_nat_rtsp",
759
      .name   = N_("External RTSP port (NAT)"),
760
      .desc   = N_("Enter external PORT if behind Forwarding redirection."
761
                   "(0 = use the same local port)."),
762
      .off    = offsetof(struct satip_server_conf, satip_nat_rtsp),
763
      .opts   = PO_EXPERT,
764
      .group  = 1,
765
    },
766
    {
757 767
      .type   = PT_BOOL,
758 768
      .id     = "satip_nom3u",
759 769
      .name   = N_("Disable X_SATIPM3U tag"),
......
868 878
  char http_ip[128];
869 879
  int descramble, rewrite_pmt, muxcnf;
870 880
  char *nat_ip;
881
  int nat_port;
871 882

  
872 883
  if (satip_server_rtsp_port <= 0)
873 884
    return;
......
890 901
  rewrite_pmt = satip_server_conf.satip_rewrite_pmt;
891 902
  muxcnf = satip_server_conf.satip_muxcnf;
892 903
  nat_ip = strdup(satip_server_conf.satip_nat_ip ?: "");
904
  nat_port = satip_server_conf.satip_nat_rtsp ?: satip_server_rtsp_port;
893 905

  
894 906
  if (announce)
895 907
    pthread_mutex_unlock(&global_lock);
896 908

  
897 909
  pthread_mutex_lock(&satip_server_reinit);
898 910

  
899
  satip_server_rtsp_init(http_server_ip, satip_server_rtsp_port, descramble, rewrite_pmt, muxcnf, nat_ip);
911
  satip_server_rtsp_init(http_server_ip, satip_server_rtsp_port, descramble, rewrite_pmt, muxcnf, nat_ip, nat_port);
900 912
  satip_server_info(prefix, descramble, muxcnf);
901 913

  
902 914
  if (announce)
src/satip/server.h
62 62
  int satip_atsc_t;
63 63
  int satip_atsc_c;
64 64
  char *satip_nat_ip;
65
  int satip_nat_rtsp;
65 66
};
66 67

  
67 68
extern struct satip_server_conf satip_server_conf;
......
92 93

  
93 94
void satip_server_rtsp_init(const char *bindaddr, int port,
94 95
                            int descramble, int rewrite_pmt, int muxcnf,
95
                            const char *nat_ip);
96
                            const char *nat_ip, int nat_port);
96 97
void satip_server_rtsp_register(void);
97 98
void satip_server_rtsp_done(void);
98 99