Work in progress

This commit is contained in:
Rene Zeldenthuis
2024-11-04 00:46:58 +01:00
parent 4dc36fb1e8
commit 12332fd7eb
3 changed files with 14 additions and 11 deletions

View File

@@ -7,6 +7,7 @@ class micro_rtsp_requests
{
public:
std::string process_request(const std::string& request);
bool active() const { return stream_active_; }
private:
// enum rtsp_command

View File

@@ -47,7 +47,8 @@ std::string micro_rtsp_requests::handle_options(unsigned long cseq)
<< "CSeq: " << cseq << "\r\n"
<< std::put_time(std::gmtime(&now), "Date: %a, %b %d %Y %H:%M:%S GMT") << "\r\n"
<< "Content-Length: 0\r\n"
<< "Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE";
<< "Public: DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE\r\n"
<< "\r\n";
return oss.str();
}
@@ -85,7 +86,7 @@ std::string micro_rtsp_requests::handle_describe(unsigned long cseq, const std::
oss << "RTSP/1.0 200 OK\r\n"
<< "CSeq: " << cseq << "\r\n"
<< std::put_time(std::gmtime(&now), "Date: %a, %b %d %Y %H:%M:%S GMT") << "\r\n"
<< "Content-Base: rtsp://" << host << ":" << port << path << "\r\n"
<< "Content-Base: rtsp://" << host << ":" << port << path << "/" << "\r\n"
<< "Content-Type: application/sdp\r\n"
<< "Content-Length: " << body.size() << "\r\n"
<< "\r\n"
@@ -118,7 +119,7 @@ std::string micro_rtsp_requests::handle_setup(unsigned long cseq, const std::map
if (tcp_transport_)
ostransport << "RTP/AVP/TCP;unicast;interleaved=0-1";
else
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_;
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_*/;
auto now = time(nullptr);
std::ostringstream oss;
@@ -126,7 +127,7 @@ std::string micro_rtsp_requests::handle_setup(unsigned long cseq, const std::map
<< "CSeq: " << cseq << "\r\n"
<< std::put_time(std::gmtime(&now), "Date: %a, %b %d %Y %H:%M:%S GMT") << "\r\n"
<< "Transport: " << ostransport.str() << "\r\n"
<< "Session: " << rtsp_session_id_;
<< "Session: " << rtsp_session_id_<< "\r\n";
return oss.str();
}
@@ -158,7 +159,8 @@ std::string micro_rtsp_requests::handle_teardown(unsigned long cseq)
std::ostringstream oss;
oss << "RTSP/1.0 200 OK\r\n"
<< "CSeq: " << cseq << "\r\n"
<< std::put_time(std::gmtime(&now), "Date: %a, %b %d %Y %H:%M:%S GMT") << "\r\n";
<< std::put_time(std::gmtime(&now), "Date: %a, %b %d %Y %H:%M:%S GMT") << "\r\n"
<< "\r\n";
return oss.str();
}
@@ -185,8 +187,8 @@ std::string micro_rtsp_requests::process_request(const std::string &request)
{
if ((pos = line.find(':')) != std::string::npos)
headers[line.substr(0, pos)] = line.substr(pos + 1);
else
log_e("No : found for header: %s", line.c_str());
// else
// log_e("No : found for header: %s", line.c_str());
}
log_i("request_line: %s", request_line.c_str());

View File

@@ -68,7 +68,7 @@ void micro_rtsp_server::loop()
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);
for (auto client : clients_)
{
log_v("Stream frame to client: 0x%08x", client);
log_i("Stream frame to client: 0x%08x", client);
// RTP over TCP encapsulates in a $
client.write((const uint8_t *)packet, packet->length + sizeof(rtp_over_tcp_hdr_t));
// TODO: UDP