Changeset 714
- Timestamp:
- 12/05/11 23:31:23 (6 months ago)
- Files:
-
- 8 edited
-
branches/1.0/sources/thelib/include/protocols/rtp/basertspappprotocolhandler.h (modified) (3 diffs)
-
branches/1.0/sources/thelib/include/protocols/rtp/sdp.h (modified) (2 diffs)
-
branches/1.0/sources/thelib/src/protocols/rtp/basertspappprotocolhandler.cpp (modified) (6 diffs)
-
branches/1.0/sources/thelib/src/protocols/rtp/sdp.cpp (modified) (2 diffs)
-
trunk/sources/thelib/include/protocols/rtp/basertspappprotocolhandler.h (modified) (3 diffs)
-
trunk/sources/thelib/include/protocols/rtp/sdp.h (modified) (2 diffs)
-
trunk/sources/thelib/src/protocols/rtp/basertspappprotocolhandler.cpp (modified) (6 diffs)
-
trunk/sources/thelib/src/protocols/rtp/sdp.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/sources/thelib/include/protocols/rtp/basertspappprotocolhandler.h
r694 r714 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 74 74 virtual bool HandleRTSPRequestRecord(RTSPProtocol *pFrom, 75 75 Variant &requestHeaders, string &requestContent); 76 virtual bool HandleRTSPRequestPause(RTSPProtocol *pFrom, 77 Variant &requestHeaders, string &requestContent); 76 78 77 79 //handle response routines … … 133 135 string ComputeSDP(RTSPProtocol *pFrom, string localStreamName, 134 136 string targetStreamName, string host); 135 bool ParseTransportLine(string raw, Variant &result);136 137 }; 137 138 -
branches/1.0/sources/thelib/include/protocols/rtp/sdp.h
r551 r714 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 66 66 string GetStreamName(); 67 67 uint32_t GetTotalBandwidth(); 68 static bool ParseTransportLine(string raw, Variant &result); 68 69 private: 69 70 static bool ParseSection(Variant &result, vector<string> &lines, -
branches/1.0/sources/thelib/src/protocols/rtp/basertspappprotocolhandler.cpp
r713 r714 354 354 return false; 355 355 } 356 } else if (method == RTSP_METHOD_PAUSE) { 357 if (!HandleRTSPRequestPause(pFrom, requestHeaders, requestContent)) { 358 return false; 359 } 356 360 } else { 357 361 FATAL("Method not implemented yet:\n%s", STR(requestHeaders.ToString())); … … 467 471 string raw = requestHeaders[RTSP_HEADERS].GetValue(RTSP_HEADERS_TRANSPORT, false); 468 472 Variant transport; 469 if (! ParseTransportLine(raw, transport)) {473 if (!SDP::ParseTransportLine(raw, transport)) { 470 474 FATAL("Unable to parse transport line %s", STR(raw)); 471 475 return false; … … 574 578 string transportLine = requestHeaders[RTSP_HEADERS].GetValue(RTSP_HEADERS_TRANSPORT, false); 575 579 Variant transport; 576 if (! ParseTransportLine(transportLine, transport)) {580 if (!SDP::ParseTransportLine(transportLine, transport)) { 577 581 FATAL("Unable to parse transport line"); 578 582 return false; … … 834 838 835 839 //4. Send back the response 840 pFrom->PushResponseFirstLine(RTSP_VERSION_1_0, 200, "OK"); 841 return pFrom->SendResponseMessage(); 842 } 843 844 bool BaseRTSPAppProtocolHandler::HandleRTSPRequestPause(RTSPProtocol *pFrom, 845 Variant &requestHeaders, string &requestContent) { 836 846 pFrom->PushResponseFirstLine(RTSP_VERSION_1_0, 200, "OK"); 837 847 return pFrom->SendResponseMessage(); … … 1128 1138 string raw = responseHeaders[RTSP_HEADERS].GetValue(RTSP_HEADERS_TRANSPORT, false); 1129 1139 Variant transport; 1130 if (! ParseTransportLine(raw, transport)) {1140 if (!SDP::ParseTransportLine(raw, transport)) { 1131 1141 FATAL("Unable to parse transport line %s", STR(raw)); 1132 1142 return false; … … 1658 1668 } 1659 1669 1660 bool BaseRTSPAppProtocolHandler::ParseTransportLine(string raw, Variant &result) {1661 result.Reset();1662 1663 //1. split after ';'1664 vector<string> parts;1665 split(raw, ";", parts);1666 1667 //2. Construct the result1668 for (uint32_t i = 0; i < parts.size(); i++) {1669 string part = parts[i];1670 trim(part);1671 if (part == "")1672 continue;1673 string::size_type pos = part.find('=');1674 if (pos == string::npos) {1675 result[lowerCase(part)] = (bool)true;1676 continue;1677 }1678 result[lowerCase(part.substr(0, pos))] = part.substr(pos + 1);1679 }1680 1681 vector<string> keys;1682 ADD_VECTOR_END(keys, "client_port");1683 ADD_VECTOR_END(keys, "server_port");1684 ADD_VECTOR_END(keys, "interleaved");1685 1686 for (uint32_t i = 0; i < keys.size(); i++) {1687 string key = keys[i];1688 if (!result.HasKey(key))1689 continue;1690 parts.clear();1691 raw = (string) result[key];1692 split(raw, "-", parts);1693 if (parts.size() != 2) {1694 FATAL("Invalid transport line: %s", STR(raw));1695 return false;1696 }1697 uint16_t data = atoi(STR(parts[0]));1698 uint16_t rtcp = atoi(STR(parts[1]));1699 if (((data % 2) != 0) || ((data + 1) != rtcp)) {1700 FATAL("Invalid transport line: %s", STR(raw));1701 return false;1702 }1703 string all = format("%"PRIu16"-%"PRIu16, data, rtcp);1704 if (all != raw) {1705 FATAL("Invalid transport line: %s", STR(raw));1706 return false;1707 }1708 result.RemoveKey(key);1709 result[key]["data"] = (uint16_t) data;1710 result[key]["rtcp"] = (uint16_t) rtcp;1711 result[key]["all"] = all;1712 }1713 1714 return true;1715 }1716 1717 1670 #endif /* HAS_PROTOCOL_RTP */ -
branches/1.0/sources/thelib/src/protocols/rtp/sdp.cpp
r587 r714 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 174 174 return ""; 175 175 return (string) (*this)[SDP_SESSION][SDP_S]; 176 } 177 178 bool SDP::ParseTransportLine(string raw, Variant &result) { 179 result.Reset(); 180 181 //1. split after ';' 182 vector<string> parts; 183 split(raw, ";", parts); 184 185 //2. Construct the result 186 for (uint32_t i = 0; i < parts.size(); i++) { 187 string part = parts[i]; 188 trim(part); 189 if (part == "") 190 continue; 191 string::size_type pos = part.find('='); 192 if (pos == string::npos) { 193 result[lowerCase(part)] = (bool)true; 194 continue; 195 } 196 result[lowerCase(part.substr(0, pos))] = part.substr(pos + 1); 197 } 198 199 vector<string> keys; 200 ADD_VECTOR_END(keys, "client_port"); 201 ADD_VECTOR_END(keys, "server_port"); 202 ADD_VECTOR_END(keys, "interleaved"); 203 204 for (uint32_t i = 0; i < keys.size(); i++) { 205 string key = keys[i]; 206 if (!result.HasKey(key)) 207 continue; 208 parts.clear(); 209 raw = (string) result[key]; 210 split(raw, "-", parts); 211 if ((parts.size() != 2) && (parts.size() != 1)) { 212 FATAL("Invalid transport line: %s", STR(raw)); 213 return false; 214 } 215 string all = ""; 216 uint16_t data = 0; 217 uint16_t rtcp = 0; 218 if (parts.size() == 2) { 219 data = atoi(STR(parts[0])); 220 rtcp = atoi(STR(parts[1])); 221 if (((data % 2) != 0) || ((data + 1) != rtcp)) { 222 FATAL("Invalid transport line: %s", STR(raw)); 223 return false; 224 } 225 all = format("%"PRIu16"-%"PRIu16, data, rtcp); 226 } else { 227 data = atoi(STR(parts[0])); 228 all = format("%"PRIu16, data); 229 rtcp = 0; 230 } 231 if (all != raw) { 232 FATAL("Invalid transport line: %s", STR(raw)); 233 return false; 234 } 235 result.RemoveKey(key); 236 result[key]["data"] = (uint16_t) data; 237 result[key]["rtcp"] = (uint16_t) rtcp; 238 result[key]["all"] = all; 239 } 240 241 return true; 176 242 } 177 243 -
trunk/sources/thelib/include/protocols/rtp/basertspappprotocolhandler.h
r694 r714 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 74 74 virtual bool HandleRTSPRequestRecord(RTSPProtocol *pFrom, 75 75 Variant &requestHeaders, string &requestContent); 76 virtual bool HandleRTSPRequestPause(RTSPProtocol *pFrom, 77 Variant &requestHeaders, string &requestContent); 76 78 77 79 //handle response routines … … 133 135 string ComputeSDP(RTSPProtocol *pFrom, string localStreamName, 134 136 string targetStreamName, string host); 135 bool ParseTransportLine(string raw, Variant &result);136 137 }; 137 138 -
trunk/sources/thelib/include/protocols/rtp/sdp.h
r551 r714 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 66 66 string GetStreamName(); 67 67 uint32_t GetTotalBandwidth(); 68 static bool ParseTransportLine(string raw, Variant &result); 68 69 private: 69 70 static bool ParseSection(Variant &result, vector<string> &lines, -
trunk/sources/thelib/src/protocols/rtp/basertspappprotocolhandler.cpp
r713 r714 354 354 return false; 355 355 } 356 } else if (method == RTSP_METHOD_PAUSE) { 357 if (!HandleRTSPRequestPause(pFrom, requestHeaders, requestContent)) { 358 return false; 359 } 356 360 } else { 357 361 FATAL("Method not implemented yet:\n%s", STR(requestHeaders.ToString())); … … 467 471 string raw = requestHeaders[RTSP_HEADERS].GetValue(RTSP_HEADERS_TRANSPORT, false); 468 472 Variant transport; 469 if (! ParseTransportLine(raw, transport)) {473 if (!SDP::ParseTransportLine(raw, transport)) { 470 474 FATAL("Unable to parse transport line %s", STR(raw)); 471 475 return false; … … 574 578 string transportLine = requestHeaders[RTSP_HEADERS].GetValue(RTSP_HEADERS_TRANSPORT, false); 575 579 Variant transport; 576 if (! ParseTransportLine(transportLine, transport)) {580 if (!SDP::ParseTransportLine(transportLine, transport)) { 577 581 FATAL("Unable to parse transport line"); 578 582 return false; … … 834 838 835 839 //4. Send back the response 840 pFrom->PushResponseFirstLine(RTSP_VERSION_1_0, 200, "OK"); 841 return pFrom->SendResponseMessage(); 842 } 843 844 bool BaseRTSPAppProtocolHandler::HandleRTSPRequestPause(RTSPProtocol *pFrom, 845 Variant &requestHeaders, string &requestContent) { 836 846 pFrom->PushResponseFirstLine(RTSP_VERSION_1_0, 200, "OK"); 837 847 return pFrom->SendResponseMessage(); … … 1128 1138 string raw = responseHeaders[RTSP_HEADERS].GetValue(RTSP_HEADERS_TRANSPORT, false); 1129 1139 Variant transport; 1130 if (! ParseTransportLine(raw, transport)) {1140 if (!SDP::ParseTransportLine(raw, transport)) { 1131 1141 FATAL("Unable to parse transport line %s", STR(raw)); 1132 1142 return false; … … 1658 1668 } 1659 1669 1660 bool BaseRTSPAppProtocolHandler::ParseTransportLine(string raw, Variant &result) {1661 result.Reset();1662 1663 //1. split after ';'1664 vector<string> parts;1665 split(raw, ";", parts);1666 1667 //2. Construct the result1668 for (uint32_t i = 0; i < parts.size(); i++) {1669 string part = parts[i];1670 trim(part);1671 if (part == "")1672 continue;1673 string::size_type pos = part.find('=');1674 if (pos == string::npos) {1675 result[lowerCase(part)] = (bool)true;1676 continue;1677 }1678 result[lowerCase(part.substr(0, pos))] = part.substr(pos + 1);1679 }1680 1681 vector<string> keys;1682 ADD_VECTOR_END(keys, "client_port");1683 ADD_VECTOR_END(keys, "server_port");1684 ADD_VECTOR_END(keys, "interleaved");1685 1686 for (uint32_t i = 0; i < keys.size(); i++) {1687 string key = keys[i];1688 if (!result.HasKey(key))1689 continue;1690 parts.clear();1691 raw = (string) result[key];1692 split(raw, "-", parts);1693 if (parts.size() != 2) {1694 FATAL("Invalid transport line: %s", STR(raw));1695 return false;1696 }1697 uint16_t data = atoi(STR(parts[0]));1698 uint16_t rtcp = atoi(STR(parts[1]));1699 if (((data % 2) != 0) || ((data + 1) != rtcp)) {1700 FATAL("Invalid transport line: %s", STR(raw));1701 return false;1702 }1703 string all = format("%"PRIu16"-%"PRIu16, data, rtcp);1704 if (all != raw) {1705 FATAL("Invalid transport line: %s", STR(raw));1706 return false;1707 }1708 result.RemoveKey(key);1709 result[key]["data"] = (uint16_t) data;1710 result[key]["rtcp"] = (uint16_t) rtcp;1711 result[key]["all"] = all;1712 }1713 1714 return true;1715 }1716 1717 1670 #endif /* HAS_PROTOCOL_RTP */ -
trunk/sources/thelib/src/protocols/rtp/sdp.cpp
r587 r714 1 /* 1 /* 2 2 * Copyright (c) 2010, 3 3 * Gavriloaie Eugen-Andrei (shiretu@gmail.com) … … 174 174 return ""; 175 175 return (string) (*this)[SDP_SESSION][SDP_S]; 176 } 177 178 bool SDP::ParseTransportLine(string raw, Variant &result) { 179 result.Reset(); 180 181 //1. split after ';' 182 vector<string> parts; 183 split(raw, ";", parts); 184 185 //2. Construct the result 186 for (uint32_t i = 0; i < parts.size(); i++) { 187 string part = parts[i]; 188 trim(part); 189 if (part == "") 190 continue; 191 string::size_type pos = part.find('='); 192 if (pos == string::npos) { 193 result[lowerCase(part)] = (bool)true; 194 continue; 195 } 196 result[lowerCase(part.substr(0, pos))] = part.substr(pos + 1); 197 } 198 199 vector<string> keys; 200 ADD_VECTOR_END(keys, "client_port"); 201 ADD_VECTOR_END(keys, "server_port"); 202 ADD_VECTOR_END(keys, "interleaved"); 203 204 for (uint32_t i = 0; i < keys.size(); i++) { 205 string key = keys[i]; 206 if (!result.HasKey(key)) 207 continue; 208 parts.clear(); 209 raw = (string) result[key]; 210 split(raw, "-", parts); 211 if ((parts.size() != 2) && (parts.size() != 1)) { 212 FATAL("Invalid transport line: %s", STR(raw)); 213 return false; 214 } 215 string all = ""; 216 uint16_t data = 0; 217 uint16_t rtcp = 0; 218 if (parts.size() == 2) { 219 data = atoi(STR(parts[0])); 220 rtcp = atoi(STR(parts[1])); 221 if (((data % 2) != 0) || ((data + 1) != rtcp)) { 222 FATAL("Invalid transport line: %s", STR(raw)); 223 return false; 224 } 225 all = format("%"PRIu16"-%"PRIu16, data, rtcp); 226 } else { 227 data = atoi(STR(parts[0])); 228 all = format("%"PRIu16, data); 229 rtcp = 0; 230 } 231 if (all != raw) { 232 FATAL("Invalid transport line: %s", STR(raw)); 233 return false; 234 } 235 result.RemoveKey(key); 236 result[key]["data"] = (uint16_t) data; 237 result[key]["rtcp"] = (uint16_t) rtcp; 238 result[key]["all"] = all; 239 } 240 241 return true; 176 242 } 177 243
Note: See TracChangeset
for help on using the changeset viewer.
