Skip to content

Commit 12332fd

Browse files
committed
Work in progress
1 parent 4dc36fb commit 12332fd

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

lib/micro-rtsp-server/include/micro_rtsp_requests.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ class micro_rtsp_requests
77
{
88
public:
99
std::string process_request(const std::string& request);
10-
10+
bool active() const { return stream_active_; }
11+
1112
private:
1213
// enum rtsp_command
1314
// {

lib/micro-rtsp-server/src/micro_rtsp_requests.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ std::string micro_rtsp_requests::handle_options(unsigned long cseq)
4747
<< "CSeq: " << cseq << "\r\n"
4848
<< std::put_time(std::gmtime(&now), "Date: %a, %b %d %Y %H:%M:%S GMT") << "\r\n"
4949
<< "Content-Length: 0\r\n"
50-
<< "Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE";
50+
<< "Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE\r\n"
51+
<< "\r\n";
5152
return oss.str();
5253
}
5354

@@ -85,7 +86,7 @@ std::string micro_rtsp_requests::handle_describe(unsigned long cseq, const std::
8586
oss << "RTSP/1.0 200 OK\r\n"
8687
<< "CSeq: " << cseq << "\r\n"
8788
<< std::put_time(std::gmtime(&now), "Date: %a, %b %d %Y %H:%M:%S GMT") << "\r\n"
88-
<< "Content-Base: rtsp://" << host << ":" << port << path << "\r\n"
89+
<< "Content-Base: rtsp://" << host << ":" << port << path << "/" << "\r\n"
8990
<< "Content-Type: application/sdp\r\n"
9091
<< "Content-Length: " << body.size() << "\r\n"
9192
<< "\r\n"
@@ -118,15 +119,15 @@ std::string micro_rtsp_requests::handle_setup(unsigned long cseq, const std::map
118119
if (tcp_transport_)
119120
ostransport << "RTP/AVP/TCP;unicast;interleaved=0-1";
120121
else
121-
ostransport << "RTP/AVP;unicast;destination=127.0.0.1;source=127.0.0.1;client_port=" << start_client_port_ << "-" << end_client_port_ + 1 << ";server_port=" << rtp_streamer_port_ << "-" << rtcp_streamer_port_;
122+
ostransport << "RTP/AVP;unicast;destination=127.0.0.1;source=127.0.0.1;client_port=" << start_client_port_ << "-" << end_client_port_ + 1 << ";server_port=" << rtp_streamer_port_ << "-" << rtp_streamer_port_/*rtcp_streamer_port_*/;
122123

123124
auto now = time(nullptr);
124125
std::ostringstream oss;
125126
oss << "RTSP/1.0 200 OK\r\n"
126127
<< "CSeq: " << cseq << "\r\n"
127128
<< std::put_time(std::gmtime(&now), "Date: %a, %b %d %Y %H:%M:%S GMT") << "\r\n"
128129
<< "Transport: " << ostransport.str() << "\r\n"
129-
<< "Session: " << rtsp_session_id_;
130+
<< "Session: " << rtsp_session_id_<< "\r\n";
130131
return oss.str();
131132
}
132133

@@ -144,7 +145,7 @@ std::string micro_rtsp_requests::handle_play(unsigned long cseq)
144145
<< "Range: npt=0.000-\r\n"
145146
<< "Session: " << rtsp_session_id_ << "\r\n"
146147
<< "RTP-Info: url=rtsp://127.0.0.1:8554" << available_stream_name_ << "/track1" << "\r\n"
147-
<< "\r\n";
148+
<< "\r\n";
148149
return oss.str();
149150
}
150151

@@ -158,7 +159,8 @@ std::string micro_rtsp_requests::handle_teardown(unsigned long cseq)
158159
std::ostringstream oss;
159160
oss << "RTSP/1.0 200 OK\r\n"
160161
<< "CSeq: " << cseq << "\r\n"
161-
<< std::put_time(std::gmtime(&now), "Date: %a, %b %d %Y %H:%M:%S GMT") << "\r\n";
162+
<< std::put_time(std::gmtime(&now), "Date: %a, %b %d %Y %H:%M:%S GMT") << "\r\n"
163+
<< "\r\n";
162164
return oss.str();
163165
}
164166

@@ -185,8 +187,8 @@ std::string micro_rtsp_requests::process_request(const std::string &request)
185187
{
186188
if ((pos = line.find(':')) != std::string::npos)
187189
headers[line.substr(0, pos)] = line.substr(pos + 1);
188-
else
189-
log_e("No : found for header: %s", line.c_str());
190+
// else
191+
// log_e("No : found for header: %s", line.c_str());
190192
}
191193

192194
log_i("request_line: %s", request_line.c_str());

lib/micro-rtsp-server/src/micro_rtsp_server.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void micro_rtsp_server::loop()
6868
auto packet = streamer_.create_jpg_packet(jpg.jpeg_data_start, jpg.jpeg_data_end, &jpg_scan_current, ts, jpg.quantization_table_luminance_->data, jpg.quantization_table_chrominance_->data);
6969
for (auto client : clients_)
7070
{
71-
log_v("Stream frame to client: 0x%08x", client);
71+
log_i("Stream frame to client: 0x%08x", client);
7272
// RTP over TCP encapsulates in a $
7373
client.write((const uint8_t *)packet, packet->length + sizeof(rtp_over_tcp_hdr_t));
7474
// TODO: UDP
@@ -95,7 +95,7 @@ void micro_rtsp_server::rtsp_client::handle_request()
9595
if (bytes_available > 0)
9696
{
9797
std::string request(bytes_available, '\0');
98-
if (read((uint8_t*)&request[0], bytes_available) == bytes_available)
98+
if (read((uint8_t *)&request[0], bytes_available) == bytes_available)
9999
{
100100
request.resize(bytes_available);
101101
log_i("Request: %s", request.c_str());

0 commit comments

Comments
 (0)