Browse Source

pmt_pid is based by channel index ( >0 && <256 ), pmt_id = channel_index*32

originally the output ts stream 's pmt_pid is based by service_id , and pmt_id = service_id*32 , it may be overflow or duplicated.
wing_pn 7 years ago
parent
commit
9311174046
3 changed files with 20 additions and 7 deletions
  1. 2
    2
      config.c
  2. 15
    3
      data.c
  3. 3
    2
      data.h

+ 2
- 2
config.c View File

142
 				}
142
 				}
143
 				// Init channel
143
 				// Init channel
144
 				if (channel == NULL) {
144
 				if (channel == NULL) {
145
-					channel = channel_new(service_id, is_radio, id, name, source);
145
+					channel = channel_new(service_id, is_radio, id, name, source, i);
146
 				} else {
146
 				} else {
147
 					chansrc_add(channel, source);
147
 					chansrc_add(channel, source);
148
 				}
148
 				}
222
 		if (r->cookie != cookie) {
222
 		if (r->cookie != cookie) {
223
 			proxy_log(r, "Remove");
223
 			proxy_log(r, "Remove");
224
 			/* Replace channel reference with real object and instruct free_restreamer to free it */
224
 			/* Replace channel reference with real object and instruct free_restreamer to free it */
225
-			r->channel = channel_new(r->channel->service_id, r->channel->radio, r->channel->id, r->channel->name, r->channel->source);
225
+			r->channel = channel_new(r->channel->service_id, r->channel->radio, r->channel->id, r->channel->name, r->channel->source, r->channel->index);
226
 			r->freechannel = 1;
226
 			r->freechannel = 1;
227
 			r->dienow = 1;
227
 			r->dienow = 1;
228
 		}
228
 		}

+ 15
- 3
data.c View File

88
 	}
88
 	}
89
 };
89
 };
90
 
90
 
91
-void chansrc_add(CHANNEL *c, char *src) {
91
+void chansrc_add(CHANNEL *c, const char *src) {
92
 	if (c->num_src >= MAX_CHANNEL_SOURCES-1)
92
 	if (c->num_src >= MAX_CHANNEL_SOURCES-1)
93
 		return;
93
 		return;
94
 	c->sources[c->num_src] = strdup(src);
94
 	c->sources[c->num_src] = strdup(src);
121
 
121
 
122
 
122
 
123
 
123
 
124
-CHANNEL *channel_new(int service_id, int is_radio, char *id, char *name, char *source) {
124
+CHANNEL *channel_new(int service_id, int is_radio, const char *id, const char *name, const char *source, int channel_index){
125
+
126
+    if (channel_index<=0 || channel_index>=256)
127
+    {
128
+        
129
+	    LOGf("CONFIG: Error channel_new invalid index %d\n", channel_index);
130
+        return NULL;
131
+    }
132
+    //LOGf("CONFIG: ------------------channel_new() serviceid %d id %s name %s source %s index %d\n", service_id, id, name , source , channel_index);
133
+    
125
 	CHANNEL *c = calloc(1, sizeof(CHANNEL));
134
 	CHANNEL *c = calloc(1, sizeof(CHANNEL));
126
 	c->service_id = service_id;
135
 	c->service_id = service_id;
127
 	c->radio = is_radio;
136
 	c->radio = is_radio;
128
-	c->base_pid = service_id * 32; // The first pid is saved for PMT
137
+    c->index = channel_index;
138
+	c->base_pid = c->index * 32; // The first pid is saved for PMT , channel_index must > 0
129
 	c->pmt_pid = c->base_pid; // The first pid is saved for PMT
139
 	c->pmt_pid = c->base_pid; // The first pid is saved for PMT
130
 	c->id = strdup(id);
140
 	c->id = strdup(id);
131
 	c->name = strdup(name);
141
 	c->name = strdup(name);
132
 	chansrc_add(c, source);
142
 	chansrc_add(c, source);
143
+
144
+
133
 	return c;
145
 	return c;
134
 }
146
 }
135
 
147
 

+ 3
- 2
data.h View File

59
 
59
 
60
 typedef struct {
60
 typedef struct {
61
 	/* Config */
61
 	/* Config */
62
+    int         index;
62
 	int			base_pid;
63
 	int			base_pid;
63
 	int			service_id;
64
 	int			service_id;
64
 	int			pmt_pid;
65
 	int			pmt_pid;
219
 void		epg_free		(EPG_ENTRY **e);
220
 void		epg_free		(EPG_ENTRY **e);
220
 int			epg_changed		(EPG_ENTRY *a, EPG_ENTRY *b);
221
 int			epg_changed		(EPG_ENTRY *a, EPG_ENTRY *b);
221
 
222
 
222
-CHANNEL *	channel_new		(int service_id, int is_radio, char *id, char *name, char *source);
223
+CHANNEL *	channel_new		(int service_id, int is_radio, const char *id, const char *name, const char *source, int channel_index);
223
 void		channel_free	(CHANNEL **c);
224
 void		channel_free	(CHANNEL **c);
224
 void		channel_free_epg(CHANNEL *c);
225
 void		channel_free_epg(CHANNEL *c);
225
 
226
 
228
 
229
 
229
 CHANSRC *	chansrc_init	(char *url);
230
 CHANSRC *	chansrc_init	(char *url);
230
 void		chansrc_free	(CHANSRC **url);
231
 void		chansrc_free	(CHANSRC **url);
231
-void		chansrc_add		(CHANNEL *c, char *src);
232
+void		chansrc_add		(CHANNEL *c, const char *src);
232
 void		chansrc_next	(CHANNEL *c);
233
 void		chansrc_next	(CHANNEL *c);
233
 void		chansrc_set		(CHANNEL *c, uint8_t src_id);
234
 void		chansrc_set		(CHANNEL *c, uint8_t src_id);
234
 
235
 

Loading…
Cancel
Save