mirror of
				https://github.com/ossrs/srs.git
				synced 2025-03-09 15:49:59 +00:00 
			
		
		
		
	remove debug code, fix rtc.html
This commit is contained in:
		
							parent
							
								
									768598a3bb
								
							
						
					
					
						commit
						6c88f58079
					
				
					 11 changed files with 19 additions and 261 deletions
				
			
		| 
						 | 
				
			
			@ -1,90 +0,0 @@
 | 
			
		|||
<!DOCTYPE html>
 | 
			
		||||
<html lang="zh-cmn-Hans">
 | 
			
		||||
<head>
 | 
			
		||||
<meta charset="utf-8">
 | 
			
		||||
</head>
 | 
			
		||||
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
rtc_media_player: <br>
 | 
			
		||||
<video id = "rtc_media_player" autoplay></video>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
 | 
			
		||||
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 method = "POST";
 | 
			
		||||
var shouldBeAsync = true;
 | 
			
		||||
 | 
			
		||||
var request = new XMLHttpRequest();
 | 
			
		||||
 | 
			
		||||
request.open(method, url, shouldBeAsync);
 | 
			
		||||
request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
 | 
			
		||||
 | 
			
		||||
var pc = new PeerConnection(null);
 | 
			
		||||
 | 
			
		||||
var constraints = {
 | 
			
		||||
    mandatory: {
 | 
			
		||||
        OfferToReceiveAudio: true,
 | 
			
		||||
        OfferToReceiveVideo: true
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
var sendViewerOfferFn = function(desc) {
 | 
			
		||||
    console.log('sendViewerOfferFn:', desc);
 | 
			
		||||
 | 
			
		||||
    pc.setLocalDescription(desc);
 | 
			
		||||
 | 
			
		||||
    var sdp_json = {"sdp":desc.sdp, "app":"webrtc", "stream":"test"};
 | 
			
		||||
    request.send(JSON.stringify(sdp_json));
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
pc.createOffer(sendViewerOfferFn, 
 | 
			
		||||
    function(error) { 
 | 
			
		||||
        console.log('sendViewerOfferFn error:' + error); 
 | 
			
		||||
    }, 
 | 
			
		||||
    constraints
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
pc.onaddstream = function(event) {
 | 
			
		||||
    console.log('onaddstream');
 | 
			
		||||
    document.getElementById('rtc_media_player').srcObject = event.stream;
 | 
			
		||||
    rtc_media_player.load();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
pc.onicecandidate = function(event) {
 | 
			
		||||
    console.log('onicecandidate');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
pc.onconnectionstatechange = function(event) {
 | 
			
		||||
    console.log('onconnectionstatechange');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
pc.onicegatheringstatechange = function(event) {
 | 
			
		||||
    console.log('onicegatheringstatechange');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
pc.onsignalingstatechange = function(event) {
 | 
			
		||||
    console.log('onsignalingstatechange');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
request.onerror = function(event) {
 | 
			
		||||
    console.log('http error');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
request.onload = function () {
 | 
			
		||||
    console.log('onload,' , request.responseText);
 | 
			
		||||
    var json = JSON.parse(request.responseText);
 | 
			
		||||
    console.log('onmessage viewerResponse:', json.sdp);
 | 
			
		||||
 | 
			
		||||
    pc.setRemoteDescription(new SessionDescription({type:'answer', sdp:json.sdp}));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
</html>
 | 
			
		||||
| 
						 | 
				
			
			@ -1,97 +0,0 @@
 | 
			
		|||
<!DOCTYPE html>
 | 
			
		||||
<html lang="zh-cmn-Hans">
 | 
			
		||||
<head>
 | 
			
		||||
<meta charset="utf-8">
 | 
			
		||||
</head>
 | 
			
		||||
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
<br>local_media_player: <br>
 | 
			
		||||
<video id = "local_media_player" autoplay></video>
 | 
			
		||||
<br>rtc_media_player: <br>
 | 
			
		||||
<video id = "rtc_media_player" autoplay></video>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
 | 
			
		||||
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 method = "POST";
 | 
			
		||||
var shouldBeAsync = true;
 | 
			
		||||
 | 
			
		||||
var request = new XMLHttpRequest();
 | 
			
		||||
 | 
			
		||||
request.open(method, url, shouldBeAsync);
 | 
			
		||||
request.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
 | 
			
		||||
 | 
			
		||||
var pc = new PeerConnection(null);
 | 
			
		||||
 | 
			
		||||
var sendSdpOffer = function(desc) {
 | 
			
		||||
    console.log('sendSdpOffer:', desc);
 | 
			
		||||
 | 
			
		||||
    pc.setLocalDescription(desc);
 | 
			
		||||
 | 
			
		||||
    var sdp_json = {"sdp":desc.sdp, "app":"webrtc", "stream":"test"};
 | 
			
		||||
    request.send(JSON.stringify(sdp_json));
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
pc.onaddstream = function(event) {
 | 
			
		||||
    console.log('onaddstream');
 | 
			
		||||
    document.getElementById('rtc_media_player').srcObject = event.stream;
 | 
			
		||||
    rtc_media_player.load();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
pc.onicecandidate = function(event) {
 | 
			
		||||
    console.log('onicecandidate');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
pc.onconnectionstatechange = function(event) {
 | 
			
		||||
    console.log('onconnectionstatechange');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
pc.onicegatheringstatechange = function(event) {
 | 
			
		||||
    console.log('onicegatheringstatechange');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
pc.onsignalingstatechange = function(event) {
 | 
			
		||||
    console.log('onsignalingstatechange');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
navigator.webkitGetUserMedia({
 | 
			
		||||
    "audio": true,
 | 
			
		||||
    "video": { 
 | 
			
		||||
        width: 800,
 | 
			
		||||
        height:600,
 | 
			
		||||
        frameRate:30,
 | 
			
		||||
        bitRate:8000,
 | 
			
		||||
    }
 | 
			
		||||
}, function(stream){
 | 
			
		||||
    document.getElementById('local_media_player').srcObject = stream;
 | 
			
		||||
    pc.addStream(stream);
 | 
			
		||||
    pc.createOffer(sendSdpOffer, function (error) {
 | 
			
		||||
        console.log('Failure callback: ' + error);
 | 
			
		||||
        });
 | 
			
		||||
}, function(error){
 | 
			
		||||
    //处理媒体流创建失败错误
 | 
			
		||||
    console.log('getUserMedia error: ' + error);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
request.onerror = function(event) {
 | 
			
		||||
    console.log('http error');
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
request.onload = function () {
 | 
			
		||||
    console.log('onload,' , request.responseText);
 | 
			
		||||
    var json = JSON.parse(request.responseText);
 | 
			
		||||
    console.log('onmessage viewerResponse:', json.sdp);
 | 
			
		||||
 | 
			
		||||
    pc.setRemoteDescription(new SessionDescription({type:'answer', sdp:json.sdp}));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
 | 
			
		||||
</html>
 | 
			
		||||
| 
						 | 
				
			
			@ -7,7 +7,7 @@
 | 
			
		|||
<body>
 | 
			
		||||
 | 
			
		||||
rtc_media_player: <br>
 | 
			
		||||
<video id = "rtc_media_player" autoplay></video>
 | 
			
		||||
<video width="1280" height="720" id = "rtc_media_player" autoplay></video>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -16,7 +16,7 @@ rtc_media_player: <br>
 | 
			
		|||
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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -37,7 +37,7 @@
 | 
			
		|||
#include <srs_kernel_utility.hpp>
 | 
			
		||||
 | 
			
		||||
// 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'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -12,23 +12,6 @@ using namespace std;
 | 
			
		|||
#include <srs_kernel_log.hpp>
 | 
			
		||||
#include <srs_kernel_utility.hpp>
 | 
			
		||||
 | 
			
		||||
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());
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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	
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue