Skip to content

Commit 60c8b37

Browse files
committed
For #1638, #307, merge john, add NACK suport, remove debug code, verbose log
2 parents c2916ac + 2b56f9e commit 60c8b37

10 files changed

+421
-134
lines changed

trunk/src/app/srs_app_http_api.cpp

+10-29
Original file line numberDiff line numberDiff line change
@@ -795,21 +795,13 @@ SrsGoApiSdp::~SrsGoApiSdp()
795795
srs_error_t SrsGoApiSdp::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
796796
{
797797
srs_error_t err = srs_success;
798-
799-
SrsStatistic* stat = SrsStatistic::instance();
800-
801-
// path: {pattern}{stream_id}
802-
// e.g. /api/v1/streams/100 pattern= /api/v1/streams/, stream_id=100
803-
int sid = r->parse_rest_id(entry->pattern);
804-
805-
SrsStatisticStream* stream = NULL;
806-
if (sid >= 0 && (stream = stat->find_stream(sid)) == NULL) {
807-
return srs_api_response_code(w, r, ERROR_RTMP_STREAM_NOT_FOUND);
808-
}
809798

799+
// path: {pattern}
800+
// method: POST
801+
// e.g. /api/v1/sdp/ args = json:{"sdp":"sdp...", "app":"webrtc", "stream":"test"}
802+
810803
string req_json;
811804
r->body_read_all(req_json);
812-
srs_trace("req_json=%s", req_json.c_str());
813805

814806
SrsJsonAny* json = SrsJsonAny::loads(req_json);
815807
SrsJsonObject* req_obj = json->to_object();
@@ -826,18 +818,17 @@ srs_error_t SrsGoApiSdp::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage*
826818
string app = app_obj->to_str();
827819
string stream_name = stream_name_obj->to_str();
828820

829-
srs_trace("remote_sdp_str=%s", remote_sdp_str.c_str());
830-
srs_trace("app=%s, stream=%s", app.c_str(), stream_name.c_str());
831-
832821
SrsSdp remote_sdp;
833822
err = remote_sdp.decode(remote_sdp_str);
834823
if (err != srs_success) {
835824
return srs_api_response_code(w, r, SRS_CONSTS_HTTP_BadRequest);
836825
}
837826

827+
SrsRequest request;
828+
request.app = app;
829+
request.stream = stream_name;
838830
SrsSdp local_sdp;
839-
SrsRtcSession* rtc_session = rtc_server->create_rtc_session(remote_sdp, local_sdp);
840-
rtc_session->set_app_stream(app, stream_name);
831+
SrsRtcSession* rtc_session = rtc_server->create_rtc_session(request, remote_sdp, local_sdp);
841832

842833
string local_sdp_str = "";
843834
err = local_sdp.encode(local_sdp_str);
@@ -849,22 +840,12 @@ srs_error_t SrsGoApiSdp::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage*
849840
SrsAutoFree(SrsJsonObject, obj);
850841

851842
obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS));
852-
obj->set("server", SrsJsonAny::integer(stat->server_id()));
853-
854-
// XXX: ice candidate
855-
//string candidate_str = "candidate:1 1 udp 2115783679 192.168.170.129:8000 typ host generation 0 ufrag "
856-
// + local_sdp.get_ice_ufrag() + "netwrok-cost 50";
857-
858-
//SrsJsonObject* candidate_obj = SrsJsonAny::object();
859-
//SrsAutoFree(SrsJsonObject, candidate_obj);
843+
obj->set("server", SrsJsonAny::integer(SrsStatistic::instance()->server_id()));
860844

861-
//candidate_obj->set("candidate", SrsJsonAny::str(candidate_str.c_str()));
862-
//candidate_obj->set("sdpMid", SrsJsonAny::str("0"));
863-
//candidate_obj->set("sdpMLineIndex", SrsJsonAny::str("0"));
845+
// TODO: add candidates in response json?
864846

865847
if (r->is_http_post()) {
866848
obj->set("sdp", SrsJsonAny::str(local_sdp_str.c_str()));
867-
// obj->set("candidate", candidate_obj);
868849
} else {
869850
return srs_go_http_error(w, SRS_CONSTS_HTTP_MethodNotAllowed);
870851
}

trunk/src/app/srs_app_log.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#include <srs_kernel_utility.hpp>
3838

3939
// the max size of a line of log.
40-
#define LOG_MAX_SIZE 4096000
40+
#define LOG_MAX_SIZE 4096
4141

4242
// the tail append to each log.
4343
#define LOG_TAIL '\n'

0 commit comments

Comments
 (0)