1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
ServerMediaSession* sms[50];
UsageEnvironment* env;
Boolean reuseFirstSource = False;
Boolean iFramesOnly = False;
TaskScheduler* scheduler;
UserAuthenticationDatabase* authDB;
char const* descriptionString ="Session streamed by \"testOnDemandRTSPServer1\"";
RTSPServer* rtspServer;
char* url[50]
static int k=0,j=0,z=0,w=0;
char const* descriptionString ="Session streamed by \"testOnDemandRTSPServer1\"";
RTSPServer* rtspServer;
char* url[50];
char const* streamName[2];
char const* inputAddressStr[2];
int inputPortNum[2];
int main()
{
StartRtspServer();
b.OnRun();
}
BOOL CFIServerDlg::OnRun()
{
OnStartFIServer();
return TRUE; // ret
}
int StartRtspServer()
{
char buffer[2500];
wLog->WriteDebugLog("Entering in StartRtspServer().");
// Begin by setting up our usage environment:
scheduler = BasicTaskScheduler::createNew();
env = BasicUsageEnvironment::createNew(*scheduler);
UserAuthenticationDatabase* authDB = NULL;
portNumBits rtspServerPortNum = 554;
rtspServer = RTSPServer::createNew(*env,rtspServerPortNum, authDB);
if (rtspServer == NULL)
{
sprintf(buffer,"Failed to create RTSP server with Port:%d %s",rtspServerPortNum,env->getResultMsg());
wLog->WriteErrorLog(buffer);
*env << "Failed to create RTSP server: " <<env->getResultMsg()<<"\n";
return 1;
}
else
{
wLog->WriteInfoLog("Created RTSP server..");
*env << "Created RTSP server.."<<"\n.";
return 0;
}
void CFIServerDlg::OnStartFIServer()
{
wLog->WriteDebugLog("Entering in OnStartFIServer()");
int success = m_FINetCom->StartFIServer();
if(success == 0)
{
m_FINetCom->StartFICom();
}
}
DWORD CFINetCom::StartFIServer()
{
//AL VARIABLES ARE DEFINED NO ISSUE REGARDING VARIABLES
m_ThreadHandle[2] = CreateThread(NULL,0, (LPTHREAD_START_ROUTINE)MessageHandleThread, this, 0, &ThreadId3);
if(m_ThreadHandle[2] == NULL)
{
wLog->WriteErrorLog("StartFIServer() Error while creating MessageHandleThread thread.");
cout<<"Debug: StartFIServer() Error while creating MessageHandleThread thread.\n";
}
}
*************************************************************************
*
* NAME : MessageHandleThread()
*
* DESCRIPTION : The message handle thread for handling various messages comming from
client and streamer.
*
* PARAMETERS : CFINetCom*
*
* RETURN : DWORD
*
**************************************************************************/
DWORD WINAPI CFINetCom::MessageHandleThread(CFINetCom* MyServ)
{
case START_STREAM:
{
HANDLE th1;
DWORD tid=NULL;
th1 = CreateThread(NULL,0, (LPTHREAD_START_ROUTINE)StartStreamingThread,&ip_port, 0, &tid);
if(th1 == NULL)
{
wLog->WriteDebugLog("StartFIServer() Error while creating MessageReplyThread .");
cout<<"Debug: StartFIServer() Error while creating MessageReplyThread .\n";
}
break;
}
DWORD WINAPI StartStreamingThread(Parameters ip_port)
{
streamName[0] = "test";
inputAddressStr[0] = "239.255.42.42";
inputPortNum[0] = 4444;
streamName[1] = "stream2";
inputAddressStr[1] = "237.255.42.42";
inputPortNum[1] = 5043;
Boolean const inputStreamIsRawUDP = False;
sms[w] = ServerMediaSession::createNew(*env, streamName[w], streamName[w],descriptionString);
sms[w]->addSubsession(MPEG2TransportUDPServerMediaSubsession::createNew(*env, inputAddressStr[w], inputPortNum[w], inputStreamIsRawUDP));
rtspServer->addServerMediaSession(sms[w]);
url[w] = rtspServer->rtspURL(sms[w]);
if (inputAddressStr[w] != NULL)
{
sprintf(buffer,"IP multicast address %s",inputAddressStr[w]);
wLog->WriteDebugLog(buffer);
*env << "IP multicast address " << inputAddressStr[w] << ",";
}
else
{
//printf("\nunicast;\n");
wLog->WriteDebugLog("unicast;");
*env << "unicast;";
}
delete[] url[w];
if(j==0)
{
if (rtspServer->setUpTunnelingOverHTTP(TunnelingPort) || rtspServer->setUpTunnelingOverHTTP(TunnelingPort) || rtspServer->setUpTunnelingOverHTTP(TunnelingPort))
{
sprintf(buffer,"(We use port %d for optional RTSP-over-HTTP tunneling.)", rtspServer->httpServerPortNum());
wLog->WriteDebugLog(buffer);
*env << "\n(We use port " << rtspServer->httpServerPortNum() << " for optional RTSP-over-HTTP tunneling.)\n";
}
else
{
wLog->WriteDebugLog("(RTSP-over-HTTP tunneling is not available.)");
*env << "\n(RTSP-over-HTTP tunneling is not available.)\n";
}
j++;
}
else
{
printf("(We use port %d for optional RTSP-over-HTTP tunneling.)", rtspServer->httpServerPortNum());
sprintf(buffer,"(We use port %d for optional RTSP-over-HTTP tunneling.)", rtspServer->httpServerPortNum());
wLog->WriteDebugLog(buffer);
}
w++;
wLog->WriteDebugLog("Leaving StartStreamingThread");
if(w == 1)
env->taskScheduler().doEventLoop(); // does not return
return 0; // only to prevent compiler warning,IT BREAKS HERE
}
|