[Live-devel] Corruption of the heap and Access violation reading errors at testRTSPClient.cpp [ on windows platform ]

Novalis Vapuru 6.45.vapuru at gmail.com
Mon Mar 26 02:18:15 PDT 2012


I read Faq, but it seems that I did not pay attention much. You are right.

I modify the code , and it works perfectly .
Thanks.

Best Wishes

Novalis


PS:

Here is the modified part:



RTSPClient* rtspClient;
EventTriggerId stopTrigger;

UsageEnvironment* env;
char doEventLoopWatchVariable;
bool doesDoEventLoopEnded ;

void Stop(void *myParameter)
{
	shutdownStream(rtspClient);
}

void Clear()
{
	std::cout << "Try to delete env and scheduler " << std::endl;

	TaskScheduler* scheduler = &(env->taskScheduler());

	bool canDelete = ( (env->liveMediaPriv == NULL) &&
(env->groupsockPriv == NULL));

	if(canDelete)
	{

		std::cout << "now can eble to delete enviroment" << std::endl;
	}

	else
	{
		std::cout << "can not able to delete enviroment" << std::endl;
	}


    env->reclaim();
    delete scheduler;

}

void Start()
{

	// Begin by setting up our usage environment:
	TaskScheduler* scheduler = BasicTaskScheduler::createNew();
	env = BasicUsageEnvironment::createNew(*scheduler);

	stopTrigger = env->taskScheduler().createEventTrigger(&Stop);
	
	char* programName ="Test";
	char* rtpsURL = "rtsp://192.168.3.165/video.h264";
	rtspClient = openURL(*env, programName,rtpsURL );

	rtspClient->sendDescribeCommand(continueAfterDESCRIBE);

	doEventLoopWatchVariable = 0;
	doesDoEventLoopEnded  = false;

	// All subsequent activity takes place within the event loop:
	env->taskScheduler().doEventLoop(&doEventLoopWatchVariable); // does not return

	doesDoEventLoopEnded = true;

}


int main(int argc, char** argv)
{

	boost::thread StartClientThread = boost::thread(Start);

	boost::this_thread::sleep( boost::posix_time::seconds(10) );

	env->taskScheduler().triggerEvent(stopTrigger);

	doEventLoopWatchVariable = 1;

	while(!doesDoEventLoopEnded)
	{
		std::cout << "do event loop does not end " << std::endl;
	}


	std::cout << "do event loop ended " << std::endl;
	std::cout << "now try to cleanup client " << std::endl;

	Clear();

	int endMain;

	std::cin >> endMain; // Just for not to exit main loop

	return 0;
}


More information about the live-devel mailing list