Ejemplo n.º 1
0
bool CGraphmatFile :: LoadFileToGraphan (const string&  CommandLine)
{
    try
    {
        m_SourceFileName = CommandLine.c_str();
        m_GraFileName = MakeFName (m_SourceFileName,"gra");
        m_XmlMacSynName = MakeFName (m_SourceFileName,"xml");
        m_SaveTxtName = MakeFName (m_SourceFileName,"tds");

        if (IsHtmlFile(m_SourceFileName))
        {
            HTML Convert(m_SourceFileName);
            string Text = Convert.getText();

            if (!InitInputBuffer(Text))
            {
                m_LastError = Format("Cannot init inpur buffer for %i bytes", Text.length());
                return false;
            }

            if   (m_bSaveHtmlFileToTdsFile)
                WriteVector(m_SaveTxtName, GetInputBuffer());
        }
        else
        {
            if (access(m_SourceFileName.c_str(), 04) != 0) return  false;
            string Text;
            LoadFileToString(m_SourceFileName, Text);
            if (!InitInputBuffer(Text))
            {
                m_LastError = Format("Cannot init inpur buffer for %i bytes", Text.length());
                return false;
            };

        };



        return  GraphmatMain ();

    }
    catch (CExpc& C)
    {
        m_LastError = C.m_ErrorCode;
        return false;
    }
    catch (...)
    {
        m_LastError = "general exception";
        return false;
    };
};
Ejemplo n.º 2
0
bool CGraphmatFile::LoadStringToGraphan(const string& szBuffer)
{
    try {
        m_bWriteGraFile = false;
        m_bWriteXmlMacSyn = false;
        m_SaveTxtName = "";

        if (!InitInputBuffer(szBuffer))
        {
            m_LastError = Format("Cannot init inpur buffer for %i bytes", szBuffer.length());
            return false;
        };

        return GraphmatMain();
    }
    catch (CExpc& C)
    {
        m_LastError = C.m_ErrorCode;
        return false;
    }
    catch (...)
    {
        m_LastError = "general exception";
        return false;
    };
}
Ejemplo n.º 3
0
void
WidevineDecryptor::Decrypt(GMPBuffer* aBuffer,
                           GMPEncryptedBufferMetadata* aMetadata)
{
  if (!mCallback) {
    Log("WidevineDecryptor::Decrypt() this=%p FAIL; !mCallback", this);
    return;
  }
  const GMPEncryptedBufferMetadata* crypto = aMetadata;
  InputBuffer sample;
  nsTArray<SubsampleEntry> subsamples;
  InitInputBuffer(crypto, aBuffer->Id(), aBuffer->Data(), aBuffer->Size(), sample, subsamples);
  WidevineDecryptedBlock decrypted;
  Status rv = CDM()->Decrypt(sample, &decrypted);
  Log("Decryptor::Decrypt(timestamp=%lld) rv=%d sz=%d",
      sample.timestamp, rv, decrypted.DecryptedBuffer()->Size());
  if (rv == kSuccess) {
    aBuffer->Resize(decrypted.DecryptedBuffer()->Size());
    memcpy(aBuffer->Data(),
           decrypted.DecryptedBuffer()->Data(),
           decrypted.DecryptedBuffer()->Size());
  }
  mCallback->Decrypted(aBuffer, ToGMPErr(rv));
}
Ejemplo n.º 4
0
void
WidevineVideoDecoder::Decode(GMPVideoEncodedFrame* aInputFrame,
                             bool aMissingFrames,
                             const uint8_t* aCodecSpecificInfo,
                             uint32_t aCodecSpecificInfoLength,
                             int64_t aRenderTimeMs)
{
  // We should not be given new input if a drain has been initiated
  MOZ_ASSERT(!mDrainPending);
  // We may not get the same out of the CDM decoder as we put in, and there
  // may be some latency, i.e. we may need to input (say) 30 frames before
  // we receive output. So we need to store the durations of the frames input,
  // and retrieve them on output.
  mFrameDurations[aInputFrame->TimeStamp()] = aInputFrame->Duration();

  mSentInput = true;
  InputBuffer sample;

  RefPtr<MediaRawData> raw(new MediaRawData(aInputFrame->Buffer(), aInputFrame->Size()));
  raw->mExtraData = mExtraData;
  raw->mKeyframe = (aInputFrame->FrameType() == kGMPKeyFrame);
  // Convert input from AVCC, which GMPAPI passes in, to AnnexB, which
  // Chromium uses internally.
  mp4_demuxer::AnnexB::ConvertSampleToAnnexB(raw);

  const GMPEncryptedBufferMetadata* crypto = aInputFrame->GetDecryptionData();
  nsTArray<SubsampleEntry> subsamples;
  InitInputBuffer(crypto, aInputFrame->TimeStamp(), raw->Data(), raw->Size(), sample, subsamples);

  // For keyframes, ConvertSampleToAnnexB will stick the AnnexB extra data
  // at the start of the input. So we need to account for that as clear data
  // in the subsamples.
  if (raw->mKeyframe && !subsamples.IsEmpty()) {
    subsamples[0].clear_bytes += mAnnexB->Length();
  }

  WidevineVideoFrame frame;
  Status rv = CDM()->DecryptAndDecodeFrame(sample, &frame);
  Log("WidevineVideoDecoder::Decode(timestamp=%lld) rv=%d", sample.timestamp, rv);

  // Destroy frame, so that the shmem is now free to be used to return
  // output to the Gecko process.
  aInputFrame->Destroy();
  aInputFrame = nullptr;

  if (rv == kSuccess) {
    if (!ReturnOutput(frame)) {
      Log("WidevineVideoDecoder::Decode() Failed in ReturnOutput()");
      mCallback->Error(GMPDecodeErr);
      return;
    }
    // A reset should only be started at most at level mReturnOutputCallDepth 1,
    // and if it's started it should be finished by that call by the time
    // the it returns, so it should always be false by this point.
    MOZ_ASSERT(!mResetInProgress);
    // Only request more data if we don't have pending samples.
    if (mFrameAllocationQueue.empty()) {
      MOZ_ASSERT(mCDMWrapper);
      mCallback->InputDataExhausted();
    }
  } else if (rv == kNeedMoreData) {
    MOZ_ASSERT(mCDMWrapper);
    mCallback->InputDataExhausted();
  } else {
    mCallback->Error(ToGMPErr(rv));
  }
  // Finish a drain if pending and we have no pending ReturnOutput calls on the stack.
  if (mDrainPending && mReturnOutputCallDepth == 0) {
    Drain();
  }
}