00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "playCommon.hh"
00021 #include "SIPClient.hh"
00022
00023 SIPClient* ourSIPClient = NULL;
00024 Medium* createClient(UsageEnvironment& env, char const* , int verbosityLevel, char const* applicationName) {
00025
00026 char const* suffix = &applicationName[strlen(applicationName)];
00027 while (suffix != applicationName) {
00028 if (*suffix == '/' || *suffix == '\\') {
00029 applicationName = ++suffix;
00030 break;
00031 }
00032 --suffix;
00033 }
00034
00035 extern unsigned char desiredAudioRTPPayloadFormat;
00036 extern char* mimeSubtype;
00037 return ourSIPClient = SIPClient::createNew(env, desiredAudioRTPPayloadFormat, mimeSubtype, verbosityLevel, applicationName);
00038 }
00039
00040 void getOptions(RTSPClient::responseHandler* afterFunc) {
00041 ourSIPClient->envir().setResultMsg("NOT SUPPORTED IN CLIENT");
00042 afterFunc(NULL, -1, strDup(ourSIPClient->envir().getResultMsg()));
00043 }
00044
00045 void getSDPDescription(RTSPClient::responseHandler* afterFunc) {
00046 extern char* proxyServerName;
00047 if (proxyServerName != NULL) {
00048
00049 NetAddressList addresses(proxyServerName);
00050 if (addresses.numAddresses() == 0) {
00051 ourSIPClient->envir() << "Failed to find network address for \"" << proxyServerName << "\"\n";
00052 } else {
00053 NetAddress address = *(addresses.firstAddress());
00054 unsigned proxyServerAddress
00055 = *(unsigned*)(address.data());
00056 extern unsigned short proxyServerPortNum;
00057 if (proxyServerPortNum == 0) proxyServerPortNum = 5060;
00058
00059 ourSIPClient->setProxyServer(proxyServerAddress, proxyServerPortNum);
00060 }
00061 }
00062
00063 extern unsigned short desiredPortNum;
00064 unsigned short clientStartPortNum = desiredPortNum;
00065 if (clientStartPortNum == 0) clientStartPortNum = 8000;
00066 ourSIPClient->setClientStartPortNum(clientStartPortNum);
00067
00068 extern char const* streamURL;
00069 char const* username = ourAuthenticator->username();
00070 char const* password = ourAuthenticator->password();
00071 char* result;
00072 if (username != NULL && password != NULL) {
00073 result = ourSIPClient->inviteWithPassword(streamURL, username, password);
00074 } else {
00075 result = ourSIPClient->invite(streamURL);
00076 }
00077
00078 int resultCode = result == NULL ? -1 : 0;
00079 afterFunc(NULL, resultCode, strDup(result));
00080 }
00081
00082 void setupSubsession(MediaSubsession* subsession, Boolean , RTSPClient::responseHandler* afterFunc) {
00083 subsession->setSessionId("mumble");
00084
00085 afterFunc(NULL, 0, NULL);
00086 }
00087
00088 void startPlayingSession(MediaSession* , double , double , float , RTSPClient::responseHandler* afterFunc) {
00089 if (ourSIPClient->sendACK()) {
00090
00091
00092
00093 afterFunc(NULL, 0, NULL);
00094 } else {
00095 afterFunc(NULL, -1, strDup(ourSIPClient->envir().getResultMsg()));
00096 }
00097 }
00098
00099 void tearDownSession(MediaSession* , RTSPClient::responseHandler* afterFunc) {
00100 if (ourSIPClient == NULL || ourSIPClient->sendBYE()) {
00101 afterFunc(NULL, 0, NULL);
00102 } else {
00103 afterFunc(NULL, -1, strDup(ourSIPClient->envir().getResultMsg()));
00104 }
00105 }
00106
00107 Boolean allowProxyServers = True;
00108 Boolean controlConnectionUsesTCP = False;
00109 Boolean supportCodecSelection = True;
00110 char const* clientProtocolName = "SIP";