OSDN Git Service

implement DTCP_Descriptor class in Utils
authorcocot <cocot@users.sourceforge.jp>
Tue, 3 Mar 2009 12:28:09 +0000 (21:28 +0900)
committercocot <cocot@users.sourceforge.jp>
Tue, 3 Mar 2009 12:28:09 +0000 (21:28 +0900)
src/Utils.cc
src/Utils.h

index 7d55f91..836f543 100644 (file)
@@ -1298,10 +1298,37 @@ ushort PatPacket::GetProgramInfoLength(void)
     return (ushort)(GetLength() - 9);
 }
 
+DTCP_Descriptor::DTCP_Descriptor(pByte data, int startIndex)
+    throw(std::invalid_argument):Descriptor(data, startIndex)
+{
+    if (sizeof(data.get()) < 6)
+        throw std::invalid_argument("Invalid DTCP descriptor");
+    if (GetTag() != Constants::DTCP_DESCRIPTOR_TAG)
+        throw std::invalid_argument("Invalid DTCP descriptor tag");
+    if (GetLength() < 4)
+        throw std::invalid_argument("Invalid DTCP descriptor length");
+    if (data[startIndex + 2] != 0x0f || data[startIndex + 3] != 0xff)
+        throw std::invalid_argument("Invalid DTCP descriptor CA system ID");
+}
+
+DtcpCci DTCP_Descriptor::GetCopyStatus(void)
+{
+    return (DtcpCci)(mData[4] & 0x3);
+}
+
+bool DTCP_Descriptor::GetAnalogConstrain(void)
+{
+    return ((mData[5] & 0x4) == 0);
+}
+
+bool DTCP_Descriptor::GetMacrovision(void)
+{
+    return ((mData[5] & 0x3) > 0);
+}
+
 
 
 // implement class BluRayOutput
-// implement class DTCP_Descriptor : Descriptor
 // implement class SitPacket : TsTable
 // implement class PmPacket : TsTable
 // implement class H264Info : ElementaryParse
index 552a75e..87ee521 100644 (file)
@@ -178,13 +178,17 @@ class Descriptor {
   pByte GetData(void);
   byte GetTag(void);
   byte GetLength(void);
- private:
+ protected:
   pByte mData;
 };
 
-class DTCP_Descriptor : Descriptor {
+class DTCP_Descriptor : public Descriptor {
  public:
-  DTCP_Descriptor(pByte data, int startIndex);
+  DTCP_Descriptor(pByte data, int startIndex)
+    throw(std::invalid_argument);
+  DtcpCci GetCopyStatus(void);
+  bool GetAnalogConstrain(void);
+  bool GetMacrovision(void);
 };
 
 class Constants {