Browse Source

Merge pull request #7 from ningpeng/master

1. when pat table changed in ts stream ,  Reconnect ts stream
Georgi Chorbadzhiyski 7 years ago
parent
commit
27b879cb86
2 changed files with 18 additions and 12 deletions
  1. 2
    2
      input.c
  2. 16
    10
      network.c

+ 2
- 2
input.c View File

182
 	// Process PAT
182
 	// Process PAT
183
 	s->pat = ts_pat_push_packet(s->pat, ts_packet);
183
 	s->pat = ts_pat_push_packet(s->pat, ts_packet);
184
 
184
 
185
-	s->last_pat = ts_pat_push_packet(s->last_pat, ts_packet);
185
+	
186
 	if (s->last_pat->initialized) {
186
 	if (s->last_pat->initialized) {
187
 		if (!ts_pat_is_same(s->pat, s->last_pat)) {
187
 		if (!ts_pat_is_same(s->pat, s->last_pat)) {
188
 			proxy_log(r, "PAT changed.");
188
 			proxy_log(r, "PAT changed.");
191
 		ts_pat_free(&s->last_pat);
191
 		ts_pat_free(&s->last_pat);
192
 		s->last_pat = ts_pat_alloc();
192
 		s->last_pat = ts_pat_alloc();
193
 	}
193
 	}
194
-
194
+    s->last_pat = ts_pat_push_packet(s->last_pat, ts_packet);
195
 	if (s->pat->initialized) {
195
 	if (s->pat->initialized) {
196
 		// PMT pid is still unknown
196
 		// PMT pid is still unknown
197
 		if (!s->pmt_pid) {
197
 		if (!s->pmt_pid) {

+ 16
- 10
network.c View File

202
 		}
202
 		}
203
 		// connected ok, continue
203
 		// connected ok, continue
204
 	} else {
204
 	} else {
205
-		if (!IN_MULTICAST(ntohl(r->src_sockname.sin_addr.s_addr))) {
206
-			LOGf("ERR  : %s is not multicast address\n", r->channel->source);
207
-			FATAL_ERROR;
208
-		}
205
+
206
+		char multicast = IN_MULTICAST(ntohl(r->src_sockname.sin_addr.s_addr));
207
+		
208
+		//if (!IN_MULTICAST(ntohl(r->src_sockname.sin_addr.s_addr))) {
209
+		//	LOGf("ERR  : %s is not multicast address\n", r->channel->source);
210
+		//	FATAL_ERROR;
211
+		//}
209
 		struct ip_mreq mreq;
212
 		struct ip_mreq mreq;
210
 		struct sockaddr_in receiving_from;
213
 		struct sockaddr_in receiving_from;
211
 
214
 
217
 		// LOGf("CONN : Listening on multicast socket %s srv_fd: %i retries left: %i\n", r->channel->source, r->sock, retries);
220
 		// LOGf("CONN : Listening on multicast socket %s srv_fd: %i retries left: %i\n", r->channel->source, r->sock, retries);
218
 		int on = 1;
221
 		int on = 1;
219
 		setsockopt(r->sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
222
 		setsockopt(r->sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
220
-		// subscribe to multicast group
221
-		memcpy(&mreq.imr_multiaddr, &(r->src_sockname.sin_addr), sizeof(struct in_addr));
222
-		mreq.imr_interface.s_addr = htonl(INADDR_ANY);
223
-		if (setsockopt(r->sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
224
-			LOGf("ERR  : Failed to add IP membership on %s srv_fd: %i\n", r->channel->source, r->sock);
225
-			FATAL_ERROR;
223
+		
224
+		if (multicast)  {
225
+    		// subscribe to multicast group
226
+    		memcpy(&mreq.imr_multiaddr, &(r->src_sockname.sin_addr), sizeof(struct in_addr));
227
+    		mreq.imr_interface.s_addr = htonl(INADDR_ANY);
228
+    		if (setsockopt(r->sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
229
+    			LOGf("ERR  : Failed to add IP membership on %s srv_fd: %i\n", r->channel->source, r->sock);
230
+    			FATAL_ERROR;
231
+    		}
226
 		}
232
 		}
227
 		// bind to the socket so data can be read
233
 		// bind to the socket so data can be read
228
 		memset(&receiving_from, 0, sizeof(receiving_from));
234
 		memset(&receiving_from, 0, sizeof(receiving_from));

Loading…
Cancel
Save