Browse Source

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

Georgi Chorbadzhiyski 12 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
 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);
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
 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);
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
 // SDT
168
 // SDT
166
 struct ts_sdt *	ts_sdt_alloc		();
169
 struct ts_sdt *	ts_sdt_alloc		();
167
 struct ts_sdt * ts_sdt_alloc_init	(uint16_t org_network_id, uint16_t transport_stream_id);
170
 struct ts_sdt * ts_sdt_alloc_init	(uint16_t org_network_id, uint16_t transport_stream_id);
174
 
177
 
175
 int             ts_sdt_add_service_descriptor(struct ts_sdt *sdt, uint16_t service_id, uint8_t video, char *provider_name, char *service_name);
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
 // EIT
183
 // EIT
178
 struct ts_eit * ts_eit_alloc				();
184
 struct ts_eit * ts_eit_alloc				();
179
 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);
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
 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);
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
 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);
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
 // TDT
205
 // TDT
198
 struct ts_tdt *	ts_tdt_alloc();
206
 struct ts_tdt *	ts_tdt_alloc();
199
 struct ts_tdt *	ts_tdt_alloc_init	(time_t ts);
207
 struct ts_tdt *	ts_tdt_alloc_init	(time_t ts);
211
 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);
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
 void			ts_tot_set_localtime_offset_sofia	(struct ts_tdt *tdt, time_t now);
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
 // Private section
225
 // Private section
215
 struct ts_privsec *	ts_privsec_alloc();
226
 struct ts_privsec *	ts_privsec_alloc();
216
 void				ts_privsec_clear		(struct ts_privsec *pprivsec);
227
 void				ts_privsec_clear		(struct ts_privsec *pprivsec);

+ 6
- 0
tsfuncs_eit.c View File

297
 
297
 
298
 	ts_eit_check_generator(eit);
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
 	FREE(secdata);
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
 void ts_nit_check_generator(struct ts_nit *nit) {
229
 void ts_nit_check_generator(struct ts_nit *nit) {
215
 	struct ts_nit *nit1 = ts_nit_alloc();
230
 	struct ts_nit *nit1 = ts_nit_alloc();
216
 	int i;
231
 	int i;
268
 
283
 
269
 	ts_nit_check_generator(nit);
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
     FREE(secdata);
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
 void ts_sdt_check_generator(struct ts_sdt *sdt) {
205
 void ts_sdt_check_generator(struct ts_sdt *sdt) {
191
 	struct ts_sdt *sdt1 = ts_sdt_alloc();
206
 	struct ts_sdt *sdt1 = ts_sdt_alloc();
192
 	int i;
207
 	int i;
239
 
254
 
240
 	ts_sdt_check_generator(sdt);
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
     FREE(secdata);
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
 void ts_tdt_check_generator(struct ts_tdt *tdt) {
162
 void ts_tdt_check_generator(struct ts_tdt *tdt) {
148
 	struct ts_tdt *tdt1 = ts_tdt_alloc();
163
 	struct ts_tdt *tdt1 = ts_tdt_alloc();
149
 	int i;
164
 	int i;
206
 
221
 
207
 	ts_tdt_check_generator(tdt);
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
+}

Loading…
Cancel
Save