[Live-devel] About RTSPServer
RA-Vincent Kao
Vincent_Kao at ralinktech.com
Mon May 23 00:08:18 PDT 2011
Dear all,
I post my source as following(refer to Live555MediaServer.cpp):
HANDLE g_hStartServerThread;
char g_watch; //Used for doEventLoop()
volatile BOOL g_bServerStarted = FALSE;
void StartServerThread( LPVOID pParam )
{
DBGPRINT(RT_DEBUG_TRACE, _T("[RaWLAPI][WDP] --> StartServerThread\n"));
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. Try first with the default port number (554),
// and then with the alternative port number (8554):
RTSPServer* rtspServer;
portNumBits rtspServerPortNum = 554;
rtspServer = DynamicRTSPServer::createNew(*env, rtspServerPortNum, authDB);
if (rtspServer == NULL) {
rtspServerPortNum = 8554;
rtspServer = DynamicRTSPServer::createNew(*env, rtspServerPortNum, authDB);
}
if (rtspServer == NULL) {
*env << "Failed to create RTSP server: " << env->getResultMsg() << "\n";
exit(1);
}
DBGPRINT(RT_DEBUG_TRACE, _T("[RaWLAPI][WDP] LIVE555 Media Server version = %s\n"), MEDIA_SERVER_VERSION_STRING);
DBGPRINT(RT_DEBUG_TRACE, _T("[RaWLAPI][WDP] LIVE555 Streaming Media library version = %s\n"), LIVEMEDIA_LIBRARY_VERSION_STRING);
char* urlPrefix = rtspServer->rtspURLPrefix();
DBGPRINT(RT_DEBUG_TRACE, _T("[RaWLAPI][WDP] URL = %s\n"), urlPrefix);
DBGPRINT(RT_DEBUG_TRACE, _T("[RaWLAPI][WDP] Support file type: aac, amr, m4e, 264, dv, mp3, mpg, ts, wmv\n"));
// Also, attempt to create a HTTP server for RTSP-over-HTTP tunneling.
// Try first with the default HTTP port (80), and then with the alternative HTTP
// port numbers (8000 and 8080).
if (rtspServer->setUpTunnelingOverHTTP(80) || rtspServer->setUpTunnelingOverHTTP(8000) || rtspServer->setUpTunnelingOverHTTP(8080)) {
DBGPRINT(RT_DEBUG_TRACE, _T("[RaWLAPI][WDP] Use port %d for optional RTSP-over-HTTP tunneling\n"), rtspServer->httpServerPortNum());
} else {
DBGPRINT(RT_DEBUG_ERROR, _T("[RaWLAPI][WDP] RTSP-over-HTTP tunneling is not available!\n"));
}
g_watch = 0;
g_bServerStarted = TRUE;
env->taskScheduler().doEventLoop(&g_watch); // does not return
Medium::close(rtspServer); //Close socket
DBGPRINT(RT_DEBUG_TRACE, _T("[RaWLAPI][WDP] <-- StartServerThread\n"));
}
//************* API ************/
DWORD WINAPI RARTSP_StartOrStopRTSPServer(BOOL bStart, TCHAR *szServerIP, int nServerPort)
{
DWORD dwRet = RAWL_ERROR_SUCCESS;
if(bStart)
{
g_hStartServerThread = NULL;
g_hStartServerThread = (HANDLE)_beginthread(StartServerThread, NULL, NULL);
while(FALSE == g_bServerStarted)
{
Sleep(10);
}
}
else //Stop server
{
g_watch = 1; //Let doEventLoop() return
}
return dwRet;
}
When I want to stop server,
I modify watch variable to let event loop return,
and then call Media::Close to close server's socket.
But socket still exist(netstat -a show socket established) after that call.
And though socket can be destroyed after terminate application,
debug log also generates many memory leaks.
And I wonder why Live555MediaServer.cpp does not delete scheduler and env objects,
how are these objects released when application is terminated?
Thanks.
Vincent Kao
-----Original Message-----
From: live-devel-bounces at ns.live555.com [mailto:live-devel-bounces at ns.live555.com] On Behalf Of Ross Finlayson
Sent: Friday, May 20, 2011 6:35 PM
To: LIVE555 Streaming Media - development & use
Subject: Re: [Live-devel] About RTSPServer
>Yes, I called Medium::close(pointerToYourRTSPServerObject) to stop
>RTSP Server.
>But I found socket still exist after call that.
That's odd. The "RTSPServer" destructor definitely closes the
server's socket. I don't know why that's not working for you.
--
Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
_______________________________________________
live-devel mailing list
live-devel at lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel
CONFIDENTIALITY STATEMENT : The information, attachments and any rights attaching in this e-mail are confidential and privileged; it is intended only for the individual or entity named as the recipient hereof.Any disclosure, copying, distribution, dissemination or use of the contents of this e-mail by persons other than the intended recipient is STRICTLY PROHIBITED and may violate applicable laws.If you have received this e-mail in error, please delete the original message and notify us by return email or collect call immediately. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20110523/61bd7eda/attachment-0001.html>
More information about the live-devel
mailing list