From d9089f824f3fe0e2ba31f68f78d7de40de139b63 Mon Sep 17 00:00:00 2001
From: Andreas Romeyke <andreas.romeyke@slub-dresden.de>
Date: Fri, 24 Feb 2017 14:11:35 +0100
Subject: [PATCH] - added rule to express that either a stream should not exist
 or exist with given properties to all film-profiles

---
 HINTS                                         | 22 +++++++++-----
 ...iaconch_policy_retrodigitized_film16mm.xml | 29 ++++++++++---------
 ...iaconch_policy_retrodigitized_film35mm.xml |  3 ++
 ...diaconch_policy_retrodigitized_film8mm.xml | 29 ++++++++++---------
 4 files changed, 49 insertions(+), 34 deletions(-)

diff --git a/HINTS b/HINTS
index 1c95cb1..9749ef4 100644
--- a/HINTS
+++ b/HINTS
@@ -1,24 +1,29 @@
 the policy format of mediaconch is not well documented yet, here some observations
 (date: 2017-02-20)
 
-- within the policy-xml there are no XML-comments allowed
+- within the policy-xml there are no XML-comments allowed 
+  (will be fixed in upcoming mediaconch version)
+
 - tag <description /> is only allowed on top level, otherwise it will be
-interpreted as a rule with value "true". This could affect the result if next
-real rule fails. Example:
+  interpreted as a rule with value "true". This could affect the result if next
+  real rule fails. Example:
   <policy type="or" name="foo">
     <description>foo</description>
     <rule name="bar" value="baz" tracktype="General" occurrence="*" operator="=">1</rule>
   </policy>
-will always "true", also if <rule name="bar" .. /> fails.
-- there is no way to express an "optional depends". This means you can't
-  express a rule like "Either Audio or not, but if Audio it must be a FLAC"
-
+  will always "true", also if <rule name="bar" .. /> fails.
 
+- to express that either a stream should not exist or exist with given properties, try this:
+  <policy type="or" name="Audio">
+    <rule name="Audio does not exist" value="Default" tracktype="Audio" occurrence="*" operator="must not exist"/>
+    <policy type="or" name="Audio exist">
+      ... <!-- here to check given audio properties -->
+    </policy>
+  </policy>
 
 Expected video-sizes:
 - a good source about videosizes could be https://de.wikipedia.org/wiki/Digital_Intermediate
 
-
 Preservation policy for video material of SLUB:
 - there is no policy offically released yet, please be patient… :)
 
@@ -26,3 +31,4 @@ Howto check files against policy:
 - you need an installed mediaconch
 - on Bash call:
   $> mediaconch --Policy=SLUB_mediaconch_policy_retrodigitized_film35mm.xml -fh file-to-test.mkv > report.html
+
diff --git a/SLUB_mediaconch_policy_retrodigitized_film16mm.xml b/SLUB_mediaconch_policy_retrodigitized_film16mm.xml
index 272cf0f..c09355f 100644
--- a/SLUB_mediaconch_policy_retrodigitized_film16mm.xml
+++ b/SLUB_mediaconch_policy_retrodigitized_film16mm.xml
@@ -42,19 +42,22 @@
     </policy>
     
     <policy type="or" name="Audio">
-      <rule name="General/AudioCount is 1" value="AudioCount" tracktype="General" occurrence="*" operator="=">1</rule>
-      <policy type="or" name="Audio is PCM or FLAC">
-        <rule name="Audio is PCM" value="Format" tracktype="Audio" occurrence="*" operator="=">PCM</rule>
-        <rule name="Audio is FLAC" value="Format" tracktype="Audio" occurrence="*" operator="=">FLAC</rule>
-      </policy>
-      <rule name="Audio is 48000 Hz?" value="SamplingRate" tracktype="Audio" occurrence="*" operator="=">48000</rule>
-      <policy type="or" name="Audio is Stereo or Mono?">
-        <rule name="Audio is mono?" value="Channels" tracktype="Audio" occurrence="*" operator="=">1</rule>
-        <rule name="Audio is stereo?" value="Channels" tracktype="Audio" occurrence="*" operator="=">2</rule>
-      </policy>
-      <policy type="or" name="Audio Bit Depth is 16 or 24?">
-        <rule name="Bit Depth is 16?" value="BitDepth" tracktype="Audio" occurrence="*" operator="=">16</rule>
-        <rule name="Bit Depth is 24?" value="BitDepth" tracktype="Audio" occurrence="*" operator="=">24</rule>
+      <rule name="Audio does not exist" value="Default" tracktype="Audio" occurrence="*" operator="must not exist"/>
+      <policy type="or" name="Audio exist">
+        <rule name="General/AudioCount is 1" value="AudioCount" tracktype="General" occurrence="*" operator="=">1</rule>
+        <policy type="or" name="Audio is PCM or FLAC">
+          <rule name="Audio is PCM" value="Format" tracktype="Audio" occurrence="*" operator="=">PCM</rule>
+          <rule name="Audio is FLAC" value="Format" tracktype="Audio" occurrence="*" operator="=">FLAC</rule>
+        </policy>
+        <rule name="Audio is 48000 Hz?" value="SamplingRate" tracktype="Audio" occurrence="*" operator="=">48000</rule>
+        <policy type="or" name="Audio is Stereo or Mono?">
+          <rule name="Audio is mono?" value="Channels" tracktype="Audio" occurrence="*" operator="=">1</rule>
+          <rule name="Audio is stereo?" value="Channels" tracktype="Audio" occurrence="*" operator="=">2</rule>
+        </policy>
+        <policy type="or" name="Audio Bit Depth is 16 or 24?">
+          <rule name="Bit Depth is 16?" value="BitDepth" tracktype="Audio" occurrence="*" operator="=">16</rule>
+          <rule name="Bit Depth is 24?" value="BitDepth" tracktype="Audio" occurrence="*" operator="=">24</rule>
+        </policy>
       </policy>
     </policy>
   </policy>
diff --git a/SLUB_mediaconch_policy_retrodigitized_film35mm.xml b/SLUB_mediaconch_policy_retrodigitized_film35mm.xml
index 54fdde8..1e9b841 100644
--- a/SLUB_mediaconch_policy_retrodigitized_film35mm.xml
+++ b/SLUB_mediaconch_policy_retrodigitized_film35mm.xml
@@ -49,6 +49,8 @@
     </policy>
     
     <policy type="or" name="Audio">
+      <rule name="Audio does not exist" value="Default" tracktype="Audio" occurrence="*" operator="must not exist"/>
+      <policy type="or" name="Audio exist">
         <rule name="General/AudioCount is 1" value="AudioCount" tracktype="General" occurrence="*" operator="=">1</rule>
         <policy type="or" name="Audio is PCM or FLAC">
           <rule name="Audio is PCM" value="Format" tracktype="Audio" occurrence="*" operator="=">PCM</rule>
@@ -63,6 +65,7 @@
           <rule name="Bit Depth is 16?" value="BitDepth" tracktype="Audio" occurrence="*" operator="=">16</rule>
           <rule name="Bit Depth is 24?" value="BitDepth" tracktype="Audio" occurrence="*" operator="=">24</rule>
         </policy>
+      </policy>
     </policy>
   </policy>
 </policy>
diff --git a/SLUB_mediaconch_policy_retrodigitized_film8mm.xml b/SLUB_mediaconch_policy_retrodigitized_film8mm.xml
index a557a1c..cce0d94 100644
--- a/SLUB_mediaconch_policy_retrodigitized_film8mm.xml
+++ b/SLUB_mediaconch_policy_retrodigitized_film8mm.xml
@@ -49,19 +49,22 @@
     </policy>
 
     <policy type="or" name="Audio">
-      <rule name="General/AudioCount is 1" value="AudioCount" tracktype="General" occurrence="*" operator="=">1</rule>
-      <policy type="or" name="Audio is PCM or FLAC">
-        <rule name="Audio is PCM" value="Format" tracktype="Audio" occurrence="*" operator="=">PCM</rule>
-        <rule name="Audio is FLAC" value="Format" tracktype="Audio" occurrence="*" operator="=">FLAC</rule>
-      </policy>
-      <rule name="Audio is 48000 Hz?" value="SamplingRate" tracktype="Audio" occurrence="*" operator="=">48000</rule>
-      <policy type="or" name="Audio is Stereo or Mono?">
-        <rule name="Audio is mono?" value="Channels" tracktype="Audio" occurrence="*" operator="=">1</rule>
-        <rule name="Audio is stereo?" value="Channels" tracktype="Audio" occurrence="*" operator="=">2</rule>
-      </policy>
-      <policy type="or" name="Audio Bit Depth is 16 or 24?">
-        <rule name="Bit Depth is 16?" value="BitDepth" tracktype="Audio" occurrence="*" operator="=">16</rule>
-        <rule name="Bit Depth is 24?" value="BitDepth" tracktype="Audio" occurrence="*" operator="=">24</rule>
+      <rule name="Audio does not exist" value="Default" tracktype="Audio" occurrence="*" operator="must not exist"/>
+      <policy type="or" name="Audio exist">
+        <rule name="General/AudioCount is 1" value="AudioCount" tracktype="General" occurrence="*" operator="=">1</rule>
+        <policy type="or" name="Audio is PCM or FLAC">
+          <rule name="Audio is PCM" value="Format" tracktype="Audio" occurrence="*" operator="=">PCM</rule>
+          <rule name="Audio is FLAC" value="Format" tracktype="Audio" occurrence="*" operator="=">FLAC</rule>
+        </policy>
+        <rule name="Audio is 48000 Hz?" value="SamplingRate" tracktype="Audio" occurrence="*" operator="=">48000</rule>
+        <policy type="or" name="Audio is Stereo or Mono?">
+          <rule name="Audio is mono?" value="Channels" tracktype="Audio" occurrence="*" operator="=">1</rule>
+          <rule name="Audio is stereo?" value="Channels" tracktype="Audio" occurrence="*" operator="=">2</rule>
+        </policy>
+        <policy type="or" name="Audio Bit Depth is 16 or 24?">
+          <rule name="Bit Depth is 16?" value="BitDepth" tracktype="Audio" occurrence="*" operator="=">16</rule>
+          <rule name="Bit Depth is 24?" value="BitDepth" tracktype="Audio" occurrence="*" operator="=">24</rule>
+        </policy>
       </policy>
     </policy>
   </policy>
-- 
GitLab