VolumeSlotNumber CoreUnix::MountPointToSlotNumber (const DirectoryPath &mountPoint) const { string mountPointStr (mountPoint); if (mountPointStr.find (GetDefaultMountPointPrefix()) == 0) { try { return StringConverter::ToUInt32 (StringConverter::GetTrailingNumber (mountPointStr)); } catch (...) { } } return GetFirstFreeSlotNumber(); }
static void CallEndSession(QTSS_ClientSessionObject* theClientSession) { // action=listener_remove&server=myserver.com&port=8000&client=1&mount=/live&user=&pass=&duration=3600 // the duration SInt64* connectedTime = NULL; UInt32 connectedTimeLen = sizeof(connectedTime); (void)QTSS_GetValuePtr(*theClientSession, qtssCliSesTimeConnectedInMsec, 0, (void**)&connectedTime, &connectedTimeLen); qtss_printf("QTSSIcecastAuthModule::CallEndSession connected time in seconds %li\n", (*connectedTime / 1000)); long duration = (long)*connectedTime / 1000; // the mount point char mountPoint[128] = {0}; StrPtrLen mountPointStr(mountPoint,sizeof(mountPoint)); (void)QTSS_GetValue(*theClientSession, attrClientSessionMountPoint, 0, (void*)mountPointStr.Ptr, &mountPointStr.Len); printf("QTSSIcecastAuthModule::CallEndSession: mount point: %s\n", mountPoint); // TODO - we don't use this data on the remote end (yet), but implement - will probably need to copy // credentials into the client session from the RTSP session (annoying, but both aren't visible at all times) // // username and password // char* username = NULL; // (void)QTSS_GetValueAsString(theRTSPSession, attrRtspSessionProvidedUsername, 0, &username); // printf("QTSSIcecastAuthModule::CallEndSession: Provided username extracted from client session: %s\n", username); // // char* password = NULL; // (void)QTSS_GetValueAsString(theRTSPSession, attrRtspSessionProvidedPassword, 0, &password); // printf("QTSSIcecastAuthModule::CallEndSession: Provided password extracted from client session: %s\n", password); // ice session id char* iceSessID = NULL; QTSS_Error getSessErr = QTSS_GetValueAsString(*theClientSession, attrClientSessionFullSessionID, 0, &iceSessID); char postdata[512]; qtss_sprintf(postdata, "action=listener_remove&server=%s&port=554&client=%s&mount=%s&user=%s&pass=%s&duration=%li", hostname, iceSessID, mountPoint, "", "", duration); printf("QTSSIcecastAuthModule::CallAuthorizeSession: generated postdata: %s\n", postdata); printf("QTSSIcecastAuthModule::CallAuthorizeSession: i would post this to: %s\n", sEndSessionEndpoint); }
static Bool16 CallAuthorizeSession(QTSS_ClientSessionObject* theClientSession, QTSS_RTSPSessionObject* theRTSPSession, QTSS_RTSPRequestObject* theRTSPRequest, char* username, char* password) { qtss_printf("QTSSIcecastAuthModule::CallAuthorizeSession called\n"); //{ :action => "listener_add", :server => "server", :port => "8000", :client => "sessionidone", // :mount => "somemount.sdp", :user => "lstoll", :pass => @working_hash, :ip => "127.0.0.1", :agent => "RSPEC"} // generate the client session id (and save in client) format <start time millis>-<rtsp session id> char ice_sessid[128]; QTSS_TimeVal clientSessCreateTime = NULL; UInt32 createTimeLen = sizeof (clientSessCreateTime); QTSS_GetValue(*theClientSession, qtssCliSesCreateTimeInMsec, 0, (void*) & clientSessCreateTime, &createTimeLen); char* qtssRTSPSesIDString = NULL; (void) QTSS_GetValueAsString(*theRTSPSession, qtssRTSPSesID, 0, &qtssRTSPSesIDString); sprintf(ice_sessid, "%lld-%s", clientSessCreateTime, qtssRTSPSesIDString); printf("QTSSIcecastAuthModule::CallAuthorizeSession generated session id: %s\n", ice_sessid); (void) QTSS_SetValue(*theClientSession, attrClientSessionFullSessionID, 0, &ice_sessid, sizeof (ice_sessid)); // get the user agent char* userAgentString = NULL; (void) QTSS_GetValueAsString(*theClientSession, qtssCliSesFirstUserAgent, 0, &userAgentString); printf("QTSSIcecastAuthModule::CallAuthorizeSession: request user agent: %s\n", userAgentString); // get the client IP address char remoteAddress[20] = {0}; StrPtrLen theClientIPAddressStr(remoteAddress,sizeof(remoteAddress)); (void)QTSS_GetValue(*theRTSPSession, qtssRTSPSesRemoteAddrStr, 0, (void*)theClientIPAddressStr.Ptr, &theClientIPAddressStr.Len); // get the mount point char mountPoint[128] = {0}; StrPtrLen mountPointStr(mountPoint,sizeof(mountPoint)); (void)QTSS_GetValue(*theRTSPRequest, qtssRTSPReqURI, 0, (void*)mountPointStr.Ptr, &mountPointStr.Len); printf("QTSSIcecastAuthModule::CallAuthorizeSession: mount point: %s\n", mountPoint); // and set it in the client for use on session end (void) QTSS_SetValue(*theClientSession, attrClientSessionMountPoint, 0, mountPointStr.Ptr, mountPointStr.Len); char postdata[512]; qtss_sprintf(postdata, "action=listener_add&server=%s&port=554&client=%s&mount=%s&user=%s&pass=%s&ip=%s&agent%s", hostname, ice_sessid, mountPoint, username, password, remoteAddress, userAgentString); printf("QTSSIcecastAuthModule::CallAuthorizeSession: generated postdata: %s\n", postdata); printf("QTSSIcecastAuthModule::CallAuthorizeSession: i would post this to: %s\n", sStartSessionEndpoint); return true; // // CURL *easyhandle = NULL; // easyhandle = curl_easy_init(); // CURLcode curl_code; // // // curl_easy_setopt(easyhandle, CURLOPT_POSTFIELDS, postdata); // curl_easy_setopt(easyhandle, CURLOPT_URL, "http://posthere.com/"); // curl_easy_perform(easyhandle); /* post away! */ // // long http_code = 0; // curl_easy_getinfo(easyhandle, CURLINFO_HTTP_CODE, &http_code); // if (http_code == 200 && curl_code != CURLE_ABORTED_BY_CALLBACK) { // // the call to the remote server was OK. pass. // return true; // } else { // return false; // } // return false; }