MediaAlbumArt *StagefrightMetadataRetriever::extractAlbumArt() { LOGV("extractAlbumArt (extractor: %s)", mExtractor.get() != NULL ? "YES" : "NO"); if (0 == (mMode & METADATA_MODE_METADATA_RETRIEVAL_ONLY)) { LOGV("extractAlbumArt/metadata retrieval disabled by mode"); return NULL; } if (mExtractor == NULL) { return NULL; } if (!mParsedMetaData) { parseMetaData(); mParsedMetaData = true; } if (mAlbumArt) { return new MediaAlbumArt(*mAlbumArt); } return NULL; }
//************************************************************************************************* //! Parses a tagged TIFF image file for RPC info. Returns TRUE if successful. //************************************************************************************************* bool rspfQuickbirdRpcModel::parseTiffFile(const rspfFilename& file) { setErrorStatus(); // Make the gsd nan so it gets computed. theGSD.makeNan(); rspfFilename tiffFile = file; rspfRefPtr<rspfTiffTileSource> tiff = new rspfTiffTileSource(); if (!tiff->open(file)) { return false; } theImageClipRect = tiff->getImageRectangle(); parseMetaData(file); if (!parseRpcData(file)) return false; if (!parseTileData(file)) return false; finishConstruction(); clearErrorStatus(); return true; }
const char *StagefrightMetadataRetriever::extractMetadata(int keyCode) { if (0 == (mMode & METADATA_MODE_METADATA_RETRIEVAL_ONLY)) { LOGV("extractAlbumArt/metadata retrieval disabled by mode"); return NULL; } if (mExtractor == NULL) { return NULL; } if (!mParsedMetaData) { parseMetaData(); mParsedMetaData = true; } ssize_t index = mMetaData.indexOfKey(keyCode); if (index < 0) { return NULL; } return strdup(mMetaData.valueAt(index).string()); }
bool ossimQuickbirdMetaData::open(const ossimFilename& imageFile) { static const char MODULE[] = "ossimQuickbirdMetaData::open"; clearFields(); //retrieve information from the metadata file //if the Quickbird tif is 02APR01105228-M1BS-000000128955_01_P001.TIF //the metadata file will be 02APR01105228-M1BS-000000128955_01_P001.IMD ossimFilename metadatafile = imageFile; metadatafile.setExtension(ossimString("IMD")); if( parseMetaData(metadatafile) == false ) { if(traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " errors parsing metadata" << std::endl; } return false; } return true; }
bool FEMemoryMetaData::loadMetaDataFromFile(QString filestr) { qDebug() << "Loading config file from:" << filestr; QFile file(filestr); if (!file.open(QIODevice::ReadOnly)) { return false; //Can't open the file. } QByteArray filebytes = file.readAll(); qDebug() << "Loaded:" << filebytes.size() << "chars from config file"; file.close(); return parseMetaData(filebytes); }
bool FEMemoryMetaData::loadMetaDataFromFile(QString filestr) { qDebug() << "Loading config file from:" << filestr; QFile file(filestr); if (!file.open(QIODevice::ReadOnly)) { //QMessageBox::information(0,"Error","Error opening config file: " + file.errorString()); return false; //Can't open the file. } QByteArray filebytes = file.readAll(); qDebug() << "Loaded:" << filebytes.size() << "chars from config file"; file.close(); return parseMetaData(filebytes); }
const char *StagefrightMetadataRetriever::extractMetadata(int keyCode) { if (mExtractor == NULL) { return NULL; } if (!mParsedMetaData) { parseMetaData(); mParsedMetaData = true; } ssize_t index = mMetaData.indexOfKey(keyCode); if (index < 0) { return NULL; } return mMetaData.valueAt(index).string(); }
MediaAlbumArt *StagefrightMetadataRetriever::extractAlbumArt() { ALOGV("extractAlbumArt (extractor: %s)", mExtractor.get() != NULL ? "YES" : "NO"); if (mExtractor == NULL) { return NULL; } if (!mParsedMetaData) { parseMetaData(); mParsedMetaData = true; } if (mAlbumArt) { return new MediaAlbumArt(*mAlbumArt); } return NULL; }
//***************************************************************************** // CONSTRUCTOR: ossimIkonosRpcModel // // Constructs given filenames for metadata and RPC data. // //***************************************************************************** ossimIkonosRpcModel::ossimIkonosRpcModel(const ossimFilename& metadata, const ossimFilename& rpcdata) : ossimRpcModel(), theSupportData(0) { if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel Constructor #2: entering..." << std::endl; theSupportData = new ossimIkonosMetaData(); parseMetaData(metadata); parseRpcData (rpcdata); finishConstruction(); //*** // Save current state in RPC model format: //*** ossimString drivePart; ossimString pathPart; ossimString filePart; ossimString extPart; metadata.split(drivePart, pathPart, filePart, extPart); ossimFilename init_rpc_geom; init_rpc_geom.merge(drivePart, pathPart, INIT_RPC_GEOM_FILENAME, ""); // (metadata.path().dirCat(ossimRpcModel::INIT_RPC_GEOM_FILENAME)); ossimKeywordlist kwl (init_rpc_geom); saveState(kwl); if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel Constructor #2: returning..." << std::endl; }
status_t M3UParser::parse(const void *_data, size_t size) { int32_t lineNo = 0; sp<AMessage> itemMeta; const char *data = (const char *)_data; size_t offset = 0; while (offset < size) { size_t offsetLF = offset; while (offsetLF < size && data[offsetLF] != '\n') { ++offsetLF; } if (offsetLF >= size) { break; } AString line; if (offsetLF > offset && data[offsetLF - 1] == '\r') { line.setTo(&data[offset], offsetLF - offset - 1); } else { line.setTo(&data[offset], offsetLF - offset); } // LOGI("#%s#", line.c_str()); if (line.empty()) { offset = offsetLF + 1; continue; } if (lineNo == 0 && line == "#EXTM3U") { mIsExtM3U = true; } if (mIsExtM3U) { status_t err = OK; if (line.startsWith("#EXT-X-TARGETDURATION")) { if (mIsVariantPlaylist) { return ERROR_MALFORMED; } err = parseMetaData(line, &mMeta, "target-duration"); } else if (line.startsWith("#EXT-X-MEDIA-SEQUENCE")) { if (mIsVariantPlaylist) { return ERROR_MALFORMED; } err = parseMetaData(line, &mMeta, "media-sequence"); } else if (line.startsWith("#EXT-X-ENDLIST")) { mIsComplete = true; } else if (line.startsWith("#EXTINF")) { if (mIsVariantPlaylist) { return ERROR_MALFORMED; } err = parseMetaData(line, &itemMeta, "duration"); } else if (line.startsWith("#EXT-X-DISCONTINUITY")) { if (mIsVariantPlaylist) { return ERROR_MALFORMED; } if (itemMeta == NULL) { itemMeta = new AMessage; } itemMeta->setInt32("discontinuity", true); } else if (line.startsWith("#EXT-X-STREAM-INF")) { if (mMeta != NULL) { return ERROR_MALFORMED; } mIsVariantPlaylist = true; err = parseStreamInf(line, &itemMeta); } if (err != OK) { return err; } } if (!line.startsWith("#")) { if (!mIsVariantPlaylist) { int32_t durationSecs; if (itemMeta == NULL || !itemMeta->findInt32("duration", &durationSecs)) { return ERROR_MALFORMED; } } mItems.push(); Item *item = &mItems.editItemAt(mItems.size() - 1); CHECK(MakeURL(mBaseURI.c_str(), line.c_str(), &item->mURI)); item->mMeta = itemMeta; itemMeta.clear(); } offset = offsetLF + 1; ++lineNo; } return OK; }
//************************************************************************************************* //! Parses a NITF image file for RPC info. Returns TRUE if successful. //************************************************************************************************* bool rspfQuickbirdRpcModel::parseNitfFile(const rspfFilename& file) { setErrorStatus(); rspfFilename nitfFile = file; rspfRefPtr<rspfNitfFile> nitfFilePtr = new rspfNitfFile; if(!nitfFilePtr->parseFile(nitfFile)) { nitfFile = nitfFile.setExtension("NTF"); if(!nitfFilePtr->parseFile(nitfFile)) { nitfFile = nitfFile.setExtension("ntf"); if(!nitfFilePtr->parseFile(nitfFile)) return false; } } rspfRefPtr<rspfNitfImageHeader> ih = nitfFilePtr->getNewImageHeader(0); if (!ih) return false; theImageClipRect = ih->getImageRect(); // Give preference to external RPC data file: bool useInternalRpcTags = false; if(!parseRpcData(file)) useInternalRpcTags = true; if (!parseTileData(file)) return false; // Check for IMD (metadata) file: parseMetaData(file); // Get the gsd. theGSD.line = rspf::nan(); theGSD.samp = rspf::nan(); rspfRefPtr<rspfNitfRegisteredTag> tag; tag = ih->getTagData(PIAIMC_TAG); if (tag.valid()) { rspfNitfPiaimcTag* p = PTR_CAST(rspfNitfPiaimcTag, tag.get()); if (p) { theGSD.line = p->getMeanGsdInMeters(); theGSD.samp = theGSD.line; } } if (rspf::isnan(theGSD.line)) { tag = ih->getTagData(USE00A_TAG); if (tag.valid()) { rspfNitfUse00aTag* p = PTR_CAST(rspfNitfUse00aTag, tag.get()); if (p) { theGSD.line = p->getMeanGsdInMeters(); theGSD.samp = theGSD.line; } } } // If external RPC data file was correctly parsed, then we can bypass this code block. Otherwise // need to parse internal NITF tags for RPC data: if (useInternalRpcTags) { // Get the the RPC tag: rspfNitfRpcBase* rpcTag = NULL; // Look for the RPC00B tag first. tag = ih->getTagData(RPC00B_TAG); if (tag.valid()) rpcTag = PTR_CAST(rspfNitfRpcBase, tag.get()); if (!tag.valid()) { // Look for RPC00A tag. tag = ih->getTagData(RPC00A_TAG); if (tag.valid()) rpcTag = PTR_CAST(rspfNitfRpcBase, tag.get()); } if (!rpcTag) return false; // Set the polynomial type. if (rpcTag->getRegisterTagName() == "RPC00B") thePolyType = B; else thePolyType = A; // Parse coefficients: for (rspf_uint32 i=0; i<20; ++i) { theLineNumCoef[i] = rpcTag->getLineNumeratorCoeff(i).toFloat64(); theLineDenCoef[i] = rpcTag->getLineDenominatorCoeff(i).toFloat64(); theSampNumCoef[i] = rpcTag->getSampleNumeratorCoeff(i).toFloat64(); theSampDenCoef[i] = rpcTag->getSampleDenominatorCoeff(i).toFloat64(); } // Initialize other items in tags: theLineScale = rpcTag->getLineScale().toFloat64(); theSampScale = rpcTag->getSampleScale().toFloat64(); theLatScale = rpcTag->getGeodeticLatScale().toFloat64(); theLonScale = rpcTag->getGeodeticLonScale().toFloat64(); theHgtScale = rpcTag->getGeodeticHeightScale().toFloat64(); theLineOffset = rpcTag->getLineOffset().toFloat64(); theSampOffset = rpcTag->getSampleOffset().toFloat64(); theLatOffset = rpcTag->getGeodeticLatOffset().toFloat64(); theLonOffset = rpcTag->getGeodeticLonOffset().toFloat64(); theHgtOffset = rpcTag->getGeodeticHeightOffset().toFloat64(); theImageID = ih->getImageId(); } finishConstruction(); clearErrorStatus(); return true; }
uint8_t flvHeader::open(const char *name) { uint32_t prevLen, type, size, pts,pos=0; _isvideopresent=0; _isaudiopresent=0; audioTrack=NULL; videoTrack=NULL; _videostream.dwRate=0; _filename=ADM_strdup(name); _fd=fopen(name,"rb"); if(!_fd) { printf("[FLV] Cannot open %s\n",name); return 0; } // Get size uint32_t fileSize=0; fseeko(_fd,0,SEEK_END); fileSize=ftello(_fd); fseeko(_fd,0,SEEK_SET); printf("[FLV] file size :%u bytes\n",fileSize); // It must begin by F L V 01 uint8_t four[4]; read(4,four); if(four[0]!='F' || four[1]!='L' || four[2]!='V') { printf("[FLV] Not a flv file %s\n",name); return 0; } // Next one is flags uint32_t flags=read8(); if(flags & 1) // VIDEO { _isvideopresent=1; printf("[FLV] Video flag\n"); } else { GUI_Info_HIG(ADM_LOG_INFO,"Warning","This FLV file says it has no video.\nI will assume it has and try to continue"); _isvideopresent=1; } if(flags & 4) // Audio { _isaudiopresent=1; printf("[FLV] Audio flag\n"); } // Skip header uint32_t skip=read32(); fseeko(_fd,skip,SEEK_SET); printf("[FLV] Skipping %u header bytes\n",skip); pos=ftello(_fd);; printf("pos:%u/%u\n",pos,fileSize); // Create our video index videoTrack=new flvTrak(50); if(_isaudiopresent) audioTrack=new flvTrak(50); else audioTrack=NULL; // Loop while(pos<fileSize-14) { pos=ftello(_fd); prevLen=read32(); type=read8(); size=read24(); pts=read24(); read32(); // ??? uint32_t remaining=size; //printf("[FLV] At %08x found type %x size %u pts%u\n",pos,type,size,pts); switch(type) { case FLV_TAG_TYPE_AUDIO: { if(!_isaudiopresent) { audioTrack=new flvTrak(50); _isaudiopresent=1; /* Damn lying headers...*/ }; uint8_t flags=read8(); int of=1+4+3+3+1+4; remaining--; int format=flags>>4; int fq=(flags>>2)&3; int bps=(flags>>1) & 1; int channel=(flags) & 1; if(!audioTrack->_nbIndex) // first frame.. { setAudioHeader(format,fq,bps,channel); } insertAudio(pos+of,remaining,pts); } break; case FLV_TAG_TYPE_META: parseMetaData(remaining); remaining=0; break; case FLV_TAG_TYPE_VIDEO: { int of=1+4+3+3+1+4; uint8_t flags=read8(); remaining--; int frameType=flags>>4; int codec=(flags)&0xf; if(codec==FLV_CODECID_VP6) { read8(); // 1 byte of extraData remaining--; of++; } int first=0; if(!videoTrack->_nbIndex) first=1; insertVideo(pos+of,remaining,frameType,pts); if(first) // first frame.. { if(!setVideoHeader(codec,&remaining)) return 0; } } break; default: printf("[FLV]At 0x%x, unhandled type %u\n",pos,type); } Skip(remaining); } // while // Udpate frame count etc.. printf("[FLV] Found %u frames\n",videoTrack->_nbIndex); _videostream.dwLength= _mainaviheader.dwTotalFrames=videoTrack->_nbIndex; // Compute average fps float f=_videostream.dwLength; uint64_t duration=videoTrack->_index[videoTrack->_nbIndex-1].timeCodeUs; if(duration) f=1000.*1000.*1000.*f/duration; else f=25000; // If it was available from the metadata, use the one from metadata if(! _videostream.dwRate) { float d=searchMinimum(); printf("[FLV] minimum delta :%d\n",(uint32_t)d); d=1/d; d*=1000*1000*1000; uint32_t avg=(uint32_t)floor(f); uint32_t max=(uint32_t)floor(d); if(max<2) max=2; // 500 fps max printf("[FLV] Avg fps :%d, max fps :%d\n",avg,max); _videostream.dwRate=max; } _videostream.dwScale=1000; _mainaviheader.dwMicroSecPerFrame=ADM_UsecFromFps1000(_videostream.dwRate); printf("[FLV] Duration %"LLU" ms\n",videoTrack->_index[videoTrack->_nbIndex-1].timeCodeUs/1000); // _videostream.fccType=fourCC::get((uint8_t *)"vids"); _video_bih.biBitCount=24; _videostream.dwInitialFrames= 0; _videostream.dwStart= 0; videoTrack->_index[0].flags=AVI_KEY_FRAME; // audio track if(_isaudiopresent) { ADM_flvAccess *access=new ADM_flvAccess(name,audioTrack); _audioStream=ADM_audioCreateStream(&wavHeader,access); } else { _audioStream = NULL; access=NULL; } printf("[FLV]FLV successfully read\n"); return 1; }
//***************************************************************************** // CONSTRUCTOR: ossimIkonosRpcModel // // Constructs given a geometry file that specifies the filenames for the // metadata and RPC data files. // //***************************************************************************** ossimIkonosRpcModel::ossimIkonosRpcModel(const ossimFilename& geom_file) : ossimRpcModel(), theSupportData(0) { if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel Constructor #1: entering..." << std::endl; } theSupportData = new ossimIkonosMetaData(); ossimKeywordlist kwl(geom_file); const char* value; //*** // Assure this keywordlist contains correct type info: //*** value = kwl.find(ossimKeywordNames::TYPE_KW); if (!value || (strcmp(value, "ossimIkonosRpcModel"))) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel Constructor #1:" << "\nFailed attempt to construct. sensor type \""<<value << "\" does not match \"ossimIkonosRpcModel\"." << std::endl; } theErrorStatus++; if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel Constructor #1: returning..." << std::endl; } return; } //*** // Read meta data filename from geom file: //*** value = kwl.find(META_DATA_FILE); if (!value) { theErrorStatus++; if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel Constructor #1: returning..." << std::endl; } return; } ossimFilename metadata (value); //*** // Read RPC data filename from geom file: //*** value = kwl.find(RPC_DATA_FILE); if (!value) { theErrorStatus++; if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel Constructor #1: returning..." << std::endl; return; } ossimFilename rpcdata (value); parseMetaData(metadata); parseRpcData (rpcdata); finishConstruction(); ossimString drivePart; ossimString pathPart; ossimString filePart; ossimString extPart; geom_file.split(drivePart, pathPart, filePart, extPart); if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG returning..." << std::endl; return; }
int countwords_HTML(SWISH *sw, FileProp *fprop, FileRec *fi, char *buffer) { int ftotalwords; int *metaID; int metaIDlen; int position; /* Position of word in file */ int currentmetanames; char *p, *newp, *tag, *endtag; int structure; FileRec *thisFileEntry = fi; struct metaEntry *metaNameEntry; IndexFILE *indexf = sw->indexlist; struct MOD_Index *idx = sw->Index; char *Content = NULL, *Name = NULL, *summary = NULL; char *title = (char *)sw_ConvHTMLEntities2ISO(sw, (unsigned char *)parseHTMLtitle(sw, buffer)); if (!isoktitle(sw, title)) return -2; if (fprop->stordesc) summary = parseHtmlSummary(buffer, fprop->stordesc->field, fprop->stordesc->size, sw); addCommonProperties( sw, fprop, fi, title, summary, 0 ); /* Init meta info */ metaID = (int *) Mem_ZoneAlloc(sw->Index->perDocTmpZone,(metaIDlen = 16) * sizeof(int)); currentmetanames = 0; ftotalwords = 0; structure = IN_FILE; metaID[0] = 1; position = 1; for (p = buffer; p && *p;) { /* Look for non escaped '<' */ if ((tag = strchr(p, '<')) && ((tag == p) || (*(tag - 1) != '\\'))) { /* Index up to the tag */ *tag++ = '\0'; newp = (char *)sw_ConvHTMLEntities2ISO(sw, (unsigned char *)p); if ( ! currentmetanames ) currentmetanames++; ftotalwords += indexstring(sw, newp, idx->filenum, structure, currentmetanames, metaID, &position); /* Now let us look for a not escaped '>' */ for (endtag = tag;;) if ((endtag = strchr(endtag, '>'))) { if (*(endtag - 1) != '\\') break; else endtag++; } else break; if (endtag) { *endtag++ = '\0'; if ((tag[0] == '!') && lstrstr(tag, "META") && (lstrstr(tag, "START") || lstrstr(tag, "END"))) { /* Check for META TAG TYPE 1 */ structure |= IN_META; if (lstrstr(tag, "START")) { char *parsed_tag; if ( (metaNameEntry = getHTMLMeta(indexf, tag, sw, NULL, &parsed_tag, fprop->real_path))) { /* realloc memory if needed */ if (currentmetanames == metaIDlen) { int *newbuf = (int *)Mem_ZoneAlloc(sw->Index->perDocTmpZone, metaIDlen * 2 * sizeof(int)); memcpy((char *)newbuf,(char *)metaID,metaIDlen * sizeof(int)); metaID = newbuf; metaIDlen *= 2; } /* add metaname to array of current metanames */ metaID[currentmetanames] = metaNameEntry->metaID; /* Bump position for all metanames unless metaname in dontbumppositionOnmetatags */ if (!isDontBumpMetaName(sw->dontbumpstarttagslist, metaNameEntry->metaName)) position++; currentmetanames++; p = endtag; /* If it is also a property store it until a < is found */ if ((metaNameEntry = getPropNameByName(&indexf->header, parsed_tag))) { if ((endtag = strchr(p, '<'))) *endtag = '\0'; p = (char *)sw_ConvHTMLEntities2ISO(sw, (unsigned char *)p); remove_newlines(p); /** why isn't this just done for the entire doc? */ if (!addDocProperty(&thisFileEntry->docProperties, metaNameEntry, (unsigned char *)p, strlen(p), 0)) progwarn("property '%s' not added for document '%s'\n", metaNameEntry->metaName, fprop->real_path); if (endtag) *endtag = '<'; continue; } } } else if (lstrstr(tag, "END")) { /* this will close the last metaname */ if (currentmetanames) { currentmetanames--; if (!currentmetanames) metaID[0] = 1; } } p = endtag; } /* Check for META TAG TYPE 2 */ else if ((tag[0] != '!') && lstrstr(tag, "META") && (Name = lstrstr(tag, "NAME")) && (Content = lstrstr(tag, "CONTENT"))) { ftotalwords += parseMetaData(sw, indexf, tag, idx->filenum, structure, Name, Content, thisFileEntry, &position, fprop->real_path); p = endtag; } /* Check for COMMENT */ else if ((tag[0] == '!') && sw->indexComments) { ftotalwords += parsecomment(sw, tag, idx->filenum, structure, 1, &position); p = endtag; } /* Default: Continue */ else { structure = getstructure(tag, structure); p = endtag; } } else p = tag; /* tag not closed: continue */ } else { /* No more '<' */ newp = (char *)sw_ConvHTMLEntities2ISO(sw, (unsigned char *)p); if ( ! currentmetanames ) currentmetanames++; ftotalwords += indexstring(sw, newp, idx->filenum, structure, currentmetanames, metaID, &position); p = NULL; } } return ftotalwords; }