OSDN Git Service

modify PatPacket class in Utils
authorcocot <cocot@users.sourceforge.jp>
Sat, 21 Mar 2009 05:20:02 +0000 (14:20 +0900)
committercocot <cocot@users.sourceforge.jp>
Sat, 21 Mar 2009 05:20:02 +0000 (14:20 +0900)
src/Utils.cc
src/Utils.h

index 4ed500c..abf468c 100755 (executable)
@@ -1282,37 +1282,25 @@ void PatPacket::SetTransportStreamId(ushort value)
     RefreshCrc();
 }
 
-/*
-boost::shared_array<ProgramInfo> PatPacket::GetPrograms(void)
-{
-    boost::shared_array<ProgramInfo> programs;
-    programs.reset();
-    if (GetProgramInfoLength() == 0)
-        return programs;
-    programs = boost::shared_array<ProgramInfo>(new ProgramInfo[GetProgramInfoLength() / 4]);
-    for (int i = 0; i < GetProgramInfoLength(); i += 4)
-        programs[i / 4] = boost::shared_array<ProgramInfo>(
-            new ProgramInfo(mData, 13 + GetPointerSize() + i));
-    return programs;
-}
-
-boost::shared_array<ProgramInfo> PatPacket::GetPrograms(void)
+std::vector<boost::shared_ptr<ProgramInfo> > PatPacket::GetPrograms(void)
 {
-    boost::shared_array<ProgramInfo> programs;
-    programs.reset();
+    std::vector<boost::shared_ptr<ProgramInfo> > programs;
     if (GetProgramInfoLength() == 0)
         return programs;
-    programs = boost::shared_array<ProgramInfo>(new ProgramInfo[GetProgramInfoLength() / 4]);
+    boost::shared_ptr<ProgramInfo> program;
     for (int i = 0; i < GetProgramInfoLength(); i += 4)
-        programs[i / 4] = boost::shared_array<ProgramInfo>(
+    {
+        program = boost::shared_ptr<ProgramInfo>(
             new ProgramInfo(mData, 13 + GetPointerSize() + i));
+        programs.push_back(program);
+    }
     return programs;
 }
 
-void PatPacket::SetPrograms(boost::shared_ptr<ProgramInfo> value)
+void PatPacket::SetPrograms(std::vector<boost::shared_ptr<ProgramInfo> > value)
     throw(std::invalid_argument)
 {
-    if (NULL == value || sizeof(value.get()) == 0)
+    if (value.size() == 0)
     {
         if (GetProgramInfoLength() == 0)
             return;
@@ -1321,21 +1309,20 @@ void PatPacket::SetPrograms(boost::shared_ptr<ProgramInfo> value)
     }
     else
     {
-        if ((sizeof(value.get()) * 4) + 17 + GetPointerSize()
-            > Constants.TS_SIZE)
+        if ((value.size() * 4) + 17 + GetPointerSize()
+            > Constants::TS_SIZE)
             throw std::invalid_argument("program info data too long");
-        SetLength((ushort)(9 + (sizeof(value.get()) * 4)));
+        SetLength((ushort)(9 + value.size() * 4));
         int index = 13 + GetPointerSize();
         for(int pi = 0; pi < GetProgramInfoLength() / 4; pi++)
         {
             for (int i = 0; i < 4; i++)
-                mData[index + i] = value[pi].Data[i];
+                mData[index + i] = value[pi]->GetData()[i];
             index += 4;
         }
         RefreshCrc();
     }
 }
-*/
 
 ushort PatPacket::GetProgramInfoLength(void)
 {
index b0a9a06..ad6766c 100755 (executable)
@@ -349,8 +349,8 @@ class PatPacket : public TsTable {
   PatPacket(pByte data)throw(std::invalid_argument);
   ushort GetTransportStreamId(void);
   void SetTransportStreamId(ushort TSId);
-  boost::shared_array<ProgramInfo> GetPrograms(void);
-  void SetPrograms(boost::shared_array<ProgramInfo> programinfo)
+  std::vector<boost::shared_ptr<ProgramInfo> > GetPrograms(void);
+  void SetPrograms(std::vector<boost::shared_ptr<ProgramInfo> > programinfo)
       throw(std::invalid_argument);
   ushort GetProgramInfoLength(void);
 };