当前位置: 首页>>代码示例>>C++>>正文


C++ PacketStream类代码示例

本文整理汇总了C++中PacketStream的典型用法代码示例。如果您正苦于以下问题:C++ PacketStream类的具体用法?C++ PacketStream怎么用?C++ PacketStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PacketStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: runAVInputReaderRecorderTest

    // ---------------------------------------------------------------------
    // Audio CaptureRecorder Test
    //
    void runAVInputReaderRecorderTest()
    {
        PacketStream stream;

        // Create the Encoder Options
        av::EncoderOptions options;
        options.ofile = "audio_test.mp4";
        options.duration = 5; //time(0) +
        options.oformat = av::Format("AAC", "aac",
            av::AudioCodec("AAC", "aac", 2, 44100, 96000, "fltp"));
            //av::AudioCodec("MP3", "libmp3lame", 2, 44100, 128000, "s16p"));

        // Attach the Audio Capture
        av::AVInputReader::Ptr reader(new av::AVInputReader());
        reader->openAudioDevice(0,
            options.oformat.audio.channels,
            options.oformat.audio.sampleRate);
        reader->getEncoderFormat(options.iformat);

        // Attach the Audio Capture
        stream.attachSource<av::AVInputReader>(reader, true);

        // Attach the Audio Encoder
        auto encoder = new av::AVPacketEncoder(options);
        encoder->initialize();
        stream.attach(encoder, 5, true);

        stream.start();
        scy::pause();
        stream.stop();
    }
开发者ID:runt18,项目名称:libsourcey,代码行数:34,代码来源:mediatests.cpp

示例2:

STDMETHODIMP
BasicPacketFlow::HandleSubscribe(INT32 lRuleNumber, UINT16 unStreamNumber)
{
    PacketStream* pStream = &m_pStreams[unStreamNumber];
    HX_ASSERT(pStream->m_bStreamRegistered);

    INT32 ret = pStream->SubscribeRule(lRuleNumber,
                                       m_bInitialSubscriptionDone,
                                       m_bIsMulticast,
                                       m_pFlowMgr);

    if (ret >= 0)
    {
        m_bSubscribed = TRUE;
	
	if (m_pRateManager)
	{
	    IHXPacketFlowControl* pRateMgrFlowControl = NULL;
	    if (HXR_OK == m_pRateManager->QueryInterface(IID_IHXPacketFlowControl,
							 (void**)&pRateMgrFlowControl))
	    {
		pRateMgrFlowControl->HandleSubscribe(lRuleNumber, unStreamNumber);
		HX_RELEASE(pRateMgrFlowControl);
	    }
	}
    }

    return HXR_OK;
}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:29,代码来源:basicpcktflow.cpp

示例3: runAudioStreamRecorderTest

    // ---------------------------------------------------------------------
    // Audio CaptureRecorder Test
    //
    void runAudioStreamRecorderTest()
    {
        PacketStream stream;

        // Create the Encoder Options
        av::EncoderOptions options;
        options.ofile = "audio_test.mp3";
        //options.stopAt = time(0) + 5;
        options.oformat = av::Format("MP3", "mp3",
            av::AudioCodec("MP3", "libmp3lame", 2, 44100, 128000, "s16p"));

        // Create the Audio Capture
        av::Device dev;
        auto& media = av::MediaFactory::instance();
        media.devices().getDefaultAudioInputDevice(dev);
        InfoL << "Default audio capture " << dev.id << endl;
        av::AudioCapture::Ptr audioCapture = media.createAudioCapture(0, //dev.id
            options.oformat.audio.channels,
            options.oformat.audio.sampleRate);
        audioCapture->getEncoderFormat(options.iformat);

        // Attach the Audio Capture
        stream.attachSource<av::AudioCapture>(audioCapture, true);

        // Attach the Audio Encoder
        //auto encoder = new av::AVPacketEncoder(options);
        //encoder->initialize();
        //stream.attach(encoder, 5, true);

        //CaptureRecorder enc(audioCapture, options);

        stream.start();
        scy::pause();
        stream.stop();
    }
开发者ID:runt18,项目名称:libsourcey,代码行数:38,代码来源:mediatests.cpp

示例4: SendFinishRace

void Game::SendFinishRace()
{
	PacketStream PS;

	ENUM_Event e = FINISHEDRACE;
	PS.writeInt(e);

	e = ENDOFMESSAGE;
	PS.writeInt(e);

	// get the data from the stream
	char data[100];
	PS.toCharArray(data);

	// send the data
	Net::GetInstance()->SendData(data,"127.0.0.1",m_sendToPort);

	// increment num packets sent
	m_numPacketsSent++;

	m_raceFinished = true;
	if(m_host)
	{
		m_hostWon = true;
	}
	else
	{
		m_hostWon = false;
	}
}
开发者ID:jeromebyrne,项目名称:college_PeerToPeerRace,代码行数:30,代码来源:Game.cpp

示例5: sendQuery

void GameNetInterface::sendQuery(const Address &theAddress, const Nonce &clientNonce, U32 identityToken)
{
   PacketStream packet;
   packet.write(U8(Query));
   clientNonce.write(&packet);
   packet.write(identityToken);
   packet.sendto(mSocket, theAddress);
}
开发者ID:AnsonX10,项目名称:bitfighter,代码行数:8,代码来源:gameNetInterface.cpp

示例6: sendPing

// Send ping to the server.  If server has different PROTOCOL_VERSION, the packet will be ignored.  This prevents players
// from seeing servers they are incompatible with.
void GameNetInterface::sendPing(const Address &theAddress, const Nonce &clientNonce)
{
   PacketStream packet;
   packet.write(U8(Ping));
   clientNonce.write(&packet);
   packet.write(CS_PROTOCOL_VERSION);
   packet.sendto(mSocket, theAddress);
}
开发者ID:AnsonX10,项目名称:bitfighter,代码行数:10,代码来源:gameNetInterface.cpp

示例7: routingPacket

void* routingPacket(void* buffin)
{
	PacketBufferV* buff = (PacketBufferV*) buffin;
	int npix_idx = 0;
	int nsamp_idx = 0;
	// load packet type (once per thread)
	PacketStream* ps;
	pthread_mutex_lock(&lockp);
	try {
		ps = new PacketStream(configFileName.c_str());
	} catch (PacketException* e)
	{
		cout << "Error during routingPacket: ";
		cout << e->geterror() << endl;
	}
	pthread_mutex_unlock(&lockp);
	
	ByteStreamPtr localBuffer[PACKET_NUM];
	int npix[PACKET_NUM];
	int nsamp[PACKET_NUM];
	for(int n=0; n<NTIMES; n++)
	{
		// copy PACKET_NUM packets data locally
		pthread_mutex_lock(&lockp);
		for(int m=0; m<PACKET_NUM; m++)
		{
			ByteStreamPtr rawPacket = buff->getNext();
			localBuffer[m] = rawPacket;
			
		}
		pthread_mutex_unlock(&lockp);
		
		for(int m=0; m<PACKET_NUM; m++)
		{
			ByteStreamPtr rawPacket = localBuffer[m];
			Packet *p = ps->getPacket(rawPacket);
			// get npixel and nsamples
			if(p->getPacketID() > 0) {
				sizeMB += (p->size() / 1000000.0);
				//do something with the packet
				;
			}
#ifdef DEBUG
			else {
				cout << "Warning: no packet recognized" << endl;
			}
#endif
			
#ifdef DEBUG
			std::cout << "tot size (MB) " << sizeMB << std::endl;
#endif
		}
	}
	delete ps;
	return 0;
}
开发者ID:ASTRO-BO,项目名称:RTAtest,代码行数:56,代码来源:mt.cpp

示例8: while

void LoginServerSession::parseInputPacket()
{
	PacketStream * ps = NULL;
	int msg_length = 0;
//	try
	{
		msg_length = m_input_msg_block.length();
		while(true)
		{
			if (m_input_msg_block.length() < sizeof(Header))
			{
				break;
			}

			ps = new PacketStream();
			memcpy(ps->re_head(), m_input_msg_block.rd_ptr(), ps->head_size());
			if (m_input_msg_block.length() >= ps->head_size() + ps->body_size())
			{
				m_input_msg_block.rd_ptr(ps->head_size());
				if (ps->body_size() > 0)
				{
					memcpy(ps->re_body(), m_input_msg_block.rd_ptr(), ps->body_size());
					m_input_msg_block.rd_ptr(ps->body_size());
				}
				else
				{
					// do nothing
				}

//				ManageStat::instance()->statClientInputTraffic(ps->stream_size(), 1);
				ManageClientValidation::instance()->handlePackage(ps);
				msg_length = m_input_msg_block.length();
			}
			else
			{
				delete ps;
				break;
			}
		}

		if (m_input_msg_block.rd_ptr() != m_input_msg_block.base())
		{
			msg_length = m_input_msg_block.length();
			if (msg_length > 0)
			{
				memcpy(m_input_msg_block.base(), m_input_msg_block.rd_ptr(), msg_length);
			}
			m_input_msg_block.rd_ptr(m_input_msg_block.base());
			m_input_msg_block.wr_ptr(m_input_msg_block.base() + msg_length);
		}
	}
	//catch (...)
	//{
	//	GATE_LOG_ERROR(ACE_TEXT("Raise unknown exception in LoginServerSession::parseInputPacket, last error is <%d>\n"), ACE_OS::last_error());
	//}
}
开发者ID:BianJian,项目名称:steppingstone,代码行数:56,代码来源:LoginServerSession.cpp

示例9: sendConnectChallengeResponse

void NetInterface::sendConnectChallengeResponse(const Address &addr, Nonce &clientNonce, bool wantsKeyExchange, bool wantsCertificate)
{
   PacketStream out;
   out.write(U8(ConnectChallengeResponse));
   clientNonce.write(&out);
   
   U32 identityToken = computeClientIdentityToken(addr, clientNonce);
   out.write(identityToken);

   // write out a client puzzle
   Nonce serverNonce = mPuzzleManager.getCurrentNonce();
   U32 difficulty = mPuzzleManager.getCurrentDifficulty();
   serverNonce.write(&out);
   out.write(difficulty);

   if(out.writeFlag(mRequiresKeyExchange || (wantsKeyExchange && !mPrivateKey.isNull())))
   {
      if(out.writeFlag(wantsCertificate && !mCertificate.isNull()))
         out.write(mCertificate);
      else
         out.write(mPrivateKey->getPublicKey());
   }
   TNLLogMessageV(LogNetInterface, ("Sending Challenge Response: %8x", identityToken));

   out.sendto(mSocket, addr);
}
开发者ID:HwakyoungLee,项目名称:opentnl,代码行数:26,代码来源:netInterface.cpp

示例10: main

int main(int argc, char** argv)
{
    Logger::instance().add(new ConsoleChannel("debug", Level::Trace)); // Debug
    {
        // Create a PacketStream to pass packets
        // from device captures to the encoder
        PacketStream stream;

        av::EncoderOptions options;
        options.ofile = OUTPUT_FILENAME;
        options.oformat = OUTPUT_FORMAT;
        options.iformat.audio.enabled = false; // enabled if available
        options.iformat.video.enabled = false; // enabled if available

        // Create a device manager instance to enumerate system devices
        av::Device device;
        av::DeviceManager devman;

        // Create and attach the default video capture
        av::VideoCapture video;
        if (devman.getDefaultCamera(device)) {
            LInfo("Using video device: ", device.name)
            video.openVideo(device.id, { 640, 480 });
            video.getEncoderFormat(options.iformat);
            stream.attachSource(&video, false, true);
        }

        // Create and attach the default audio capture
        av::AudioCapture audio;
        if (devman.getDefaultMicrophone(device)) {
            LInfo("Using audio device: ", device.name)
            audio.openAudio(device.id, { 2, 44100 });
            audio.getEncoderFormat(options.iformat);
            stream.attachSource(&audio, false, true);
        }

        // Create and attach the multiplex encoder
        av::MultiplexPacketEncoder encoder(options);
        encoder.init();
        stream.attach(&encoder, 5, false);

        // Start the stream
        stream.start();

        // Keep recording until Ctrl-C is pressed
        LInfo("Recording video: ", OUTPUT_FILENAME)
        waitForShutdown([](void* opaque) {
            reinterpret_cast<PacketStream*>(opaque)->stop();
        }, &stream);
    }

    // Logger::destroy();
    return 0;
}
开发者ID:sourcey,项目名称:libsourcey,代码行数:54,代码来源:devicerecorder.cpp

示例11: checkIncomingPackets

void NetInterface::checkIncomingPackets()
{
   PacketStream stream;
   NetError error;
   Address sourceAddress;

   mCurrentTime = Platform::getRealMilliseconds();

   // read out all the available packets:
   while((error = stream.recvfrom(mSocket, &sourceAddress)) == NoError)
      processPacket(sourceAddress, &stream);
}
开发者ID:HwakyoungLee,项目名称:opentnl,代码行数:12,代码来源:netInterface.cpp

示例12: sendConnectReject

void NetInterface::sendConnectReject(ConnectionParameters *conn, const Address &theAddress, const char *reason)
{
   if(!reason)
      return; // if the stream is NULL, we reject silently

   PacketStream out;
   out.write(U8(ConnectReject));
   conn->mNonce.write(&out);
   conn->mServerNonce.write(&out);
   out.writeString(reason);
   out.sendto(mSocket, theAddress);
}
开发者ID:HwakyoungLee,项目名称:opentnl,代码行数:12,代码来源:netInterface.cpp

示例13: assert

bool StreamManager::closeStream(const std::string& name, bool whiny) 
{
	assert(!name.empty());

	DebugL << "Close stream: " << name << endl;
	PacketStream* stream = get(name, whiny);
	if (stream) {
		stream->close();
		return true;
	}
	return false;
}
开发者ID:AsamQi,项目名称:libsourcey,代码行数:12,代码来源:streammanager.cpp

示例14: sendConnectReject

void NetInterface::sendConnectReject(ConnectionParameters *conn, const Address &theAddress, NetConnection::TerminationReason reason)
{
   //if(!reason)
   //   return; // if the stream is NULL, we reject silently

   PacketStream out;
   out.write(U8(ConnectReject));
   conn->mNonce.write(&out);
   conn->mServerNonce.write(&out);
   out.writeEnum(reason, NetConnection::TerminationReasons);
   out.writeString("");
   out.sendto(mSocket, theAddress);
}
开发者ID:mrozbarry,项目名称:bitfighter-experiments,代码行数:13,代码来源:netInterface.cpp

示例15: SubmitQuestion

bool AskService::SubmitQuestion(IAnswer *answerCB, char16* nickname, char16* password, char16* questionText, int32 numberOfPhotos, int32 responseType, ArrayOfString *customResponses, int32 durationType, bool isPrivate)
{
    if (!StartRequest(answerCB, AskService::EPS_SUBMITQUESTION))
    {
        return false;
    }

    PacketStream *str = pServer->GetStream();
    bool isOk = true;

    isOk = isOk && str->WriteInt32(16);//request id

  
    isOk = isOk &&  str->WriteWString(nickname);
    isOk = isOk &&  str->WriteWString(password);
    isOk = isOk &&  str->WriteWString(questionText);
    isOk = isOk &&  str->WriteInt32(numberOfPhotos);
    isOk = isOk &&  str->WriteInt32(responseType);
    isOk = isOk &&  customResponses->WriteToStream(str);
    isOk = isOk &&  str->WriteInt32(durationType);
    isOk = isOk &&  str->WriteInt8((int8)isPrivate);

    return isOk && EndRequest();

}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:25,代码来源:AskService.cpp


注:本文中的PacketStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。