Skip to content

Commit

Permalink
Threads: Fix build fail for API refined.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Apr 30, 2021
1 parent ef6635d commit bc8dd13
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 32 deletions.
3 changes: 1 addition & 2 deletions trunk/src/app/srs_app_hybrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,7 @@ srs_error_t SrsHybridServer::on_thread_message(SrsThreadMessage* msg, SrsThreadP

if (msg->id == (uint64_t)SrsThreadMessageIDRtcCreateSession) {
SrsThreadMessageRtcCreateSession* s = (SrsThreadMessageRtcCreateSession*)msg->ptr;
err = adapter->rtc->create_session(s->req, s->remote_sdp, s->local_sdp, s->mock_eip,
s->publish, s->dtls, s->srtp, &s->session);
err = adapter->rtc->create_session(s->ruc, *s->local_sdp, &s->session);

if (err != srs_success) {
// TODO: FIXME: Response with error information?
Expand Down
7 changes: 2 additions & 5 deletions trunk/src/app/srs_app_rtc_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,15 @@ class SrsRtcServer;
class SrsRequest;
class SrsSdp;
class SrsRtcConnection;
class SrsRtcUserConfig;

class ISrsRtcServer
{
public:
ISrsRtcServer();
virtual ~ISrsRtcServer();
public:
virtual srs_error_t create_session(
SrsRequest* req, const SrsSdp& remote_sdp, SrsSdp& local_sdp, const std::string& mock_eip,
bool publish, bool dtls, bool srtp,
SrsRtcConnection** psession
) = 0;
virtual srs_error_t create_session(SrsRtcUserConfig* ruc, SrsSdp& local_sdp, SrsRtcConnection** psession) = 0;
};

class SrsGoApiRtcPlay : public ISrsHttpHandler
Expand Down
18 changes: 5 additions & 13 deletions trunk/src/app/srs_app_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1890,13 +1890,11 @@ srs_error_t SrsApiServer::listen_api()
return err;
}

srs_error_t SrsApiServer::create_session(
SrsRequest* req, const SrsSdp& remote_sdp, SrsSdp& local_sdp, const std::string& mock_eip,
bool publish, bool dtls, bool srtp,
SrsRtcConnection** psession
) {
srs_error_t SrsApiServer::create_session(SrsRtcUserConfig* ruc, SrsSdp& local_sdp, SrsRtcConnection** psession) {
srs_error_t err = srs_success;

SrsRequest* req = ruc->req_;

// TODO: FIXME: Should update the hybrids for RTMP streams.
// Serve all connections of a stream, which identified by url, by the same hybrid thread.
string url = req->get_stream_url();
Expand Down Expand Up @@ -1936,13 +1934,8 @@ srs_error_t SrsApiServer::create_session(
}

SrsThreadMessageRtcCreateSession s;
s.req = req;
s.remote_sdp = remote_sdp;
s.local_sdp = local_sdp;
s.mock_eip = mock_eip;
s.publish = publish;
s.dtls = dtls;
s.srtp = srtp;
s.ruc = ruc;
s.local_sdp = &local_sdp;
s.session = NULL;

SrsThreadMessage m;
Expand All @@ -1967,7 +1960,6 @@ srs_error_t SrsApiServer::create_session(
}

// Covert to output params.
local_sdp = s.local_sdp;
// TODO: FIMXE: Should never return it, for it's not thread-safe.
*psession = s.session;

Expand Down
15 changes: 3 additions & 12 deletions trunk/src/app/srs_app_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,7 @@ class SrsApiServer : public ISrsTcpMuxHandler, public ISrsResourceManager, publi
virtual srs_error_t http_handle();
srs_error_t listen_api();
private:
virtual srs_error_t create_session(
SrsRequest* req, const SrsSdp& remote_sdp, SrsSdp& local_sdp, const std::string& mock_eip,
bool publish, bool dtls, bool srtp,
SrsRtcConnection** psession
);
virtual srs_error_t create_session(SrsRtcUserConfig* ruc, SrsSdp& local_sdp, SrsRtcConnection** psession);
};

// It's only used in master/srs thread.
Expand All @@ -451,15 +447,10 @@ extern SrsApiServer* _srs_api;
struct SrsThreadMessageRtcCreateSession
{
// Input.
SrsRequest* req;
SrsSdp remote_sdp;
std::string mock_eip;
bool publish;
bool dtls;
bool srtp;
SrsRtcUserConfig* ruc;

// Output.
SrsSdp local_sdp;
SrsSdp* local_sdp;
// TODO: FIXME: It's not thread-safe.
SrsRtcConnection* session;
};
Expand Down

0 comments on commit bc8dd13

Please sign in to comment.