Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
rzeldent committed Nov 3, 2024
1 parent 4dc36fb commit 12332fd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
3 changes: 2 additions & 1 deletion lib/micro-rtsp-server/include/micro_rtsp_requests.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ class micro_rtsp_requests
{
public:
std::string process_request(const std::string& request);

bool active() const { return stream_active_; }

private:
// enum rtsp_command
// {
Expand Down
18 changes: 10 additions & 8 deletions lib/micro-rtsp-server/src/micro_rtsp_requests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -118,15 +119,15 @@ 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;
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"
<< "Transport: " << ostransport.str() << "\r\n"
<< "Session: " << rtsp_session_id_;
<< "Session: " << rtsp_session_id_<< "\r\n";
return oss.str();
}

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

Expand All @@ -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();
}

Expand All @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions lib/micro-rtsp-server/src/micro_rtsp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -95,7 +95,7 @@ void micro_rtsp_server::rtsp_client::handle_request()
if (bytes_available > 0)
{
std::string request(bytes_available, '\0');
if (read((uint8_t*)&request[0], bytes_available) == bytes_available)
if (read((uint8_t *)&request[0], bytes_available) == bytes_available)
{
request.resize(bytes_available);
log_i("Request: %s", request.c_str());
Expand Down

0 comments on commit 12332fd

Please sign in to comment.