Skip to content

Commit

Permalink
For ossrs#1500, support gb28181
Browse files Browse the repository at this point in the history
  • Loading branch information
basson099 committed Mar 10, 2020
1 parent 5586c2a commit 47c7b30
Show file tree
Hide file tree
Showing 12 changed files with 3,238 additions and 32 deletions.
33 changes: 33 additions & 0 deletions trunk/src/app/srs_app_http_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,39 @@ srs_error_t SrsGoApiClusters::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
return srs_api_response(w, r, obj->dumps());
}


SrsGoApi28181StreamCreation::SrsGoApi28181StreamCreation(SrsServer* srv)
{
server = srv;
}

SrsGoApi28181StreamCreation::~SrsGoApi28181StreamCreation()
{
}

srs_error_t SrsGoApi28181StreamCreation::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
{
srs_error_t err = srs_success;
std::string suuid = "";
int port = 0;
std::stringstream sstream;
SrsJsonObject* content = SrsJsonAny::object();
SrsAutoFree(SrsJsonObject, content);
if((err = server->create_28181stream_listener(SrsListener28181UdpStream,port,suuid))!=srs_success)
{
srs_warn("SrsGoApi28181StreamCreation - create listener failed[%d]",srs_error_code(err));
content->set("status",SrsJsonAny::str("failed"));
content->set("desc",SrsJsonAny::str("create listener failed"));
return srs_api_response(w, r, content->dumps());
}
sstream<<port;
content->set("status",SrsJsonAny::str("successful"));
content->set("stream-uuid",SrsJsonAny::str(suuid.c_str()));
content->set("listen-port",SrsJsonAny::str(sstream.str().c_str()));
return srs_api_response(w, r, content->dumps());
}


SrsGoApiError::SrsGoApiError()
{
}
Expand Down
12 changes: 12 additions & 0 deletions trunk/src/app/srs_app_http_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,18 @@ class SrsGoApiClusters : public ISrsHttpHandler
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
};

class SrsGoApi28181StreamCreation : public ISrsHttpHandler
{
public:
SrsGoApi28181StreamCreation(SrsServer * srv);
virtual ~SrsGoApi28181StreamCreation();
public:
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
private:
SrsServer * server;
};


class SrsGoApiError : public ISrsHttpHandler
{
public:
Expand Down
Loading

0 comments on commit 47c7b30

Please sign in to comment.