mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
for #133, show more info about rtp.
This commit is contained in:
parent
45c0b12958
commit
6a64164985
4 changed files with 41 additions and 25 deletions
|
@ -128,15 +128,19 @@ int SrsRtspConn::do_cycle()
|
||||||
}
|
}
|
||||||
} else if (req->is_announce()) {
|
} else if (req->is_announce()) {
|
||||||
srs_assert(req->sdp);
|
srs_assert(req->sdp);
|
||||||
video_id = req->sdp->video_stream_id;
|
video_id = ::atoi(req->sdp->video_stream_id.c_str());
|
||||||
audio_id = req->sdp->audio_stream_id;
|
audio_id = ::atoi(req->sdp->audio_stream_id.c_str());
|
||||||
|
video_codec = req->sdp->video_codec;
|
||||||
|
audio_codec = req->sdp->audio_codec;
|
||||||
|
audio_sample_rate = ::atoi(req->sdp->audio_sample_rate.c_str());
|
||||||
|
audio_channel = ::atoi(req->sdp->audio_channel.c_str());
|
||||||
sps = req->sdp->video_sps;
|
sps = req->sdp->video_sps;
|
||||||
pps = req->sdp->video_pps;
|
pps = req->sdp->video_pps;
|
||||||
asc = req->sdp->audio_sh;
|
asc = req->sdp->audio_sh;
|
||||||
srs_trace("rtsp: video(#%s, %s), audio(#%s, %s, %sHZ %schannels)",
|
srs_trace("rtsp: video(#%d, %s, %s/%s), audio(#%d, %s, %s/%s, %dHZ %dchannels)",
|
||||||
req->sdp->video_stream_id.c_str(), req->sdp->video_codec.c_str(),
|
video_id, video_codec.c_str(), req->sdp->video_protocol.c_str(), req->sdp->video_transport_format.c_str(),
|
||||||
req->sdp->audio_stream_id.c_str(), req->sdp->audio_codec.c_str(),
|
audio_id, audio_codec.c_str(), req->sdp->audio_protocol.c_str(), req->sdp->audio_transport_format.c_str(),
|
||||||
req->sdp->audio_sample_rate.c_str(), req->sdp->audio_channel.c_str()
|
audio_sample_rate, audio_channel
|
||||||
);
|
);
|
||||||
|
|
||||||
SrsRtspResponse* res = new SrsRtspResponse(req->seq);
|
SrsRtspResponse* res = new SrsRtspResponse(req->seq);
|
||||||
|
@ -167,7 +171,12 @@ int SrsRtspConn::do_cycle()
|
||||||
srs_error("rtsp: rtp listen at port=%d failed. ret=%d", lpm, ret);
|
srs_error("rtsp: rtp listen at port=%d failed. ret=%d", lpm, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
srs_trace("rtsp: rtp listen at port=%d ok.", lpm);
|
srs_trace("rtsp: #%d %s over %s/%s/%s %s client-port=%d-%d, server-port=%d-%d",
|
||||||
|
req->stream_id, (req->stream_id == video_id)? "Video":"Audio",
|
||||||
|
req->transport->transport.c_str(), req->transport->profile.c_str(), req->transport->lower_transport.c_str(),
|
||||||
|
req->transport->cast_type.c_str(), req->transport->client_port_min, req->transport->client_port_max,
|
||||||
|
lpm, lpm + 1
|
||||||
|
);
|
||||||
|
|
||||||
// create session.
|
// create session.
|
||||||
if (session.empty()) {
|
if (session.empty()) {
|
||||||
|
|
|
@ -76,10 +76,14 @@ private:
|
||||||
private:
|
private:
|
||||||
std::string session;
|
std::string session;
|
||||||
// video stream.
|
// video stream.
|
||||||
std::string video_id;
|
int video_id;
|
||||||
|
std::string video_codec;
|
||||||
SrsRtpConn* video_rtp;
|
SrsRtpConn* video_rtp;
|
||||||
// audio stream.
|
// audio stream.
|
||||||
std::string audio_id;
|
int audio_id;
|
||||||
|
std::string audio_codec;
|
||||||
|
int audio_sample_rate;
|
||||||
|
int audio_channel;
|
||||||
SrsRtpConn* audio_rtp;
|
SrsRtpConn* audio_rtp;
|
||||||
// video sequence header.
|
// video sequence header.
|
||||||
std::string sps;
|
std::string sps;
|
||||||
|
|
|
@ -461,6 +461,7 @@ SrsRtspRequest::SrsRtspRequest()
|
||||||
{
|
{
|
||||||
seq = 0;
|
seq = 0;
|
||||||
content_length = 0;
|
content_length = 0;
|
||||||
|
stream_id = 0;
|
||||||
sdp = NULL;
|
sdp = NULL;
|
||||||
transport = NULL;
|
transport = NULL;
|
||||||
}
|
}
|
||||||
|
@ -766,13 +767,15 @@ int SrsRtspStack::do_recv_message(SrsRtspRequest* req)
|
||||||
// for setup, parse the stream id from uri.
|
// for setup, parse the stream id from uri.
|
||||||
if (req->is_setup()) {
|
if (req->is_setup()) {
|
||||||
size_t pos = string::npos;
|
size_t pos = string::npos;
|
||||||
|
std::string stream_id;
|
||||||
if ((pos = req->uri.rfind("/")) != string::npos) {
|
if ((pos = req->uri.rfind("/")) != string::npos) {
|
||||||
req->stream_id = req->uri.substr(pos + 1);
|
stream_id = req->uri.substr(pos + 1);
|
||||||
}
|
}
|
||||||
if ((pos = req->stream_id.find("=")) != string::npos) {
|
if ((pos = stream_id.find("=")) != string::npos) {
|
||||||
req->stream_id = req->stream_id.substr(pos + 1);
|
stream_id = stream_id.substr(pos + 1);
|
||||||
}
|
}
|
||||||
srs_info("rtsp: setup stream id=%s", req->stream_id.c_str());
|
req->stream_id = ::atoi(stream_id.c_str());
|
||||||
|
srs_info("rtsp: setup stream id=%d", req->stream_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse rdp body.
|
// parse rdp body.
|
||||||
|
|
|
@ -48,7 +48,7 @@ class ISrsProtocolReaderWriter;
|
||||||
// SP = <US-ASCII SP, space (32)>
|
// SP = <US-ASCII SP, space (32)>
|
||||||
#define __SRS_RTSP_SP ' ' // 0x20
|
#define __SRS_RTSP_SP ' ' // 0x20
|
||||||
|
|
||||||
// 4 RTSP Message
|
// 4 RTSP Message, @see rtsp-rfc2326-1998.pdf, page 37
|
||||||
// Lines are terminated by CRLF, but
|
// Lines are terminated by CRLF, but
|
||||||
// receivers should be prepared to also interpret CR and LF by
|
// receivers should be prepared to also interpret CR and LF by
|
||||||
// themselves as line terminators.
|
// themselves as line terminators.
|
||||||
|
@ -100,7 +100,7 @@ enum SrsRtspSdpState
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 10 Method Definitions
|
* 10 Method Definitions, @see rtsp-rfc2326-1998.pdf, page 57
|
||||||
* The method token indicates the method to be performed on the resource
|
* The method token indicates the method to be performed on the resource
|
||||||
* identified by the Request-URI. The method is case-sensitive. New
|
* identified by the Request-URI. The method is case-sensitive. New
|
||||||
* methods may be defined in the future. Method names may not start with
|
* methods may be defined in the future. Method names may not start with
|
||||||
|
@ -147,7 +147,7 @@ enum SrsRtspTokenState
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the sdp in announce.
|
* the sdp in announce, @see rtsp-rfc2326-1998.pdf, page 159
|
||||||
* Appendix C: Use of SDP for RTSP Session Descriptions
|
* Appendix C: Use of SDP for RTSP Session Descriptions
|
||||||
* The Session Description Protocol (SDP, RFC 2327 [6]) may be used to
|
* The Session Description Protocol (SDP, RFC 2327 [6]) may be used to
|
||||||
* describe streams or presentations in RTSP.
|
* describe streams or presentations in RTSP.
|
||||||
|
@ -241,7 +241,7 @@ private:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the rtsp transport.
|
* the rtsp transport.
|
||||||
* 12.39 Transport
|
* 12.39 Transport, @see rtsp-rfc2326-1998.pdf, page 115
|
||||||
* This request header indicates which transport protocol is to be used
|
* This request header indicates which transport protocol is to be used
|
||||||
* and configures its parameters such as destination address,
|
* and configures its parameters such as destination address,
|
||||||
* compression, multicast time-to-live and destination port for a single
|
* compression, multicast time-to-live and destination port for a single
|
||||||
|
@ -288,7 +288,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the rtsp request message.
|
* the rtsp request message.
|
||||||
* 6 Request
|
* 6 Request, @see rtsp-rfc2326-1998.pdf, page 39
|
||||||
* A request message from a client to a server or vice versa includes,
|
* A request message from a client to a server or vice versa includes,
|
||||||
* within the first line of that message, the method to be applied to
|
* within the first line of that message, the method to be applied to
|
||||||
* the resource, the identifier of the resource, and the protocol
|
* the resource, the identifier of the resource, and the protocol
|
||||||
|
@ -322,14 +322,14 @@ public:
|
||||||
*/
|
*/
|
||||||
long seq;
|
long seq;
|
||||||
/**
|
/**
|
||||||
* 12.16 Content-Type
|
* 12.16 Content-Type, @see rtsp-rfc2326-1998.pdf, page 99
|
||||||
* See [H14.18]. Note that the content types suitable for RTSP are
|
* See [H14.18]. Note that the content types suitable for RTSP are
|
||||||
* likely to be restricted in practice to presentation descriptions and
|
* likely to be restricted in practice to presentation descriptions and
|
||||||
* parameter-value types.
|
* parameter-value types.
|
||||||
*/
|
*/
|
||||||
std::string content_type;
|
std::string content_type;
|
||||||
/**
|
/**
|
||||||
* 12.14 Content-Length
|
* 12.14 Content-Length, @see rtsp-rfc2326-1998.pdf, page 99
|
||||||
* This field contains the length of the content of the method (i.e.
|
* This field contains the length of the content of the method (i.e.
|
||||||
* after the double CRLF following the last header). Unlike HTTP, it
|
* after the double CRLF following the last header). Unlike HTTP, it
|
||||||
* MUST be included in all messages that carry content beyond the header
|
* MUST be included in all messages that carry content beyond the header
|
||||||
|
@ -353,7 +353,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* for setup message, parse the stream id from uri.
|
* for setup message, parse the stream id from uri.
|
||||||
*/
|
*/
|
||||||
std::string stream_id;
|
int stream_id;
|
||||||
public:
|
public:
|
||||||
SrsRtspRequest();
|
SrsRtspRequest();
|
||||||
virtual ~SrsRtspRequest();
|
virtual ~SrsRtspRequest();
|
||||||
|
@ -366,7 +366,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the rtsp response message.
|
* the rtsp response message.
|
||||||
* 7 Response
|
* 7 Response, @see rtsp-rfc2326-1998.pdf, page 43
|
||||||
* [H6] applies except that HTTP-Version is replaced by RTSP-Version.
|
* [H6] applies except that HTTP-Version is replaced by RTSP-Version.
|
||||||
* Also, RTSP defines additional status codes and does not define some
|
* Also, RTSP defines additional status codes and does not define some
|
||||||
* HTTP codes. The valid response codes and the methods they can be used
|
* HTTP codes. The valid response codes and the methods they can be used
|
||||||
|
@ -396,7 +396,7 @@ public:
|
||||||
// @see about the status of rtsp, see SRS_CONSTS_RTSP_OK
|
// @see about the status of rtsp, see SRS_CONSTS_RTSP_OK
|
||||||
int status;
|
int status;
|
||||||
/**
|
/**
|
||||||
* 12.17 CSeq
|
* 12.17 CSeq, @see rtsp-rfc2326-1998.pdf, page 99
|
||||||
* The CSeq field specifies the sequence number for an RTSP requestresponse
|
* The CSeq field specifies the sequence number for an RTSP requestresponse
|
||||||
* pair. This field MUST be present in all requests and
|
* pair. This field MUST be present in all requests and
|
||||||
* responses. For every RTSP request containing the given sequence
|
* responses. For every RTSP request containing the given sequence
|
||||||
|
@ -426,7 +426,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 10.1 OPTIONS
|
* 10.1 OPTIONS, @see rtsp-rfc2326-1998.pdf, page 59
|
||||||
* The behavior is equivalent to that described in [H9.2]. An OPTIONS
|
* The behavior is equivalent to that described in [H9.2]. An OPTIONS
|
||||||
* request may be issued at any time, e.g., if the client is about to
|
* request may be issued at any time, e.g., if the client is about to
|
||||||
* try a nonstandard request. It does not influence server state.
|
* try a nonstandard request. It does not influence server state.
|
||||||
|
@ -446,7 +446,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 10.4 SETUP
|
* 10.4 SETUP, @see rtsp-rfc2326-1998.pdf, page 65
|
||||||
* The SETUP request for a URI specifies the transport mechanism to be
|
* The SETUP request for a URI specifies the transport mechanism to be
|
||||||
* used for the streamed media. A client can issue a SETUP request for a
|
* used for the streamed media. A client can issue a SETUP request for a
|
||||||
* stream that is already playing to change transport parameters, which
|
* stream that is already playing to change transport parameters, which
|
||||||
|
|
Loading…
Reference in a new issue