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-24 16:27:30 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6463d22a1404ec753172afd0465eb67dec017279
6463d22a
1 parent
7f02bfa3
for #250, add mpegts over udp stream caster class.
隐藏空白字符变更
内嵌
并排对比
正在显示
8 个修改的文件
包含
148 行增加
和
29 行删除
trunk/configure
trunk/ide/srs_upp/srs_upp.upp
trunk/ide/srs_vs2010/srs.vcxproj
trunk/ide/srs_vs2010/srs.vcxproj.filters
trunk/src/app/srs_app_mpegts_udp.cpp
trunk/src/app/srs_app_mpegts_udp.hpp
trunk/src/app/srs_app_server.cpp
trunk/src/app/srs_app_server.hpp
trunk/configure
查看文件 @
6463d22
...
...
@@ -390,7 +390,8 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
"srs_app_pithy_print"
"srs_app_reload"
"srs_app_http_api"
"srs_app_http_conn"
"srs_app_http_hooks"
"srs_app_json"
"srs_app_ingest"
"srs_app_ffmpeg"
"srs_app_utility"
"srs_app_dvr"
"srs_app_edge"
"srs_app_kbps"
"srs_app_heartbeat"
"srs_app_empty"
"srs_app_http_client"
"srs_app_recv_thread"
"srs_app_security"
"srs_app_statistic"
)
"srs_app_recv_thread"
"srs_app_security"
"srs_app_statistic"
"srs_app_mpegts_udp"
)
APP_INCS
=
"src/app"
;
MODULE_DIR
=
${
APP_INCS
}
. auto/modules.sh
APP_OBJS
=
"
${
MODULE_OBJS
[@]
}
"
fi
...
...
trunk/ide/srs_upp/srs_upp.upp
查看文件 @
6463d22
...
...
@@ -102,6 +102,8 @@ file
../../src/app/srs_app_kbps.cpp,
../../src/app/srs_app_log.hpp,
../../src/app/srs_app_log.cpp,
../../src/app/srs_app_mpegts_udp.hpp,
../../src/app/srs_app_mpegts_udp.cpp,
../../src/app/srs_app_recv_thread.hpp,
../../src/app/srs_app_recv_thread.cpp,
../../src/app/srs_app_refer.hpp,
...
...
trunk/ide/srs_vs2010/srs.vcxproj
查看文件 @
6463d22
...
...
@@ -83,6 +83,7 @@
<ClInclude Include="..\..\src\app\srs_app_json.hpp" />
<ClInclude Include="..\..\src\app\srs_app_kbps.hpp" />
<ClInclude Include="..\..\src\app\srs_app_log.hpp" />
<ClInclude Include="..\..\src\app\srs_app_mpegts_udp.hpp" />
<ClInclude Include="..\..\src\app\srs_app_pithy_print.hpp" />
<ClInclude Include="..\..\src\app\srs_app_recv_thread.hpp" />
<ClInclude Include="..\..\src\app\srs_app_refer.hpp" />
...
...
@@ -158,6 +159,7 @@
<ClCompile Include="..\..\src\app\srs_app_json.cpp" />
<ClCompile Include="..\..\src\app\srs_app_kbps.cpp" />
<ClCompile Include="..\..\src\app\srs_app_log.cpp" />
<ClCompile Include="..\..\src\app\srs_app_mpegts_udp.cpp" />
<ClCompile Include="..\..\src\app\srs_app_pithy_print.cpp" />
<ClCompile Include="..\..\src\app\srs_app_recv_thread.cpp" />
<ClCompile Include="..\..\src\app\srs_app_refer.cpp" />
...
...
trunk/ide/srs_vs2010/srs.vcxproj.filters
查看文件 @
6463d22
...
...
@@ -223,6 +223,9 @@
<ClCompile Include="..\..\src\protocol\srs_rtmp_utility.cpp">
<Filter>srs</Filter>
</ClCompile>
<ClCompile Include="..\..\src\app\srs_app_mpegts_udp.cpp">
<Filter>srs</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\app\srs_app_bandwidth.hpp">
...
...
@@ -408,6 +411,9 @@
<ClInclude Include="..\..\src\protocol\srs_rtmp_utility.hpp">
<Filter>srs</Filter>
</ClInclude>
<ClInclude Include="..\..\src\app\srs_app_mpegts_udp.hpp">
<Filter>srs</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="research">
...
...
trunk/src/app/srs_app_mpegts_udp.cpp
0 → 100644
查看文件 @
6463d22
/*
The MIT License (MIT)
Copyright (c) 2013-2015 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_app_mpegts_udp.hpp>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <srs_app_config.hpp>
#include <srs_kernel_error.hpp>
#include <srs_kernel_log.hpp>
#ifdef SRS_AUTO_STREAM_CASTER
SrsMpegtsOverUdp
::
SrsMpegtsOverUdp
(
SrsConfDirective
*
c
)
{
}
SrsMpegtsOverUdp
::~
SrsMpegtsOverUdp
()
{
}
int
SrsMpegtsOverUdp
::
on_udp_packet
(
sockaddr_in
*
from
,
char
*
buf
,
int
nb_buf
)
{
int
ret
=
ERROR_SUCCESS
;
std
::
string
peer_ip
=
inet_ntoa
(
from
->
sin_addr
);
int
peer_port
=
ntohs
(
from
->
sin_port
);
srs_info
(
"udp: got %s:%d packet %d bytes"
,
peer_ip
.
c_str
(),
peer_port
,
nb_buf
);
// TODO: FIXME: implements it.
return
ret
;
}
#endif
...
...
trunk/src/app/srs_app_mpegts_udp.hpp
0 → 100644
查看文件 @
6463d22
/*
The MIT License (MIT)
Copyright (c) 2013-2015 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_APP_MPEGTS_UDP_HPP
#define SRS_APP_MPEGTS_UDP_HPP
/*
#include <srs_app_mpegts_udp.hpp>
*/
#include <srs_core.hpp>
class
sockaddr_in
;
class
SrsConfDirective
;
#ifdef SRS_AUTO_STREAM_CASTER
/**
* the mpegts over udp stream caster.
*/
class
SrsMpegtsOverUdp
{
public
:
SrsMpegtsOverUdp
(
SrsConfDirective
*
c
);
virtual
~
SrsMpegtsOverUdp
();
public
:
/**
* when udp listener got a udp packet, notice server to process it.
* @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
);
};
#endif
#endif
...
...
trunk/src/app/srs_app_server.cpp
查看文件 @
6463d22
...
...
@@ -44,6 +44,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_source.hpp>
#include <srs_app_utility.hpp>
#include <srs_app_heartbeat.hpp>
#include <srs_app_mpegts_udp.hpp>
// signal defines.
#define SIGNAL_RELOAD SIGHUP
...
...
@@ -226,14 +227,18 @@ int SrsListener::cycle()
return
ret
;
}
SrsUdpListener
::
SrsUdpListener
(
SrsServer
*
server
,
SrsListenerType
type
)
:
SrsListener
(
server
,
type
)
#ifdef SRS_AUTO_STREAM_CASTER
SrsUdpListener
::
SrsUdpListener
(
SrsServer
*
server
,
SrsListenerType
type
,
SrsConfDirective
*
c
)
:
SrsListener
(
server
,
type
)
{
nb_buf
=
SRS_UDP_MAX_PACKET_SIZE
;
buf
=
new
char
[
nb_buf
];
caster
=
new
SrsMpegtsOverUdp
(
c
);
}
SrsUdpListener
::~
SrsUdpListener
()
{
srs_freep
(
caster
);
srs_freep
(
buf
);
}
int
SrsUdpListener
::
listen
(
int
port
)
...
...
@@ -313,7 +318,7 @@ int SrsUdpListener::cycle()
continue
;
}
if
((
ret
=
_server
->
on_udp_packet
(
_type
,
&
from
,
buf
,
nread
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
caster
->
on_udp_packet
(
&
from
,
buf
,
nread
))
!=
ERROR_SUCCESS
)
{
srs_warn
(
"handle udp packet failed. ret=%d"
,
ret
);
continue
;
}
...
...
@@ -328,6 +333,7 @@ int SrsUdpListener::cycle()
return
ret
;
}
#endif
SrsSignalManager
*
SrsSignalManager
::
instance
=
NULL
;
...
...
@@ -1015,7 +1021,7 @@ int SrsServer::listen_stream_caster()
std
::
string
caster
=
_srs_config
->
get_stream_caster_engine
(
stream_caster
);
if
(
caster
==
SRS_CONF_DEFAULT_STREAM_CASTER_MPEGTS_OVER_UDP
)
{
listener
=
new
SrsUdpListener
(
this
,
SrsListenerMpegTsOverUdp
);
listener
=
new
SrsUdpListener
(
this
,
SrsListenerMpegTsOverUdp
,
stream_caster
);
}
else
{
ret
=
ERROR_STREAM_CASTER_ENGINE
;
srs_error
(
"unsupported stream caster %s. ret=%d"
,
caster
.
c_str
(),
ret
);
...
...
@@ -1141,19 +1147,6 @@ int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd)
return
ret
;
}
int
SrsServer
::
on_udp_packet
(
SrsListenerType
type
,
sockaddr_in
*
from
,
char
*
buf
,
int
nb_buf
)
{
int
ret
=
ERROR_SUCCESS
;
std
::
string
peer_ip
=
inet_ntoa
(
from
->
sin_addr
);
int
peer_port
=
ntohs
(
from
->
sin_port
);
// TODO: FIXME: implements it.
srs_warn
(
"udp: drop %s:%d packet %d bytes"
,
peer_ip
.
c_str
(),
peer_port
,
nb_buf
);
return
ret
;
}
int
SrsServer
::
on_reload_listen
()
{
return
listen
();
...
...
trunk/src/app/srs_app_server.hpp
查看文件 @
6463d22
...
...
@@ -44,7 +44,10 @@ class SrsHttpServer;
class
SrsIngester
;
class
SrsHttpHeartbeat
;
class
SrsKbps
;
class
sockaddr_in
;
class
SrsConfDirective
;
#ifdef SRS_AUTO_STREAM_CASTER
class
SrsMpegtsOverUdp
;
#endif
// listener type for server to identify the connection,
// that is, use different type to process the connection.
...
...
@@ -84,6 +87,7 @@ public:
virtual
int
cycle
();
};
#ifdef SRS_AUTO_STREAM_CASTER
/**
* the udp listener, for udp server.
*/
...
...
@@ -92,8 +96,9 @@ class SrsUdpListener : public SrsListener
private
:
char
*
buf
;
int
nb_buf
;
SrsMpegtsOverUdp
*
caster
;
public
:
SrsUdpListener
(
SrsServer
*
server
,
SrsListenerType
type
);
SrsUdpListener
(
SrsServer
*
server
,
SrsListenerType
type
,
SrsConfDirective
*
c
);
virtual
~
SrsUdpListener
();
public
:
virtual
int
listen
(
int
port
);
...
...
@@ -101,6 +106,7 @@ public:
public:
virtual
int
cycle
();
};
#endif
/**
* convert signal to io,
...
...
@@ -256,16 +262,6 @@ public:
* @param client_stfd, the client fd in st boxed, the underlayer fd.
*/
virtual
int
accept_client
(
SrsListenerType
type
,
st_netfd_t
client_stfd
);
/**
* when udp listener got a udp packet, notice server to process it.
* @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
(
SrsListenerType
type
,
sockaddr_in
*
from
,
char
*
buf
,
int
nb_buf
);
// interface ISrsThreadHandler.
public:
virtual
int
on_reload_listen
();
...
...
请
注册
或
登录
后发表评论