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-01-30 00:04:20 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a384cc400a4e9eac0b9c98d5e0503f8823d9cf98
a384cc40
1 parent
35ab0ea6
for #250, use udp packet handler.
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
35 行增加
和
32 行删除
trunk/src/app/srs_app_mpegts_udp.cpp
trunk/src/app/srs_app_mpegts_udp.hpp
trunk/src/app/srs_app_server.hpp
trunk/src/app/srs_app_mpegts_udp.cpp
查看文件 @
a384cc4
...
...
@@ -39,6 +39,14 @@ using namespace std;
#ifdef SRS_AUTO_STREAM_CASTER
ISrsUdpHandler
::
ISrsUdpHandler
()
{
}
ISrsUdpHandler
::~
ISrsUdpHandler
()
{
}
SrsMpegtsOverUdp
::
SrsMpegtsOverUdp
(
SrsConfDirective
*
c
)
{
stream
=
new
SrsStream
();
...
...
@@ -95,7 +103,7 @@ int SrsMpegtsOverUdp::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf)
}
// process each ts packet
if
((
ret
=
on_ts_packet
(
stream
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
context
->
decode
(
stream
,
this
))
!=
ERROR_SUCCESS
)
{
srs_warn
(
"mpegts: ignore parse ts packet failed. ret=%d"
,
ret
);
continue
;
}
...
...
@@ -111,18 +119,6 @@ int SrsMpegtsOverUdp::on_udp_packet(sockaddr_in* from, char* buf, int nb_buf)
return
ret
;
}
int
SrsMpegtsOverUdp
::
on_ts_packet
(
SrsStream
*
stream
)
{
int
ret
=
ERROR_SUCCESS
;
if
((
ret
=
context
->
decode
(
stream
,
this
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"mpegts: decode ts packet failed. ret=%d"
,
ret
);
return
ret
;
}
return
ret
;
}
int
SrsMpegtsOverUdp
::
on_ts_message
(
SrsTsMessage
*
msg
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
trunk/src/app/srs_app_mpegts_udp.hpp
查看文件 @
a384cc4
...
...
@@ -43,34 +43,43 @@ class SrsSimpleBuffer;
#include <srs_kernel_ts.hpp>
/**
* the
mpegts over udp stream cast
er.
* the
udp packet handl
er.
*/
class
SrsMpegtsOverUdp
:
public
ISrsTs
Handler
class
ISrsUdp
Handler
{
private
:
SrsStream
*
stream
;
SrsTsContext
*
context
;
SrsSimpleBuffer
*
buffer
;
std
::
string
output
;
public
:
SrsMpegtsOverUdp
(
SrsConfDirective
*
c
);
virtual
~
SrsMpegtsOverUdp
();
ISrsUdpHandler
();
virtual
~
ISrsUdpHandler
();
public
:
/**
* when udp listener got a udp packet, notice server to process it.
* @param type, the client type, used to create concrete connection,
* @param type, the client type, used to create concrete connection,
* for instance RTMP connection to serve client.
* @param from, the udp packet from address.
* @param buf, the udp packet bytes, user should copy if need to use.
* @param nb_buf, the size of udp packet bytes.
* @remark user should never use the buf, for it's a shared memory bytes.
*/
virtual
int
on_udp_packet
(
sockaddr_in
*
from
,
char
*
buf
,
int
nb_buf
);
virtual
int
on_udp_packet
(
sockaddr_in
*
from
,
char
*
buf
,
int
nb_buf
)
=
0
;
};
/**
* the mpegts over udp stream caster.
*/
class
SrsMpegtsOverUdp
:
virtual
public
ISrsTsHandler
,
virtual
public
ISrsUdpHandler
{
private
:
/**
* the stream contains the ts packet to parse.
*/
virtual
int
on_ts_packet
(
SrsStream
*
stream
);
SrsStream
*
stream
;
SrsTsContext
*
context
;
SrsSimpleBuffer
*
buffer
;
std
::
string
output
;
public
:
SrsMpegtsOverUdp
(
SrsConfDirective
*
c
);
virtual
~
SrsMpegtsOverUdp
();
// interface ISrsUdpHandler
public:
virtual
int
on_udp_packet
(
sockaddr_in
*
from
,
char
*
buf
,
int
nb_buf
);
// interface ISrsTsHandler
public:
virtual
int
on_ts_message
(
SrsTsMessage
*
msg
);
...
...
trunk/src/app/srs_app_server.hpp
查看文件 @
a384cc4
...
...
@@ -45,9 +45,7 @@ class SrsIngester;
class
SrsHttpHeartbeat
;
class
SrsKbps
;
class
SrsConfDirective
;
#ifdef SRS_AUTO_STREAM_CASTER
class
SrsMpegtsOverUdp
;
#endif
class
ISrsUdpHandler
;
// listener type for server to identify the connection,
// that is, use different type to process the connection.
...
...
@@ -96,7 +94,7 @@ class SrsUdpListener : public SrsListener
private
:
char
*
buf
;
int
nb_buf
;
SrsMpegtsOverUdp
*
caster
;
ISrsUdpHandler
*
caster
;
public
:
SrsUdpListener
(
SrsServer
*
server
,
SrsListenerType
type
,
SrsConfDirective
*
c
);
virtual
~
SrsUdpListener
();
...
...
请
注册
或
登录
后发表评论