Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2015-02-17 22:20:47 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
45c0b12958ca6f8b24d0c9ee00eabe16b2fe53e4
45c0b129
1 parent
f14af454
for #133, finish rtsp sdp, start rtp.
显示空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
48 行增加
和
3 行删除
trunk/src/app/srs_app_rtsp.cpp
trunk/src/protocol/srs_rtsp_stack.cpp
trunk/src/protocol/srs_rtsp_stack.hpp
trunk/src/app/srs_app_rtsp.cpp
查看文件 @
45c0b12
...
...
@@ -68,7 +68,7 @@ SrsRtspConn::SrsRtspConn(SrsRtspCaster* c, st_netfd_t fd, std::string o)
{
output
=
o
;
session
=
"
O9EaZ4bf"
;
// TODO: FIXME: generate session id.
session
=
"
"
;
video_rtp
=
NULL
;
audio_rtp
=
NULL
;
...
...
@@ -118,7 +118,9 @@ int SrsRtspConn::do_cycle()
srs_info
(
"rtsp: got rtsp request"
);
if
(
req
->
is_options
())
{
if
((
ret
=
rtsp
->
send_message
(
new
SrsRtspOptionsResponse
(
req
->
seq
)))
!=
ERROR_SUCCESS
)
{
SrsRtspOptionsResponse
*
res
=
new
SrsRtspOptionsResponse
(
req
->
seq
);
res
->
session
=
session
;
if
((
ret
=
rtsp
->
send_message
(
res
))
!=
ERROR_SUCCESS
)
{
if
(
!
srs_is_client_gracefully_close
(
ret
))
{
srs_error
(
"rtsp: send OPTIONS response failed. ret=%d"
,
ret
);
}
...
...
@@ -136,7 +138,10 @@ int SrsRtspConn::do_cycle()
req
->
sdp
->
audio_stream_id
.
c_str
(),
req
->
sdp
->
audio_codec
.
c_str
(),
req
->
sdp
->
audio_sample_rate
.
c_str
(),
req
->
sdp
->
audio_channel
.
c_str
()
);
if
((
ret
=
rtsp
->
send_message
(
new
SrsRtspResponse
(
req
->
seq
)))
!=
ERROR_SUCCESS
)
{
SrsRtspResponse
*
res
=
new
SrsRtspResponse
(
req
->
seq
);
res
->
session
=
session
;
if
((
ret
=
rtsp
->
send_message
(
res
))
!=
ERROR_SUCCESS
)
{
if
(
!
srs_is_client_gracefully_close
(
ret
))
{
srs_error
(
"rtsp: send ANNOUNCE response failed. ret=%d"
,
ret
);
}
...
...
@@ -164,6 +169,11 @@ int SrsRtspConn::do_cycle()
}
srs_trace
(
"rtsp: rtp listen at port=%d ok."
,
lpm
);
// create session.
if
(
session
.
empty
())
{
session
=
"O9EaZ4bf"
;
// TODO: FIXME: generate session id.
}
SrsRtspSetupResponse
*
res
=
new
SrsRtspSetupResponse
(
req
->
seq
);
res
->
client_port_min
=
req
->
transport
->
client_port_min
;
res
->
client_port_max
=
req
->
transport
->
client_port_max
;
...
...
@@ -176,6 +186,15 @@ int SrsRtspConn::do_cycle()
}
return
ret
;
}
}
else
if
(
req
->
is_record
())
{
SrsRtspResponse
*
res
=
new
SrsRtspResponse
(
req
->
seq
);
res
->
session
=
session
;
if
((
ret
=
rtsp
->
send_message
(
res
))
!=
ERROR_SUCCESS
)
{
if
(
!
srs_is_client_gracefully_close
(
ret
))
{
srs_error
(
"rtsp: send SETUP response failed. ret=%d"
,
ret
);
}
return
ret
;
}
}
}
...
...
trunk/src/protocol/srs_rtsp_stack.cpp
查看文件 @
45c0b12
...
...
@@ -486,6 +486,11 @@ bool SrsRtspRequest::is_setup()
return
method
==
__SRS_METHOD_SETUP
;
}
bool
SrsRtspRequest
::
is_record
()
{
return
method
==
__SRS_METHOD_RECORD
;
}
SrsRtspResponse
::
SrsRtspResponse
(
int
cseq
)
{
seq
=
cseq
;
...
...
@@ -513,6 +518,11 @@ int SrsRtspResponse::encode(stringstream& ss)
<<
"Pragma: no-cache"
<<
__SRS_RTSP_CRLF
<<
"Server: "
<<
RTMP_SIG_SRS_SERVER
<<
__SRS_RTSP_CRLF
;
// session if specified.
if
(
!
session
.
empty
())
{
ss
<<
__SRS_TOKEN_SESSION
<<
":"
<<
session
<<
__SRS_RTSP_CRLF
;
}
if
((
ret
=
encode_header
(
ss
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"rtsp: encode header failed. ret=%d"
,
ret
);
return
ret
;
...
...
@@ -730,6 +740,13 @@ int SrsRtspStack::do_recv_message(SrsRtspRequest* req)
srs_error
(
"rtsp: parse transport failed, transport=%s. ret=%d"
,
transport
.
c_str
(),
ret
);
return
ret
;
}
}
else
if
(
token
==
__SRS_TOKEN_SESSION
)
{
if
((
ret
=
recv_token_eof
(
req
->
session
))
!=
ERROR_SUCCESS
)
{
if
(
!
srs_is_client_gracefully_close
(
ret
))
{
srs_error
(
"rtsp: parse %s failed. ret=%d"
,
__SRS_TOKEN_SESSION
,
ret
);
}
return
ret
;
}
}
else
{
// unknown header name, parse util EOF.
SrsRtspTokenState
state
=
SrsRtspTokenStateNormal
;
...
...
trunk/src/protocol/srs_rtsp_stack.hpp
查看文件 @
45c0b12
...
...
@@ -337,6 +337,10 @@ public:
* assumed. It is interpreted according to [H14.14].
*/
long
content_length
;
/**
* the session id.
*/
std
::
string
session
;
/**
* the sdp in announce, NULL for no sdp.
...
...
@@ -357,6 +361,7 @@ public:
virtual
bool
is_options
();
virtual
bool
is_announce
();
virtual
bool
is_setup
();
virtual
bool
is_record
();
};
/**
...
...
@@ -401,6 +406,10 @@ public:
* for retransmissions of the same request).
*/
long
seq
;
/**
* the session id.
*/
std
::
string
session
;
public
:
SrsRtspResponse
(
int
cseq
);
virtual
~
SrsRtspResponse
();
...
...
请
注册
或
登录
后发表评论