本文整理汇总了C++中json::Value::toNetPacked方法的典型用法代码示例。如果您正苦于以下问题:C++ Value::toNetPacked方法的具体用法?C++ Value::toNetPacked怎么用?C++ Value::toNetPacked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json::Value
的用法示例。
在下文中一共展示了Value::toNetPacked方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNext
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());
}
示例2: getNext
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());
}
示例3: while
//.........这里部分代码省略.........
if (trackData[sNum].codec == THEORA){
trackData[sNum].lastTime += mspft;
}else{
//Getting current blockSize
unsigned int blockSize = 0;
Utils::bitstreamLSBF packet;
packet.append(DTSCOut["data"].asString());
if (packet.get(1) == 0){
blockSize = trackData[sNum].blockSize[trackData[sNum].vModes[packet.get(vorbis::ilog(trackData[sNum].vModes.size()-1))].blockFlag];
}else{
std::cerr << "Warning! packet type != 0" << std::endl;
}
trackData[sNum].lastTime += mspfv * (blockSize/trackData[sNum].channels);
}
if (trackData[sNum].codec == THEORA){//marking keyframes
if (it == (oggPage.getSegmentTableDeque().end() - 1)){
//if we are in the vicinity of a new keyframe
if (trackData[sNum].idHeader.parseGranuleUpper(trackData[sNum].lastGran) != trackData[sNum].idHeader.parseGranuleUpper(temp)){
//try to mark right
DTSCOut["keyframe"] = 1;
trackData[sNum].lastGran = temp;
}else{
DTSCOut["interframe"] = 1;
}
}
}
// Ending packet
if (oggPage.typeContinue()){//Continuing page
DTSCOut["OggCont"] = 1;
}
if (oggPage.typeEOS()){//ending page of ogg stream
DTSCOut["OggEOS"] = 1;
}
std::cout << DTSCOut.toNetPacked();
}
}else{//if we ouput a header:
//switch on codec
switch(trackData[sNum].codec){
case THEORA:{
theora::header tHead;
if(tHead.read(oggPage.getFullPayload()+offset, (*it))){//if the current segment is a Theora header part
//fillDTSC header
switch(tHead.getHeaderType()){
case 0:{ //identification header
trackData[sNum].idHeader = tHead;
DTSCHeader["tracks"][trackData[sNum].name]["height"] = (long long)tHead.getPICH();
DTSCHeader["tracks"][trackData[sNum].name]["width"] = (long long)tHead.getPICW();
DTSCHeader["tracks"][trackData[sNum].name]["idheader"] = std::string(oggPage.getFullPayload()+offset, (*it));
break;
}
case 1: //comment header
DTSCHeader["tracks"][trackData[sNum].name]["commentheader"] = std::string(oggPage.getFullPayload()+offset, (*it));
break;
case 2:{ //setup header, also the point to start writing the header
DTSCHeader["tracks"][trackData[sNum].name]["codec"] = "theora";
DTSCHeader["tracks"][trackData[sNum].name]["trackid"] = (long long)trackData[sNum].dtscID;
DTSCHeader["tracks"][trackData[sNum].name]["type"] = "video";
DTSCHeader["tracks"][trackData[sNum].name]["init"] = std::string(oggPage.getFullPayload()+offset, (*it));
headerSeen --;
trackData[sNum].parsedHeaders = true;
trackData[sNum].lastGran = 0;
break;
}
}
}
break;
示例4: parseChunk
//.........这里部分代码省略.........
case 6: fprintf(stderr, "CTRL: UCM PingRequest %i\n", ntohl(*((int*)(next.data.c_str()+2)))); break;
case 7: fprintf(stderr, "CTRL: UCM PingResponse %i\n", ntohl(*((int*)(next.data.c_str()+2)))); break;
default: fprintf(stderr, "CTRL: UCM Unknown (%hi)\n", ucmtype); break;
}
#endif
} break;
case 5://window size of other end
#if DEBUG >= 4
fprintf(stderr, "CTRL: Window size\n");
#endif
RTMPStream::rec_window_size = ntohl(*(int*)next.data.c_str());
RTMPStream::rec_window_at = RTMPStream::rec_cnt;
Socket.Send(RTMPStream::SendCTL(3, RTMPStream::rec_cnt));//send ack (msg 3)
break;
case 6:
#if DEBUG >= 4
fprintf(stderr, "CTRL: Set peer bandwidth\n");
#endif
//4 bytes window size, 1 byte limit type (ignored)
RTMPStream::snd_window_size = ntohl(*(int*)next.data.c_str());
Socket.Send(RTMPStream::SendCTL(5, RTMPStream::snd_window_size));//send window acknowledgement size (msg 5)
break;
case 8://audio data
case 9://video data
case 18://meta data
if (SS.connected()){
F.ChunkLoader(next);
JSON::Value pack_out = F.toJSON(meta_out);
if (!pack_out.isNull()){
if (!sending){
counter++;
if (counter > 8){
sending = true;
SS.SendNow(meta_out.toNetPacked());
SS.SendNow(prebuffer.str().c_str());//write buffer
prebuffer.str("");//clear buffer
SS.Send(pack_out.toNetPacked());
}else{
prebuffer << pack_out.toNetPacked();
}
}else{
SS.SendNow(pack_out.toNetPacked());
}
}
}else{
#if DEBUG >= 4
fprintf(stderr, "Received useless media data\n");
#endif
Socket.close();
}
break;
case 15:
#if DEBUG >= 4
fprintf(stderr, "Received AFM3 data message\n");
#endif
break;
case 16:
#if DEBUG >= 4
fprintf(stderr, "Received AFM3 shared object\n");
#endif
break;
case 17:{
#if DEBUG >= 4
fprintf(stderr, "Received AFM3 command message\n");
#endif
if (next.data[0] != 0){
示例5: writePacket
void DTSC::File::writePacket(JSON::Value & newPacket) {
writePacket(newPacket.toNetPacked());
}