OSDN Git Service

implement class Descriptor in Utils
authorcocot <cocot@users.sourceforge.jp>
Tue, 24 Feb 2009 11:53:58 +0000 (20:53 +0900)
committercocot <cocot@users.sourceforge.jp>
Tue, 24 Feb 2009 11:53:58 +0000 (20:53 +0900)
src/Utils.cc
src/Utils.h

index bae5e1e..c16a3a9 100644 (file)
@@ -590,6 +590,32 @@ void TsTable::RefreshCrc(void)
 
 
 
+Descriptor::Descriptor(byte* data, int startIndex)throw(std::invalid_argument)
+{
+    if (strlen(data) < 2)
+        throw std::invalid_argument("Invalid descriptor");
+    if (startIndex + 2 + data[startIndex + 1] > strlen(data))
+        throw std::invalid_argument("Invalid descriptor");
+    mData = new byte[2 + data[startIndex + 1]];
+    for (int i = 0; i < strlen(mData); i++)
+        mData[i] = data[i + startIndex];
+}
+
+byte Descriptor::GetTag(void)
+{
+    return mData[0];
+}
+
+byte Descriptor::GetLength(void)
+{
+    return mData[1];
+}
+
+byte* Descriptor::GetData(void)
+{
+    return mData;
+}
+
 
 } // namespace
 
index 7e17b9d..9c039cb 100644 (file)
@@ -167,7 +167,12 @@ class BluRayOutput {
 
 class Descriptor {
  public:
-  Descriptor(byte* data, int startIndex);
+  Descriptor(byte* data, int startIndex)throw(std::invalid_argument);
+  byte* GetData(void);
+  byte GetTag(void);
+  byte GetLength(void);
+ private:
+  byte* mData;
 };
 
 class DTCP_Descriptor : Descriptor {