OSDN Git Service

replace char* to shared_array in Utils
authorcocot <cocot@users.sourceforge.jp>
Sat, 28 Feb 2009 11:31:42 +0000 (20:31 +0900)
committercocot <cocot@users.sourceforge.jp>
Sat, 28 Feb 2009 11:31:42 +0000 (20:31 +0900)
src/Utils.cc
src/Utils.h
src/tsremuxcpp_define.h

index c0d23d6..0ecaa59 100644 (file)
@@ -150,13 +150,23 @@ namespace TsRemux
         0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
         0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 };
 
-StreamInfo::StreamInfo(byte* data, int index)throw(std::invalid_argument)
+pByte Utility::ToArray(const Bytes vector)
+{
+    pByte array = pByte(new byte[vector.size()]);
+    for(int i = 0; i < vector.size(); i++)
+    {
+        array[i] = vector.at(i);
+    } 
+    return array;
+}
+
+StreamInfo::StreamInfo(pByte data, int index)throw(std::invalid_argument)
 {
     if (NULL == data) {
                 throw std::invalid_argument("stream data is NULL");
     }
 
-    if (std::strlen(data) + index < 5) {
+    if (std::strlen(data.get()) + index < 5) {
                 throw std::invalid_argument("stream data too short");
     }
 
@@ -166,13 +176,14 @@ StreamInfo::StreamInfo(byte* data, int index)throw(std::invalid_argument)
                 throw std::invalid_argument("descriptors data too long");
     }
 
-    if (5 + descLength > std::strlen(data) - index) {
+    if (5 + descLength > std::strlen(data.get()) - index) {
                 throw std::invalid_argument("stream data too short");
     }
 
-    mData = new byte[5 + descLength];
-    for (int i = 0; i < sizeof(mData); i++) {
-        mData[i] = data[i + index];
+    mData.clear();
+    for(int i = 0; i < (5 + descLength); i++)
+    { 
+        mData.push_back(data[i + index]);
     }
 
     SetVideoFormat(VF_Reserved);
@@ -234,22 +245,25 @@ void StreamInfo::SetSamplingFrequency(SamplingFrequency sampling_frequency)
 
 StreamInfo::StreamInfo(ElementaryStreamTypes streamType, ushort elementaryPid)
 {
-    mData = new byte[5];
-    StreamType = streamType;
-    ElementaryPID = elementaryPid;
+    mData.clear();
+    SetElementaryStreamTypes(streamType);
+    SetElementaryPID(elementaryPid);
     // reserved and descriptors length
-    mData[3] = 0xf0;
-    mData[4] = 0x00;
+    mData.push_back(0x00);
+    mData.push_back(0x00);
+    mData.push_back(0x00);
+    mData.push_back(0xf0);
+    mData.push_back(0x00);
 }
 
-byte* StreamInfo::GetByteData(void)
+pByte StreamInfo::GetByteData(void)
 {
-    return mData;
+    return Utility::ToArray(mData);
 }
 
 ElementaryStreamTypes StreamInfo::GetElementaryStreamTypes(void)
 {
-    return (ElementaryStreamTypes)mData[0];
+    return (ElementaryStreamTypes)mData.at(0);
 }
 
 void StreamInfo::SetElementaryStreamTypes(ElementaryStreamTypes stream_type)
@@ -258,41 +272,41 @@ void StreamInfo::SetElementaryStreamTypes(ElementaryStreamTypes stream_type)
 }
 ushort StreamInfo::GetElementaryPID(void)
 {
-    return (ushort)(((mData[1] & 0x1f) << 8) + mData[2]);
+    return (ushort)(((mData.at(1) & 0x1f) << 8) + mData.at(2));
 }
 
-void StreamInfo::GetElementaryPID(ushort pid)
+void StreamInfo::SetElementaryPID(ushort pid)
 {
     mData[1] = (byte)(((pid >> 8) & 0x1f) | 0xe0);
     mData[2] = (byte)(pid & 0xff);
 }
 
-byte* StreamInfo::GetElementaryDescriptors(void)
+pByte StreamInfo::GetElementaryDescriptors(void)
 {
-    if (std::strlen(mData) == 5) return NULL;
-    byte* descriptors = new byte[std::strlen(mData) - 5];
-    for (int i = 0; i < sizeof(descriptors); i++)
+    if(mData.size() == 5) return (pByte)NULL;
+    pByte descriptors = pByte(new byte[mData.size() - 5]);
+    for (int i = 0; i < (mData.size() - 5); i++)
     {
         descriptors[i] = mData[i + 5];
     }
     return descriptors;
 }
 
-void StreamInfo::SetElementaryDescriptors(byte* value)
+void StreamInfo::SetElementaryDescriptors(pByte value)
     throw(std::invalid_argument)
 {
     if(NULL == value || 0 == sizeof(value))
     {
-        if(std::strlen(mData) > 5)
+        if(mData.size() > 5)
         {
             // need to remove existing descriptors
-            byte* data = new byte[5];
-            data[0] = mData[0];
-            data[1] = mData[1];
-            data[2] = mData[2];
-            data[3] = 0xf0;
-            data[4] = 0x00;
-            mData = data;
+            Bytes data;
+            data.push_back(mData.at(0));
+            data.push_back(mData.at(1));
+            data.push_back(mData.at(2));
+            data.push_back(0xf0);
+            data.push_back(0x00);
+            mData.swap(data);
         }
         else
         {
@@ -302,21 +316,22 @@ void StreamInfo::SetElementaryDescriptors(byte* value)
     }
     else
     {
-        if(std::strlen(value) > 180) {
+        if(sizeof(value) > 180) {
             throw std::invalid_argument("descriptors data too long");
         }
 
-        byte* data = new byte[5 + std::strlen(value)];
-        data[0] = mData[0];
-        data[1] = mData[1];
-        data[2] = mData[2];
-        data[3] = (byte)(0xf0 | (byte)((std::strlen(value) >> 8) & 0x0f));
-        data[4] = (byte)(std::strlen(value) & 0xff);
-        for (int i = 0; i < std::strlen(value); i++)
+        Bytes data;
+        data.push_back(mData.at(0));
+        data.push_back(mData.at(1));
+        data.push_back(mData.at(2));
+        data.push_back(
+            (byte)(0xf0 | (byte)((std::strlen(value.get()) >> 8) & 0x0f)));
+        data.push_back(std::strlen(value.get()) & 0xff);
+        for (int i = 0; i < std::strlen(value.get()); i++)
         {
-            data[5 + i] = value[i];
+            data.push_back(value[i]);
         }
-        mData = data;
+        mData.swap(data);
     }
 }
 
@@ -335,7 +350,7 @@ byte ElementaryParse::GetNextBit(void)
 TsPacket::TsPacket(void)
 {
     // initialize the packet as a NULL packet
-    mData = new byte[Constants::TS_SIZE];
+    mData.clear();
     mData[0] = Constants::SYNC_BYTE; // sync byte
     mData[1] = 0x1f; // PID = 0x1FFF
     mData[2] = 0xff; // PID == 0x1FFF
@@ -380,16 +395,16 @@ byte TsPacket::GetPointerSize(void)
     return (byte)(mData[4] + 1 + mData[mData[4] + 5]);
 }
 
-byte* TsPacket::GetData(void)
+pByte TsPacket::GetData(void)
 {
-    return mData;
+    return Utility::ToArray(mData);
 }
 
-void TsPacket::SetData(byte* data, int startIndex)throw(std::invalid_argument)
+void TsPacket::SetData(pByte data, int startIndex)throw(std::invalid_argument)
 {
     if (NULL == data)
         throw std::invalid_argument("NULL packet");
-    else if (Constants::TS_SIZE > std::strlen(data) - startIndex)
+    else if (Constants::TS_SIZE > std::strlen(data.get()) - startIndex)
         throw std::invalid_argument("small packet");
     else if (Constants::SYNC_BYTE != data[0 + startIndex])
         throw std::invalid_argument("sync byte missing");
@@ -453,7 +468,7 @@ bool TsPacket::HasPesHeader(void)
     return false;
 }
 
-byte* TsPacket::Payload(void)
+pByte TsPacket::Payload(void)
 {
     int offset = 4;
     if ((mData[3] & 0x20) > 0)
@@ -461,17 +476,18 @@ byte* TsPacket::Payload(void)
         // adaptation field present
         offset += (1 + mData[4]);
         if (offset >= Constants::TS_SIZE)
-            return NULL;
+            return (pByte)NULL;
     }
     if ((mData[3] & 0x10) > 0)
     {
         // payload present
-        byte* ret = new byte[Constants::TS_SIZE - offset];
+        pByte ret = pByte(new byte[Constants::TS_SIZE - offset]);
         for (int i = 0; i < sizeof(ret); i++)
             ret[i] = mData[i + offset];
+        ret[Constants::TS_SIZE - offset] = '\0';
         return ret;
     }
-    return NULL;
+    return (pByte)NULL;
 }
 
 void TsPacket::IncrementContinuityCounter(void)
@@ -511,23 +527,22 @@ TsTable::TsTable(void)
     mData[12] = 0x0;
 }
 
-TsTable::TsTable(byte* data)
+TsTable::TsTable(pByte data)
 {
     SetData(data, 0);
 }
 
-void TsTable::AddData(byte* data, int offset, int len)
+void TsTable::AddData(pByte data, int offset, int len)
 {
-    byte* newData = NULL;
-    newData = new byte[std::strlen(mData)+(len-offset)+1];
-    std::strncpy(&newData[0], &mData[0], std::strlen(mData));
-    std::strncat(&newData[0], &data[0], (len-offset));
-    mData = &newData[0];
+    for(int i = 0; i < len; i++)
+    {
+        mData.push_back(data[offset + i]);
+    }
 }
 
 bool TsTable::Complete(void)
 {
-    int currentLen = strlen(mData) - (GetPointerSize() + 8);
+    int currentLen = mData.size() - (GetPointerSize() + 8);
     if (GetLength() > currentLen)
         return false;
     return true;
@@ -535,7 +550,7 @@ bool TsTable::Complete(void)
 
 byte TsTable::GetTableId(void)
 {
-    return mData[5 + GetPointerSize()];
+    return mData.at(5 + GetPointerSize());
 }
 
 void TsTable::SetTableId(byte value)
@@ -545,8 +560,8 @@ void TsTable::SetTableId(byte value)
 
 ushort TsTable::GetNumberId(void)
 {
-    return (ushort)((mData[8 + GetPointerSize()] << 8)
-        + mData[9 + GetPointerSize()]);
+    return (ushort)((mData.at(8 + GetPointerSize()) << 8)
+        + mData.at(9 + GetPointerSize()));
 }
 
 void TsTable::SetNumberId(ushort value)
@@ -557,8 +572,8 @@ void TsTable::SetNumberId(ushort value)
 
 ushort TsTable::GetLength(void)
 {
-    return (ushort)(((mData[6 + GetPointerSize()] & 0x0f) << 8)
-        + mData[7 + GetPointerSize()]);
+    return (ushort)(((mData.at(6 + GetPointerSize()) & 0x0f) << 8)
+        + mData.at(7 + GetPointerSize()));
 }
 
 void TsTable::SetLength(ushort value)
@@ -572,7 +587,7 @@ void TsTable::SetLength(ushort value)
 void TsTable::RefreshCrc(void)
 {
     uint crc = Constants::ComputeCrc(
-        mData, GetLength() - 1, 5 + GetPointerSize());
+        Utility::ToArray(mData), GetLength() - 1, 5 + GetPointerSize());
     mData[GetLength() + 4 + GetPointerSize()]
         = (byte)((crc >> 24) & 0xff);
     mData[GetLength() + 5 + GetPointerSize()]
@@ -587,33 +602,30 @@ void TsTable::RefreshCrc(void)
     }
 }
 
-
-
-
-Descriptor::Descriptor(byte* data, int startIndex)throw(std::invalid_argument)
+Descriptor::Descriptor(pByte data, int startIndex)throw(std::invalid_argument)
 {
-    if (strlen(data) < 2)
+    if (strlen(data.get()) < 2)
         throw std::invalid_argument("Invalid descriptor");
-    if (startIndex + 2 + data[startIndex + 1] > strlen(data))
+    if (startIndex + 2 + data[startIndex + 1] > strlen(data.get()))
         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];
+    mData.clear();
+    for (int i = 0; i < (2 + data[startIndex + 1]); i++)
+        mData.push_back(data[i + startIndex]);
 }
 
 byte Descriptor::GetTag(void)
 {
-    return mData[0];
+    return mData.at(0);
 }
 
 byte Descriptor::GetLength(void)
 {
-    return mData[1];
+    return mData.at(1);
 }
 
-byte* Descriptor::GetData(void)
+pByte Descriptor::GetData(void)
 {
-    return mData;
+    return Utility::ToArray(mData);
 }
 
 PcrPacket::PcrPacket(Int64 pcr, byte counter, ushort pid)
@@ -639,7 +651,7 @@ PcrPacket::PcrPacket(Int64 pcr, byte counter, ushort pid)
         mData[i] = 0xff;
 }
 
-PesPacket::PesPacket(byte* buff, int offset, int length, ushort pid)
+PesPacket::PesPacket(pByte buff, int offset, int length, ushort pid)
 {
     mData.assign(0,length);
     SetPID(pid);
@@ -657,20 +669,20 @@ void PesPacket::SetPriority(bool value)
     mPriority = value;
 }
 
-byte* PesPacket::GetData(void)
+pByte PesPacket::GetData(void)
 {
-    byte* buff = new byte[mData.size()+1];
+    pByte buff = pByte(new byte[mData.size()+1]);
     for(int i = 0; i < mData.size();i++)
         buff[i] = mData.at(i);
     buff[mData.size()] = '\0';
     return buff;
 }
 
-byte* PesPacket::GetPayload(void)
+pByte PesPacket::GetPayload(void)
 {
-    PesHeader* ph = GetHeader();
+    boost::shared_ptr<PesHeader> ph = GetHeader();
     if(ph == NULL) return GetData();
-    byte* buff = new byte[mData.size()-(9 + ph->HeaderLength)+1];
+    pByte buff = pByte(new byte[mData.size()-(9 + ph->HeaderLength)+1]);
     for(int i=(9 + ph->HeaderLength); i < mData.size(); i++)
         buff[i] = mData.at(i);
     buff[mData.size()-(9 + ph->HeaderLength)] = '\0';
@@ -679,7 +691,7 @@ byte* PesPacket::GetPayload(void)
 
 byte PesPacket::GetByte(int i)
 {
-    return mData[i];
+    return mData.at(i);
 }
 
 void PesPacket::SetByte(byte value)
@@ -718,23 +730,23 @@ void PesPacket::SetComplete(bool value)
     }
 }
 
-/*
-PesHeader* PesPacket::GetHeader(void)
+boost::shared_ptr<PesHeader> PesPacket::GetHeader(void)
 {
     try
     {
-        PesHeader* ph = new PesHeader(data.ToArray());
+        boost::shared_ptr<PesHeader> ph
+            = boost::shared_ptr<PesHeader>(
+            new PesHeader(Utility::ToArray(mData)));
         return ph;
     }
-    catch (...)
+    catch(...)
     {
         // no valid header (yet)
-        return NULL;
+        return (boost::shared_ptr<PesHeader>)NULL;
     }
 }
-*/
 
-void PesPacket::AddData(std::vector<byte> moredata)
+void PesPacket::AddData(pByte moredata)
 {
     for(std::vector<byte>::iterator it = mData.begin();
         it != mData.end();
@@ -744,7 +756,7 @@ void PesPacket::AddData(std::vector<byte> moredata)
     }
 }
 
-void PesPacket::AddData(byte* buff, int offset, int length)
+void PesPacket::AddData(pByte buff, int offset, int length)
 {
     for (int i = offset; i < length + offset; i++)
         mData.push_back(buff[i]);
index 6209fef..4babdca 100644 (file)
@@ -5,6 +5,7 @@
 #include <list>
 #include <vector>
 #include <stdexcept>
+#include <boost/shared_array.hpp>
 // #include "BlueMux.h"
 #include "tsremuxcpp_define.h"
 
@@ -101,9 +102,14 @@ struct EpElement {
   EpElement(signed long long pts, unsigned long spn);
 };
 
+class Utility {
+ public:
+  static pByte ToArray(Bytes vector);
+};
 class StreamInfo {
  public:
-  StreamInfo(byte* data, int index)throw(std::invalid_argument);
+  StreamInfo(pByte data, int index)throw(std::invalid_argument);
+  StreamInfo(ElementaryStreamTypes streamType, ushort elementaryPid);
   VideoFormat GetVideoFormat(void);
   void SetVideoFormat(VideoFormat videoformat);
   AspectRatio GetAspectRatio(void);
@@ -114,71 +120,70 @@ class StreamInfo {
   void SetAudioPresentationType(AudioPresentationType audioPresentationTyp);
   SamplingFrequency GetSamplingFrequency(void);
   void SetSamplingFrequency(SamplingFrequency samplingFrequency);
-  StreamInfo(ElementaryStreamTypes streamType, ushort elementaryPid);
-  byte* GetByteData(void);
   ElementaryStreamTypes GetElementaryStreamTypes(void);
   void SetElementaryStreamTypes(ElementaryStreamTypes stream_type);
   ushort GetElementaryPID(void);
-  void GetElementaryPID(ushort pid);
-  byte* GetElementaryDescriptors(void);
-  void SetElementaryDescriptors(byte* value)throw(std::invalid_argument);
+  void SetElementaryPID(ushort pid);
+  pByte GetElementaryDescriptors(void);
+  void SetElementaryDescriptors(pByte value)throw(std::invalid_argument);
+  pByte GetByteData(void);
  private:
-  byte* mData;
+  Bytes mData;
   VideoFormat mVideoFormat;
   AspectRatio mAspectRatio;
   FrameRate mFrameRate;
   AudioPresentationType mAudioPresentationType;
   SamplingFrequency mSamplingFrequency;
-  ElementaryStreamTypes StreamType;
-  ushort ElementaryPID;
-  byte* ElementaryDescriptors;
+//  ElementaryStreamTypes StreamType;
+//  ushort ElementaryPID;
+//  Bytes ElementaryDescriptors;
 };
 
 class BluRayOutput {
  public:
   BluRayOutput(std::string path, TimeSpan chapterLen);
   void Author(EpElement* EpInfo, StreamInfo* sis, UInt32 numOfSourcePackets);
-  byte* BuildPlayList(byte* PlayItems);
-  byte* BuildFirstPlayItem(byte stc_id, UInt32 start,
+  pByte BuildPlayList(byte* PlayItems);
+  pByte BuildFirstPlayItem(byte stc_id, UInt32 start,
         UInt32 end, byte* StnTable);
-  byte* BuildFirstPlayMarks(UInt32 start, UInt32 end, UInt32 interval);
-  byte* Build_clpi(byte* ClipInfo, byte* SequenceInfo,
+  pByte BuildFirstPlayMarks(UInt32 start, UInt32 end, UInt32 interval);
+  pByte Build_clpi(byte* ClipInfo, byte* SequenceInfo,
         byte* ProgramInfo, byte* CPI);
-  byte* BuildClipInfo(UInt32 numOfSourcePackets, EpElement* EpInfo);
-  byte* BuildSequenceInfo(UInt32 start, UInt32 end);
-  byte* BuildProgramInfo(ushort pids, byte* StreamCodingInfos);
-  byte* BuildVideoStreamCodingInfo(ElementaryStreamTypes type,
+  pByte BuildClipInfo(UInt32 numOfSourcePackets, EpElement* EpInfo);
+  pByte BuildSequenceInfo(UInt32 start, UInt32 end);
+  pByte BuildProgramInfo(ushort pids, byte* StreamCodingInfos);
+  pByte BuildVideoStreamCodingInfo(ElementaryStreamTypes type,
         VideoFormat format, FrameRate rate, AspectRatio ratio);
-  byte* BuildAudioStreamCodingInfo(ElementaryStreamTypes type,
+  pByte BuildAudioStreamCodingInfo(ElementaryStreamTypes type,
         AudioPresentationType format, SamplingFrequency rate);
-  byte* BuildPgStreamCodingInfo(void);
-  byte* BuildCpi(byte* EpMap);
-  byte* BuildEpMap(EpElement* EpInfo);
+  pByte BuildPgStreamCodingInfo(void);
+  pByte BuildCpi(byte* EpMap);
+  pByte BuildEpMap(EpElement* EpInfo);
  private:
-  byte* BuildStreamEntry(ushort pid);
-  byte* BuildVideoStreamAttributes(byte type, VideoFormat vf, FrameRate fr);
-  byte* BuildAudioStreamAttributes(byte type, AudioPresentationType vf,
+  pByte BuildStreamEntry(ushort pid);
+  pByte BuildVideoStreamAttributes(byte type, VideoFormat vf, FrameRate fr);
+  pByte BuildAudioStreamAttributes(byte type, AudioPresentationType vf,
         SamplingFrequency fr);
-  byte* BuildStnTable(byte* VideoEntry, byte* VideoAttributes,
+  pByte BuildStnTable(byte* VideoEntry, byte* VideoAttributes,
         byte* AudioEntries, byte* AudioAttributes,
         byte* PgEntries, byte* PgAttributes);
-  byte* UintToByteArraryNetwork(UInt32 value);
-  byte* Build_mlps(byte* PlayList, byte* PlayListMark);
+  pByte UintToByteArraryNetwork(UInt32 value);
+  pByte Build_mlps(byte* PlayList, byte* PlayListMark);
 };
 
 class Descriptor {
  public:
-  Descriptor(byte* data, int startIndex)throw(std::invalid_argument);
-  byte* GetData(void);
+  Descriptor(pByte data, int startIndex)throw(std::invalid_argument);
+  pByte GetData(void);
   byte GetTag(void);
   byte GetLength(void);
  private:
-  byte* mData;
+  Bytes mData;
 };
 
 class DTCP_Descriptor : Descriptor {
  public:
-  DTCP_Descriptor(byte* data, int startIndex);
+  DTCP_Descriptor(pByte data, int startIndex);
 };
 
 class Constants {
@@ -260,20 +265,20 @@ class Constants {
   static readonly byte ac3_registration_descriptor[];
   static readonly byte DefaultSitTableOne[];
   static readonly uint crc_table[];
-  static uint ComputeCrc(byte* data);
-  static uint ComputeCrc(byte* data, int length);
-  static uint ComputeCrc(byte* data, int length, int startIndex);
+  static uint ComputeCrc(pByte data);
+  static uint ComputeCrc(pByte data, int length);
+  static uint ComputeCrc(pByte data, int length, int startIndex);
 };
 
 class ProgramInfo {
  public:
-  ProgramInfo(byte* data, int index);
+  ProgramInfo(pByte data, int index);
   ProgramInfo(ushort programNumber, ushort programPid);
   ushort ProgramNumber;
   ushort ProgramPID;
-  byte* Data;
+  Bytes Data;
  private:
-  byte* mData;
+  Bytes mData;
 };
 
 class TsPacket {
@@ -284,17 +289,17 @@ class TsPacket {
   ushort GetPID(void);
   void SetPID(ushort pid);
   byte GetPointerSize(void);
-  byte* GetData(void);
-  void SetData(byte* data, int startIndex)throw(std::invalid_argument);
+  pByte GetData(void);
+  void SetData(pByte data, int startIndex)throw(std::invalid_argument);
   bool HasPcr(void);
   Int64 GetPcr(void)throw(std::out_of_range);
-  byte* Payload(void);
+  pByte Payload(void);
   void IncrementContinuityCounter(void);
   byte GetContinuityCounter(void);
   void SetContinuityCounter(byte value)throw(std::out_of_range);
   bool HasPesHeader(void);
  protected:
-  byte* mData;
+  Bytes mData;
  private:
   bool Priority;
   ushort PID;
@@ -308,8 +313,8 @@ class PcrPacket : TsPacket {
 class TsTable : TsPacket {
  public:
   TsTable();
-  TsTable(byte* data);
-  void AddData(byte* data, int offset, int len);
+  TsTable(pByte data);
+  void AddData(pByte data, int offset, int len);
   bool Complete(void);
   byte GetTableId(void);
   void SetTableId(byte value);
@@ -324,7 +329,7 @@ class TsTable : TsPacket {
 class PatPacket : TsTable {
  public:
   PatPacket(void);
-  PatPacket(byte* data);
+  PatPacket(pByte data);
   ushort TransportStreamId;
   ProgramInfo* Programs;
  private:
@@ -342,7 +347,7 @@ class PmPacket : TsTable {
   PmPacket(void);
   PmPacket(byte* data);
   DTCP_Descriptor DtcpInfo;
-  byte* ProgramDescriptorsData;
+  Bytes ProgramDescriptorsData;
   StreamInfo* ElementaryStreams;
   ushort ProgramNumber;
   ushort PcrPID;
@@ -353,7 +358,7 @@ class PmPacket : TsTable {
 
 class PesHeader {
  public:
-  PesHeader(byte* data);
+  PesHeader(pByte data);
   byte StreamId;
   byte GetByte(int i);
   void SetByte(byte dat);
@@ -365,39 +370,39 @@ class PesHeader {
   Int64 Pts;
   Int64 Dts;
   byte Extention2;
-  byte* Data;
+  Bytes Data;
  private:
-  byte* mData;
+  Bytes mData;
 };
 
 class PesPacket {
  public:
-  PesPacket(byte* buff, int offset, int length, ushort pid);
+  PesPacket(pByte buff, int offset, int length, ushort pid);
   bool GetPriority(void);
   void SetPriority(bool priority);
-  byte* GetData(void);
-  byte* GetPayload(void);
+  pByte GetData(void);
+  pByte GetPayload(void);
   byte GetByte(int i);
   void SetByte(byte dat);
   ushort GetPID(void);
   void SetPID(ushort id);
   bool GetComplete(void);
   void SetComplete(bool value);
-  PesHeader* GetHeader(void);
-  void AddData(std::vector<byte> moredata);
-  void AddData(byte* buff, int offset, int length);
+  boost::shared_ptr<PesHeader> GetHeader(void);
+  void AddData(pByte moredata);
+  void AddData(pByte buff, int offset, int length);
   byte GetBaseId(void);
   byte GetExtendedId(void);
   UInt32 GetExtendedType(void);
  private:
-  std::vector<byte> mData;
+  Bytes mData;
   bool mPriority;
   ushort mPID;
 };
 
 class VC1SequenceInfo {
  public:
-  VC1SequenceInfo(byte* data, int offset);
+  VC1SequenceInfo(pByte data, int offset);
   bool Valid;
   VideoFormat GetVideoFormati(void);
   void SetVideoFormat(VideoFormat videoformat);
@@ -406,7 +411,7 @@ class VC1SequenceInfo {
   FrameRate GetFrameRate(void);
   void SetFrameRate(FrameRate frameRate);
  private:
-  byte* mData;
+  Bytes mData;
   int Height;
   int Width;
   bool Interlaced;
@@ -422,8 +427,8 @@ class VC1SequenceInfo {
 
 class H264Info {
  public:
-  H264Info(byte* data, int offset);
-  byte* ElementaryDescriptors;
+  H264Info(pByte data, int offset);
+  Bytes ElementaryDescriptors;
   VideoFormat GetVideoFormati(void);
   void SetVideoFormat(VideoFormat videoformat);
   AspectRatio GetAspectRatio(void);
@@ -439,7 +444,7 @@ class H264Info {
   void ScalingListSkip(int skip);
   UInt32 Width;
   UInt32 Heigth;
-  byte* HdmvVideoRegistrationDescriptor;
+  Bytes HdmvVideoRegistrationDescriptor;
   VideoFormat mVideoFormat;
   AspectRatio mAspectRatio;
   FrameRate   mFrameRate;
@@ -468,10 +473,10 @@ class ElementaryParse {
       AudioPresentationType audioPresentationTyp);
   virtual SamplingFrequency GetsamplingFrequency(void);
   virtual void SetSamplingFrequency(SamplingFrequency samplingFrequency);
-  virtual byte* GetElementaryDescriptors(void);
+  virtual pByte GetElementaryDescriptors(void);
  protected:
   byte GetNextBit(void);
-  byte* mData;
+  Bytes mData;
   int indicator;
   bool mValid;
   VideoFormat mVideoFormat;
@@ -479,7 +484,7 @@ class ElementaryParse {
   AspectRatio mAspectRatio;
   SamplingFrequency mSamplingFrequency;
   AudioPresentationType mAudioPresentationType;
-  byte* ElementaryDescriptors;
+  Bytes ElementaryDescriptors;
 };
 
 class AC3Info : ElementaryParse {
@@ -488,7 +493,7 @@ class AC3Info : ElementaryParse {
   int FrameLength;
   bool IndependentStream;
   Ac3SyntaxType SyntaxType;
-  AC3Info(byte* data, int offset);
+  AC3Info(pByte data, int offset);
   VideoFormat GetVideoFormati(void);
   void SetVideoFormat(VideoFormat videoformat);
   AspectRatio GetAspectRatio(void);
@@ -499,7 +504,7 @@ class AC3Info : ElementaryParse {
   void SetAudioPresentationType(AudioPresentationType audioPresentationTyp);
   SamplingFrequency GetsamplingFrequency(void);
   void SetSamplingFrequency(SamplingFrequency samplingFrequency);
-  byte* GetElementaryDescriptors(void);
+  pByte GetElementaryDescriptors(void);
  private:
   static readonly int* len48k;
   static readonly int* len44k;
@@ -511,7 +516,7 @@ class AC3Info : ElementaryParse {
 
 class DtsInfo : ElementaryParse {
  public:
-  DtsInfo(byte* data, int offset);
+  DtsInfo(pByte data, int offset);
   VideoFormat GetVideoFormati(void);
   void SetVideoFormat(VideoFormat videoformat);
   AspectRatio GetAspectRatio(void);
@@ -522,7 +527,7 @@ class DtsInfo : ElementaryParse {
   void SetAudioPresentationType( AudioPresentationType audioPresentationTyp);
   SamplingFrequency GetsamplingFrequency(void);
   void SetSamplingFrequency(SamplingFrequency samplingFrequency);
-  byte* GetElementaryDescriptors(void);
+  pByte GetElementaryDescriptors(void);
   ushort FrameSize;
   byte ExtAudioId;
  private:
@@ -533,7 +538,7 @@ class DtsInfo : ElementaryParse {
 
 class MlpInfo : ElementaryParse {
  public:
-  MlpInfo(byte* data, int offset);
+  MlpInfo(pByte data, int offset);
   VideoFormat GetVideoFormati(void);
   void SetVideoFormat(VideoFormat videoformat);
   AspectRatio GetAspectRatio(void);
@@ -544,15 +549,15 @@ class MlpInfo : ElementaryParse {
   void SetAudioPresentationType(AudioPresentationType audioPresentationTyp);
   SamplingFrequency GetsamplingFrequency(void);
   void SetSamplingFrequency(SamplingFrequency samplingFrequency);
-  byte* GetElementaryDescriptors(void);
+  pByte GetElementaryDescriptors(void);
  private:
-  byte* AC3AudioDescriptor;
+  Bytes AC3AudioDescriptor;
   byte SampleRateCode;
 };
 
 class Mpeg2Info : ElementaryParse {
  public:
-  Mpeg2Info(byte* data, int offset);
+  Mpeg2Info(pByte data, int offset);
   VideoFormat GetVideoFormati(void);
   void SetVideoFormat(VideoFormat videoformat);
   AspectRatio GetAspectRatio(void);
@@ -563,9 +568,9 @@ class Mpeg2Info : ElementaryParse {
   void SetAudioPresentationType(AudioPresentationType audioPresentationTyp);
   SamplingFrequency GetsamplingFrequency(void);
   void SetSamplingFrequency(SamplingFrequency samplingFrequency);
-  byte* GetElementaryDescriptors(void);
+  pByte GetElementaryDescriptors(void);
  private:
-  byte* Mpeg2VideoRegistrationDescriptor;
+  Bytes Mpeg2VideoRegistrationDescriptor;
   ushort Horizontal;
   ushort Vertical;
   byte Aspect;
index 1922ce5..e22e2d3 100644 (file)
@@ -2,6 +2,8 @@
 #define TSREMUXCPP_DEFINE_H_
 
 #include <time.h>
+#include <boost/shared_array.hpp>
+#include <vector>
 
 #define readonly const
 
@@ -14,5 +16,8 @@ namespace TsRemux {
     typedef unsigned long long UInt64;
     typedef signed long long Int64;
     typedef time_t TimeSpan;
+    typedef boost::shared_array<byte> pByte;
+    typedef std::vector<byte> Bytes;
+    typedef std::vector<byte>::iterator Iter;
 } // namespace
 #endif TSREMUXCPP_DEFINE_H_