Changeset 625
- Timestamp:
- 09/14/11 02:35:44 (8 months ago)
- Location:
- trunk/sources
- Files:
-
- 17 edited
-
applications/applestreamingclient/src/clientcontext.cpp (modified) (3 diffs)
-
applications/proxypublish/src/proxypublishapplication.cpp (modified) (2 diffs)
-
applications/samplefactory/src/httpdownloadprotocol.cpp (modified) (1 diff)
-
applications/stresstest/src/rtmpappprotocolhandler.cpp (modified) (1 diff)
-
common/include/utils/misc/uri.h (modified) (1 diff)
-
common/include/utils/misc/variant.h (modified) (1 diff)
-
common/src/utils/misc/uri.cpp (modified) (2 diffs)
-
thelib/include/protocols/rtmp/basertmpappprotocolhandler.h (modified) (1 diff)
-
thelib/src/application/baseappprotocolhandler.cpp (modified) (1 diff)
-
thelib/src/application/baseclientapplication.cpp (modified) (2 diffs)
-
thelib/src/protocols/cli/http4cliprotocol.cpp (modified) (1 diff)
-
thelib/src/protocols/rtmp/amf0serializer.cpp (modified) (1 diff)
-
thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp (modified) (12 diffs)
-
thelib/src/protocols/rtmp/messagefactories/streammessagefactory.cpp (modified) (1 diff)
-
thelib/src/protocols/rtmp/streaming/baseoutnetrtmpstream.cpp (modified) (1 diff)
-
thelib/src/protocols/rtp/basertspappprotocolhandler.cpp (modified) (2 diffs)
-
thelib/src/protocols/variant/basevariantappprotocolhandler.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/applications/applestreamingclient/src/clientcontext.cpp
r413 r625 673 673 } 674 674 675 if (uri.fullDocumentPath == "") { 676 uri.fullDocumentPath = "/"; 677 } 678 679 if (uri.scheme == "https") { 675 if (uri.scheme() == "https") { 680 676 681 677 FOR_VECTOR_ITERATOR(uint64_t, protocolStackTypes, i) { … … 693 689 Variant parameters; 694 690 parameters["fullUri"] = uriString; 695 parameters["document"] = uri.fullDocumentPath ;696 parameters["host"] = uri.host ;691 parameters["document"] = uri.fullDocumentPath(); 692 parameters["host"] = uri.host(); 697 693 parameters["applicationId"] = _applicationId; 698 694 parameters["contextId"] = _id; … … 700 696 701 697 //4. Start the connection process 702 if (!TCPConnector<ClientContext>::Connect(uri.ip , uri.port, protocolStackTypes, parameters)) {698 if (!TCPConnector<ClientContext>::Connect(uri.ip(), uri.port(), protocolStackTypes, parameters)) { 703 699 FATAL("Unable to open connection to origin"); 704 700 return false; -
trunk/sources/applications/proxypublish/src/proxypublishapplication.cpp
r579 r625 129 129 return false; 130 130 } 131 if (uri.scheme .find("rtmp") != 0) {131 if (uri.scheme().find("rtmp") != 0) { 132 132 FATAL("Supported target scheme is rtmp for now...."); 133 133 return false; … … 135 135 136 136 137 target["targetUri"] = uri .ToVariant();137 target["targetUri"] = uri; 138 138 } 139 139 _targetServers = _configuration["targetServers"]; -
trunk/sources/applications/samplefactory/src/httpdownloadprotocol.cpp
r473 r625 107 107 //3. Prepare the custom parameters (the payload) 108 108 Variant parameters; 109 parameters["uri"] = uri .ToVariant();109 parameters["uri"] = uri; 110 110 parameters["payload"] = payload; 111 111 112 112 //4. Start the HTTP request 113 if (!TCPConnector<HTTPDownloadProtocol>::Connect(uri.ip , uri.port, chain,113 if (!TCPConnector<HTTPDownloadProtocol>::Connect(uri.ip(), uri.port(), chain, 114 114 parameters)) { 115 115 FATAL("Unable to open connection"); -
trunk/sources/applications/stresstest/src/rtmpappprotocolhandler.cpp
r411 r625 67 67 68 68 Variant streamConfig; 69 streamConfig["uri"] = uri .ToVariant();69 streamConfig["uri"] = uri; 70 70 streamConfig["localStreamName"] = generateRandomString(8); 71 71 -
trunk/sources/common/include/utils/misc/uri.h
r576 r625 24 24 #include "utils/misc/variant.h" 25 25 26 typedef struct _URI { 27 string fullUri; 28 string fullUriWithAuth; 29 string scheme; 30 string host; 31 string ip; 32 uint16_t port; 33 string userName; 34 string password; 35 string fullDocumentPath; 36 string documentPath; 37 string document; 38 string fullParameters; 39 string documentWithParameters; 40 map<string, string> parameters; 26 class DLLEXP URI 27 : public Variant { 28 private: 29 static Variant _dummy; 30 public: 31 VARIANT_GETSET(string, originalUri, ""); 32 VARIANT_GETSET(string, fullUri, ""); 33 VARIANT_GETSET(string, fullUriWithAuth, ""); 34 VARIANT_GETSET(string, scheme, ""); 35 VARIANT_GETSET(string, userName, ""); 36 VARIANT_GETSET(string, password, ""); 37 VARIANT_GETSET(string, host, ""); 38 VARIANT_GETSET(string, ip, ""); 39 VARIANT_GETSET(uint16_t, port, 0); 40 VARIANT_GETSET(bool, portSpecified, false); 41 VARIANT_GETSET(string, fullDocumentPathWithParameters, ""); 42 VARIANT_GETSET(string, fullDocumentPath, ""); 43 VARIANT_GETSET(string, fullParameters, ""); 44 VARIANT_GETSET(string, documentPath, ""); 45 VARIANT_GETSET(string, document, ""); 46 VARIANT_GETSET(string, documentWithFullParameters, ""); 47 VARIANT_GETSET(Variant, parameters, _dummy); 41 48 42 DLLEXP void Reset(); 43 44 DLLEXP Variant ToVariant(); 45 DLLEXP static bool FromVariant(Variant & variant, _URI & uri); 46 47 DLLEXP string ToString(); 48 DLLEXP static bool FromString(string stringUri, bool resolveHost, _URI & uri); 49 } URI; 49 DLLEXP static bool FromVariant(Variant & variant, URI &uri); 50 DLLEXP static bool FromString(string stringUri, bool resolveHost, URI &uri); 51 }; 50 52 51 53 #endif /* _URI_H */ -
trunk/sources/common/include/utils/misc/variant.h
r484 r625 38 38 #define DYNAMIC_FREE(type) 39 39 #endif 40 41 #define VARIANT_GET(type,name,defaultValue) \ 42 type name() { \ 43 if((*this)!=V_MAP) \ 44 return defaultValue; \ 45 if(this->HasKey(#name)) \ 46 return (type)((*this)[#name]); \ 47 return defaultValue; \ 48 }; 49 50 #define VARIANT_SET(type,name) \ 51 void name(type val) { \ 52 (*this)[#name]=(type)val; \ 53 }; 54 55 #define VARIANT_GETSET(type, name, defaultValue) VARIANT_GET(type,name,defaultValue);VARIANT_SET(type,name); 40 56 41 57 typedef enum _VariantType { -
trunk/sources/common/src/utils/misc/uri.cpp
r576 r625 22 22 #include "utils/logging/logging.h" 23 23 24 //#define LOG_URI_SPLIT(...) FINEST(__VA_ARGS__) 25 #define LOG_URI_SPLIT(...) 26 27 static map<string, uint16_t> ___schemeToPort; 24 static map<string, uint16_t> _schemeToPort; 25 Variant URI::_dummy; 26 27 #ifdef DEBUG_URI 28 #define LOG_URI(...) FINEST(__VA_ARGS__) 29 #else 30 #define LOG_URI(...) 31 #endif /* DEBUG_URI */ 28 32 29 33 bool parseURI(string stringUri, URI &uri) { 30 LOG_URI_SPLIT("stringUri: %s", STR(stringUri)); 34 /* 35 * schema://[username[:password]@]host[:port][/[path[?parameters]]] 36 */ 37 LOG_URI("------------------------"); 38 LOG_URI("stringUri: `%s`", STR(stringUri)); 39 string fullUri; 40 string fullUriWithAuth = stringUri; 41 string scheme; 42 string authentication; 43 string username; 44 string password; 45 string hostPort; 46 string host; 47 string portString; 48 uint16_t port; 49 bool portSpecified; 50 string fullDocumentPathWithParameters; 51 string fullDocumentPath; 52 string fullParameters; 53 string documentPath; 54 string document; 55 string documentWithFullParameters; 56 Variant parameters; 57 58 string::size_type cursor = 0; 59 string::size_type pos = 0; 60 61 //1. Reset 31 62 uri.Reset(); 63 64 //2. trim 32 65 trim(stringUri); 33 if (stringUri == "") 34 return false; 35 36 if (stringUri.size() > 1024) 37 return false; 38 39 uri.fullUri = uri.fullUriWithAuth = stringUri; 40 LOG_URI_SPLIT("uri.fullUri: %s", STR(uri.fullUri)); 41 42 43 // scheme://user:pwd@host:port/document/parts/here 44 45 vector<string> components; 46 split(stringUri, "/", components); 47 for (uint32_t i = 0; i < components.size(); i++) { 48 LOG_URI_SPLIT("%u: %s", i, STR(components[i])); 49 } 50 51 //0 - scheme: 52 if (components[0] == "") 53 return false; 54 55 if (components[0][components[0].size() - 1] != ':') 56 return false; 57 58 uri.scheme = lowerCase(components[0].substr(0, components[0].size() - 1)); 59 LOG_URI_SPLIT("uri.scheme: %s", STR(uri.scheme)); 60 61 62 //1 - nothing 63 if (components[1] != "") 64 return false; 65 66 //2 - user:pwd@host:port 67 vector<string> hostComponents; 68 if (components[2].find("@") != string::npos) { 69 split(components[2], "@", hostComponents); 70 if (hostComponents.size() != 2) 66 if (stringUri == "") { 67 FATAL("Empty uri"); 68 return false; 69 } 70 71 //2. Get the scheme and the default port 72 pos = stringUri.find("://", cursor); 73 if (pos == string::npos) { 74 FATAL("Unable to determine scheme"); 75 return false; 76 } 77 scheme = lowerCase(stringUri.substr(cursor, pos - cursor)); 78 cursor = pos + 3; 79 if (_schemeToPort.size() == 0) { 80 _schemeToPort["http"] = 80; 81 _schemeToPort["rtmpt"] = 80; 82 _schemeToPort["rtmpte"] = 80; 83 _schemeToPort["https"] = 443; 84 _schemeToPort["rtmps"] = 443; 85 _schemeToPort["rtsp"] = 554; 86 _schemeToPort["rtmp"] = 1935; 87 _schemeToPort["rtmpe"] = 1935; 88 _schemeToPort["mms"] = 1755; 89 } 90 if (MAP_HAS1(_schemeToPort, scheme)) { 91 port = _schemeToPort[scheme]; 92 } else { 93 FATAL("Scheme `%s` not supported", STR(scheme)); 94 return false; 95 } 96 LOG_URI("scheme: %s; default port: %"PRIu16, STR(scheme), port); 97 98 //3. get the authentication portion. the search starts from 99 //where the scheme detection left and up to the first / character 100 string::size_type limit = stringUri.find("/", cursor); 101 bool hasAuthentication = false; 102 pos = stringUri.find("@", cursor); 103 if (pos != string::npos) { 104 if (limit != string::npos) { 105 hasAuthentication = pos<limit; 106 } 107 hasAuthentication = true; 108 } 109 if (hasAuthentication) { 110 authentication = stringUri.substr(cursor, pos - cursor); 111 fullUri = stringUri.substr(0, cursor); 112 fullUri += stringUri.substr(pos + 1); 113 cursor = pos + 1; 114 } else { 115 fullUri = fullUriWithAuth; 116 } 117 if (authentication != "") { 118 pos = authentication.find(":"); 119 if (pos != string::npos) { 120 username = authentication.substr(0, pos); 121 password = authentication.substr(pos + 1); 122 } else { 123 username = authentication; 124 password = ""; 125 } 126 } 127 LOG_URI("fullUri: `%s`; fullUriWithAuth: `%s`", STR(fullUri), STR(fullUriWithAuth)); 128 LOG_URI("username: `%s`; password: `%s`", STR(username), STR(password)); 129 130 //4. Get the host:port 131 pos = stringUri.find("/", cursor); 132 if (pos == string::npos) { 133 hostPort = stringUri.substr(cursor); 134 cursor = stringUri.size() - 1; 135 fullDocumentPathWithParameters = "/"; 136 } else { 137 hostPort = stringUri.substr(cursor, pos - cursor); 138 cursor = pos + 1; 139 fullDocumentPathWithParameters = "/" + stringUri.substr(cursor); 140 } 141 trim(hostPort); 142 if (hostPort == "") { 143 FATAL("Invalid host:port specified"); 144 return false; 145 } 146 pos = hostPort.find(":"); 147 if (pos == string::npos) { 148 host = hostPort; 149 portSpecified = false; 150 } else { 151 host = hostPort.substr(0, pos); 152 trim(host); 153 portString = hostPort.substr(pos + 1); 154 portSpecified = true; 155 port = (uint16_t) atoi(STR(portString)); 156 if (format("%"PRIu16, port) != portString) { 157 FATAL("Invalid port number specified: `%s`", STR(portString)); 71 158 return false; 72 if ((hostComponents[0] == "") 73 || (hostComponents[1] == "")) { 74 return false; 75 } 76 components[2] = hostComponents[1]; 77 vector<string> userNamePasswordComponents; 78 split(hostComponents[0], ":", userNamePasswordComponents); 79 if (userNamePasswordComponents.size() != 2) 80 return false; 81 if ((userNamePasswordComponents[0] == "") 82 || (userNamePasswordComponents[1] == "")) { 83 return false; 84 } 85 uri.userName = userNamePasswordComponents[0]; 86 LOG_URI_SPLIT("uri.userName: %s", STR(uri.userName)); 87 uri.password = userNamePasswordComponents[1]; 88 LOG_URI_SPLIT("uri.password: %s", STR(uri.password)); 89 replace(uri.fullUri, uri.userName + ":" + uri.password + "@", ""); 90 } 91 92 split(components[2], ":", hostComponents); 93 if (hostComponents.size() == 1) { 94 if (hostComponents[0] == "") 95 return false; 96 uri.host = hostComponents[0]; 97 LOG_URI_SPLIT("uri.host: %s", STR(uri.host)); 98 } else if (hostComponents.size() == 2) { 99 if ((hostComponents[0] == "") 100 || (hostComponents[0] == "")) 101 return false; 102 uri.host = hostComponents[0]; 103 LOG_URI_SPLIT("uri.host: %s", STR(uri.host)); 104 int32_t port = atoi(STR(hostComponents[1])); 105 if ((port <= 0) || (port > 65535)) 106 return false; 107 uri.port = (uint16_t) port; 108 } else { 109 return false; 110 } 111 112 if (uri.port == 0) { 113 if (___schemeToPort.size() == 0) { 114 ___schemeToPort["http"] = 80; 115 ___schemeToPort["rtmpt"] = 80; 116 ___schemeToPort["rtmpte"] = 80; 117 ___schemeToPort["https"] = 443; 118 ___schemeToPort["rtmps"] = 443; 119 ___schemeToPort["rtsp"] = 554; 120 ___schemeToPort["rtmp"] = 1935; 121 ___schemeToPort["rtmpe"] = 1935; 122 ___schemeToPort["mms"] = 1755; 123 } 124 if (MAP_HAS1(___schemeToPort, uri.scheme)) 125 uri.port = ___schemeToPort[uri.scheme]; 126 else 127 return false; 128 } 129 LOG_URI_SPLIT("uri.port: %u", uri.port); 130 131 for (uint32_t i = 3; i < components.size(); i++) { 132 uri.fullDocumentPath += "/" + components[i]; 133 } 134 LOG_URI_SPLIT("uri.fullDocumentPath: %s", STR(uri.fullDocumentPath)); 135 136 uri.documentPath = "/"; 137 for (uint32_t i = 3; i < components.size() - 1; i++) { 138 uri.documentPath += components[i]; 139 if (i != components.size() - 2) 140 uri.documentPath += "/"; 141 } 142 LOG_URI_SPLIT("uri.documentPath: %s", STR(uri.documentPath)); 143 144 if ((components.size() - 1) >= 3) { 145 uri.document = components[components.size() - 1]; 146 uri.documentWithParameters = uri.document; 147 vector<string> documentComponents; 148 split(uri.document, "?", documentComponents); 149 if (documentComponents.size() == 2) { 150 uri.document = documentComponents[0]; 151 uri.fullParameters = documentComponents[1]; 152 map<string, string> params; 153 params = mapping(documentComponents[1], "&", "=", true); 154 155 FOR_MAP(params, string, string, i) { 156 uri.parameters[MAP_KEY(i)] = MAP_VAL(i); 157 LOG_URI_SPLIT("uri.parameters[\"%s\"]: %s", 158 STR(MAP_KEY(i)), 159 STR(MAP_VAL(i))); 159 } 160 } 161 LOG_URI("host: %s; port: %"PRIu16"; portSpecified: %d", STR(host), port, portSpecified); 162 163 //5. fullDocumentPathWithParameters 164 fullDocumentPath = "/"; 165 fullParameters = ""; 166 documentPath = "/"; 167 document = ""; 168 documentWithFullParameters = ""; 169 parameters.Reset(); 170 parameters.IsArray(false); 171 if (fullDocumentPathWithParameters != "/") { 172 pos = fullDocumentPathWithParameters.find("?"); 173 if (pos == string::npos) { 174 fullDocumentPath = fullDocumentPathWithParameters; 175 fullParameters = ""; 176 } else { 177 fullDocumentPath = fullDocumentPathWithParameters.substr(0, pos); 178 fullParameters = fullDocumentPathWithParameters.substr(pos + 1); 179 } 180 181 trim(fullParameters); 182 if (fullParameters != "") { 183 vector<string> elements; 184 split(fullParameters, "&", elements); 185 for (uint32_t i = 0; i < elements.size(); i++) { 186 string kvp = elements[i]; 187 if (kvp == "") 188 continue; 189 string k = ""; 190 string v = ""; 191 pos = kvp.find("="); 192 if (pos == string::npos) { 193 k = kvp; 194 v = ""; 195 } else { 196 k = kvp.substr(0, pos); 197 v = kvp.substr(pos + 1); 198 } 199 if (k == "") 200 continue; 201 parameters[k] = v; 160 202 } 161 } else { 162 uri.document = documentComponents[0]; 163 uri.fullParameters = ""; 164 } 165 } 166 LOG_URI_SPLIT("uri.document: %s", STR(uri.document)); 203 } 204 205 for (string::size_type i = fullDocumentPath.size() - 1; i >= 0; i--) { 206 if (fullDocumentPath[i] == '/') 207 break; 208 document = fullDocumentPath[i] + document; 209 } 210 documentPath = fullDocumentPath.substr(0, fullDocumentPath.size() - document.size()); 211 documentWithFullParameters = document; 212 if (fullParameters != "") 213 documentWithFullParameters += "?" + fullParameters; 214 } 215 LOG_URI("fullDocumentPathWithParameters: `%s`", STR(fullDocumentPathWithParameters)); 216 LOG_URI("fullDocumentPath: `%s`", STR(fullDocumentPath)); 217 LOG_URI("fullParameters: `%s`", STR(fullParameters)); 218 LOG_URI("documentPath: `%s`", STR(documentPath)); 219 LOG_URI("document: `%s`", STR(document)); 220 LOG_URI("documentWithFullParameters: `%s`", STR(documentWithFullParameters)); 221 LOG_URI("parameters:"); 222 #ifdef DEBUG_URI 223 224 FOR_MAP(parameters, string, Variant, i) { 225 LOG_URI("\t`%s`: `%s`", STR(MAP_KEY(i)), STR(MAP_VAL(i))); 226 } 227 #endif /* DEBUG_URI */ 228 229 uri.originalUri(stringUri); 230 uri.fullUri(fullUri); 231 uri.fullUriWithAuth(fullUriWithAuth); 232 uri.scheme(scheme); 233 uri.userName(username); 234 uri.password(password); 235 uri.host(host); 236 uri.port(port); 237 uri.portSpecified(portSpecified); 238 uri.fullDocumentPathWithParameters(fullDocumentPathWithParameters); 239 uri.fullDocumentPath(fullDocumentPath); 240 uri.fullParameters(fullParameters); 241 uri.documentPath(documentPath); 242 uri.document(document); 243 uri.documentWithFullParameters(documentWithFullParameters); 244 uri.parameters(parameters); 167 245 168 246 return true; 169 247 } 170 248 171 void URI::Reset() {172 fullUri = fullUriWithAuth = scheme = host = userName = password173 = fullDocumentPath = documentPath = document = fullParameters174 = documentWithParameters = "";175 port = 0;176 parameters.clear();177 }178 179 Variant URI::ToVariant() {180 Variant result;181 result["fullUri"] = fullUri;182 result["fullUriWithAuth"] = fullUriWithAuth;183 result["scheme"] = scheme;184 result["host"] = host;185 result["ip"] = ip;186 result["port"] = (uint16_t) port;187 result["userName"] = userName;188 result["password"] = password;189 result["fullDocumentPath"] = fullDocumentPath;190 result["documentPath"] = documentPath;191 result["document"] = document;192 result["documentWithParameters"] = documentWithParameters;193 if (fullParameters != "") {194 result["fullParameters"] = fullParameters;195 196 FOR_MAP(parameters, string, string, i) {197 result["parameters"][MAP_KEY(i)] = MAP_VAL(i);198 }199 }200 201 return result;202 }203 204 249 bool URI::FromVariant(Variant & variant, URI &uri) { 205 250 uri.Reset(); 206 251 207 if (variant != V_MAP) 208 return false; 209 210 if ((!(variant.HasKeyChain(V_STRING, true, 1, "fullUri"))) 252 if (variant != V_MAP) { 253 FATAL("Variant is not a map"); 254 return false; 255 } 256 257 if ((!(variant.HasKeyChain(V_STRING, true, 1, "originalUri"))) 258 || (!(variant.HasKeyChain(V_STRING, true, 1, "fullUri"))) 211 259 || (!(variant.HasKeyChain(V_STRING, true, 1, "fullUriWithAuth"))) 212 260 || (!(variant.HasKeyChain(V_STRING, true, 1, "scheme"))) 261 || (!(variant.HasKeyChain(V_STRING, true, 1, "userName"))) 262 || (!(variant.HasKeyChain(V_STRING, true, 1, "password"))) 213 263 || (!(variant.HasKeyChain(V_STRING, true, 1, "host"))) 214 264 || (!(variant.HasKeyChain(V_STRING, true, 1, "ip"))) 215 || (!(variant.HasKeyChain( V_UINT16, true, 1, "port")))216 || (!(variant.HasKeyChain(V_ STRING, true, 1, "userName")))217 || (!(variant.HasKeyChain(V_STRING, true, 1, " password")))265 || (!(variant.HasKeyChain(_V_NUMERIC, true, 1, "port"))) 266 || (!(variant.HasKeyChain(V_BOOL, true, 1, "portSpecified"))) 267 || (!(variant.HasKeyChain(V_STRING, true, 1, "fullDocumentPathWithParameters"))) 218 268 || (!(variant.HasKeyChain(V_STRING, true, 1, "fullDocumentPath"))) 269 || (!(variant.HasKeyChain(V_STRING, true, 1, "fullParameters"))) 219 270 || (!(variant.HasKeyChain(V_STRING, true, 1, "documentPath"))) 220 271 || (!(variant.HasKeyChain(V_STRING, true, 1, "document"))) 221 || (!(variant.HasKeyChain(V_STRING, true, 1, "documentWithParameters"))) 272 || (!(variant.HasKeyChain(V_STRING, true, 1, "documentWithFullParameters"))) 273 || (!(variant.HasKeyChain(V_MAP, true, 1, "parameters"))) 222 274 ) { 223 return false; 224 } 225 226 uri.fullUri = (string) variant["fullUri"]; 227 uri.fullUriWithAuth = (string) variant["fullUriWithAuth"]; 228 uri.scheme = (string) variant["scheme"]; 229 uri.host = (string) variant["host"]; 230 uri.ip = (string) variant["ip"]; 231 uri.port = (uint16_t) variant["port"]; 232 uri.userName = (string) variant["userName"]; 233 uri.password = (string) variant["password"]; 234 uri.fullDocumentPath = (string) variant["fullDocumentPath"]; 235 uri.documentPath = (string) variant["documentPath"]; 236 uri.document = (string) variant["document"]; 237 uri.documentWithParameters = (string) variant["documentWithParameters"]; 238 239 if (variant.HasKeyChain(V_STRING, true, 1, "fullParameters")) { 240 if (!(variant.HasKeyChain(V_MAP, true, 1, "parameters"))) { 241 uri.Reset(); 242 return false; 243 } 244 uri.fullParameters = (string) variant["fullParameters"]; 245 246 FOR_MAP(variant["parameters"], string, Variant, i) { 247 if (((VariantType) MAP_VAL(i)) != V_STRING) { 248 uri.Reset(); 249 return false; 250 } 251 uri.parameters[MAP_KEY(i)] = (string) MAP_VAL(i); 252 } 253 } else { 254 uri.fullParameters = ""; 255 uri.parameters.clear(); 256 } 275 FATAL("One or more type mismatch"); 276 return false; 277 } 278 279 Variant *pURI = (Variant *) & uri; 280 *pURI = variant; 257 281 258 282 return true; 259 }260 261 string URI::ToString() {262 return fullUriWithAuth;263 283 } 264 284 … … 270 290 271 291 if (resolveHost) { 272 uri.ip = getHostByName(uri.host);273 if ( uri.ip == "") {274 FATAL("Unable to resolve host: %s", STR(uri.host ));292 string ip = getHostByName(uri.host()); 293 if (ip == "") { 294 FATAL("Unable to resolve host: %s", STR(uri.host())); 275 295 uri.Reset(); 276 296 return false; 277 297 } 298 uri.ip(ip); 299 } else { 300 uri.ip(""); 278 301 } 279 302 -
trunk/sources/thelib/include/protocols/rtmp/basertmpappprotocolhandler.h
r608 r625 281 281 * Send the initial connect invoke 282 282 * */ 283 bool ConnectForPullPush(BaseRTMPProtocol *pFrom, string uriPath, Variant &config); 283 bool ConnectForPullPush(BaseRTMPProtocol *pFrom, string uriPath, 284 Variant &config, bool isPull); 284 285 285 286 /* -
trunk/sources/thelib/src/application/baseappprotocolhandler.cpp
r577 r625 50 50 bool BaseAppProtocolHandler::PullExternalStream(URI uri, Variant streamConfig) { 51 51 WARN("Pulling in streams for scheme %s in application %s not yet implemented. Stream configuration was:\n%s", 52 STR(uri.scheme ),52 STR(uri.scheme()), 53 53 STR(GetApplication()->GetName()), 54 54 STR(streamConfig.ToString())); -
trunk/sources/thelib/src/application/baseclientapplication.cpp
r616 r625 301 301 return false; 302 302 } 303 streamConfig["uri"] = uri .ToVariant();303 streamConfig["uri"] = uri; 304 304 305 305 //3. Depending on the scheme name, get the curresponding protocol handler 306 306 ///TODO: integrate this into protocol factory manager via protocol factories 307 BaseAppProtocolHandler *pProtocolHandler = GetProtocolHandler(uri.scheme); 307 string scheme = uri.scheme(); 308 BaseAppProtocolHandler *pProtocolHandler = GetProtocolHandler(scheme); 308 309 if (pProtocolHandler == NULL) { 309 310 WARN("Unable to find protocol handler for scheme %s in application %s", 310 STR( uri.scheme),311 STR(scheme), 311 312 STR(GetName())); 312 313 return false; … … 341 342 return false; 342 343 } 343 streamConfig["targetUri"] = uri .ToVariant();344 streamConfig["targetUri"] = uri; 344 345 345 346 //3. Depending on the scheme name, get the curresponding protocol handler 346 347 ///TODO: integrate this into protocol factory manager via protocol factories 347 BaseAppProtocolHandler *pProtocolHandler = GetProtocolHandler(uri.scheme); 348 string scheme = uri.scheme(); 349 BaseAppProtocolHandler *pProtocolHandler = GetProtocolHandler(scheme); 348 350 if (pProtocolHandler == NULL) { 349 351 WARN("Unable to find protocol handler for scheme %s in application %s", 350 STR( uri.scheme),352 STR(scheme), 351 353 STR(GetName())); 352 354 return false; -
trunk/sources/thelib/src/protocols/cli/http4cliprotocol.cpp
r471 r625 92 92 URI uri; 93 93 string dummy = "http://localhost" + (string) headers[HTTP_FIRST_LINE][HTTP_URL]; 94 FINEST("dummy: %s",STR(dummy));94 //FINEST("dummy: %s", STR(dummy)); 95 95 if (!URI::FromString(dummy, false, uri)) { 96 96 FATAL("Invalid request"); 97 97 return false; 98 98 } 99 string fullCommand =uri.document;100 fullCommand +=" ";101 if (uri.parameters.size()!=0){102 fullCommand +=unb64(MAP_VAL(uri.parameters.begin()));99 string fullCommand = uri.document(); 100 fullCommand += " "; 101 if (uri.parameters().MapSize() != 0) { 102 fullCommand += unb64(MAP_VAL(uri.parameters().begin())); 103 103 } 104 fullCommand +="\n";104 fullCommand += "\n"; 105 105 _localInputBuffer.ReadFromString(fullCommand); 106 106 -
trunk/sources/thelib/src/protocols/rtmp/amf0serializer.cpp
r427 r625 227 227 } 228 228 229 variant.IsArray(false); 230 229 231 return true; 230 232 } -
trunk/sources/thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp
r619 r625 161 161 streamConfig["localStreamName"] = "stream_" + generateRandomString(8); 162 162 WARN("No localstream name for external URI: %s. Defaulted to %s", 163 STR(uri.fullUri ),163 STR(uri.fullUri()), 164 164 STR(streamConfig["localStreamName"])); 165 165 } … … 169 169 parameters["customParameters"]["externalStreamConfig"] = streamConfig; 170 170 parameters[CONF_APPLICATION_NAME] = GetApplication()->GetName(); 171 if (uri.scheme == "rtmp") { 171 string scheme = uri.scheme(); 172 if (scheme == "rtmp") { 172 173 parameters[CONF_PROTOCOL] = CONF_PROTOCOL_OUTBOUND_RTMP; 173 } else if ( uri.scheme == "rtmpt") {174 } else if (scheme == "rtmpt") { 174 175 parameters[CONF_PROTOCOL] = CONF_PROTOCOL_OUTBOUND_RTMPT; 175 } else if ( uri.scheme == "rtmpe") {176 } else if (scheme == "rtmpe") { 176 177 parameters[CONF_PROTOCOL] = CONF_PROTOCOL_OUTBOUND_RTMPE; 177 178 } else { 178 FATAL("scheme %s not supported by RTMP handler", STR( uri.scheme));179 FATAL("scheme %s not supported by RTMP handler", STR(scheme)); 179 180 return false; 180 181 } 181 182 182 183 //3. start the connecting sequence 183 return OutboundRTMPProtocol::Connect(uri.ip , uri.port, parameters);184 return OutboundRTMPProtocol::Connect(uri.ip(), uri.port(), parameters); 184 185 } 185 186 … … 904 905 ST_IN_NET_RTMP); 905 906 request["waitForLiveStream"] = (bool)true; 906 request["streamName"] =streamName;907 request["streamName"] = streamName; 907 908 return pBaseOutNetRTMPStream != NULL; 908 909 } … … 926 927 ST_IN_NET_RTMP); 927 928 request["waitForLiveStream"] = (bool)true; 928 request["streamName"] =streamName;929 request["streamName"] = streamName; 929 930 return pBaseOutNetRTMPStream != NULL; 930 931 } … … 1302 1303 1303 1304 Variant FCSubscribeRequest = StreamMessageFactory::GetInvokeFCSubscribe( 1304 parameters["uri"]["documentWith Parameters"]);1305 parameters["uri"]["documentWithFullParameters"]); 1305 1306 if (!SendRTMPMessage(pFrom, FCSubscribeRequest, true)) { 1306 1307 FATAL("Unable to send request:\n%s", STR(FCSubscribeRequest.ToString())); … … 1375 1376 if (NeedsToPullExternalStream(pFrom)) { 1376 1377 publishPlayRequest = StreamMessageFactory::GetInvokePlay(3, rtmpStreamId, 1377 parameters["uri"]["documentWith Parameters"], -2, -1);1378 parameters["uri"]["documentWithFullParameters"], -2, -1); 1378 1379 } else { 1379 1380 string targetStreamType = ""; … … 1952 1953 1953 1954 //2. Issue the connect invoke 1954 return ConnectForPullPush(pFrom, "uri", streamConfig );1955 return ConnectForPullPush(pFrom, "uri", streamConfig, true); 1955 1956 } 1956 1957 … … 1960 1961 1961 1962 //2. Issue the connect invoke 1962 return ConnectForPullPush(pFrom, "targetUri", streamConfig );1963 return ConnectForPullPush(pFrom, "targetUri", streamConfig, false); 1963 1964 } 1964 1965 1965 1966 bool BaseRTMPAppProtocolHandler::ConnectForPullPush(BaseRTMPProtocol *pFrom, 1966 string uriPath, Variant &streamConfig ) {1967 string uriPath, Variant &streamConfig, bool isPull) { 1967 1968 URI uri; 1968 1969 if (!URI::FromVariant(streamConfig[uriPath], uri)) { … … 1972 1973 1973 1974 //2. get the application name 1974 string appName = uri.documentPath; 1975 if (appName == "/") 1976 appName = uri.document; 1975 string appName = ""; 1976 if (isPull) { 1977 appName = uri.documentPath(); 1978 } else { 1979 appName = uri.fullDocumentPath(); 1980 } 1977 1981 if (appName != "") { 1978 1982 if (appName[0] == '/') 1979 1983 appName = appName.substr(1, appName.size() - 1); 1984 if (appName != "") { 1985 if (appName[appName.size() - 1] == '/') 1986 appName = appName.substr(0, appName.size() - 1); 1987 } 1980 1988 } 1981 1989 if (appName == "") { 1982 FATAL("Invalid uri: %s", STR(uri.fullUri ));1983 return false; 1984 } 1985 if (uri.userName != "") {1990 FATAL("Invalid uri: %s", STR(uri.fullUri())); 1991 return false; 1992 } 1993 if (uri.userName() != "") { 1986 1994 if (streamConfig.HasKey("auth")) { 1987 string user = uri.userName ;1988 string password = uri.password ;1995 string user = uri.userName(); 1996 string password = uri.password(); 1989 1997 string salt = streamConfig["auth"]["salt"]; 1990 1998 string opaque = streamConfig["auth"]["opaque"]; … … 1992 2000 string response = b64(md5(b64(md5(user + salt + password, false)) + opaque + challenge, false)); 1993 2001 appName = appName + "?authmod=adobe" 1994 + "&user=" + uri.userName 2002 + "&user=" + uri.userName() 1995 2003 + "&challenge=" + challenge 1996 2004 + "&opaque=" + opaque … … 1999 2007 streamConfig["emulateUserAgent"] = "FMLE/3.0 (compatible; FMSc/1.0)"; 2000 2008 } else { 2001 appName = appName + "?authmod=adobe&user=" + uri.userName ;2009 appName = appName + "?authmod=adobe&user=" + uri.userName(); 2002 2010 streamConfig["emulateUserAgent"] = "FMLE/3.0 (compatible; FMSc/1.0)"; 2003 2011 } … … 2006 2014 //3. Compute tcUrl: rtmp://host/appName 2007 2015 string tcUrl = format("%s://%s%s/%s", 2008 STR(uri.scheme ),2009 STR(uri.host ),2010 STR(uri.port == 1935 ? "" : format(":%hu", uri.port)),2016 STR(uri.scheme()), 2017 STR(uri.host()), 2018 STR(uri.portSpecified() ? format(":%"PRIu32) : ""), 2011 2019 STR(appName)); 2012 2020 -
trunk/sources/thelib/src/protocols/rtmp/messagefactories/streammessagefactory.cpp
r368 r625 334 334 Variant metadata) { 335 335 Variant parameters; 336 metadata[HTTP_HEADERS_SERVER] = HTTP_HEADERS_SERVER_US; 336 337 parameters[(uint32_t) 0] = metadata; 337 338 return GenericMessageFactory::GetNotify(channelId, streamId, timeStamp, -
trunk/sources/thelib/src/protocols/rtmp/streaming/baseoutnetrtmpstream.cpp
r609 r625 421 421 if (pCapabilities->videoCodecId == CODEC_VIDEO_AVC) { 422 422 Variant meta; 423 meta.IsArray(false); 423 424 if ((pCapabilities->avc._widthOverride != 0) 424 425 && (pCapabilities->avc._heightOverride != 0)) { -
trunk/sources/thelib/src/protocols/rtp/basertspappprotocolhandler.cpp
r621 r625 124 124 customParameters["isClient"] = (bool)true; 125 125 customParameters["appId"] = GetApplication()->GetId(); 126 customParameters["uri"] = uri .ToVariant();126 customParameters["uri"] = uri; 127 127 customParameters["connectionType"] = "pull"; 128 128 129 129 //3. Connect 130 130 if (!TCPConnector<BaseRTSPAppProtocolHandler>::Connect( 131 uri.ip ,132 uri.port ,131 uri.ip(), 132 uri.port(), 133 133 chain, customParameters)) { 134 134 FATAL("Unable to connect to %s:%hu", … … 408 408 return false; 409 409 } 410 if (uri.documentWithParameters == "") {411 FATAL("Inavlid stream name");412 return false;413 }414 string streamName = uri.documentWithParameters;410 string streamName = uri.documentWithFullParameters(); 411 if (streamName == "") { 412 FATAL("Invalid stream name"); 413 return false; 414 } 415 415 416 416 //2. Get the inbound stream capabilities -
trunk/sources/thelib/src/protocols/variant/basevariantappprotocolhandler.cpp
r617 r625 195 195 } 196 196 197 //5. Fix the document198 if (uri.fullDocumentPath == "") {199 uri.fullDocumentPath = "/";200 }201 202 197 //6. build the end result 203 result["username"] = uri.userName ;204 result["password"] = uri.password ;205 result["host"] = uri.host ;206 result["ip"] = uri.ip ;207 result["port"] = uri.port ;208 result["document"] = uri.fullDocumentPath ;198 result["username"] = uri.userName(); 199 result["password"] = uri.password(); 200 result["host"] = uri.host(); 201 result["ip"] = uri.ip(); 202 result["port"] = uri.port(); 203 result["document"] = uri.fullDocumentPath(); 209 204 result["applicationName"] = GetApplication()->GetName(); 210 205
Note: See TracChangeset
for help on using the changeset viewer.
