本文整理汇总了C++中Name::appendSegment方法的典型用法代码示例。如果您正苦于以下问题:C++ Name::appendSegment方法的具体用法?C++ Name::appendSegment怎么用?C++ Name::appendSegment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Name
的用法示例。
在下文中一共展示了Name::appendSegment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Name
NamespaceInfo::getSuffix(int filter) const
{
using namespace suffix_filter;
Name suffix;
if (filter)
{
if (filter&(Library^Stream))
suffix.append(Name(NameComponents::NameComponentApp)).appendVersion(apiVersion_);
if (filter&(Stream^Thread))
{
suffix.append((streamType_ == MediaStreamParams::MediaStreamType::MediaStreamTypeAudio ?
NameComponents::NameComponentAudio : NameComponents::NameComponentVideo)).append(streamName_);
if (threadName_ != "")
suffix.appendTimestamp(streamTimestamp_);
}
if (filter&(Thread^Sample) && threadName_ != "")
suffix.append(threadName_);
if (isMeta_)
{
if ((filter&(Thread^Sample) && threadName_ != "") ||
filter&(Stream^Thread))
suffix.append(NameComponents::NameComponentMeta);
}
if (filter&(Thread^Sample) && threadName_ != "" &&
streamType_ == MediaStreamParams::MediaStreamType::MediaStreamTypeVideo &&
!isMeta_)
suffix.append((class_ == SampleClass::Delta ? NameComponents::NameComponentDelta : NameComponents::NameComponentKey));
if (filter&(Sample^Segment))
{
if (isMeta_)
suffix.appendVersion(metaVersion_);
else
suffix.appendSequenceNumber(sampleNo_);
}
if (filter&(Segment) && hasSegNo_)
{
if (isParity_)
suffix.append(NameComponents::NameComponentParity);
suffix.appendSegment(segNo_);
}
}
return suffix;
}
示例2: fin
NdnServer(std::string fileName, size_t segSize, size_t contentsize, int signORnot){
using namespace std;
isSign = signORnot;
ifstream fin(fileName.c_str(), fstream::binary);
fin.seekg(0, fin.end);
m_FileSize = fin.tellg();
fin.seekg(0, fin.beg);
fin.read(fileBuffer, m_FileSize);
fin.close();
m_SegmentSize = segSize * 1024;
m_ContentSize = contentsize * 1024;
m_TotalPacketNum = m_FileSize / m_ContentSize + 1;
cout << "Finish reading file\n";
std::cout << "Total file size:\t" << m_FileSize << std::endl ;
std::cout << "m_SegmentSize is:\t" << m_SegmentSize << std::endl ;
std::cout << "m_TotalSegNum is:\t" << m_FileSize / m_SegmentSize + 1 << std::endl ;
std::cout << "m_ContentSize is:\t" << m_ContentSize << std::endl ;
std::cout << "Total packet num is:\t" << m_FileSize / m_ContentSize + 1 << std::endl ;
timeval start, end;
gettimeofday(&start, 0);
for(int id = 0;id < m_TotalPacketNum; id++){
Name fileName = Name("askfile");
fileName.appendNumber(xxx);
fileName.appendSegment(1024);
fileName.appendSegmentOffset(id);
shared_ptr<Data> data = make_shared<Data>(fileName);
if(isSign == 1)
m_keyChain.sign(*data);
else
m_keyChain.signWithSha256(*data);
m_store.push_back(data);
if(id == m_TotalPacketNum - 1)
std::cout <<"Finish signing last datapacket\n";
}
gettimeofday(&end, 0);
double totalTime =(1000000.0 * (end.tv_sec - start.tv_sec) + end.tv_usec - start.tv_usec ) / 1000000;
std::cout << "Signing cost is:\t" << totalTime <<" s" << std::endl;
};
示例3: interest
void
WriteHandle::segInit(ProcessId processId, const RepoCommandParameter& parameter)
{
// use SegmentFetcher to send fetch interest.
ProcessInfo& process = m_processes[processId];
Name name = parameter.getName();
SegmentNo startBlockId = parameter.getStartBlockId();
uint64_t initialCredit = m_credit;
if (parameter.hasEndBlockId()) {
initialCredit =
std::min(initialCredit, parameter.getEndBlockId() - parameter.getStartBlockId() + 1);
}
else {
// set noEndTimeout timer
process.noEndTime = ndn::time::steady_clock::now() +
m_noEndTimeout;
}
Name fetchName = name;
SegmentNo segment = startBlockId;
fetchName.appendSegment(segment);
Interest interest(fetchName);
ndn::util::SegmentFetcher::Options options;
options.initCwnd = initialCredit;
options.interestLifetime = m_interestLifetime;
options.maxTimeout = m_maxTimeout;
auto fetcher = ndn::util::SegmentFetcher::start(face, interest, m_validator, options);
fetcher->onError.connect([] (uint32_t errorCode, const std::string& errorMsg)
{NDN_LOG_ERROR("Error: " << errorMsg);});
fetcher->afterSegmentValidated.connect([this, &fetcher, &processId] (const Data& data)
{onSegmentData(*fetcher, data, processId);});
fetcher->afterSegmentTimedOut.connect([this, &fetcher, &processId] ()
{onSegmentTimeout(*fetcher, processId);});
}
示例4: publishPacket
int MediaThread::publishPacket(PacketData &packetData,
const Name& packetPrefix,
PacketNumber packetNo,
PrefixMetaInfo prefixMeta,
double captureTimestamp)
{
if (!faceProcessor_->getTransport()->getIsConnected())
return notifyError(-1, "transport is not connected");
Name prefix = packetPrefix;
Segmentizer::SegmentList segments;
if (RESULT_FAIL(Segmentizer::segmentize(packetData, segments, segSizeNoHeader_)))
return notifyError(-1, "packet segmentation failed");
#ifdef DROP_FRAMES
static int count = 0;
count++;
bool drop = (count%100 == 0);
#endif
#ifdef DELAY_FRAMES
static int count2 = 0;
count2++;
bool delay = (count2 > 200 && count2 % 200 < 10);
if (delay)
{
LogWarnC << "drop frame " << packetPrefix << std::endl;
return segments.size();
}
#endif
try {
// update metadata for the packet
PacketData::PacketMetadata metadata = { NdnRtcUtils::currentFrequencyMeterValue(packetRateMeter_),
NdnRtcUtils::millisecondTimestamp(),
captureTimestamp};
packetData.setMetadata(metadata);
prefixMeta.crcValue_ = packetData.getCrcValue();
Name metaSuffix = PrefixMetaInfo::toName(prefixMeta);
for (Segmentizer::SegmentList::iterator it = segments.begin();
it != segments.end(); ++it)
{
// add segment #
Name segmentName = prefix;
segmentName.appendSegment(it-segments.begin());
// lookup for pending interests and construct metaifno accordingly
SegmentData::SegmentMetaInfo meta = {0,0,0};
bool pitHit = (lookupPrefixInPit(segmentName, meta) != 0);
// add name suffix meta info
segmentName.append(metaSuffix);
// pack into network data
SegmentData segmentData(it->getDataPtr(), it->getPayloadSize(), meta);
Data ndnData(segmentName);
ndnData.getMetaInfo().setFreshnessPeriod(settings_->dataFreshnessMs_);
ndnData.setContent(segmentData.getData(), segmentData.getLength());
settings_->keyChain_->sign(ndnData, settings_->certificateName_);
if (memCache_.get() && !pitHit)
{
// according to http://named-data.net/doc/ndn-ccl-api/memory-content-cache.html#memorycontentcache-registerprefix-method
// adding content should be synchronized with the processEvents
// call; this must be done in calling routines
memCache_->add(ndnData);
LogTraceC
<< "added to cache " << segmentName << " "
<< ndnData.getContent().size() << " bytes" << std::endl;
}
else
{
SignedBlob encodedData = ndnData.wireEncode();
faceProcessor_->getTransport()->send(*encodedData);
LogTraceC
<< "sent " << segmentName << " "
<< ndnData.getContent().size() << " bytes" << std::endl;
}
#if 0 // enable this if you want measuring outgoing bitrate w/o ndn overhead
NdnRtcUtils::dataRateMeterMoreData(dataRateMeter_,
ndnData.getContent().size());
#else // enable this if you want measuring outgoing bitrate with ndn overhead
NdnRtcUtils::dataRateMeterMoreData(dataRateMeter_,
ndnData.getDefaultWireEncoding().size());
#endif
#ifdef DROP_FRAMES
if (drop)
{
LogWarnC << "drop frame " << packetPrefix << std::endl;
break;
}
//.........这里部分代码省略.........