/**
 * 2nd part of the object initialization that must be callable during the
 * object's lifetime (not only on construction).
 */
void CContactCache::initPhaseTwo()
{
	PROTOACCOUNT*	acc = 0;

	m_szAccount = 0;
	if(m_szProto) {
		acc = reinterpret_cast<PROTOACCOUNT *>(::CallService(MS_PROTO_GETACCOUNT, (WPARAM)0, (LPARAM)m_szProto));
		if(acc && acc->tszAccountName)
			m_szAccount = acc->tszAccountName;
	}

	m_Valid = (m_szProto != 0 && m_szAccount != 0) ? true : false;
	if(m_Valid) {
		m_isMeta = (PluginConfig.bMetaEnabled && !strcmp(m_szProto, PluginConfig.szMetaName)) ? true : false;
		m_isSubcontact = (M->GetByte(m_hContact, PluginConfig.szMetaName, "IsSubcontact", 0) ? true : false);
		if(m_isMeta)
			updateMeta(true);
		updateState();
		updateFavorite();
	}
	else {
		m_szProto = C_INVALID_PROTO;
		m_tszProto = C_INVALID_PROTO_T;
		m_szAccount = C_INVALID_ACCOUNT;
		m_isMeta = false;
	}
}
Пример #2
0
bool Node::isWaypoint()
{
    if (!MetaUpToDate)
        updateMeta();

    return IsWaypoint;
}
Пример #3
0
bool RObject::updateStructure (RData *new_data) {
	RK_TRACE (OBJECTS);
	if (new_data->getDataLength () == 0) { // can happen, if the object no longer exists
		return false;
	}

	RK_ASSERT (new_data->getDataLength () >= 5);
	RK_ASSERT (new_data->getDataType () == RData::StructureVector);

	if (!canAccommodateStructure (new_data)) return false;

	bool properties_change = false;

	properties_change = updateName (new_data->getStructureVector ()[0]);
	properties_change = updateType (new_data->getStructureVector ()[1]);
	properties_change = updateClasses (new_data->getStructureVector ()[2]);
	properties_change = updateMeta (new_data->getStructureVector ()[3]);
	properties_change = updateDimensions (new_data->getStructureVector ()[4]);

	if (properties_change) RKGlobals::tracker ()->objectMetaChanged (this);
	if (type & NeedDataUpdate) updateDataFromR (0);
	if (isPending ()) type -= Pending;

	return true;
}
Пример #4
0
bool Node::isPOI()
{
    if (!MetaUpToDate)
        updateMeta();

    return IsPOI;
}
Пример #5
0
int eDVBMetaParser::parseRecordings(const std::string &filename)
{
	std::string::size_type slash = filename.rfind('/');
	if (slash == std::string::npos)
		return -1;
	
	std::string recordings = filename.substr(0, slash) + "/recordings.epl";
	
	FILE *f = fopen(recordings.c_str(), "r");
	if (!f)
	{
//		eDebug("no recordings.epl found: %s: %m", recordings.c_str());
		return -1;
	}
	
	std::string description;
	eServiceReferenceDVB ref;
	
//	eDebug("parsing recordings.epl..");
	
	while (1)
	{
		char line[1024];
		if (!fgets(line, 1024, f))
			break;
		
		size_t len = strlen(line);
		if (len < 2)
			// Lines with less than one char aren't meaningful
			continue;
		// Remove trailing \r\n
		--len;
		line[len] = 0;
		if (line[len-1] == '\r')
			line[len-1] = 0;
		
		if (strncmp(line, "#SERVICE: ", 10) == 0)
			ref = eServiceReferenceDVB(line + 10);
		else if (strncmp(line, "#DESCRIPTION: ", 14) == 0)
			description = line + 14;
		else if ((line[0] == '/') && (ref.path.substr(ref.path.find_last_of('/')) == filename.substr(filename.find_last_of('/'))))
		{
//			eDebug("hit! ref %s descr %s", m_ref.toString().c_str(), m_name.c_str());
			m_ref = ref;
			m_name = description;
			m_description = "";
			m_time_create = getctime(filename);
			m_length = 0;
			m_filesize = fileSize(filename);
			m_data_ok = 1;
			m_scrambled = 0;
			fclose(f);
			updateMeta(filename);
			return 0;
		}
	}
	fclose(f);
	return -1;
}
Пример #6
0
 ///\brief Builds a bootstrap for use in HTTP Dynamic streaming.
 ///\param tid The track this bootstrap is generated for.
 ///\return The generated bootstrap.
 std::string OutHDS::dynamicBootstrap(int tid){
   updateMeta();
   std::string empty;
   
   MP4::ASRT asrt;
   asrt.setUpdate(false);
   asrt.setVersion(1);
   //asrt.setQualityEntry(empty, 0);
   if (myMeta.live){
     asrt.setSegmentRun(1, 4294967295ul, 0);
   }else{
     asrt.setSegmentRun(1, myMeta.tracks[tid].fragments.size(), 0);
   }
   
   MP4::AFRT afrt;
   afrt.setUpdate(false);
   afrt.setVersion(1);
   afrt.setTimeScale(1000);
   //afrt.setQualityEntry(empty, 0);
   MP4::afrt_runtable afrtrun;
   int i = 0;
   int j = 0;
   if (myMeta.tracks[tid].fragments.size()){
     std::deque<DTSC::Fragment>::iterator fragIt = myMeta.tracks[tid].fragments.begin();
     unsigned int firstTime = myMeta.tracks[tid].getKey(fragIt->getNumber()).getTime();
     while (fragIt != myMeta.tracks[tid].fragments.end()){
       if (myMeta.vod || fragIt->getDuration() > 0){
         afrtrun.firstFragment = myMeta.tracks[tid].missedFrags + j + 1;
         afrtrun.firstTimestamp = myMeta.tracks[tid].getKey(fragIt->getNumber()).getTime() - firstTime;
         if (fragIt->getDuration() > 0){
           afrtrun.duration = fragIt->getDuration();
         }else{
           afrtrun.duration = myMeta.tracks[tid].lastms - afrtrun.firstTimestamp;
         }
         afrt.setFragmentRun(afrtrun, i);
         ++i;
       }
       ++j;
       ++fragIt;
     }
   }
   
   MP4::ABST abst;
   abst.setVersion(1);
   abst.setBootstrapinfoVersion(1);
   abst.setProfile(0);
   abst.setUpdate(false);
   abst.setTimeScale(1000);
   abst.setLive(myMeta.live);
   abst.setCurrentMediaTime(myMeta.tracks[tid].lastms);
   abst.setSmpteTimeCodeOffset(0);
   abst.setMovieIdentifier(streamName);
   abst.setSegmentRunTable(asrt, 0);
   abst.setFragmentRunTable(afrt, 0);
   
   DEBUG_MSG(DLVL_VERYHIGH, "Sending bootstrap: %s", abst.toPrettyString(0).c_str());
   return std::string((char*)abst.asBox(), (int)abst.boxedSize());
 }
Пример #7
0
int eDVBMetaParser::parseRecordings(const std::string &filename)
{
	std::string::size_type slash = filename.rfind('/');
	if (slash == std::string::npos)
		return -1;
	
	std::string recordings = filename.substr(0, slash) + "/recordings.epl";
	
	FILE *f = fopen(recordings.c_str(), "r");
	if (!f)
	{
//		eDebug("no recordings.epl found: %s: %m", recordings.c_str());
		return -1;
	}
	
	std::string description;
	eServiceReferenceDVB ref;
	
//	eDebug("parsing recordings.epl..");
	
	while (1)
	{
		char line[1024];
		if (!fgets(line, 1024, f))
			break;
		
		if (strlen(line))
			line[strlen(line)-1] = 0;
		
		if (strlen(line) && line[strlen(line)-1] == '\r')
			line[strlen(line)-1] = 0;
		
		if (!strncmp(line, "#SERVICE: ", 10))
			ref = eServiceReferenceDVB(line + 10);
		if (!strncmp(line, "#DESCRIPTION: ", 14))
			description = line + 14;
		if ((line[0] == '/') && (ref.path.substr(ref.path.find_last_of('/')) == filename.substr(filename.find_last_of('/'))))
		{
//			eDebug("hit! ref %s descr %s", m_ref.toString().c_str(), m_name.c_str());
			m_ref = ref;
			m_name = description;
			m_description = "";
			m_time_create = 0;
			m_length = 0;
			m_filesize = fileSize(filename);
						
			m_data_ok = 1;
			fclose(f);
			updateMeta(filename.c_str());
			return 0;
		}
	}
	fclose(f);
	return -1;
}
Пример #8
0
		inline void popMetaTag() {
			MetaProp &prop = metaProps.back();
			if (!prop.refines.empty()) {
				updateMeta(prop, prop.refines.substr(1));
				metaProps.pop_back();
			} else {
				if (!prop.id.empty()) {
					metaIds.emplace(prop.id, Vector<size_t>{metaProps.size() - 1});
				}
			}
		}
Пример #9
0
/**
 * 2nd part of the object initialization that must be callable during the
 * object's lifetime (not only on construction).
 */
void CContactCache::initPhaseTwo()
{
	m_szAccount = 0;
	if (cc->szProto) {
		PROTOACCOUNT *acc = Proto_GetAccount(cc->szProto);
		if (acc && acc->tszAccountName)
			m_szAccount = acc->tszAccountName;
	}

	m_Valid = (cc->szProto != 0 && m_szAccount != 0) ? true : false;
	if (m_Valid) {
		m_isMeta = db_mc_isMeta(cc->contactID) != 0; // don't use cc->IsMeta() here
		if (m_isMeta)
			updateMeta();
		updateState();
		updateFavorite();
	}
	else {
		m_szAccount = C_INVALID_ACCOUNT;
		m_isMeta = false;
	}
}
Пример #10
0
  void OutHDS::onHTTP(){

    if (H.url.find(".abst") != std::string::npos){
      initialize();
      std::string streamID = H.url.substr(streamName.size() + 10);
      streamID = streamID.substr(0, streamID.find(".abst"));
      H.Clean();
      H.SetBody(dynamicBootstrap(atoll(streamID.c_str())));
      H.SetHeader("Content-Type", "binary/octet");
      H.SetHeader("Cache-Control", "no-cache");
      H.SendResponse("200", "OK", myConn);
      H.Clean(); //clean for any possible next requests
      return;
    }
    if (H.url.find("f4m") == std::string::npos){
      initialize();
      std::string tmp_qual = H.url.substr(H.url.find("/", 10) + 1);
      unsigned int tid;
      unsigned int fragNum;
      tid = atoi(tmp_qual.substr(0, tmp_qual.find("Seg") - 1).c_str());
      int temp;
      temp = H.url.find("Seg") + 3;
      temp = H.url.find("Frag") + 4;
      fragNum = atoi(H.url.substr(temp).c_str()) - 1;
      DEBUG_MSG(DLVL_MEDIUM, "Video track %d, fragment %d\n", tid, fragNum);
      if (!audioTrack){getTracks();}
      unsigned int mstime = 0;
      unsigned int mslen = 0;
      if (fragNum < (unsigned int)myMeta.tracks[tid].missedFrags){
        H.Clean();
        H.SetBody("The requested fragment is no longer kept in memory on the server and cannot be served.\n");
        H.SendResponse("412", "Fragment out of range", myConn);
        H.Clean(); //clean for any possible next requests
        std::cout << "Fragment " << fragNum << " too old" << std::endl;
        return;
      }
      //delay if we don't have the next fragment available yet
      unsigned int timeout = 0;
      while (myConn && fragNum >= myMeta.tracks[tid].missedFrags + myMeta.tracks[tid].fragments.size() - 1){
        //time out after 21 seconds
        if (++timeout > 42){
          myConn.close();
          break;
        }
        Util::sleep(500);
        updateMeta();
      }
      mstime = myMeta.tracks[tid].getKey(myMeta.tracks[tid].fragments[fragNum - myMeta.tracks[tid].missedFrags].getNumber()).getTime();
      mslen = myMeta.tracks[tid].fragments[fragNum - myMeta.tracks[tid].missedFrags].getDuration();
      VERYHIGH_MSG("Playing from %llu for %llu ms", mstime, mslen);
      
      selectedTracks.clear();
      selectedTracks.insert(tid);
      if (audioTrack){
        selectedTracks.insert(audioTrack);
      }
      seek(mstime);
      playUntil = mstime + mslen;
      
      H.Clean();
      H.SetHeader("Content-Type", "video/mp4");
      H.StartResponse(H, myConn);
      //send the bootstrap
      std::string bootstrap = dynamicBootstrap(tid);
      H.Chunkify(bootstrap, myConn);
      //send a zero-size mdat, meaning it stretches until end of file.
      H.Chunkify("\000\000\000\000mdat", 8, myConn);
      //send init data, if needed.
      if (audioTrack > 0 && myMeta.tracks[audioTrack].init != ""){
        if (tag.DTSCAudioInit(myMeta.tracks[audioTrack])){
          tag.tagTime(mstime);
          H.Chunkify(tag.data, tag.len, myConn);
        }
      }
      if (tid > 0){
        if (tag.DTSCVideoInit(myMeta.tracks[tid])){
          tag.tagTime(mstime);
          H.Chunkify(tag.data, tag.len, myConn);
        }
      }
      parseData = true;
      wantRequest = false;
    }else{
      initialize();
      std::stringstream tmpstr;
      myMeta.toPrettyString(tmpstr);
      H.Clean();
      H.SetHeader("Content-Type", "text/xml");
      H.SetHeader("Cache-Control", "no-cache");
      H.SetBody(dynamicIndex());
      H.SendResponse("200", "OK", myConn);
    }
  }