Exemplo n.º 1
0
 void inputFLV::getNext(bool smart) {
   static JSON::Value thisPack;
   static AMF::Object amf_storage;
   thisPack.null();
   long long int lastBytePos = ftell(inFile);
   FLV::Tag tmpTag;
   while (!feof(inFile) && !FLV::Parse_Error){
     if (tmpTag.FileLoader(inFile)){
       thisPack = tmpTag.toJSON(myMeta, amf_storage);
       thisPack["bpos"] = lastBytePos;
       if ( !selectedTracks.count(thisPack["trackid"].asInt())){
         getNext();
       }
       break;
     }
   }
   if (FLV::Parse_Error){
     FAIL_MSG("FLV error: %s", FLV::Error_Str.c_str());
     thisPack.null();
     thisPacket.null();
     return;
   }
   std::string tmpStr = thisPack.toNetPacked();
   thisPacket.reInit(tmpStr.data(), tmpStr.size());
 }
Exemplo n.º 2
0
 bool inputFLV::readHeader() {
   JSON::Value lastPack;
   if (!inFile) {
     return false;
   }
   //See whether a separate header file exists.
   DTSC::File tmp(config->getString("input") + ".dtsh");
   if (tmp){
     myMeta = tmp.getMeta();
     return true;
   }
   //Create header file from FLV data
   fseek(inFile, 13, SEEK_SET);
   FLV::Tag tmpTag;
   long long int lastBytePos = 13;
   while (!feof(inFile) && !FLV::Parse_Error){
     if (tmpTag.FileLoader(inFile)){
       lastPack.null();
       lastPack = tmpTag.toJSON(myMeta);
       lastPack["bpos"] = lastBytePos;
       myMeta.update(lastPack);
       lastBytePos = ftell(inFile);
     }
   }
   if (FLV::Parse_Error){
     std::cerr << FLV::Error_Str << std::endl;
     return false;
   }
   std::ofstream oFile(std::string(config->getString("input") + ".dtsh").c_str());
   oFile << myMeta.toJSON().toNetPacked();
   oFile.close();
   return true;
 }
Exemplo n.º 3
0
 void inputFLV::getNext(bool smart) {
   static JSON::Value thisPack;
   thisPack.null();
   long long int lastBytePos = ftell(inFile);
   FLV::Tag tmpTag;
   while (!feof(inFile) && !FLV::Parse_Error){
     if (tmpTag.FileLoader(inFile)){
       thisPack = tmpTag.toJSON(myMeta);
       thisPack["bpos"] = lastBytePos;
       if ( !selectedTracks.count(thisPack["trackid"].asInt())){
         getNext();
       }
       break;
     }
   }
   if (FLV::Parse_Error){
     std::cerr << FLV::Error_Str << std::endl;
     thisPack.null();
     lastPack.null();
     return;
   }
   std::string tmpStr = thisPack.toNetPacked();
   lastPack.reInit(tmpStr.data(), tmpStr.size());
 }