| 149 | } |
| 150 | |
| 151 | void HttpcServer::processStreamingRequest(SocketClient &client) { |
| 152 | const std::string msg = client.getPercentDecodedMessage(); |
| 153 | SI_LOG_DEBUG("%s Stream data from client %s with IP %s on Port %d: %s", client.getProtocolString().c_str(), |
| 154 | "None", client.getIPAddressOfSocket().c_str(), client.getSocketPort(), msg.c_str()); |
| 155 | |
| 156 | const std::string method = StringConverter::getMethod(msg); |
| 157 | if (method.empty()) { |
| 158 | return; |
| 159 | } |
| 160 | // Save clients seq number |
| 161 | const std::string fieldCSeq = StringConverter::getHeaderFieldParameter(msg, "CSeq:"); |
| 162 | const int cseq = fieldCSeq.empty() ? 0 : std::stoi(fieldCSeq); |
| 163 | // Save sessionID |
| 164 | const std::string sessionID = StringConverter::getHeaderFieldParameter(msg, "Session:"); |
| 165 | // |
| 166 | const int streamID = StringConverter::getIntParameter(msg, method, "stream="); |
| 167 | |
| 168 | std::string httpcReply; |
| 169 | if (sessionID.empty() && method == "OPTIONS") { |
| 170 | methodOptions("", cseq, httpcReply); |
| 171 | } else if (sessionID.empty() && method == "DESCRIBE") { |
| 172 | methodDescribe("", cseq, streamID, httpcReply); |
| 173 | } else { |
| 174 | int clientID; |
| 175 | SpStream stream = _streamManager.findStreamAndClientIDFor(client, clientID); |
| 176 | if (stream != nullptr) { |
| 177 | stream->processStreamingRequest(msg, clientID, method); |
| 178 | |
| 179 | // Check the Method |
| 180 | if (method == "GET") { |
| 181 | stream->update(clientID, true); |
| 182 | getHtmlBodyNoContent(httpcReply, HTML_OK, "", CONTENT_TYPE_VIDEO, 0); |
| 183 | |
| 184 | } else if (method == "SETUP") { |
| 185 | methodSetup(*stream, clientID, httpcReply); |
| 186 | |
| 187 | // @TODO check return of update(); |
| 188 | stream->update(clientID, true); |
| 189 | |
| 190 | } else if (method == "PLAY") { |
| 191 | methodPlay(sessionID, cseq, stream->getStreamID(), httpcReply); |
| 192 | |
| 193 | // @TODO check return of update(); |
| 194 | stream->update(clientID, true); |
| 195 | |
| 196 | } else if (method == "TEARDOWN") { |
| 197 | methodTeardown(sessionID, cseq, httpcReply); |
| 198 | |
| 199 | stream->teardown(clientID); |
| 200 | } else if (method == "OPTIONS") { |
| 201 | methodOptions(sessionID, cseq, httpcReply); |
| 202 | } else if (method == "DESCRIBE") { |
| 203 | methodDescribe(sessionID, cseq, streamID, httpcReply); |
| 204 | } else { |
| 205 | // method not supported |
| 206 | SI_LOG_ERROR("%s: Method not allowed: %s", method.c_str(), msg.c_str()); |
| 207 | } |
| 208 | } else { |
nothing calls this directly
no test coverage detected