正在显示
4 个修改的文件
包含
41 行增加
和
25 行删除
| @@ -128,15 +128,19 @@ int SrsRtspConn::do_cycle() | @@ -128,15 +128,19 @@ int SrsRtspConn::do_cycle() | ||
| 128 | } | 128 | } |
| 129 | } else if (req->is_announce()) { | 129 | } else if (req->is_announce()) { |
| 130 | srs_assert(req->sdp); | 130 | srs_assert(req->sdp); |
| 131 | - video_id = req->sdp->video_stream_id; | ||
| 132 | - audio_id = req->sdp->audio_stream_id; | 131 | + video_id = ::atoi(req->sdp->video_stream_id.c_str()); |
| 132 | + audio_id = ::atoi(req->sdp->audio_stream_id.c_str()); | ||
| 133 | + video_codec = req->sdp->video_codec; | ||
| 134 | + audio_codec = req->sdp->audio_codec; | ||
| 135 | + audio_sample_rate = ::atoi(req->sdp->audio_sample_rate.c_str()); | ||
| 136 | + audio_channel = ::atoi(req->sdp->audio_channel.c_str()); | ||
| 133 | sps = req->sdp->video_sps; | 137 | sps = req->sdp->video_sps; |
| 134 | pps = req->sdp->video_pps; | 138 | pps = req->sdp->video_pps; |
| 135 | asc = req->sdp->audio_sh; | 139 | asc = req->sdp->audio_sh; |
| 136 | - srs_trace("rtsp: video(#%s, %s), audio(#%s, %s, %sHZ %schannels)", | ||
| 137 | - req->sdp->video_stream_id.c_str(), req->sdp->video_codec.c_str(), | ||
| 138 | - req->sdp->audio_stream_id.c_str(), req->sdp->audio_codec.c_str(), | ||
| 139 | - req->sdp->audio_sample_rate.c_str(), req->sdp->audio_channel.c_str() | 140 | + srs_trace("rtsp: video(#%d, %s, %s/%s), audio(#%d, %s, %s/%s, %dHZ %dchannels)", |
| 141 | + video_id, video_codec.c_str(), req->sdp->video_protocol.c_str(), req->sdp->video_transport_format.c_str(), | ||
| 142 | + audio_id, audio_codec.c_str(), req->sdp->audio_protocol.c_str(), req->sdp->audio_transport_format.c_str(), | ||
| 143 | + audio_sample_rate, audio_channel | ||
| 140 | ); | 144 | ); |
| 141 | 145 | ||
| 142 | SrsRtspResponse* res = new SrsRtspResponse(req->seq); | 146 | SrsRtspResponse* res = new SrsRtspResponse(req->seq); |
| @@ -167,7 +171,12 @@ int SrsRtspConn::do_cycle() | @@ -167,7 +171,12 @@ int SrsRtspConn::do_cycle() | ||
| 167 | srs_error("rtsp: rtp listen at port=%d failed. ret=%d", lpm, ret); | 171 | srs_error("rtsp: rtp listen at port=%d failed. ret=%d", lpm, ret); |
| 168 | return ret; | 172 | return ret; |
| 169 | } | 173 | } |
| 170 | - srs_trace("rtsp: rtp listen at port=%d ok.", lpm); | 174 | + srs_trace("rtsp: #%d %s over %s/%s/%s %s client-port=%d-%d, server-port=%d-%d", |
| 175 | + req->stream_id, (req->stream_id == video_id)? "Video":"Audio", | ||
| 176 | + req->transport->transport.c_str(), req->transport->profile.c_str(), req->transport->lower_transport.c_str(), | ||
| 177 | + req->transport->cast_type.c_str(), req->transport->client_port_min, req->transport->client_port_max, | ||
| 178 | + lpm, lpm + 1 | ||
| 179 | + ); | ||
| 171 | 180 | ||
| 172 | // create session. | 181 | // create session. |
| 173 | if (session.empty()) { | 182 | if (session.empty()) { |
| @@ -76,10 +76,14 @@ private: | @@ -76,10 +76,14 @@ private: | ||
| 76 | private: | 76 | private: |
| 77 | std::string session; | 77 | std::string session; |
| 78 | // video stream. | 78 | // video stream. |
| 79 | - std::string video_id; | 79 | + int video_id; |
| 80 | + std::string video_codec; | ||
| 80 | SrsRtpConn* video_rtp; | 81 | SrsRtpConn* video_rtp; |
| 81 | // audio stream. | 82 | // audio stream. |
| 82 | - std::string audio_id; | 83 | + int audio_id; |
| 84 | + std::string audio_codec; | ||
| 85 | + int audio_sample_rate; | ||
| 86 | + int audio_channel; | ||
| 83 | SrsRtpConn* audio_rtp; | 87 | SrsRtpConn* audio_rtp; |
| 84 | // video sequence header. | 88 | // video sequence header. |
| 85 | std::string sps; | 89 | std::string sps; |
| @@ -461,6 +461,7 @@ SrsRtspRequest::SrsRtspRequest() | @@ -461,6 +461,7 @@ SrsRtspRequest::SrsRtspRequest() | ||
| 461 | { | 461 | { |
| 462 | seq = 0; | 462 | seq = 0; |
| 463 | content_length = 0; | 463 | content_length = 0; |
| 464 | + stream_id = 0; | ||
| 464 | sdp = NULL; | 465 | sdp = NULL; |
| 465 | transport = NULL; | 466 | transport = NULL; |
| 466 | } | 467 | } |
| @@ -766,13 +767,15 @@ int SrsRtspStack::do_recv_message(SrsRtspRequest* req) | @@ -766,13 +767,15 @@ int SrsRtspStack::do_recv_message(SrsRtspRequest* req) | ||
| 766 | // for setup, parse the stream id from uri. | 767 | // for setup, parse the stream id from uri. |
| 767 | if (req->is_setup()) { | 768 | if (req->is_setup()) { |
| 768 | size_t pos = string::npos; | 769 | size_t pos = string::npos; |
| 770 | + std::string stream_id; | ||
| 769 | if ((pos = req->uri.rfind("/")) != string::npos) { | 771 | if ((pos = req->uri.rfind("/")) != string::npos) { |
| 770 | - req->stream_id = req->uri.substr(pos + 1); | 772 | + stream_id = req->uri.substr(pos + 1); |
| 771 | } | 773 | } |
| 772 | - if ((pos = req->stream_id.find("=")) != string::npos) { | ||
| 773 | - req->stream_id = req->stream_id.substr(pos + 1); | 774 | + if ((pos = stream_id.find("=")) != string::npos) { |
| 775 | + stream_id = stream_id.substr(pos + 1); | ||
| 774 | } | 776 | } |
| 775 | - srs_info("rtsp: setup stream id=%s", req->stream_id.c_str()); | 777 | + req->stream_id = ::atoi(stream_id.c_str()); |
| 778 | + srs_info("rtsp: setup stream id=%d", req->stream_id); | ||
| 776 | } | 779 | } |
| 777 | 780 | ||
| 778 | // parse rdp body. | 781 | // parse rdp body. |
| @@ -48,7 +48,7 @@ class ISrsProtocolReaderWriter; | @@ -48,7 +48,7 @@ class ISrsProtocolReaderWriter; | ||
| 48 | // SP = <US-ASCII SP, space (32)> | 48 | // SP = <US-ASCII SP, space (32)> |
| 49 | #define __SRS_RTSP_SP ' ' // 0x20 | 49 | #define __SRS_RTSP_SP ' ' // 0x20 |
| 50 | 50 | ||
| 51 | -// 4 RTSP Message | 51 | +// 4 RTSP Message, @see rtsp-rfc2326-1998.pdf, page 37 |
| 52 | // Lines are terminated by CRLF, but | 52 | // Lines are terminated by CRLF, but |
| 53 | // receivers should be prepared to also interpret CR and LF by | 53 | // receivers should be prepared to also interpret CR and LF by |
| 54 | // themselves as line terminators. | 54 | // themselves as line terminators. |
| @@ -100,7 +100,7 @@ enum SrsRtspSdpState | @@ -100,7 +100,7 @@ enum SrsRtspSdpState | ||
| 100 | }; | 100 | }; |
| 101 | 101 | ||
| 102 | /** | 102 | /** |
| 103 | -* 10 Method Definitions | 103 | +* 10 Method Definitions, @see rtsp-rfc2326-1998.pdf, page 57 |
| 104 | * The method token indicates the method to be performed on the resource | 104 | * The method token indicates the method to be performed on the resource |
| 105 | * identified by the Request-URI. The method is case-sensitive. New | 105 | * identified by the Request-URI. The method is case-sensitive. New |
| 106 | * methods may be defined in the future. Method names may not start with | 106 | * methods may be defined in the future. Method names may not start with |
| @@ -147,7 +147,7 @@ enum SrsRtspTokenState | @@ -147,7 +147,7 @@ enum SrsRtspTokenState | ||
| 147 | }; | 147 | }; |
| 148 | 148 | ||
| 149 | /** | 149 | /** |
| 150 | -* the sdp in announce. | 150 | +* the sdp in announce, @see rtsp-rfc2326-1998.pdf, page 159 |
| 151 | * Appendix C: Use of SDP for RTSP Session Descriptions | 151 | * Appendix C: Use of SDP for RTSP Session Descriptions |
| 152 | * The Session Description Protocol (SDP, RFC 2327 [6]) may be used to | 152 | * The Session Description Protocol (SDP, RFC 2327 [6]) may be used to |
| 153 | * describe streams or presentations in RTSP. | 153 | * describe streams or presentations in RTSP. |
| @@ -241,7 +241,7 @@ private: | @@ -241,7 +241,7 @@ private: | ||
| 241 | 241 | ||
| 242 | /** | 242 | /** |
| 243 | * the rtsp transport. | 243 | * the rtsp transport. |
| 244 | -* 12.39 Transport | 244 | +* 12.39 Transport, @see rtsp-rfc2326-1998.pdf, page 115 |
| 245 | * This request header indicates which transport protocol is to be used | 245 | * This request header indicates which transport protocol is to be used |
| 246 | * and configures its parameters such as destination address, | 246 | * and configures its parameters such as destination address, |
| 247 | * compression, multicast time-to-live and destination port for a single | 247 | * compression, multicast time-to-live and destination port for a single |
| @@ -288,7 +288,7 @@ public: | @@ -288,7 +288,7 @@ public: | ||
| 288 | 288 | ||
| 289 | /** | 289 | /** |
| 290 | * the rtsp request message. | 290 | * the rtsp request message. |
| 291 | -* 6 Request | 291 | +* 6 Request, @see rtsp-rfc2326-1998.pdf, page 39 |
| 292 | * A request message from a client to a server or vice versa includes, | 292 | * A request message from a client to a server or vice versa includes, |
| 293 | * within the first line of that message, the method to be applied to | 293 | * within the first line of that message, the method to be applied to |
| 294 | * the resource, the identifier of the resource, and the protocol | 294 | * the resource, the identifier of the resource, and the protocol |
| @@ -322,14 +322,14 @@ public: | @@ -322,14 +322,14 @@ public: | ||
| 322 | */ | 322 | */ |
| 323 | long seq; | 323 | long seq; |
| 324 | /** | 324 | /** |
| 325 | - * 12.16 Content-Type | 325 | + * 12.16 Content-Type, @see rtsp-rfc2326-1998.pdf, page 99 |
| 326 | * See [H14.18]. Note that the content types suitable for RTSP are | 326 | * See [H14.18]. Note that the content types suitable for RTSP are |
| 327 | * likely to be restricted in practice to presentation descriptions and | 327 | * likely to be restricted in practice to presentation descriptions and |
| 328 | * parameter-value types. | 328 | * parameter-value types. |
| 329 | */ | 329 | */ |
| 330 | std::string content_type; | 330 | std::string content_type; |
| 331 | /** | 331 | /** |
| 332 | - * 12.14 Content-Length | 332 | + * 12.14 Content-Length, @see rtsp-rfc2326-1998.pdf, page 99 |
| 333 | * This field contains the length of the content of the method (i.e. | 333 | * This field contains the length of the content of the method (i.e. |
| 334 | * after the double CRLF following the last header). Unlike HTTP, it | 334 | * after the double CRLF following the last header). Unlike HTTP, it |
| 335 | * MUST be included in all messages that carry content beyond the header | 335 | * MUST be included in all messages that carry content beyond the header |
| @@ -353,7 +353,7 @@ public: | @@ -353,7 +353,7 @@ public: | ||
| 353 | /** | 353 | /** |
| 354 | * for setup message, parse the stream id from uri. | 354 | * for setup message, parse the stream id from uri. |
| 355 | */ | 355 | */ |
| 356 | - std::string stream_id; | 356 | + int stream_id; |
| 357 | public: | 357 | public: |
| 358 | SrsRtspRequest(); | 358 | SrsRtspRequest(); |
| 359 | virtual ~SrsRtspRequest(); | 359 | virtual ~SrsRtspRequest(); |
| @@ -366,7 +366,7 @@ public: | @@ -366,7 +366,7 @@ public: | ||
| 366 | 366 | ||
| 367 | /** | 367 | /** |
| 368 | * the rtsp response message. | 368 | * the rtsp response message. |
| 369 | -* 7 Response | 369 | +* 7 Response, @see rtsp-rfc2326-1998.pdf, page 43 |
| 370 | * [H6] applies except that HTTP-Version is replaced by RTSP-Version. | 370 | * [H6] applies except that HTTP-Version is replaced by RTSP-Version. |
| 371 | * Also, RTSP defines additional status codes and does not define some | 371 | * Also, RTSP defines additional status codes and does not define some |
| 372 | * HTTP codes. The valid response codes and the methods they can be used | 372 | * HTTP codes. The valid response codes and the methods they can be used |
| @@ -396,7 +396,7 @@ public: | @@ -396,7 +396,7 @@ public: | ||
| 396 | // @see about the status of rtsp, see SRS_CONSTS_RTSP_OK | 396 | // @see about the status of rtsp, see SRS_CONSTS_RTSP_OK |
| 397 | int status; | 397 | int status; |
| 398 | /** | 398 | /** |
| 399 | - * 12.17 CSeq | 399 | + * 12.17 CSeq, @see rtsp-rfc2326-1998.pdf, page 99 |
| 400 | * The CSeq field specifies the sequence number for an RTSP requestresponse | 400 | * The CSeq field specifies the sequence number for an RTSP requestresponse |
| 401 | * pair. This field MUST be present in all requests and | 401 | * pair. This field MUST be present in all requests and |
| 402 | * responses. For every RTSP request containing the given sequence | 402 | * responses. For every RTSP request containing the given sequence |
| @@ -426,7 +426,7 @@ protected: | @@ -426,7 +426,7 @@ protected: | ||
| 426 | }; | 426 | }; |
| 427 | 427 | ||
| 428 | /** | 428 | /** |
| 429 | -* 10.1 OPTIONS | 429 | +* 10.1 OPTIONS, @see rtsp-rfc2326-1998.pdf, page 59 |
| 430 | * The behavior is equivalent to that described in [H9.2]. An OPTIONS | 430 | * The behavior is equivalent to that described in [H9.2]. An OPTIONS |
| 431 | * request may be issued at any time, e.g., if the client is about to | 431 | * request may be issued at any time, e.g., if the client is about to |
| 432 | * try a nonstandard request. It does not influence server state. | 432 | * try a nonstandard request. It does not influence server state. |
| @@ -446,7 +446,7 @@ protected: | @@ -446,7 +446,7 @@ protected: | ||
| 446 | }; | 446 | }; |
| 447 | 447 | ||
| 448 | /** | 448 | /** |
| 449 | -* 10.4 SETUP | 449 | +* 10.4 SETUP, @see rtsp-rfc2326-1998.pdf, page 65 |
| 450 | * The SETUP request for a URI specifies the transport mechanism to be | 450 | * The SETUP request for a URI specifies the transport mechanism to be |
| 451 | * used for the streamed media. A client can issue a SETUP request for a | 451 | * used for the streamed media. A client can issue a SETUP request for a |
| 452 | * stream that is already playing to change transport parameters, which | 452 | * stream that is already playing to change transport parameters, which |
-
请 注册 或 登录 后发表评论