From f5172da82b674d1d497acbda182d9e4ff5289855 Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Sun, 7 Jan 2024 08:57:17 +0100 Subject: [PATCH] Generate libmatroska v1.x semantic separately As 2.0 evolves we can't keep the same generated code on both sides. Especially as the class names will change for https://github.com/Matroska-Org/libmatroska/issues/137 --- .../workflows/libmatroska-semantic_1x.yaml | 46 ++ README.md | 1 + spectool/schema_2_kaxsemantic_cpp_1x.xsl | 498 ++++++++++++++++ spectool/schema_2_kaxsemantic_h_1x.xsl | 556 ++++++++++++++++++ 4 files changed, 1101 insertions(+) create mode 100644 .github/workflows/libmatroska-semantic_1x.yaml create mode 100644 spectool/schema_2_kaxsemantic_cpp_1x.xsl create mode 100644 spectool/schema_2_kaxsemantic_h_1x.xsl diff --git a/.github/workflows/libmatroska-semantic_1x.yaml b/.github/workflows/libmatroska-semantic_1x.yaml new file mode 100644 index 00000000..b7c5701a --- /dev/null +++ b/.github/workflows/libmatroska-semantic_1x.yaml @@ -0,0 +1,46 @@ +name: "libmatroska v1.x Semantic" +on: + push: + branches: [ master ] + pull_request: + # branches: [ master ] + schedule: + - cron: '44 16 * * 6' + +jobs: + xlst_generators: + name: Generate code from EBML Schema + runs-on: ubuntu-latest + steps: + - name: Get pushed code + uses: actions/checkout@v3 + + - name: Get EBML Schema + run: curl -o ebml_matroska.xml https://raw.githubusercontent.com/ietf-wg-cellar/matroska-specification/master/ebml_matroska.xml + + - name: Setup test tools + # we need the apt update because old packages won't load + run: | + sudo apt update + sudo apt install xsltproc + + - name: Generate code + run: | + xsltproc -o _build/src/KaxSemantic.cpp spectool/schema_2_kaxsemantic_cpp_1x.xsl ebml_matroska.xml + xsltproc -o _build/matroska/KaxSemantic.h spectool/schema_2_kaxsemantic_h_1x.xsl ebml_matroska.xml + + - name: Get current libmatroska v1.x code + run: | + curl -o KaxSemantic.cpp https://raw.githubusercontent.com/Matroska-Org/libmatroska/v1.x/src/KaxSemantic.cpp + curl -o KaxSemantic.h https://raw.githubusercontent.com/Matroska-Org/libmatroska/v1.x/matroska/KaxSemantic.h + + - name: Generate libmatroska v1.x artifacts + uses: actions/upload-artifact@v3 + with: + name: libmatroska-semantic + path: _build + + - name: Verify libmatroska semantic + run: | + diff -pur _build/matroska/KaxSemantic.h KaxSemantic.h || exit 1 + diff -pur _build/src/KaxSemantic.cpp KaxSemantic.cpp || exit 1 diff --git a/README.md b/README.md index 6e063a5b..2e9d8507 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ [![binaries](https://github.com/Matroska-Org/foundation-source/actions/workflows/generate-tools-bin.yaml/badge.svg)](https://github.com/Matroska-Org/foundation-source/actions/workflows/generate-tools-bin.yaml) [![libmatroska2 code](https://github.com/Matroska-Org/foundation-source/actions/workflows/libmatroska2-semantic.yaml/badge.svg)](https://github.com/Matroska-Org/foundation-source/actions/workflows/libmatroska2-semantic.yaml) [![libmatroska code](https://github.com/Matroska-Org/foundation-source/actions/workflows/libmatroska-semantic.yaml/badge.svg)](https://github.com/Matroska-Org/foundation-source/actions/workflows/libmatroska-semantic.yaml) +[![libmatroska v1.x code](https://github.com/Matroska-Org/foundation-source/actions/workflows/libmatroska-semantic_1x.yaml/badge.svg)](https://github.com/Matroska-Org/foundation-source/actions/workflows/libmatroska-semantic_1x.yaml) libEBML2, libMatroska2, mkvalidator, mkclean and the specifications diff --git a/spectool/schema_2_kaxsemantic_cpp_1x.xsl b/spectool/schema_2_kaxsemantic_cpp_1x.xsl new file mode 100644 index 00000000..61d698b1 --- /dev/null +++ b/spectool/schema_2_kaxsemantic_cpp_1x.xsl @@ -0,0 +1,498 @@ + + + + + /********************************************************************** +** DO NOT EDIT, GENERATED WITH schema_2_kaxsemantic_cpp.xsl +** https://github.com/Matroska-Org/foundation-source/tree/master/spectool +** +** libmatroska : parse Matroska files, see https://www.matroska.org/ +** +** Copyright (c) 2002-2020, Matroska (non-profit organisation) +** All rights reserved. +** +** This file is part of libmatroska. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License as published by the Free Software Foundation; either +** version 2.1 of the License, or (at your option) any later version. +** +** This library is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public +** License along with this library; if not, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +** +** See http://www.gnu.org/licenses/lgpl-2.1.html for LGPL licensing information.** +** Contact license@matroska.org if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include "matroska/KaxContexts.h" +#include "matroska/KaxSemantic.h" +#include "matroska/KaxSegment.h" +#include "matroska/KaxSeekHead.h" +#include "matroska/KaxCluster.h" +#include "matroska/KaxTracks.h" +#include "matroska/KaxCues.h" +#include "matroska/KaxInfoData.h" +#include "matroska/KaxBlockData.h" +#include "matroska/KaxCuesData.h" + +namespace libmatroska { + + + + + + + + + + + + + + + + + +} // namespace libmatroska + + + + + + + + + + + + + + DEFINE_START_SEMANTIC(Kax + + + + + ) + + + + + + + + + + + + + + + + + + + DEFINE_END_SEMANTIC(Kax + + + + + ) + + DEFINE_MKX_MASTER + _ORPHAN + + _CONS + (Kax + + + + + , + , + + + + + , Kax + + + + + + + + + ) + + + + + DEFINE_MKX_BINARY + + + _CONS + + + (Kax + + + + + , + , + + , Kax + + + + + + + ) + + + + + DEFINE_MKX_UINTEGER + _DEF + (Kax + + + + + , + , + + , Kax + + + + + + + , + ) + + + + + DEFINE_MKX_SINTEGER + _DEF + + _CONS + (Kax + + + + + , + , + + , Kax + + + + + + + , + ) + + + + + DEFINE_MKX_UNISTRING + _DEF + (Kax + + + + + , + , + + , Kax + + + + + + + , "" + ) + + + + + DEFINE_MKX_STRING + _DEF + (Kax + + + + + , + , + + , Kax + + + + + + + , "" + ) + + + + + DEFINE_MKX_FLOAT + _DEF + (Kax + + + + + , + , + + , Kax + + + + + + + + + , 1 + , 0 + , 8000 + , > + + + ) + + + + DEFINE_MKX_DATE + + _DEF + + + (Kax + + + + + , + , + + , Kax + + + + + + + , + ) + + + + + + + + + + + + + + + + + + + + + + DEFINE_SEMANTIC_ITEM( + + false + true + false + + , + + false + true + false + + , Kax + + + + + ) + // recursive + + + // DivX specific + // not supported + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + filepos_t Kax + + + + + ::RenderData(IOCallback & /* output */, bool /* bForceRender */, bool /* bSaveDefault */) { + assert(false); // no you are not allowed to use this element ! + return 0; + } + + + + + + + + + + + + + + + + + + + + + + + + + + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + + + + + + + + + , " + + + + FileMimeType + SeekHeader + SeekPoint + + FlagReferenced + + + + " + + + + + + + +
diff --git a/spectool/schema_2_kaxsemantic_h_1x.xsl b/spectool/schema_2_kaxsemantic_h_1x.xsl new file mode 100644 index 00000000..9440ec01 --- /dev/null +++ b/spectool/schema_2_kaxsemantic_h_1x.xsl @@ -0,0 +1,556 @@ + + + + + /********************************************************************** +** DO NOT EDIT, GENERATED WITH DATA2LIB +** https://github.com/Matroska-Org/foundation-source/tree/master/spectool +** +** libmatroska : parse Matroska files, see https://www.matroska.org/ +** +** Copyright (c) 2002-2022, Matroska (non-profit organisation) +** All rights reserved. +** +** This file is part of libmatroska. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License as published by the Free Software Foundation; either +** version 2.1 of the License, or (at your option) any later version. +** +** This library is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** Lesser General Public License for more details. +** +** You should have received a copy of the GNU Lesser General Public +** License along with this library; if not, write to the Free Software +** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +** +** See http://www.gnu.org/licenses/lgpl-2.1.html for LGPL licensing information.** +** Contact license@matroska.org if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + + +#ifndef LIBMATROSKA_SEMANTIC_H +#define LIBMATROSKA_SEMANTIC_H + +#include "matroska/KaxTypes.h" +#include <ebml/EbmlUInteger.h> +#include <ebml/EbmlSInteger.h> +#include <ebml/EbmlDate.h> +#include <ebml/EbmlFloat.h> +#include <ebml/EbmlString.h> +#include <ebml/EbmlUnicodeString.h> +#include <ebml/EbmlBinary.h> +#include <ebml/EbmlMaster.h> +#include "matroska/KaxDefines.h" + +using namespace libebml; + +namespace libmatroska { + + + + + + + + + + + + +} // namespace libmatroska + +#endif // LIBMATROSKA_SEMANTIC_H + + + + + + + + + + + + + + + + DECLARE_MKX_MASTER(Kax + + + DECLARE_MKX_BINARY (Kax + + + DECLARE_MKX_UINTEGER(Kax + + + DECLARE_MKX_SINTEGER(Kax + + + DECLARE_MKX_UNISTRING(Kax + + + DECLARE_MKX_STRING(Kax + + + DECLARE_MKX_FLOAT(Kax + + + DECLARE_MKX_DATE (Kax + + + + + + + ) + + #if defined(HAVE_EBML2) || defined(HAS_EBML2) + public: + KaxSegmentUID(EBML_DEF_CONS EBML_DEF_SEP EBML_EXTRA_PARAM); + #endif + + + public: + + + filepos_t RenderData(IOCallback & output, bool bForceRender, bool bSaveDefault) override; + + + bool ValidateSize() const override {return IsFiniteSize() && GetSize() + + + == + + ;} + + }; + + + + + + + + + + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + 2 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A + B + C + D + E + F + A + + + + + + + + + 0x + + + + + + + + + + TRACK_ENCODING_COMP + TRACK_TYPE + + VIDEO_STEREO + DISPLAY_UNIT + TRANSFER + TARGET_TYPE + + VIDEO_ + + + + + + 17 + + + + + + + + + + + + /** * + + */ + typedef enum { + + + + + MATROSKA__NONE + + = -1, + + + + + MATROSKA_ + + _ + + + + + + = + + + + + + + + + + + , // + + + + + + + , + + + + + + + + + + + + + } Matroska + + TrackEncodingCompAlgo + ColourChromaSitingHorz + ColourChromaSitingVert + ChapterProcessTime + ContentSignatureAlgo + ContentEncodingAlgo + + + Video + Audio + + + ; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + +