Skip to content

Commit

Permalink
For ossrs#1500, remove useless 28181 codes
Browse files Browse the repository at this point in the history
  • Loading branch information
basson099 committed Mar 14, 2020
1 parent a3be0c8 commit 0f880a3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
42 changes: 41 additions & 1 deletion trunk/src/app/srs_app_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ std::string srs_listener_type2string(SrsListenerType type)
case SrsListener28181TcpStream:
return "GB28181-Stream over TCP";
case SrsListener28181UdpStream:
return "GB28181-Stream over UDP"
return "GB28181-Stream over UDP";
default:
return "UNKONWN";
}
Expand Down Expand Up @@ -285,6 +285,46 @@ srs_error_t SrsHttpFlvListener::on_tcp_client(srs_netfd_t stfd)
return err;
}

SrsUdpStreamListener::SrsUdpStreamListener(SrsServer* svr, SrsListenerType t, ISrsUdpHandler* c) : SrsListener(svr, t)
{
listener = NULL;
caster = c;
}

SrsUdpStreamListener::~SrsUdpStreamListener()
{
srs_freep(listener);
}

srs_error_t SrsUdpStreamListener::listen(string i, int p)
{
srs_error_t err = srs_success;

// the caller already ensure the type is ok,
// we just assert here for unknown stream caster.
srs_assert(type == SrsListenerMpegTsOverUdp);

ip = i;
port = p;

srs_freep(listener);
listener = new SrsUdpListener(caster, ip, port);

if ((err = listener->listen()) != srs_success) {
return srs_error_wrap(err, "listen %s:%d", ip.c_str(), port);
}

// notify the handler the fd changed.
if ((err = caster->on_stfd_change(listener->stfd())) != srs_success) {
return srs_error_wrap(err, "notify fd change failed");
}

string v = srs_listener_type2string(type);
srs_trace("%s listen at udp://%s:%d, fd=%d", v.c_str(), ip.c_str(), port, listener->fd());

return err;
}

SrsUdpCasterListener::SrsUdpCasterListener(SrsServer* svr, SrsListenerType t, SrsConfDirective* c) : SrsUdpStreamListener(svr, t, NULL)
{
// the caller already ensure the type is ok,
Expand Down
13 changes: 13 additions & 0 deletions trunk/src/app/srs_app_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@ class SrsHttpFlvListener : virtual public SrsListener, virtual public ISrsTcpHan
virtual srs_error_t on_tcp_client(srs_netfd_t stfd);
};

// A UDP listener, for udp server.
class SrsUdpStreamListener : public SrsListener
{
protected:
SrsUdpListener* listener;
ISrsUdpHandler* caster;
public:
SrsUdpStreamListener(SrsServer* svr, SrsListenerType t, ISrsUdpHandler* c);
virtual ~SrsUdpStreamListener();
public:
virtual srs_error_t listen(std::string i, int p);
};

// A UDP listener, for udp stream caster server.
class SrsUdpCasterListener : public SrsUdpStreamListener
{
Expand Down

0 comments on commit 0f880a3

Please sign in to comment.