本文整理汇总了C++中UsageEnvironment::taskScheduler方法的典型用法代码示例。如果您正苦于以下问题:C++ UsageEnvironment::taskScheduler方法的具体用法?C++ UsageEnvironment::taskScheduler怎么用?C++ UsageEnvironment::taskScheduler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UsageEnvironment
的用法示例。
在下文中一共展示了UsageEnvironment::taskScheduler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test
static void test (UsageEnvironment &env)
{
fprintf(stderr, "test: begin...\n");
char done = 0;
int delay = 100 * 1000;
env.taskScheduler().scheduleDelayedTask(delay, test_task, 0);
env.taskScheduler().doEventLoop(&done);
fprintf(stderr, "test: end..\n");
}
示例2: main
int main(int argc, char** argv) {
// Begin by setting up our usage environment:
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
// We need at least one "rtsp://" URL argument:
if (argc < 2) {
usage(*env, argv[0]);
return 1;
}
// There are argc-1 URLs: argv[1] through argv[argc-1]. Open and start streaming each one:
for (int i = 1; i <= argc-1; ++i) {
openURL(*env, argv[0], argv[i]);
}
// All subsequent activity takes place within the event loop:
env->taskScheduler().doEventLoop(&eventLoopWatchVariable);
// This function call does not return, unless, at some point in time, "eventLoopWatchVariable" gets set to something non-zero.
return 0;
// If you choose to continue the application past this point (i.e., if you comment out the "return 0;" statement above),
// and if you don't intend to do anything more with the "TaskScheduler" and "UsageEnvironment" objects,
// then you can also reclaim the (small) memory used by these objects by uncommenting the following code:
/*
env->reclaim(); env = NULL;
delete scheduler; scheduler = NULL;
*/
}
示例3: teardownRTSPorSIPSession
extern "C" void demux_close_rtp(demuxer_t* demuxer) {
// Reclaim all RTP-related state:
// Get the RTP state that was stored in the demuxer's 'priv' field:
RTPState* rtpState = (RTPState*)(demuxer->priv);
if (rtpState == NULL) return;
teardownRTSPorSIPSession(rtpState);
UsageEnvironment* env = NULL;
TaskScheduler* scheduler = NULL;
if (rtpState->mediaSession != NULL) {
env = &(rtpState->mediaSession->envir());
scheduler = &(env->taskScheduler());
}
Medium::close(rtpState->mediaSession);
Medium::close(rtpState->rtspClient);
Medium::close(rtpState->sipClient);
delete rtpState->audioBufferQueue;
delete rtpState->videoBufferQueue;
delete[] rtpState->sdpDescription;
delete rtpState;
#ifdef CONFIG_LIBAVCODEC
av_freep(&avcctx);
#endif
env->reclaim(); delete scheduler;
}
示例4: rtsp_fun
void CRTSPSession::rtsp_fun()
{
//::startRTSP(m_progName.c_str(), m_rtspUrl.c_str(), m_ndebugLever);
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
if (openURL(*env, m_progName.c_str(), m_rtspUrl.c_str(), m_debugLevel) == 0)
{
m_nStatus = 1;
env->taskScheduler().doEventLoop(&eventLoopWatchVariable);
m_running = false;
eventLoopWatchVariable = 0;
if (m_rtspClient)
{
shutdownStream(m_rtspClient,0);
}
m_rtspClient = NULL;
}
env->reclaim();
env = NULL;
delete scheduler;
scheduler = NULL;
m_nStatus = 2;
}
示例5: Medium
GenericMediaServer
::GenericMediaServer(UsageEnvironment& env, int ourSocket, Port ourPort)
: Medium(env),
fServerSocket(ourSocket), fServerPort(ourPort),
fServerMediaSessions(HashTable::create(STRING_HASH_KEYS)),
fClientConnections(HashTable::create(ONE_WORD_HASH_KEYS)),
fClientSessions(HashTable::create(STRING_HASH_KEYS)) {
ignoreSigPipeOnSocket(fServerSocket); // so that clients on the same host that are killed don't also kill us
// Arrange to handle connections from others:
env.taskScheduler().turnOnBackgroundReadHandling(fServerSocket, incomingConnectionHandler, this);
}
示例6: sendBeepSound
int sendBeepSound(const char* rtspURL, const char* username, const char* password) {
FILE* fp = fopen(WAVE_FILE, "r");
if ( fp == NULL )
{
LOG("wave file not exists : %s", WAVE_FILE);
return -1;
}
else
{
fclose(fp);
}
// Begin by setting up our usage environment:
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
// Begin by creating a "RTSPClient" object. Note that there is a separate "RTSPClient" object for each stream that we wish
// to receive (even if more than stream uses the same "rtsp://" URL).
ourRTSPClient* rtspClient = ourRTSPClient::createNew(*env, rtspURL, RTSP_CLIENT_VERBOSITY_LEVEL, "SCBT BackChannel");
if (rtspClient == NULL) {
*env << "Failed to create a RTSP client for URL \"" << rtspURL << "\": " << env->getResultMsg() << "\n";
env->reclaim(); env = NULL;
delete scheduler; scheduler = NULL;
return -2;
}
rtspClient->bRequireBackChannel = bEnableBackChannel;
// Next, send a RTSP "DESCRIBE" command, to get a SDP description for the stream.
// Note that this command - like all RTSP commands - is sent asynchronously; we do not block, waiting for a response.
// Instead, the following function call returns immediately, and we handle the RTSP response later, from within the event loop:
Authenticator auth;
auth.setUsernameAndPassword(username, password);
rtspClient->sendDescribeCommand(continueAfterDESCRIBE, &auth);
//continueAfterSETUP(rtspClient, 0, new char[2]);
//startPlay(rtspClient);
// All subsequent activity takes place within the event loop:
env->taskScheduler().doEventLoop(&(rtspClient->scs.eventLoopWatchVariable));
// This function call does not return, unless, at some point in time, "eventLoopWatchVariable" gets set to something non-zero.
// If you choose to continue the application past this point (i.e., if you comment out the "return 0;" statement above),
// and if you don't intend to do anything more with the "TaskScheduler" and "UsageEnvironment" objects,
// then you can also reclaim the (small) memory used by these objects by uncommenting the following code:
env->reclaim(); env = NULL;
delete scheduler; scheduler = NULL;
return 0;
}
示例7: locker
// This task runs once an hour to check and see if the log needs to roll.
void live555Thread::Entry()
{
OSMutexLocker locker(&fMutex);
if(fLive555Env == NULL)
return;
//qtss_printf("live555Thread loop start\n");
UsageEnvironment* env = (UsageEnvironment*)fLive555Env;
fLive555EventLoopWatchVariablePtr = &fLive555EventLoopWatchVariable;
env->taskScheduler().doEventLoop(fLive555EventLoopWatchVariablePtr);
//qtss_printf("live555Thread loop over\n");
}
示例8: _tmain22
int _tmain22(int argc, _TCHAR* argv[])
{
// Begin by setting up our usage environment:
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
UsageEnvironment* env = RtspVideoBasicUsageEnvironment::createNew(*scheduler);
//RtspVideoBasicUsageEnvironment::createNew(*scheduler); //BasicUsageEnvironment::createNew(*scheduler);
// openURL(*env, "Live555Test", "rtsp://169.254.0.99/live.sdp");
// openURL(*env, "Live555Test", "rtsp://localhost:8554/stream");
openURL(*env, "Live555Test", "rtsp://127.0.0.1:8554/stream");
// All subsequent activity takes place within the event loop:
env->taskScheduler().doEventLoop(&eventLoopWatchVariable);
// This function call does not return, unless, at some point in time, "eventLoopWatchVariable" gets set to something non-zero.
return 0;
}
示例9: main
int main(int argc, char** argv) {
// Begin by setting up our usage environment:
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
UserAuthenticationDatabase* authDB = NULL;
#ifdef ACCESS_CONTROL
// To implement client access control to the RTSP server, do the following:
authDB = new UserAuthenticationDatabase;
authDB->addUserRecord("username1", "password1"); // replace these with real strings
// Repeat the above with each <username>, <password> that you wish to allow
// access to the server.
#endif
// Create the RTSP server:
RTSPServer* rtspServer = RTSPServer::createNew(*env, 554, authDB);
if (rtspServer == NULL) {
*env << "Failed to create RTSP server: " << env->getResultMsg() << "\n";
exit(1);
}
// Add live stream
WW_H264VideoSource * videoSource = 0;
ServerMediaSession * sms = ServerMediaSession::createNew(*env, "live", 0, "ww live test");
sms->addSubsession(WW_H264VideoServerMediaSubsession::createNew(*env, videoSource));
rtspServer->addServerMediaSession(sms);
char * url = rtspServer->rtspURL(sms);
*env << "using url \"" << url << "\"\n";
delete[] url;
// Run loop
env->taskScheduler().doEventLoop();
rtspServer->removeServerMediaSession(sms);
Medium::close(rtspServer);
env->reclaim();
delete scheduler;
return 1;
}
示例10: ServerConnect
LIVE_API unsigned __stdcall ServerConnect(void *pv)
{
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
UserAuthenticationDatabase* authDB = new UserAuthenticationDatabase;
authDB->addUserRecord("1", "1");
RTSPServer* rtspServer;
portNumBits rtspServerPortNum = 554;
rtspServer = DynamicRTSPServer::createNew(*env, rtspServerPortNum, authDB);
if (rtspServer == NULL) {
rtspServerPortNum = 8554;
rtspServer = DynamicRTSPServer::createNew(*env, rtspServerPortNum, authDB);
}
env->taskScheduler().doEventLoop(); // does not return
return 1;
}
示例11: StreamShutdown
//**************************************************************************************
void StreamShutdown()
{
if (m_rtspServer != NULL)
{
LogDebug("Stream server:Shutting down RTSP server");
MPRTSPServer *server = m_rtspServer;
m_rtspServer = NULL;
Medium::close(server);
}
if (m_env != NULL)
{
LogDebug("Stream server:Cleaning up environment");
UsageEnvironment *env = m_env;
m_env = NULL;
TaskScheduler *scheduler = &env->taskScheduler();
env->reclaim();
delete scheduler;
}
}
示例12: Medium
RTSPServer::RTSPServer(UsageEnvironment& env,
int ourSocket, Port ourPort,
UserAuthenticationDatabase* authDatabase,
unsigned reclamationTestSeconds)
: Medium(env),
fServerSocket(ourSocket), fServerPort(ourPort),
fAuthDB(authDatabase), fReclamationTestSeconds(reclamationTestSeconds),
fServerMediaSessions(HashTable::create(STRING_HASH_KEYS)) {
#ifdef USE_SIGNALS
// Ignore the SIGPIPE signal, so that clients on the same host that are killed
// don't also kill us:
signal(SIGPIPE, SIG_IGN);
#endif
// Arrange to handle connections from others:
// printf("RTSPServer: turnOnBackgroundReadHandling\n"); //jay
env.taskScheduler().turnOnBackgroundReadHandling(fServerSocket,
(TaskScheduler::BackgroundHandlerProc*)&incomingConnectionHandler,
this);
}
示例13: main
int main()
{
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
MFStartup(MF_VERSION);
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
in_addr dstAddr = { 127, 0, 0, 1 };
Groupsock rtpGroupsock(*env, dstAddr, 1233, 255);
rtpGroupsock.addDestination(dstAddr, 1234, 0);
RTPSink * rtpSink = H264VideoRTPSink::createNew(*env, &rtpGroupsock, 96);
MediaFoundationH264LiveSource * mediaFoundationH264Source = MediaFoundationH264LiveSource::createNew(*env);
rtpSink->startPlaying(*mediaFoundationH264Source, NULL, NULL);
// This function call does not return.
env->taskScheduler().doEventLoop();
return 0;
}
示例14: myRTSPClient
//int main(int argc, char** argv) {
int myRTSPClient(char *pInfo, char *pURL) {
// Begin by setting up our usage environment:
TaskScheduler* scheduler = BasicTaskScheduler::createNew();
UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
//openURL(*env, "TestRTSPClient.exe", "rtsp://mm2.pcslab.com/mm/7h800.mp4");
openURL(*env, pInfo, pURL);
// All subsequent activity takes place within the event loop:
env->taskScheduler().doEventLoop(&eventLoopWatchVariable);
// This function call does not return, unless, at some point in time, "eventLoopWatchVariable" gets set to something non-zero.
return 0;
// If you choose to continue the application past this point (i.e., if you comment out the "return 0;" statement above),
// and if you don't intend to do anything more with the "TaskScheduler" and "UsageEnvironment" objects,
// then you can also reclaim the (small) memory used by these objects by uncommenting the following code:
/*
env->reclaim(); env = NULL;
delete scheduler; scheduler = NULL;
*/
}
示例15: main
//.........这里部分代码省略.........
if( audioType == AUDIO_G711)
{
sinkAudio = SimpleRTPSink::createNew(*env, rtpGroupsockAudio, 96, audioSamplingFrequency, "audio", "PCMU", 1);
}
else
{
char const* encoderConfigStr = "1408";// (2<<3)|(8>>1) = 0x14 ; ((8<<7)&0xFF)|(1<<3)=0x08 ;
sinkAudio = MPEG4GenericRTPSink::createNew(*env, rtpGroupsockAudio,
96,
audioSamplingFrequency,
"audio", "AAC-hbr",
encoderConfigStr, audioNumChannels);
}
}
else{
if(audioType == AUDIO_G711)
{
sinkAudio = SimpleRTPSink::createNew(*env, rtpGroupsockAudio, 0, audioSamplingFrequency, "audio", "PCMU", 1);
}
else{
char const* encoderConfigStr = "1588";// (2<<3)|(11>>1) = 0x15 ; ((11<<7)&0xFF)|(1<<3)=0x88 ;
sinkAudio = MPEG4GenericRTPSink::createNew(*env, rtpGroupsockAudio,
96,
audioSamplingFrequency,
"audio", "AAC-hbr",
encoderConfigStr, audioNumChannels);
}
}
// Create (and start) a 'RTCP instance' for this RTP sink:
unsigned totalSessionBandwidthAudio = (audioOutputBitrate+500)/1000; // in kbps; for RTCP b/w share
rtcpAudio = RTCPInstance::createNew(*env, rtcpGroupsockAudio,
totalSessionBandwidthAudio, CNAME,
sinkAudio, NULL /* we're a server */,
streamingMode == STREAMING_MULTICAST_SSM);
// Note: This starts RTCP running automatically
sms->addSubsession(PassiveServerMediaSubsession::createNew(*sinkAudio, rtcpAudio));
// Start streaming:
sinkAudio->startPlaying(*sourceAudio, NULL, NULL);
}
rtspServer->addServerMediaSession(sms);
{
struct in_addr dest; dest.s_addr = multicastAddress;
char *url = rtspServer->rtspURL(sms);
//char *url2 = inet_ntoa(dest);
*env << "Mulicast Play this stream using the URL:\n\t" << url << "\n";
//*env << "2 Mulicast addr:\n\t" << url2 << "\n";
delete[] url;
}
}
// Begin the LIVE555 event loop:
env->taskScheduler().doEventLoop(&watchVariable); // does not return
if( streamingMode!= STREAMING_UNICAST )
{
Medium::close(rtcpAudio);
Medium::close(sinkAudio);
Medium::close(sourceAudio);
delete rtpGroupsockAudio;
delete rtcpGroupsockAudio;
Medium::close(rtcpVideo);
Medium::close(sinkVideo);
Medium::close(sourceVideo);
delete rtpGroupsockVideo;
delete rtcpGroupsockVideo;
}
Medium::close(rtspServer); // will also reclaim "sms" and its "ServerMediaSubsession"s
if( MjpegInputDevice != NULL )
{
Medium::close(MjpegInputDevice);
}
if( H264InputDevice != NULL )
{
Medium::close(H264InputDevice);
}
if( Mpeg4InputDevice != NULL )
{
Medium::close(Mpeg4InputDevice);
}
env->reclaim();
delete scheduler;
ApproInterfaceExit();
return 0; // only to prevent compiler warning
}