#include <BasicUsageEnvironment.hh>
#include <liveMedia.hh>
#include <iostream>

RTSPClient* rtsp = NULL;

void continueAfterDESCRIBE(RTSPClient* client, int result_code, char* result_string)
{
	std::cout << result_string << std::endl;
	delete[] result_string;
}

void continueAfterOPTIONS(RTSPClient* client, int result_code, char* result_string)
{
	bool b_get_param =
		// If OPTIONS fails, assume GET_PARAMETER is not supported but
		// still continue on with the stream.  Some servers (foscam)
		// return 501/not implemented for OPTIONS.
		result_code == 0
		&& result_string != NULL
		&& strstr(result_string, "GET_PARAMETER") != NULL;

	client->sendDescribeCommand(continueAfterDESCRIBE);
	delete[] result_string;
}

int main(int argc, char** argv) {
	TaskScheduler* sch = BasicTaskScheduler::createNew();
	UsageEnvironment* env = BasicUsageEnvironment::createNew(*sch);
	rtsp = RTSPClient::createNew(*env, "rtsp://root:elcom@192.168.61.60/axis-media/media.amp", 1, "testTunneling", 80);

	rtsp->sendOptionsCommand(continueAfterOPTIONS);
	sch->doEventLoop();

	return 0;
}