0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4 };
-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;
-}
+// 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)
+ if(!data)
throw std::invalid_argument("stream data is NULL");
- if(std::strlen(reinterpret_cast<char*>(data.get())) + index < 5)
+ if(sizeof(data.get()) + index < 5)
throw std::invalid_argument("stream data too short");
- uint descLength = (uint)((data[3 + index] & 0x0f) << 8) + data[4 + index];
+ uint descLength = (data[3 + index] & 0x0f) << 8 + data[4 + index];
if(descLength > Constants::TS_SIZE)
throw std::invalid_argument("descriptors data too long");
- if(5 + descLength
- > std::strlen(reinterpret_cast<char*>(data.get())) - index)
+ if(5 + descLength > sizeof(data.get()) - index)
{
throw std::invalid_argument("stream data too short");
}
- mData.clear();
- for(int i = 0; i < (5 + descLength); i++)
- {
- mData.push_back(data[i + index]);
+ mData = pByte(new byte[5 + descLength]);
+ for(int i = 0; i < sizeof(mData.get()); i++)
+ {
+ mData[i] = data[i + index];
}
SetVideoFormat(VF_Reserved);
StreamInfo::StreamInfo(ElementaryStreamTypes streamType, ushort elementaryPid)
{
- mData.clear();
+ mData = pByte(new byte[5]);
SetElementaryStreamTypes(streamType);
SetElementaryPID(elementaryPid);
// reserved and descriptors length
- mData.push_back(0x00);
- mData.push_back(0x00);
- mData.push_back(0x00);
- mData.push_back(0xf0);
- mData.push_back(0x00);
+ mData[3] = 0xf0;
+ mData[4] = 0x00;
}
pByte StreamInfo::GetByteData(void)
{
- return Utility::ToArray(mData);
+ return mData;
}
ElementaryStreamTypes StreamInfo::GetElementaryStreamTypes(void)
{
- return (ElementaryStreamTypes)mData.at(0);
+ return (ElementaryStreamTypes)mData[0];
}
void StreamInfo::SetElementaryStreamTypes(ElementaryStreamTypes stream_type)
}
ushort StreamInfo::GetElementaryPID(void)
{
- return (ushort)(((mData.at(1) & 0x1f) << 8) + mData.at(2));
+ return (ushort)(((mData[1] & 0x1f) << 8) + mData[2]);
}
void StreamInfo::SetElementaryPID(ushort pid)
pByte StreamInfo::GetElementaryDescriptors(void)
{
pByte descriptors;
- if(mData.size() == 5)
+ if(sizeof(mData.get()) == 5)
{
descriptors.reset();
}
else
{
- descriptors = pByte(new byte[mData.size() - 5]);
- for (int i = 0; i < (mData.size() - 5); i++)
+ descriptors = pByte(new byte[sizeof(mData.get()) - 5]);
+ for (int i = 0; i < (sizeof(mData.get()) - 5); i++)
{
descriptors[i] = mData[i + 5];
}
void StreamInfo::SetElementaryDescriptors(pByte value)
throw(std::invalid_argument)
{
- if(NULL == value || 0 == sizeof(value))
+ if(!value || 0 == sizeof(value.get()))
{
- if(mData.size() > 5)
+ if(sizeof(mData.get()) > 5)
{
// need to remove existing descriptors
- 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);
+ pByte data = pByte(new byte[5]);
+ data[0] = mData[0];
+ data[1] = mData[1];
+ data[2] = mData[2];
+ data[3] = 0xf0;
+ data[4] = 0x00;
+ mData = data;
}
else
{
}
else
{
- if(sizeof(value) > 180) {
+ if(sizeof(value.get()) > 180) {
throw std::invalid_argument("descriptors data too long");
}
- 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(reinterpret_cast<char*>(value.get())) >> 8)
- & 0x0f)));
- data.push_back(std::strlen(reinterpret_cast<char*>(value.get())) & 0xff);
- for (int i = 0;
- i < std::strlen(reinterpret_cast<char*>(value.get())); i++)
+ pByte data = pByte(new byte[5 + sizeof(value.get())]);
+ data[0] = mData[0];
+ data[1] = mData[1];
+ data[2] = mData[2];
+ data[3] = (byte)(0xf0 | (byte)((sizeof(value.get()) >> 8) & 0x0f));
+ data[4] = (byte)(sizeof(value.get()) & 0xff);
+ for (int i = 0; i < sizeof(value.get()); i++)
{
- data.push_back(value[i]);
+ data[5 + i] = value[i];
}
- mData.swap(data);
+ mData = data;
+ }
+}
+
+ProgramInfo::ProgramInfo(pByte data, int index)throw(std::invalid_argument)
+{
+ if(!data)
+ throw std::invalid_argument("program data is null");
+
+ if(sizeof(data.get()) + index < 4)
+ throw std::invalid_argument("program data too short");
+
+ mData = pByte(new byte[4]);
+ for(int i = 0; i < sizeof(mData.get()); i++)
+ {
+ mData[i] = data[i + index];
}
}
+ProgramInfo::ProgramInfo(ushort programNumber, ushort programPid)
+{
+ mData = pByte(new byte[4]);
+ SetProgramNumber(programNumber);
+ SetProgramPID(programPid);
+}
+
+ushort ProgramInfo::GetProgramNumber(void)
+{
+ return (ushort)((mData[0] << 8) + mData[1]);
+}
+
+void ProgramInfo::SetProgramNumber(ushort value)
+{
+ mData[0] = (byte)((value >> 8) & 0xff);
+ mData[1] = (byte)(value & 0xff);
+}
+
+ushort ProgramInfo::GetProgramPID(void)
+{
+ return (ushort)(((mData[2] & 0x1f) << 8) + mData[3]);
+}
+
+void ProgramInfo::SetProgramPID(ushort value)
+{
+ mData[2] = (byte)(((value >> 8) & 0x1f) | 0xe0);
+ mData[3] = (byte)(value & 0xff);
+}
+
+pByte ProgramInfo::GetData(void)
+{
+ return mData;
+}
+
ElementaryParse::ElementaryParse(void)
{
indicator = 0;
TsPacket::TsPacket(void)
{
- // initialize the packet as a NULL packet
- mData.clear();
+ // initialize the packet as a null packet
+ mData = pByte(new byte[Constants::TS_SIZE]);
mData[0] = Constants::SYNC_BYTE; // sync byte
mData[1] = 0x1f; // PID = 0x1FFF
mData[2] = 0xff; // PID == 0x1FFF
mData[3] = 0x10; // no adaptation field
- for (int i = 4; i < Constants::TS_SIZE; i++) {
+ for (int i = 4; i < Constants::TS_SIZE; i++)
mData[i] = 0xff;
- }
}
bool TsPacket::GetPriority(void)
pByte TsPacket::GetData(void)
{
- return Utility::ToArray(mData);
+ return mData;
}
void TsPacket::SetData(pByte data, int startIndex)throw(std::invalid_argument)
{
- if (NULL == data)
+ if (!data)
throw std::invalid_argument("NULL packet");
- else if (Constants::TS_SIZE
- > std::strlen(reinterpret_cast<char*>(data.get())) - startIndex)
+ else if (Constants::TS_SIZE > sizeof(data.get()) - startIndex)
throw std::invalid_argument("small packet");
else if (Constants::SYNC_BYTE != data[0 + startIndex])
throw std::invalid_argument("sync byte missing");
SetData(data, 0);
}
-void TsTable::AddData(pByte data, int offset, int len)
+void TsTable::AddData(pByte value, int offset, int len)
{
- for(int i = 0; i < len; i++)
- {
- mData.push_back(data[offset + i]);
- }
+ pByte data = pByte(new byte[sizeof(mData.get()) + len]);
+ memcpy(reinterpret_cast<char*>(data.get()),
+ reinterpret_cast<char*>(mData.get()),
+ sizeof(mData.get()));
+ memcpy(reinterpret_cast<char*>(data.get() + sizeof(mData.get())),
+ reinterpret_cast<char*>(value.get() + offset),
+ len);
+ mData = data;
}
bool TsTable::Complete(void)
{
- int currentLen = mData.size() - (GetPointerSize() + 8);
+ int currentLen = sizeof(mData.get()) - (GetPointerSize() + 8);
if (GetLength() > currentLen)
return false;
return true;
byte TsTable::GetTableId(void)
{
- return mData.at(5 + GetPointerSize());
+ return mData[5 + GetPointerSize()];
}
void TsTable::SetTableId(byte value)
ushort TsTable::GetNumberId(void)
{
- return (ushort)((mData.at(8 + GetPointerSize()) << 8)
- + mData.at(9 + GetPointerSize()));
+ return (ushort)((mData[8 + GetPointerSize()] << 8)
+ + mData[9 + GetPointerSize()]);
}
void TsTable::SetNumberId(ushort value)
ushort TsTable::GetLength(void)
{
- return (ushort)(((mData.at(6 + GetPointerSize()) & 0x0f) << 8)
- + mData.at(7 + GetPointerSize()));
+ return (ushort)(((mData[6 + GetPointerSize()] & 0x0f) << 8)
+ + mData[7 + GetPointerSize()]);
}
void TsTable::SetLength(ushort value)
void TsTable::RefreshCrc(void)
{
uint crc = Constants::ComputeCrc(
- Utility::ToArray(mData), GetLength() - 1, 5 + GetPointerSize());
+ mData, GetLength() - 1, 5 + GetPointerSize());
mData[GetLength() + 4 + GetPointerSize()]
= (byte)((crc >> 24) & 0xff);
mData[GetLength() + 5 + GetPointerSize()]
Descriptor::Descriptor(pByte data, int startIndex)throw(std::invalid_argument)
{
- if (strlen(reinterpret_cast<char*>(data.get())) < 2)
+ if (sizeof(data.get()) < 2)
throw std::invalid_argument("Invalid descriptor");
+
if (startIndex + 2 + data[startIndex + 1]
> strlen(reinterpret_cast<char*>(data.get())))
throw std::invalid_argument("Invalid descriptor");
- mData.clear();
- for (int i = 0; i < (2 + data[startIndex + 1]); i++)
- mData.push_back(data[i + startIndex]);
+
+ mData = pByte(new byte[2 + data[startIndex + 1]]);
+ for (int i = 0; i < sizeof(mData.get()); i++)
+ mData[i] = data[i + startIndex];
}
byte Descriptor::GetTag(void)
{
- return mData.at(0);
+ return mData[0];
}
byte Descriptor::GetLength(void)
{
- return mData.at(1);
+ return mData[1];
}
pByte Descriptor::GetData(void)
{
- return Utility::ToArray(mData);
+ return mData;
}
PcrPacket::PcrPacket(Int64 pcr, byte counter, ushort pid)
PesPacket::PesPacket(pByte buff, int offset, int length, ushort pid)
{
- mData.assign(0,length);
+ mData = pByte(new byte[length]);
SetPID(pid);
AddData(buff, offset, length);
SetPriority(false);
pByte PesPacket::GetData(void)
{
- 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;
+ return mData;
}
pByte PesPacket::GetPayload(void)
{
boost::shared_ptr<PesHeader> ph = GetHeader();
- if(ph == NULL) return GetData();
- pByte buff = pByte(new byte[mData.size() - 9 + ph.get()->GetHeaderLength() + 1]);
- for(int i=(9 + ph.get()->GetHeaderLength()); i < mData.size(); i++)
- buff[i] = mData.at(i);
- buff[mData.size()-(9 + ph.get()->GetHeaderLength())] = '\0';
+ if(!ph) return GetData();
+ pByte buff = pByte(
+ new byte[sizeof(mData.get()) - 9 + ph.get()->GetHeaderLength() + 1]);
+ for(int i=(9 + ph.get()->GetHeaderLength()); i < sizeof(mData.get()); i++)
+ buff[i] = mData[i];
+ buff[sizeof(mData.get()) - (9 + ph.get()->GetHeaderLength())] = '\0';
return buff;
}
byte PesPacket::GetByte(int i)
{
- return mData.at(i);
+ return mData[i];
}
-void PesPacket::SetByte(byte value)
+void PesPacket::SetByte(int i, byte value)
{
-// mData[i] = value;
+ mData[i] = value;
}
ushort PesPacket::GetPID(void)
bool PesPacket::GetComplete(void)
{
- if(mData.size() < 6) return false;
+ if(sizeof(mData.get()) < 6) return false;
ushort len = (ushort)((mData[4] << 8) + mData[5]);
if(len == 0) return false;
- if(mData.size() != len + 6) return false;
+ if(sizeof(mData.get()) != len + 6) return false;
return true;
}
{
if(value)
{
- ushort len = (ushort)(mData.size() - 6);
- if (mData.size() > (0xffff - 6))
+ ushort len = (ushort)(sizeof(mData.get()) - 6);
+ if (sizeof(mData.get()) > (0xffff - 6))
len = 0;
mData[4] = (byte)((len >> 8) & 0xff);
mData[5] = (byte)(len & 0xff);
boost::shared_ptr<PesHeader> ph;
try
{
- ph = boost::shared_ptr<PesHeader>(
- new PesHeader(Utility::ToArray(mData)));
+ ph = boost::shared_ptr<PesHeader>(new PesHeader(mData));
return ph;
}
catch(...)
void PesPacket::AddData(pByte moredata)
{
- for(std::vector<byte>::iterator it = mData.begin();
- it != mData.end();
- it++)
- {
- mData.push_back(*it);
- }
+ pByte data = pByte(new byte[sizeof(mData.get()) + sizeof(moredata.get())]);
+ memcpy(reinterpret_cast<char*>(data.get()),
+ reinterpret_cast<char*>(mData.get()),
+ sizeof(mData.get()));
+ memcpy(reinterpret_cast<char*>(data.get() + sizeof(mData.get())),
+ reinterpret_cast<char*>(mData.get()),
+ sizeof(mData.get()));
+ mData = data;
}
-void PesPacket::AddData(pByte buff, int offset, int length)
+void PesPacket::AddData(pByte buff, int offset, int len)
{
- for (int i = offset; i < length + offset; i++)
- mData.push_back(buff[i]);
+ pByte data = pByte(new byte[sizeof(mData.get()) + len]);
+ memcpy(reinterpret_cast<char*>(data.get()),
+ reinterpret_cast<char*>(mData.get()),
+ sizeof(mData.get()));
+ memcpy(reinterpret_cast<char*>(data.get() + sizeof(mData.get())),
+ reinterpret_cast<char*>(mData.get() + offset),
+ len);
+ mData = data;
}
byte PesPacket::GetBaseId(void)
{
- if (mData.size() > 3)
+ if (sizeof(mData.get()) > 3)
return mData[3];
return 0;
}
byte PesPacket::GetExtendedId(void)
{
- if ((mData.size() > 8) && mData.size() > (8 + mData[8]))
+ if ((sizeof(mData.get()) > 8) && sizeof(mData.get()) > (8 + mData[8]))
return mData[9 + mData[8]];
return 0;
}
UInt32 PesPacket::GetExtendedType(void)
{
- if ((mData.size() > 8) && mData.size() > (11 + mData[8]))
+ if ((sizeof(mData.get()) > 8) && sizeof(mData.get()) > (11 + mData[8]))
{
UInt32 format = (UInt32)mData[9 + mData[8]] << 24;
format += (UInt32)mData[10 + mData[8]] << 16;
throw new std::invalid_argument("Invalid PES header/packet length");
if (sizeof(data.get()) < hlen)
throw std::invalid_argument("PES Header too short");
- mData.clear();
+ mData = pByte(new byte[hlen]);
for (int i = 0; i < hlen; i++)
- mData.push_back(data[i]);
+ mData[i] = data[i];
}
byte PesHeader::GetStreamId(void)
byte PesHeader::GetByte(int i)
{
- return mData.at(i);
+ return mData[i];
}
void PesHeader::SetByte(int i, byte data)
byte PesHeader::GetHeaderLength(void)
{
- return mData.at(8);
+ return mData[8];
}
int PesHeader::GetTotalHeaderLength(void)
ushort PesHeader::GetPacketLength(void)
{
- return (ushort)((mData.at(4) << 8) + mData.at(5));
+ return (ushort)((mData[4] << 8) + mData[5]);
}
bool PesHeader::HasPts(void)
{
- if(mData.size() > 13)
- return (mData.at(7) & 0x80) > 0;
+ if(sizeof(mData.get()) > 13)
+ return (mData[7] & 0x80) > 0;
return false;
}
bool PesHeader::HasDts(void)
{
- if(mData.size() > 18 )
- return (mData.at(7) & 0x40) > 0;
+ if(sizeof(mData.get()) > 18 )
+ return (mData[7] & 0x40) > 0;
return false;
}
{
if (HasPts() == false)
throw std::invalid_argument("No Pts available");
- byte old = (byte)(mData.at(9) & 0xf1);
+ byte old = (byte)(mData[9] & 0xf1);
mData[9] = (byte)(((value & 0x1C0000000LL) >> 29) | old);
mData[10] = (byte)((value & 0x3fC00000LL) >> 22);
mData[11] = (byte)(((value & 0x3f8000LL) >> 14) | 0x01);
byte PesHeader::GetExtention2(void)
{
int offset = 6;
- if((mData.at(offset) & 0xc0) != 0x80)
+ if((mData[offset] & 0xc0) != 0x80)
return 0; // first two bits must be '10'
- byte PTS_DTS_flags = (byte)(mData.at(offset + 1) & 0xc0);
- byte ESCR_flag = (byte)(mData.at(offset + 1) & 0x20);
- byte ES_rate_flag = (byte)(mData.at(offset + 1) & 0x10);
- byte DSM_trick_mode_flag = (byte)(mData.at(offset + 1) & 0x08);
- byte additional_copy_info_flag = (byte)(mData.at(offset + 1) & 0x04);
- byte PES_CRC_flag = (byte)(mData.at(offset + 1) & 0x02);
- byte PES_extension_flag = (byte)(mData.at(offset + 1) & 0x01);
- if(mData.at(offset + 2) == 0)
+ byte PTS_DTS_flags = (byte)(mData[offset + 1] & 0xc0);
+ byte ESCR_flag = (byte)(mData[offset + 1] & 0x20);
+ byte ES_rate_flag = (byte)(mData[offset + 1] & 0x10);
+ byte DSM_trick_mode_flag = (byte)(mData[offset + 1] & 0x08);
+ byte additional_copy_info_flag = (byte)(mData[offset + 1] & 0x04);
+ byte PES_CRC_flag = (byte)(mData[offset + 1] & 0x02);
+ byte PES_extension_flag = (byte)(mData[offset + 1] & 0x01);
+ if(mData[offset + 2] == 0)
return 0;
- int length = offset + mData.at(offset + 2) + 3;
- if(mData.size() < length)
+ int length = offset + mData[offset + 2] + 3;
+ if(sizeof(mData.get()) < length)
return 0;
offset += 3;
if(PTS_DTS_flags == 0x80)
offset += 2;
if(PES_extension_flag == 0)
return 0;
- byte PES_private_data_flag = (byte)(mData.at(offset) & 0x80);
- byte pack_header_field_flag = (byte)(mData.at(offset) & 0x40);
+ byte PES_private_data_flag = (byte)(mData[offset] & 0x80);
+ byte pack_header_field_flag = (byte)(mData[offset] & 0x40);
byte program_packet_sequence_counter_flag
- = (byte)(mData.at(offset) & 0x20);
- byte PSTD_mDataer_flag = (byte)(mData.at(offset) & 0x10);
- byte PES_extension_flag_2 = (byte)(mData.at(offset) & 0x01);
+ = (byte)(mData[offset] & 0x20);
+ byte PSTD_mDataer_flag = (byte)(mData[offset] & 0x10);
+ byte PES_extension_flag_2 = (byte)(mData[offset] & 0x01);
offset++;
if(PES_private_data_flag > 0)
offset += 25;
if(pack_header_field_flag > 0)
- offset += (mData.at(offset) + 1);
+ offset += (mData[offset] + 1);
if(program_packet_sequence_counter_flag > 0)
offset += 2;
if(PSTD_mDataer_flag > 0)
return 0;
if(mData[offset] != 0x81)
return 0;
- return mData.at(offset + 1);
+ return mData[offset + 1];
}
pByte PesHeader::GetData(void)
{
- return Utility::ToArray(mData);
+ return mData;
}
VC1SequenceInfo::VC1SequenceInfo(pByte data, int offset)
{
UInt32 marker = 0xffffffff;
- for(; offset < sizeof(reinterpret_cast<char*>(data.get())); offset++)
+ for(; offset < sizeof(data.get()); offset++)
{
marker = marker << 8;
marker &= 0xffffff00;
break;
}
offset++;
- mData.clear();
- if(offset < sizeof(reinterpret_cast<char*>(data.get())))
+ if(offset < sizeof(data.get()))
{
// sequence header
- for(int i = 0;
- offset < sizeof(reinterpret_cast<char*>(data.get()));
- i++, offset++)
- {
- mData.push_back(data[offset]);
- }
+ mData = pByte(new byte[sizeof(data.get()) - offset]);
+ for(int i = 0; offset < sizeof(data.get()); i++, offset++)
+ mData[i] = data[offset];
}
+ else
+ mData.reset();
}
int VC1SequenceInfo::GetHeight(void)
{
- if(!mData.empty()&& mData.size() > 4)
- return ((((mData.at(3) & 0x0f) << 8) + mData.at(4)) << 1) + 2;
+ if(!mData && sizeof(mData.get()) > 4)
+ return ((((mData[3] & 0x0f) << 8) + mData[4]) << 1) + 2;
else
return -1;
}
int VC1SequenceInfo::GetWidth(void)
{
- if(!mData.empty() && mData.size() > 3)
- return (((mData.at(2) << 4) + ((mData.at(3) & 0xf0) >> 4)) << 1) + 2;
+ if(!mData && sizeof(mData.get()) > 3)
+ return (((mData[2] << 4) + ((mData[3] & 0xf0) >> 4)) << 1) + 2;
else
return -1;
}
bool VC1SequenceInfo::Valid(void)
{
- return !mData.empty();
+ return !mData;
}
bool VC1SequenceInfo::Interlaced(void)
{
- if(!mData.empty() && mData.size() > 5)
- return ((mData.at(5) & 0x40) > 0);
+ if(!mData && sizeof(mData.get()) > 5)
+ return ((mData[5] & 0x40) > 0);
return false;
}
bool VC1SequenceInfo::DisplayExt(void)
{
- if(!mData.empty() && mData.size() > 5)
- return ((mData.at(5) & 0x02) > 0);
+ if(!mData && sizeof(mData.get()) > 5)
+ return ((mData[5] & 0x02) > 0);
return false;
}
bool VC1SequenceInfo::AspectFlag(void)
{
- if(DisplayExt() && mData.size() > 9)
- return ((mData.at(9) & 0x10) > 0);
+ if(DisplayExt() && sizeof(mData.get()) > 9)
+ return ((mData[9] & 0x10) > 0);
return false;
}
byte VC1SequenceInfo::GetVc1AspectRatio(void)
{
- if(AspectFlag() && mData.size() > 9)
- return (byte)(mData.at(9) & 0x0f);
+ if(AspectFlag() && sizeof(mData.get()) > 9)
+ return (byte)(mData[9] & 0x0f);
return 0;
}
{
if(AspectFlag())
{
- if(GetVc1AspectRatio() == 15 && mData.size() > 12)
- return ((mData.at(12) & 0x80) > 0);
- else if(GetVc1AspectRatio() != 15 && mData.size() > 10)
- return ((mData.at(10) & 0x80) > 0);
+ if(GetVc1AspectRatio() == 15 && sizeof(mData.get()) > 12)
+ return ((mData[12] & 0x80) > 0);
+ else if(GetVc1AspectRatio() != 15 && sizeof(mData.get()) > 10)
+ return ((mData[10] & 0x80) > 0);
else
return false;
}
- else if(mData.size() > 9)
- return ((mData.at(9) & 0x08) > 0);
+ else if(sizeof(mData.get()) > 9)
+ return ((mData[9] & 0x08) > 0);
else
return false;
}
{
if(AspectFlag())
{
- if (GetVc1AspectRatio() == 15 && mData.size() > 12)
- return ((mData.at(12) & 0x40) > 0);
- else if (GetVc1AspectRatio() != 15 && mData.size() > 10)
- return ((mData.at(10) & 0x40) > 0);
+ if (GetVc1AspectRatio() == 15 && sizeof(mData.get()) > 12)
+ return ((mData[12] & 0x40) > 0);
+ else if (GetVc1AspectRatio() != 15 && sizeof(mData.get()) > 10)
+ return ((mData[10] & 0x40) > 0);
else
return false;
}
- else if (mData.size() > 9)
- return ((mData.at(9) & 0x04) > 0);
+ else if (sizeof(mData.get()) > 9)
+ return ((mData[9] & 0x04) > 0);
else
return false;
}
byte FrameRateDr = 0;
if(AspectFlag())
{
- if(GetVc1AspectRatio() == 15 && mData.size() > 13)
+ if(GetVc1AspectRatio() == 15 && sizeof(mData.get()) > 13)
{
- FrameRateNr = (byte)(((mData.at(12) & 0x3f) << 2)
- + ((mData.at(13) & 0xc0) >> 6));
- FrameRateDr = (byte)((mData.at(13) & 0x3c) >> 2);
+ FrameRateNr = (byte)(((mData[12] & 0x3f) << 2)
+ + ((mData[13] & 0xc0) >> 6));
+ FrameRateDr = (byte)((mData[13] & 0x3c) >> 2);
}
- else if(GetVc1AspectRatio() != 15 && mData.size() > 11)
+ else if(GetVc1AspectRatio() != 15 && sizeof(mData.get()) > 11)
{
- FrameRateNr = (byte)(((mData.at(10) & 0x3f) << 2)
- + ((mData.at(11) & 0xc0) >> 6));
- FrameRateDr = (byte)((mData.at(11) & 0x3c) >> 2);
+ FrameRateNr = (byte)(((mData[10] & 0x3f) << 2)
+ + ((mData[11] & 0xc0) >> 6));
+ FrameRateDr = (byte)((mData[11] & 0x3c) >> 2);
}
}
- else if(mData.size() > 11)
+ else if(sizeof(mData.get()) > 11)
{
- FrameRateNr = (byte)(((mData.at(9) & 0x03) << 6)
- + ((mData.at(10) & 0xfc) >> 2));
- FrameRateDr = (byte)(((mData.at(10) & 0x03) << 2)
+ FrameRateNr = (byte)(((mData[9] & 0x03) << 6)
+ + ((mData[10] & 0xfc) >> 2));
+ FrameRateDr = (byte)(((mData[10] & 0x03) << 2)
+ ((mData[11] & 0xc0) >> 6));
}
return FR_Reserved;
}
+// implement class PatPacket : TsTable
+PatPacket::PatPacket(void)
+{
+ SetPID(Constants::PAT_PID);
+ SetTableId(Constants::PAT_TABLE_ID);
+ SetLength(9);
+ SetTransportStreamId(1);
+ RefreshCrc();
+}
+
+PatPacket::PatPacket(pByte data)throw(std::invalid_argument)
+{
+ if(GetTableId() != Constants::PAT_TABLE_ID)
+ throw std::invalid_argument(
+ "packet does not contain a valid PAT table ID");
+ if (0 != GetPID())
+ throw std::invalid_argument("packet does not contain a valid PAT PID");
+}
+
+ushort PatPacket::GetTransportStreamId(void)
+{
+ return GetNumberId();
+}
+
+void PatPacket::SetTransportStreamId(ushort value)
+{
+ SetNumberId(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(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;
+}
+
+void PatPacket::SetPrograms(boost::shared_ptr<ProgramInfo> value)
+ throw(std::invalid_argument)
+{
+ if (NULL == value || sizeof(value.get()) == 0)
+ {
+ if (GetProgramInfoLength() == 0)
+ return;
+ SetLength(9);
+ RefreshCrc();
+ }
+ else
+ {
+ if ((sizeof(value.get()) * 4) + 17 + GetPointerSize()
+ > Constants.TS_SIZE)
+ throw std::invalid_argument("program info data too long");
+ SetLength((ushort)(9 + (sizeof(value.get()) * 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];
+ index += 4;
+ }
+ RefreshCrc();
+ }
+}
+*/
+ushort PatPacket::GetProgramInfoLength(void)
+{
+ return (ushort)(GetLength() - 9);
+}
// implement class BluRayOutput
// implement class DTCP_Descriptor : Descriptor
-// implement class PatPacket : TsTable
// implement class SitPacket : TsTable
// implement class PmPacket : TsTable
// implement class H264Info : ElementaryParse