PVMFStatus PVAMRFFRecognizerPlugin::Recognize(PVMFDataStreamFactory& aSourceDataStreamFactory, PVMFRecognizerMIMEStringList* aFormatHint,
        Oscl_Vector<PVMFRecognizerResult, OsclMemAllocator>& aRecognizerResult)
{
    OSCL_UNUSED_ARG(aFormatHint);
    OSCL_wHeapString<OsclMemAllocator> tmpfilename;
    Oscl_FileServer fileServ;
    PVFile pvfile;
    pvfile.SetCPM(&aSourceDataStreamFactory);

    if (!(pvfile.Open(tmpfilename.get_cstr(), Oscl_File::MODE_READ | Oscl_File::MODE_BINARY, fileServ)))
    {
        char* readData = NULL;

        readData = (char*)(oscl_malloc(sizeof(char) * AMRFF_MIN_DATA_SIZE_FOR_RECOGNITION));
        if (readData != NULL)
        {
            int bytesRead = 0;
            bytesRead = pvfile.Read(readData, sizeof(char), AMRFF_MIN_DATA_SIZE_FOR_RECOGNITION);
            if (bytesRead != AMRFF_MIN_DATA_SIZE_FOR_RECOGNITION)
            {
                pvfile.Close();
                oscl_free(readData);
                return PVMFFailure;
            }
            if (readData[0] == '#' && readData[1] == '!' && readData[2] == 'A' && readData[3] == 'M' && readData[4] == 'R')
            {
                PVMFRecognizerResult result;
                result.iRecognizedFormat = PVMF_MIME_AMRFF;
                result.iRecognitionConfidence = PVMFRecognizerConfidenceCertain;
                aRecognizerResult.push_back(result);
            }
        }
        pvfile.Close();
        oscl_free(readData);
        return PVMFFailure;
    }
    else
    {
        return PVMFFailure;
    }
    return PVMFSuccess;
}
コード例 #2
0
static int fill_buffer(stream_t *s, char* buffer, int max_len){
  PVFile*    ipFilePtr = (PVFile*)(s->fd);    
  int size;
  MPFileParser *parser = (MPFileParser *)s->Context;
  AVSyncLock *pParserLock = parser->GetParserLock();
#if 1
  if(pParserLock)
  {
	  AVUNLOCK_REQ(pParserLock);
	  //LOGE("pParserLock lock isLock = %d",pParserLock->isLock);
  }
#endif

  size = ipFilePtr->Read(buffer, 1, max_len);
#if 1
  if(pParserLock)
  {
	  // LOGE("pParserLock unlock isLock = %d",pParserLock->isLock);
	  AVLOCK_REQ(pParserLock);
  }
#endif
  return size;

}