Update of /cvsroot/xine/xine-lib/src/demuxers
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv9947

Modified Files:
        demux_aac.c demux_mpgaudio.c id3.c id3.h 
Log Message:
Add a function to parse a generic ID3v2 tag, and make both demux_aac and 
demux_mpgaudio use it without repeating the same code.

Index: demux_aac.c
===================================================================
RCS file: /cvsroot/xine/xine-lib/src/demuxers/demux_aac.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- demux_aac.c 3 Mar 2007 00:33:51 -0000       1.15
+++ demux_aac.c 3 Mar 2007 00:58:52 -0000       1.16
@@ -37,9 +37,9 @@
 
 #define LOG_MODULE "demux_aac"
 #define LOG_VERBOSE
-
+/*
 #define LOG
-
+*/
 
 #include "xine_internal.h"
 #include "xineutils.h"
@@ -88,37 +88,7 @@
 
     this->input->seek(this->input, 4, SEEK_SET);
 
-    /* Now parse the tag */
-    switch(peak[3]) {
-    case 2: /* ID3v2.2 */
-      xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
-             LOG_MODULE ": ID3V2.2 tag\n");
-      if ( ! id3v22_parse_tag(this->input, this->stream, peak) )
-       xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
-               LOG_MODULE ": ID3V2.2 tag parsing error\n");
-       return 0;
-      break;
-
-    case 3: /* ID3v2.3 */
-      xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
-             LOG_MODULE ": ID3V2.3 tag\n");
-      if ( ! id3v23_parse_tag(this->input, this->stream, peak) )
-       xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
-               LOG_MODULE ": ID3V2.3 tag parsing error\n");
-      break;
-
-    case 4: /* ID3v2.4 */
-      xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
-             LOG_MODULE ": ID3V2.4 tag\n");
-      if ( ! id3v24_parse_tag(this->input, this->stream, peak) )
-       xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
-               LOG_MODULE ": ID3V2.4 tag parsing error\n");
-      break;
-
-    default:
-      xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
-             LOG_MODULE ": Unknown ID3v2 version: 0x%02x.\n", peak[3]);
-    }
+    id3v2_parse_tag(this->input, this->stream, peak);
 
     lprintf("ID3v2 tag encountered, skipping %u bytes.\n", id3size);
   }

Index: demux_mpgaudio.c
===================================================================
RCS file: /cvsroot/xine/xine-lib/src/demuxers/demux_mpgaudio.c,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -r1.149 -r1.150
--- demux_mpgaudio.c    3 Mar 2007 00:02:30 -0000       1.149
+++ demux_mpgaudio.c    3 Mar 2007 00:58:52 -0000       1.150
@@ -606,39 +606,14 @@
        
         return parse_frame_payload(this, header_buf, decoder_flags);
         
-      } else if ((BE_32(header_buf)) == ID3V22_TAG) {
-        xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
-                LOG_MODULE ": ID3V2.2 tag\n");
-        if (!id3v22_parse_tag(this->input, this->stream, header_buf)) {
+      } else if ( header_buf[0] == 'I' && header_buf[1] == 'D' && 
header_buf[2] == '3' ) {
+       if (!id3v2_parse_tag(this->input, this->stream, header_buf)) {
           xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
-                  LOG_MODULE ": ID3V2.2 tag parsing error\n");
+                  LOG_MODULE ": ID3V2 tag parsing error\n");
           bytes = 1; /* resync */
         } else {
           bytes = 4;
         }
-
-      } else if ((BE_32(header_buf)) == ID3V23_TAG) {
-        xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
-                LOG_MODULE ": ID3V2.3 tag\n");
-        if (!id3v23_parse_tag(this->input, this->stream, header_buf)) {
-          xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
-                  LOG_MODULE ": ID3V2.3 tag parsing error\n");
-          bytes = 1; /* resync */
-        } else {
-          bytes = 4;
-        }
-
-      } else if ((BE_32(header_buf)) == ID3V24_TAG) {
-        xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
-                LOG_MODULE ": ID3V2.4 tag\n");
-        if (!id3v24_parse_tag(this->input, this->stream, header_buf)) {
-          xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
-                  LOG_MODULE ": ID3V2.4 tag parsing error\n");
-          bytes = 1; /* resync */
-        } else {
-          bytes = 4;
-        }
-
       } else {
         /* skip */
         bytes = 1;

Index: id3.c
===================================================================
RCS file: /cvsroot/xine/xine-lib/src/demuxers/id3.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- id3.c       5 Apr 2006 22:12:18 -0000       1.12
+++ id3.c       3 Mar 2007 00:58:52 -0000       1.13
@@ -878,3 +878,33 @@
     return 0;
   }
 }
+
+int id3v2_parse_tag(input_plugin_t *input,
+                   xine_stream_t *stream,
+                   int8_t *mp3_frame_header) {
+  _x_assert(mp3_frame_header[0] == 'I' && mp3_frame_header[1] == 'D' && 
mp3_frame_header[2] == '3');
+
+  int result = 0;
+
+  switch(mp3_frame_header[3]) {
+  case 2:
+    xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.2 tag\n");
+    result = id3v22_parse_tag(input, stream, mp3_frame_header);
+    break;
+   
+  case 3:
+    xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.3 tag\n");
+    result = id3v23_parse_tag(input, stream, mp3_frame_header);
+    break;
+
+  case 4:
+    xprintf(stream->xine, XINE_VERBOSITY_LOG, "ID3V2.3 tag\n");
+    result = id3v24_parse_tag(input, stream, mp3_frame_header);
+    break;
+
+  default:
+    xprintf(stream->xine, XINE_VERBOSITY_LOG, "Unknown ID3v2 version: 
0x%02x.\n", mp3_frame_header[3]);
+  }
+
+  return result;
+}

Index: id3.h
===================================================================
RCS file: /cvsroot/xine/xine-lib/src/demuxers/id3.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- id3.h       15 Sep 2005 18:45:15 -0000      1.4
+++ id3.h       3 Mar 2007 00:58:52 -0000       1.5
@@ -38,6 +38,7 @@
 #define ID3V24_TAG        FOURCC_TAG('I', 'D', '3', 4) /* id3 v2.4 header tag 
*/
 #define ID3V24_FOOTER_TAG FOURCC_TAG('3', 'D', 'I', 0) /* id3 v2.4 footer tag 
*/
 
+
 /*
  *  ID3 v2.2
  */
@@ -164,4 +165,9 @@
                      xine_stream_t *stream,
                      int8_t *mp3_frame_header);
 
+/* Generic function that switch between the three above */
+int id3v2_parse_tag(input_plugin_t *input,
+                   xine_stream_t *stream,
+                   int8_t *mp3_frame_header);
+
 #endif /* ID3_H */


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Xine-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xine-cvslog

Reply via email to