示例#1
0
ASDCP::Result_t
ASDCP::TimedText::MXFWriter::h__Writer::WriteAncillaryResource(const ASDCP::TimedText::FrameBuffer& FrameBuf,
							       ASDCP::AESEncContext* Ctx, ASDCP::HMACContext* HMAC)
{
  if ( ! m_State.Test_RUNNING() )
    return RESULT_STATE;

  Kumu::fpos_t here = m_File.Tell();
  assert(m_Dict);

  // create generic stream partition header
  static UL GenericStream_DataElement(m_Dict->ul(MDD_GenericStream_DataElement));
  MXF::Partition GSPart(m_Dict);

  GSPart.ThisPartition = here;
  GSPart.PreviousPartition = m_HeaderPart.m_RIP.PairArray.back().ByteOffset;
  GSPart.BodySID = m_EssenceStreamID;
  GSPart.OperationalPattern = m_HeaderPart.OperationalPattern;

  m_HeaderPart.m_RIP.PairArray.push_back(RIP::Pair(m_EssenceStreamID++, here));
  GSPart.EssenceContainers.push_back(UL(m_Dict->ul(MDD_TimedTextEssence)));
  UL TmpUL(m_Dict->ul(MDD_GenericStreamPartition));
  Result_t result = GSPart.WriteToFile(m_File, TmpUL);

  if ( ASDCP_SUCCESS(result) )
    result = WriteEKLVPacket(FrameBuf, GenericStream_DataElement.Value(), Ctx, HMAC);

  m_FramesWritten++;
  return result;
}
示例#2
0
文件: UL.cpp 项目: dcsch/asiotest
bool UL::isTypeOf(const UL& ul, const UInt8* mask, UInt32 maskLen) const
{
    for (UInt32 i = 1; i <= 16; i++)
    {
        // Skip the version byte if we have no explicit mask
        if (maskLen == 0 && i == 8)
        {
            continue;
        }

        // If the right-hand side is a zero, then we'll move on to the
        // next byte.
        if (ul.getByte(i) == 0)
        {
            continue;
        }

        // Now compare the two bytes, masking both
        UInt8 maskByte = (maskLen >= i) ? mask[i - 1] : 0xff;

        if ((getByte(i) & maskByte) != (ul.getByte(i) & maskByte))
        {
            return false;
        }
    }
    return true;
}
示例#3
0
文件: main.cpp 项目: r0mai/nng-2014
MUL pe()
{
    MUL res;
    VUL x{0,1,2};
    do
    {
        res.push_back( x );
    }
    while ( std::next_permutation(x.begin(),x.end()) );
    return res;
}
示例#4
0
// Closes the MXF file, writing the index and other closing information.
//
Result_t
AS_02::PHDR::MXFWriter::h__Writer::Finalize(const std::string& PHDR_master_metadata)
{
    if ( ! m_State.Test_RUNNING() )
        return RESULT_STATE;

    Result_t result = m_State.Goto_FINAL();

    if ( KM_SUCCESS(result) )
    {
        if ( m_IndexWriter.GetDuration() > 0 )
        {
            m_IndexWriter.ThisPartition = this->m_File.Tell();
            m_IndexWriter.WriteToFile(this->m_File);
            m_RIP.PairArray.push_back(RIP::Pair(0, this->m_IndexWriter.ThisPartition));
        }

        if ( ! PHDR_master_metadata.empty() )
        {
            // write PHDRSimplePayload
            Kumu::fpos_t here = m_File.Tell();

            // create generic stream partition header
            static UL GenericStream_DataElement(m_Dict->ul(MDD_GenericStream_DataElement));
            ASDCP::MXF::Partition GSPart(m_Dict);

            GSPart.ThisPartition = here;
            GSPart.PreviousPartition = m_RIP.PairArray.back().ByteOffset;
            GSPart.OperationalPattern = m_HeaderPart.OperationalPattern;
            GSPart.BodySID = 2;
            m_MetadataTrackSubDescriptor->SimplePayloadSID = 2;

            m_RIP.PairArray.push_back(RIP::Pair(2, here));
            GSPart.EssenceContainers = m_HeaderPart.EssenceContainers;

            static UL gs_part_ul(m_Dict->ul(MDD_GenericStreamPartition));
            Result_t result = GSPart.WriteToFile(m_File, gs_part_ul);

            if ( KM_SUCCESS(result) )
            {
                ASDCP::FrameBuffer tmp_buf;
                tmp_buf.SetData((byte_t*)PHDR_master_metadata.c_str(), PHDR_master_metadata.size());
                tmp_buf.Size(PHDR_master_metadata.size());

                result = Write_EKLV_Packet(m_File, *m_Dict, m_HeaderPart, m_Info, m_CtFrameBuf, m_FramesWritten,
                                           m_StreamOffset, tmp_buf, GenericStream_DataElement.Value(), 0, 0);
            }
        }

        result = WriteAS02Footer();
    }

    return result;
}
示例#5
0
ASDCP::Result_t
ASDCP::KLVFilePacket::WriteKLToFile(Kumu::FileWriter& Writer, const UL& label, ui32_t length)
{
  byte_t buffer[kl_length];
  memcpy(buffer, label.Value(), label.Size());

  if ( ! Kumu::write_BER(buffer+SMPTE_UL_LENGTH, length, MXF_BER_LENGTH) )
    return RESULT_FAIL;

  ui32_t write_count;
  Writer.Write(buffer, kl_length, &write_count);
  assert(write_count == kl_length);
  return RESULT_OK;
}
示例#6
0
ASDCP::Result_t
ASDCP::KLVPacket::WriteKLToBuffer(ASDCP::FrameBuffer& Buffer, const UL& label, ui32_t length)
{
  assert(label.HasValue());

  if ( Buffer.Size() + kl_length > Buffer.Capacity() )
    {
      DefaultLogSink().Error("Small write buffer\n");
      return RESULT_FAIL;
    }
  
  memcpy(Buffer.Data() + Buffer.Size(), label.Value(), label.Size());

  if ( ! Kumu::write_BER(Buffer.Data() + Buffer.Size() + SMPTE_UL_LENGTH, length, MXF_BER_LENGTH) )
    return RESULT_FAIL;

  Buffer.Size(Buffer.Size() + kl_length);
  return RESULT_OK;
}