Changeset 1419 in ntrip
- Timestamp:
- Dec 31, 2008, 2:49:53 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/bncnetqueryrtp.cpp
r1418 r1419 128 128 } 129 129 delete hlpSocket; 130 131 QByteArray clientPort = QString("%1").arg(clientPortInt).toAscii(); 132 delete _udpSocket; 133 _udpSocket = new QUdpSocket(); 134 _udpSocket->bind(clientPortInt); 135 connect(_udpSocket, SIGNAL(readyRead()), _eventLoop, SLOT(quit())); 136 137 QByteArray reqStr; 138 reqStr = "SETUP " + urlLoc.toEncoded() + " RTSP/1.0\r\n" 139 + "Cseq: 1\r\n" 140 + "Ntrip-Version: Ntrip/2.0\r\n" 141 + "Ntrip-Component: Ntripclient\r\n" 142 + "User-Agent: NTRIP BNC/" BNCVERSION "\r\n" 143 + "Transport: RTP/GNSS;unicast;client_port=" + clientPort + "\r\n" 144 + userAndPwd 145 + "\r\n"; 146 _socket->write(reqStr, reqStr.length()); 147 148 // Read Server Answer 1 149 // -------------------- 150 if (_socket->waitForBytesWritten(timeOut)) { 151 if (_socket->waitForReadyRead(timeOut)) { 152 QTextStream in(_socket); 153 QByteArray session; 154 QString line = in.readLine(); 155 while (!line.isEmpty()) { 156 if (line.indexOf("Session:") == 0) { 157 session = line.mid(9).toAscii(); 158 break; 130 131 // Setup the RTSP Connection 132 // ------------------------- 133 if (clientPortInt) { 134 QByteArray clientPort = QString("%1").arg(clientPortInt).toAscii(); 135 delete _udpSocket; 136 _udpSocket = new QUdpSocket(); 137 _udpSocket->bind(clientPortInt); 138 connect(_udpSocket, SIGNAL(readyRead()), _eventLoop, SLOT(quit())); 139 140 QByteArray reqStr; 141 reqStr = "SETUP " + urlLoc.toEncoded() + " RTSP/1.0\r\n" 142 + "Cseq: 1\r\n" 143 + "Ntrip-Version: Ntrip/2.0\r\n" 144 + "Ntrip-Component: Ntripclient\r\n" 145 + "User-Agent: NTRIP BNC/" BNCVERSION "\r\n" 146 + "Transport: RTP/GNSS;unicast;client_port=" + clientPort + "\r\n" 147 + userAndPwd 148 + "\r\n"; 149 _socket->write(reqStr, reqStr.length()); 150 151 // Read Server Answer 1 152 // -------------------- 153 if (_socket->waitForBytesWritten(timeOut)) { 154 if (_socket->waitForReadyRead(timeOut)) { 155 QTextStream in(_socket); 156 QByteArray session; 157 QString line = in.readLine(); 158 while (!line.isEmpty()) { 159 if (line.indexOf("Session:") == 0) { 160 session = line.mid(9).toAscii(); 161 break; 162 } 163 line = in.readLine(); 159 164 } 160 line = in.readLine();161 }162 163 // Send Request 2164 // --------------165 if (!session.isEmpty()) {166 reqStr = "PLAY " + urlLoc.toEncoded() + " RTSP/1.0\r\n"167 + "Cseq: 2\r\n"168 + "Session: " + session + "\r\n"169 + "\r\n";170 _socket->write(reqStr, reqStr.length());171 172 // Read Server Answer 2173 // --------------------174 if (_socket->waitForBytesWritten(timeOut)) {175 if (_socket->waitForReadyRead(timeOut)) {176 QTextStream in(_socket);177 line = in.readLine();178 while (!line.isEmpty()) {179 if (line.indexOf("200 OK") != -1) {180 emit newMessage("UDP connection established", true);181 return;165 166 // Send Request 2 167 // -------------- 168 if (!session.isEmpty()) { 169 reqStr = "PLAY " + urlLoc.toEncoded() + " RTSP/1.0\r\n" 170 + "Cseq: 2\r\n" 171 + "Session: " + session + "\r\n" 172 + "\r\n"; 173 _socket->write(reqStr, reqStr.length()); 174 175 // Read Server Answer 2 176 // -------------------- 177 if (_socket->waitForBytesWritten(timeOut)) { 178 if (_socket->waitForReadyRead(timeOut)) { 179 QTextStream in(_socket); 180 line = in.readLine(); 181 while (!line.isEmpty()) { 182 if (line.indexOf("200 OK") != -1) { 183 emit newMessage("UDP connection established", true); 184 return; 185 } 186 line = in.readLine(); 182 187 } 183 line = in.readLine();184 188 } 185 189 }
Note:
See TracChangeset
for help on using the changeset viewer.