mediaServer/live555MediaServer.cpp

Go to the documentation of this file.
00001 /**********
00002 This library is free software; you can redistribute it and/or modify it under
00003 the terms of the GNU Lesser General Public License as published by the
00004 Free Software Foundation; either version 2.1 of the License, or (at your
00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
00006 
00007 This library is distributed in the hope that it will be useful, but WITHOUT
00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00009 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
00010 more details.
00011 
00012 You should have received a copy of the GNU Lesser General Public License
00013 along with this library; if not, write to the Free Software Foundation, Inc.,
00014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015 **********/
00016 // Copyright (c) 1996-2010, Live Networks, Inc.  All rights reserved
00017 // LIVE555 Media Server
00018 // main program
00019 
00020 #include <BasicUsageEnvironment.hh>
00021 #include "DynamicRTSPServer.hh"
00022 #include "RTSPOverHTTPServer.hh"
00023 #include "version.hh"
00024 
00025 int main(int argc, char** argv) {
00026   // Begin by setting up our usage environment:
00027   TaskScheduler* scheduler = BasicTaskScheduler::createNew();
00028   UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
00029 
00030   UserAuthenticationDatabase* authDB = NULL;
00031 #ifdef ACCESS_CONTROL
00032   // To implement client access control to the RTSP server, do the following:
00033   authDB = new UserAuthenticationDatabase;
00034   authDB->addUserRecord("username1", "password1"); // replace these with real strings
00035   // Repeat the above with each <username>, <password> that you wish to allow
00036   // access to the server.
00037 #endif
00038 
00039   // Create the RTSP server.  Try first with the default port number (554),
00040   // and then with the alternative port number (8554):
00041   RTSPServer* rtspServer;
00042   portNumBits rtspServerPortNum = 554;
00043   rtspServer = DynamicRTSPServer::createNew(*env, rtspServerPortNum, authDB);
00044   if (rtspServer == NULL) {
00045     rtspServerPortNum = 8554;
00046     rtspServer = DynamicRTSPServer::createNew(*env, rtspServerPortNum, authDB);
00047   }
00048   if (rtspServer == NULL) {
00049     *env << "Failed to create RTSP server: " << env->getResultMsg() << "\n";
00050     exit(1);
00051   }
00052 
00053   *env << "LIVE555 Media Server\n";
00054   *env << "\tversion " << MEDIA_SERVER_VERSION_STRING
00055        << " (LIVE555 Streaming Media library version "
00056        << LIVEMEDIA_LIBRARY_VERSION_STRING << ").\n";
00057 
00058   char* urlPrefix = rtspServer->rtspURLPrefix();
00059   *env << "Play streams from this server using the URL\n\t"
00060        << urlPrefix << "<filename>\nwhere <filename> is a file present in the current directory.\n";
00061   *env << "Each file's type is inferred from its name suffix:\n";
00062   *env << "\t\".aac\" => an AAC Audio (ADTS format) file\n";
00063   *env << "\t\".amr\" => an AMR Audio file\n";
00064   *env << "\t\".m4e\" => a MPEG-4 Video Elementary Stream file\n";
00065   *env << "\t\".dv\" => a DV Video file\n";
00066   *env << "\t\".mp3\" => a MPEG-1 or 2 Audio file\n";
00067   *env << "\t\".mpg\" => a MPEG-1 or 2 Program Stream (audio+video) file\n";
00068   *env << "\t\".ts\" => a MPEG Transport Stream file\n";
00069   *env << "\t\t(a \".tsx\" index file - if present - provides server 'trick play' support)\n";
00070   *env << "\t\".wav\" => a WAV Audio file\n";
00071   *env << "See http://www.live555.com/mediaServer/ for additional documentation.\n";
00072 
00073 #if 0 // RTSP-over-HTTP tunneling is not yet working
00074   // Also, attempt to create a HTTP server for RTSP-over-HTTP tunneling.
00075   // Try first with the default HTTP port (80), and then with the alternative HTTP
00076   // port number (8000).
00077   RTSPOverHTTPServer* rtspOverHTTPServer;
00078   portNumBits httpServerPortNum = 80;
00079   rtspOverHTTPServer = RTSPOverHTTPServer::createNew(*env, httpServerPortNum, rtspServerPortNum);
00080   if (rtspOverHTTPServer == NULL) {
00081     httpServerPortNum = 8000;
00082     rtspOverHTTPServer = RTSPOverHTTPServer::createNew(*env, httpServerPortNum, rtspServerPortNum);
00083   }
00084   if (rtspOverHTTPServer == NULL) {
00085     *env << "(No server for RTSP-over-HTTP tunneling was created.)\n";
00086   } else {
00087     *env << "(We use port " << httpServerPortNum << " for RTSP-over-HTTP tunneling.)\n";
00088   }
00089 #endif
00090 
00091   env->taskScheduler().doEventLoop(); // does not return
00092 
00093   return 0; // only to prevent compiler warning
00094 }

Generated on Fri Sep 3 02:35:42 2010 for live by  doxygen 1.5.2