Browse Source

Add ts_{nit,sdt,eit,tdt}_is_same() and ts_{nit,sdt,tdt}_is_copy().

Georgi Chorbadzhiyski 8 years ago
parent
commit
e8488e35ab
5 changed files with 80 additions and 0 deletions
  1. 11 0
      tsfuncs.h
  2. 6 0
      tsfuncs_eit.c
  3. 21 0
      tsfuncs_nit.c
  4. 21 0
      tsfuncs_sdt.c
  5. 21 0
      tsfuncs_tdt.c

+ 11 - 0
tsfuncs.h View File

@@ -162,6 +162,9 @@ int				ts_nit_add_frequency_list_descriptor_cable	(struct ts_nit *nit, uint16_t
162 162
 int				ts_nit_add_cable_delivery_descriptor		(struct ts_nit *nit, uint16_t ts_id, uint16_t org_net_id, uint32_t freq, uint8_t modulation, uint32_t symbol_rate);
163 163
 int				ts_nit_add_service_list_descriptor			(struct ts_nit *nit, uint16_t ts_id, uint16_t org_net_id, uint32_t *services, uint8_t num_services);
164 164
 
165
+struct ts_nit *	ts_nit_copy			(struct ts_nit *nit);
166
+int				ts_nit_is_same		(struct ts_nit *nit1, struct ts_nit *nit2);
167
+
165 168
 // SDT
166 169
 struct ts_sdt *	ts_sdt_alloc		();
167 170
 struct ts_sdt * ts_sdt_alloc_init	(uint16_t org_network_id, uint16_t transport_stream_id);
@@ -174,6 +177,9 @@ void			ts_sdt_generate		(struct ts_sdt *sdt, uint8_t **ts_packets, int *num_pack
174 177
 
175 178
 int             ts_sdt_add_service_descriptor(struct ts_sdt *sdt, uint16_t service_id, uint8_t video, char *provider_name, char *service_name);
176 179
 
180
+struct ts_sdt *	ts_sdt_copy			(struct ts_sdt *sdt);
181
+int				ts_sdt_is_same		(struct ts_sdt *sdt1, struct ts_sdt *sdt2);
182
+
177 183
 // EIT
178 184
 struct ts_eit * ts_eit_alloc				();
179 185
 struct ts_eit *	ts_eit_alloc_init			(uint16_t service_id, uint16_t transport_stream_id, uint16_t org_network_id, uint8_t table_id, uint8_t sec_number, uint8_t last_sec_number);
@@ -194,6 +200,8 @@ void			ts_eit_regenerate_packets	(struct ts_eit *eit);
194 200
 int				ts_eit_add_short_event_descriptor	(struct ts_eit *eit, uint16_t event_id, uint8_t running, time_t start_time, int duration_sec, char *event_name, char *event_short_descr);
195 201
 int				ts_eit_add_extended_event_descriptor(struct ts_eit *eit, uint16_t event_id, uint8_t running, time_t start_time, int duration_sec, char *text);
196 202
 
203
+int				ts_eit_is_same		(struct ts_eit *eit1, struct ts_eit *eit2);
204
+
197 205
 // TDT
198 206
 struct ts_tdt *	ts_tdt_alloc();
199 207
 struct ts_tdt *	ts_tdt_alloc_init	(time_t ts);
@@ -211,6 +219,9 @@ void			ts_tdt_set_time		(struct ts_tdt *tdt, time_t ts);
211 219
 void			ts_tot_set_localtime_offset			(struct ts_tdt *tdt, time_t now, time_t change_time, uint8_t polarity, uint16_t ofs, uint16_t ofs_next);
212 220
 void			ts_tot_set_localtime_offset_sofia	(struct ts_tdt *tdt, time_t now);
213 221
 
222
+struct ts_tdt *	ts_tdt_copy			(struct ts_tdt *tdt);
223
+int				ts_tdt_is_same		(struct ts_tdt *tdt1, struct ts_tdt *tdt2);
224
+
214 225
 // Private section
215 226
 struct ts_privsec *	ts_privsec_alloc();
216 227
 void				ts_privsec_clear		(struct ts_privsec *pprivsec);

+ 6 - 0
tsfuncs_eit.c View File

@@ -297,3 +297,9 @@ void ts_eit_dump(struct ts_eit *eit) {
297 297
 
298 298
 	ts_eit_check_generator(eit);
299 299
 }
300
+
301
+int ts_eit_is_same(struct ts_eit *eit1, struct ts_eit *eit2) {
302
+	if (eit1 == eit2) return 1; // Same
303
+	if ((!eit1 && eit2) || (eit1 && !eit2)) return 0; // Not same (one is NULL)
304
+	return ts_section_is_same(eit1->section_header, eit2->section_header);
305
+}

+ 21 - 0
tsfuncs_nit.c View File

@@ -211,6 +211,21 @@ void ts_nit_generate(struct ts_nit *nit, uint8_t **ts_packets, int *num_packets)
211 211
 	FREE(secdata);
212 212
 }
213 213
 
214
+struct ts_nit *ts_nit_copy(struct ts_nit *nit) {
215
+	struct ts_nit *newnit = ts_nit_alloc();
216
+	int i;
217
+	for (i=0;i<nit->section_header->num_packets; i++) {
218
+		newnit = ts_nit_push_packet(newnit, nit->section_header->packet_data + (i * TS_PACKET_SIZE));
219
+	}
220
+	if (newnit->initialized) {
221
+		return newnit;
222
+	} else {
223
+		ts_LOGf("Error copying nit!\n");
224
+		ts_nit_free(&newnit);
225
+		return NULL;
226
+	}
227
+}
228
+
214 229
 void ts_nit_check_generator(struct ts_nit *nit) {
215 230
 	struct ts_nit *nit1 = ts_nit_alloc();
216 231
 	int i;
@@ -268,3 +283,9 @@ void ts_nit_dump(struct ts_nit *nit) {
268 283
 
269 284
 	ts_nit_check_generator(nit);
270 285
 }
286
+
287
+int ts_nit_is_same(struct ts_nit *nit1, struct ts_nit *nit2) {
288
+	if (nit1 == nit2) return 1; // Same
289
+	if ((!nit1 && nit2) || (nit1 && !nit2)) return 0; // Not same (one is NULL)
290
+	return ts_section_is_same(nit1->section_header, nit2->section_header);
291
+}

+ 21 - 0
tsfuncs_sdt.c View File

@@ -187,6 +187,21 @@ void ts_sdt_generate(struct ts_sdt *sdt, uint8_t **ts_packets, int *num_packets)
187 187
     FREE(secdata);
188 188
 }
189 189
 
190
+struct ts_sdt *ts_sdt_copy(struct ts_sdt *sdt) {
191
+	struct ts_sdt *newsdt = ts_sdt_alloc();
192
+	int i;
193
+	for (i=0;i<sdt->section_header->num_packets; i++) {
194
+		newsdt = ts_sdt_push_packet(newsdt, sdt->section_header->packet_data + (i * TS_PACKET_SIZE));
195
+	}
196
+	if (newsdt->initialized) {
197
+		return newsdt;
198
+	} else {
199
+		ts_LOGf("Error copying sdt!\n");
200
+		ts_sdt_free(&newsdt);
201
+		return NULL;
202
+	}
203
+}
204
+
190 205
 void ts_sdt_check_generator(struct ts_sdt *sdt) {
191 206
 	struct ts_sdt *sdt1 = ts_sdt_alloc();
192 207
 	int i;
@@ -239,3 +254,9 @@ void ts_sdt_dump(struct ts_sdt *sdt) {
239 254
 
240 255
 	ts_sdt_check_generator(sdt);
241 256
 }
257
+
258
+int ts_sdt_is_same(struct ts_sdt *sdt1, struct ts_sdt *sdt2) {
259
+	if (sdt1 == sdt2) return 1; // Same
260
+	if ((!sdt1 && sdt2) || (sdt1 && !sdt2)) return 0; // Not same (one is NULL)
261
+	return ts_section_is_same(sdt1->section_header, sdt2->section_header);
262
+}

+ 21 - 0
tsfuncs_tdt.c View File

@@ -144,6 +144,21 @@ void ts_tdt_generate(struct ts_tdt *tdt, uint8_t **ts_packets, int *num_packets)
144 144
     FREE(secdata);
145 145
 }
146 146
 
147
+struct ts_tdt *ts_tdt_copy(struct ts_tdt *tdt) {
148
+	struct ts_tdt *newtdt = ts_tdt_alloc();
149
+	int i;
150
+	for (i=0;i<tdt->section_header->num_packets; i++) {
151
+		newtdt = ts_tdt_push_packet(newtdt, tdt->section_header->packet_data + (i * TS_PACKET_SIZE));
152
+	}
153
+	if (newtdt->initialized) {
154
+		return newtdt;
155
+	} else {
156
+		ts_LOGf("Error copying tdt!\n");
157
+		ts_tdt_free(&newtdt);
158
+		return NULL;
159
+	}
160
+}
161
+
147 162
 void ts_tdt_check_generator(struct ts_tdt *tdt) {
148 163
 	struct ts_tdt *tdt1 = ts_tdt_alloc();
149 164
 	int i;
@@ -206,3 +221,9 @@ void ts_tdt_dump(struct ts_tdt *tdt) {
206 221
 
207 222
 	ts_tdt_check_generator(tdt);
208 223
 }
224
+
225
+int ts_tdt_is_same(struct ts_tdt *tdt1, struct ts_tdt *tdt2) {
226
+	if (tdt1 == tdt2) return 1; // Same
227
+	if ((!tdt1 && tdt2) || (tdt1 && !tdt2)) return 0; // Not same (one is NULL)
228
+	return ts_section_is_same(tdt1->section_header, tdt2->section_header);
229
+}