diff --git a/trunk/research/players/rtc.html b/trunk/research/players/rtc.html
deleted file mode 100644
index 4dd8e44f2..000000000
--- a/trunk/research/players/rtc.html
+++ /dev/null
@@ -1,90 +0,0 @@
-
-
-
-
-
-
-
-
-rtc_media_player:
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/trunk/research/players/rtc_upload.html b/trunk/research/players/rtc_upload.html
deleted file mode 100644
index 68c515d8e..000000000
--- a/trunk/research/players/rtc_upload.html
+++ /dev/null
@@ -1,97 +0,0 @@
-
-
-
-
-
-
-
-
-
local_media_player:
-
-
rtc_media_player:
-
-
-
-
-
-
-
diff --git a/trunk/research/players/srs_rtc_player.html b/trunk/research/players/srs_rtc_player.html
index bbb605ab5..164468490 100644
--- a/trunk/research/players/srs_rtc_player.html
+++ b/trunk/research/players/srs_rtc_player.html
@@ -7,7 +7,7 @@
rtc_media_player:
-
+
@@ -16,7 +16,7 @@ rtc_media_player:
var PeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
var SessionDescription = window.RTCSessionDescription || window.mozRTCSessionDescription || window.webkitRTCSessionDescription;
-var url = "http://hw.com:1985/api/v1/sdp/";
+var url = document.location.protocol + "//" + document.domain + ":1985/api/v1/sdp/";
var method = "POST";
var shouldBeAsync = true;
diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp
index fd418bf86..76b877742 100644
--- a/trunk/src/app/srs_app_http_api.cpp
+++ b/trunk/src/app/srs_app_http_api.cpp
@@ -794,18 +794,11 @@ SrsGoApiSdp::~SrsGoApiSdp()
srs_error_t SrsGoApiSdp::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
{
srs_error_t err = srs_success;
-
- SrsStatistic* stat = SrsStatistic::instance();
-
- // path: {pattern}{stream_id}
- // e.g. /api/v1/streams/100 pattern= /api/v1/streams/, stream_id=100
- int sid = r->parse_rest_id(entry->pattern);
-
- SrsStatisticStream* stream = NULL;
- if (sid >= 0 && (stream = stat->find_stream(sid)) == NULL) {
- return srs_api_response_code(w, r, ERROR_RTMP_STREAM_NOT_FOUND);
- }
+ // path: {pattern}
+ // method: POST
+ // e.g. /api/v1/sdp/ args = json:{"sdp":"sdp...", "app":"webrtc", "stream":"test"}
+
string req_json;
r->body_read_all(req_json);
srs_trace("req_json=%s", req_json.c_str());
@@ -850,20 +843,10 @@ srs_error_t SrsGoApiSdp::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage*
obj->set("code", SrsJsonAny::integer(ERROR_SUCCESS));
obj->set("server", SrsJsonAny::integer(stat->server_id()));
- // XXX: ice candidate
- //string candidate_str = "candidate:1 1 udp 2115783679 192.168.170.129:9527 typ host generation 0 ufrag "
- // + local_sdp.get_ice_ufrag() + "netwrok-cost 50";
-
- //SrsJsonObject* candidate_obj = SrsJsonAny::object();
- //SrsAutoFree(SrsJsonObject, candidate_obj);
-
- //candidate_obj->set("candidate", SrsJsonAny::str(candidate_str.c_str()));
- //candidate_obj->set("sdpMid", SrsJsonAny::str("0"));
- //candidate_obj->set("sdpMLineIndex", SrsJsonAny::str("0"));
+ // TODO: add candidates in response json?
if (r->is_http_post()) {
obj->set("sdp", SrsJsonAny::str(local_sdp_str.c_str()));
- // obj->set("candidate", candidate_obj);
} else {
return srs_go_http_error(w, SRS_CONSTS_HTTP_MethodNotAllowed);
}
diff --git a/trunk/src/app/srs_app_log.cpp b/trunk/src/app/srs_app_log.cpp
index f743a056c..4d73ebf8e 100644
--- a/trunk/src/app/srs_app_log.cpp
+++ b/trunk/src/app/srs_app_log.cpp
@@ -37,7 +37,7 @@
#include
// the max size of a line of log.
-#define LOG_MAX_SIZE 4096000
+#define LOG_MAX_SIZE 4096
// the tail append to each log.
#define LOG_TAIL '\n'
diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp
index 802e911c8..e49a4c556 100644
--- a/trunk/src/app/srs_app_rtc_conn.cpp
+++ b/trunk/src/app/srs_app_rtc_conn.cpp
@@ -689,6 +689,7 @@ void SrsRtcSenderThread::send_and_free_messages(SrsSharedPtrMessage** msgs, int
int nb_protected_buf = msg->rtp_packets[i]->size;
rtc_session->dtls_session->protect_rtp(protected_buf, msg->rtp_packets[i]->payload, nb_protected_buf);
+ // TODO: use sendmmsg to send multi packet one system call
udp_mux_skt->sendto(protected_buf, nb_protected_buf, 0);
}
}
diff --git a/trunk/src/app/srs_app_rtc_conn.hpp b/trunk/src/app/srs_app_rtc_conn.hpp
index fc67ba431..c1b786af4 100644
--- a/trunk/src/app/srs_app_rtc_conn.hpp
+++ b/trunk/src/app/srs_app_rtc_conn.hpp
@@ -153,8 +153,6 @@ private:
SrsRtcSession* rtc_session;
SrsUdpMuxSocket ukt;
public:
- // Constructor.
- // @param tm The receive timeout in srs_utime_t.
SrsRtcSenderThread(SrsRtcSession* s, SrsUdpMuxSocket* u, int parent_cid);
virtual ~SrsRtcSenderThread();
public:
@@ -231,8 +229,6 @@ protected:
private:
SrsRtcServer* rtc_server;
public:
- // Constructor.
- // @param tm The receive timeout in srs_utime_t.
SrsRtcTimerThread(SrsRtcServer* rtc_svr, int parent_cid);
virtual ~SrsRtcTimerThread();
public:
diff --git a/trunk/src/app/srs_app_rtp.cpp b/trunk/src/app/srs_app_rtp.cpp
index ee88f419d..729251fc4 100644
--- a/trunk/src/app/srs_app_rtp.cpp
+++ b/trunk/src/app/srs_app_rtp.cpp
@@ -77,8 +77,8 @@ srs_error_t SrsRtpMuxer::frame_to_packet(SrsSharedPtrMessage* shared_frame, SrsF
uint8_t header = sample.bytes[0];
uint8_t nal_type = header & kNalTypeMask;
+ // ignore SEI nal
if (nal_type == 0x06) {
- srs_trace("ignore SEI");
continue;
}
@@ -87,13 +87,6 @@ srs_error_t SrsRtpMuxer::frame_to_packet(SrsSharedPtrMessage* shared_frame, SrsF
} else {
packet_fu_a(shared_frame, format, &sample, rtp_packet_vec);
}
-
-#if 0
- srs_trace("nal size=%d, nal=%s", sample.size, dump_string_hex(sample.bytes, sample.size, sample.size).c_str());
- for (int i = 0; i < shared_frame->nb_rtp_fragments; ++i) {
- srs_trace("rtp=%s", dump_string_hex(shared_frame->rtp_fragments[i].bytes, shared_frame->rtp_fragments[i].size, kRtpPacketSize).c_str());
- }
-#endif
}
shared_frame->set_rtp_packets(rtp_packet_vec);
diff --git a/trunk/src/app/srs_app_rtp.hpp b/trunk/src/app/srs_app_rtp.hpp
index 2a23440cd..badfea443 100644
--- a/trunk/src/app/srs_app_rtp.hpp
+++ b/trunk/src/app/srs_app_rtp.hpp
@@ -52,6 +52,7 @@ const uint8_t kFuA = 28;
const uint8_t kStart = 0x80;
const uint8_t kEnd = 0x40;
+// FIXME: ssrc can relate to source
const uint32_t kVideoSSRC = 3233846889;
class SrsRtpMuxer
diff --git a/trunk/src/protocol/srs_stun_stack.cpp b/trunk/src/protocol/srs_stun_stack.cpp
index a057715d6..146bb23f7 100644
--- a/trunk/src/protocol/srs_stun_stack.cpp
+++ b/trunk/src/protocol/srs_stun_stack.cpp
@@ -12,23 +12,6 @@ using namespace std;
#include
#include
-static string dump_string_hex(const std::string& str, const int& max_len = 128)
-{
- char buf[1024*16];
- int len = 0;
-
- for (int i = 0; i < str.size() && i < max_len; ++i) {
- int nb = snprintf(buf + len, sizeof(buf) - len - 1, "%02X ", (uint8_t)str[i]);
- if (nb <= 0)
- break;
-
- len += nb;
- }
- buf[len] = '\0';
-
- return string(buf, len);
-}
-
static srs_error_t hmac_encode(const std::string& algo, const char* key, const int& key_length,
const char* input, const int input_length, char* output, unsigned int& output_length)
{
@@ -95,8 +78,6 @@ srs_error_t SrsStunPacket::decode(const char* buf, const int nb_buf)
return srs_error_wrap(err, "invalid stun packet, size=%d", stream->size());
}
- srs_trace("stun packet, nb_buf=%d", nb_buf);
-
message_type = stream->read_2bytes();
uint16_t message_len = stream->read_2bytes();
string magic_cookie = stream->read_string(4);
@@ -113,8 +94,6 @@ srs_error_t SrsStunPacket::decode(const char* buf, const int nb_buf)
uint16_t type = stream->read_2bytes();
uint16_t len = stream->read_2bytes();
- srs_trace("type=%u, len=%u", type, len);
-
if (stream->left() < len) {
return srs_error_wrap(err, "invalid stun packet");
}
@@ -124,11 +103,9 @@ srs_error_t SrsStunPacket::decode(const char* buf, const int nb_buf)
if (len % 4 != 0) {
stream->read_string(4 - (len % 4));
}
- //srs_trace("val=%s", val.c_str());
switch (type) {
- // FIXME: enum
- case 6: {
+ case Username: {
username = val;
size_t p = val.find(":");
if (p != string::npos) {
@@ -168,7 +145,7 @@ srs_error_t SrsStunPacket::encode_binding_response(const string& pwd, SrsBuffer*
stream->write_2bytes(BindingResponse);
stream->write_2bytes(property_username.size() + mapped_address.size());
- stream->write_4bytes(0x2112A442);
+ stream->write_4bytes(kStunMagicCookie);
stream->write_string(transcation_id);
stream->write_string(property_username);
stream->write_string(mapped_address);
@@ -226,22 +203,12 @@ string SrsStunPacket::encode_mapped_address()
SrsBuffer* stream = new SrsBuffer(buf, sizeof(buf));
SrsAutoFree(SrsBuffer, stream);
- uint32_t magic_cookie = 0x2112A442;
-#if 1
stream->write_2bytes(XorMappedAddress);
stream->write_2bytes(8);
stream->write_1bytes(0); // ignore this bytes
stream->write_1bytes(1); // ipv4 family
- stream->write_2bytes(mapped_port ^ (magic_cookie >> 16));
- stream->write_4bytes(mapped_address ^ magic_cookie);
-#else
- stream->write_2bytes(MappedAddress);
- stream->write_2bytes(8);
- stream->write_1bytes(0); // ignore this bytes
- stream->write_1bytes(1); // ipv4 family
- stream->write_2bytes(mapped_port);
- stream->write_4bytes(mapped_address);
-#endif
+ stream->write_2bytes(mapped_port ^ (kStunMagicCookie >> 16));
+ stream->write_4bytes(mapped_address ^ kStunMagicCookie);
return string(stream->data(), stream->pos());
}
diff --git a/trunk/src/protocol/srs_stun_stack.hpp b/trunk/src/protocol/srs_stun_stack.hpp
index aa2bc2192..db74c90b3 100644
--- a/trunk/src/protocol/srs_stun_stack.hpp
+++ b/trunk/src/protocol/srs_stun_stack.hpp
@@ -31,6 +31,10 @@
class SrsBuffer;
+// @see: https://tools.ietf.org/html/rfc5389
+// The magic cookie field MUST contain the fixed value 0x2112A442 in network byte order
+const uint32_t kStunMagicCookie = 0x2112A442;
+
enum SrsStunMessageType
{
// see @ https://tools.ietf.org/html/rfc3489#section-11.1