[vlc-devel] commit: decomp: add support for xz compressed streams (LZMA) ( Rémi Denis-Courmont )

git version control git at videolan.org
Tue Dec 1 20:26:08 CET 2009


vlc | branch: 1.0-bugfix | Rémi Denis-Courmont <remi at remlab.net> | Thu Nov 19 19:29:40 2009 +0200| [4c86512456d56d84d1f74c4cd72e19757d26434f] | committer: Rémi Denis-Courmont 

decomp: add support for xz compressed streams (LZMA)

(cherry picked from commit 25c5aee0ba1cddd7683eb2fbcb7471548e3b861c)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4c86512456d56d84d1f74c4cd72e19757d26434f
---

 modules/stream_filter/decomp.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/modules/stream_filter/decomp.c b/modules/stream_filter/decomp.c
index 5171ea7..fc6b444 100644
--- a/modules/stream_filter/decomp.c
+++ b/modules/stream_filter/decomp.c
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * decomp.c : Decompression module for vlc
  *****************************************************************************
- * Copyright © 2008 Rémi Denis-Courmont
+ * Copyright © 2008-2009 Rémi Denis-Courmont
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published by
@@ -46,6 +46,7 @@
 
 static int  OpenGzip (vlc_object_t *);
 static int  OpenBzip2 (vlc_object_t *);
+static int  OpenXZ (vlc_object_t *);
 static void Close (vlc_object_t *);
 
 vlc_module_begin ()
@@ -53,6 +54,9 @@ vlc_module_begin ()
     set_category (CAT_INPUT)
     set_subcategory (SUBCAT_INPUT_STREAM_FILTER)
     set_capability ("stream_filter", 20)
+    set_callbacks (OpenXZ, Close)
+
+    add_submodule ()
     set_callbacks (OpenBzip2, Close)
     /* TODO: access shortnames for stream_UrlNew() */
 
@@ -407,3 +411,21 @@ static int OpenBzip2 (vlc_object_t *obj)
     return Open (stream, "bzcat");
 }
 
+/**
+ * Detects xz file format
+ */
+static int OpenXZ (vlc_object_t *obj)
+{
+    stream_t      *stream = (stream_t *)obj;
+    const uint8_t *peek;
+
+    /* (Try to) parse the xz stream header */
+    if (stream_Peek (stream->p_source, &peek, 8) < 8)
+        return VLC_EGENERIC;
+
+    if (memcmp (peek, "\xfd\x37\x7a\x58\x5a", 6))
+        return VLC_EGENERIC;
+
+    msg_Dbg (obj, "detected xz compressed stream");
+    return Open (stream, "xzcat");
+}




More information about the vlc-devel mailing list