[NUT-devel] [nut]: r212 - in trunk/libnut: demuxer.c libnut.h

ods15 subversion at mplayerhq.hu
Wed Nov 15 13:04:43 CET 2006


Author: ods15
Date: Wed Nov 15 13:04:43 2006
New Revision: 212

Modified:
   trunk/libnut/demuxer.c
   trunk/libnut/libnut.h

Log:
make demuxer support mid-stream info packets via callback (even though spec disallows it right now...)


Modified: trunk/libnut/demuxer.c
==============================================================================
--- trunk/libnut/demuxer.c	(original)
+++ trunk/libnut/demuxer.c	Wed Nov 15 13:04:43 2006
@@ -345,6 +345,12 @@
 	return err;
 }
 
+static void free_info_packet(nut_context_t * nut, nut_info_packet_t * info) {
+	int i;
+	for (i = 0; i < info->count; i++) nut->alloc->free(info->fields[i].data);
+	nut->alloc->free(info->fields);
+}
+
 static int get_info_header(nut_context_t * nut, nut_info_packet_t * info) {
 	input_buffer_t itmp, * tmp = new_mem_buffer(&itmp);
 	int i, err = 0;
@@ -644,6 +650,7 @@
 }
 
 static int get_packet(nut_context_t * nut, nut_packet_t * pd, int * saw_syncpoint) {
+	nut_info_packet_t info = { 0 };
 	uint64_t tmp;
 	int err = 0, after_sync = 0, checksum = 0, flags, i;
 	off_t start;
@@ -659,13 +666,14 @@
 				CHECK(get_bytes(nut->i, 1, &tmp));
 				break;
 			case MAIN_STARTCODE:
-				do {
-					CHECK(get_header(nut->i, NULL));
-					CHECK(get_bytes(nut->i, 8, &tmp));
-				} while (tmp != SYNCPOINT_STARTCODE);
 				nut->i->buf_ptr -= 8;
+				CHECK(skip_reserved_headers(nut, SYNCPOINT_STARTCODE));
 				return 3;
-			case INFO_STARTCODE:
+			case INFO_STARTCODE: if (nut->dopts.new_info && !nut->seek_status) {
+				CHECK(get_info_header(nut, &info));
+				nut->dopts.new_info(nut->dopts.priv, &info);
+				break;
+			} // else - fall through!
 			default:
 				CHECK(get_header(nut->i, NULL));
 				return 3;
@@ -737,6 +745,7 @@
 
 	if (saw_syncpoint) *saw_syncpoint = !!after_sync;
 err_out:
+	free_info_packet(nut, &info);
 	return err;
 }
 
@@ -1401,11 +1410,7 @@
 		nut->alloc->free(nut->sc[i].sh.codec_specific);
 		nut->alloc->free(nut->sc[i].pts_cache);
 	}
-	for (i = 0; i < nut->info_count; i++) {
-		int j;
-		for (j = 0; j < nut->info[i].count; j++) nut->alloc->free(nut->info[i].fields[j].data);
-		nut->alloc->free(nut->info[i].fields);
-	}
+	for (i = 0; i < nut->info_count; i++) free_info_packet(nut, &nut->info[i]);
 
 	nut->alloc->free(nut->syncpoints.s);
 	nut->alloc->free(nut->syncpoints.pts);

Modified: trunk/libnut/libnut.h
==============================================================================
--- trunk/libnut/libnut.h	(original)
+++ trunk/libnut/libnut.h	Wed Nov 15 13:04:43 2006
@@ -113,6 +113,8 @@
 	nut_alloc_t alloc;
 	int read_index; // implies cache_syncpoints
 	int cache_syncpoints;
+	void * priv;
+	void (*new_info)(void * priv, nut_info_packet_t * info);
 } nut_demuxer_opts_t;
 
 typedef struct nut_context_s nut_context_t;



More information about the NUT-devel mailing list