Refine TAB to spaces.

pull/1748/head
winlin 5 years ago
parent d59ec158f9
commit d9a5572531

@ -973,7 +973,7 @@ srs_error_t SrsGoApiRtcPlay::check_remote_sdp(const SrsSdp& remote_sdp)
srs_error_t SrsGoApiRtcPlay::exchange_sdp(const std::string& app, const std::string& stream, const SrsSdp& remote_sdp, SrsSdp& local_sdp)
{
srs_error_t err = srs_success;
srs_error_t err = srs_success;
local_sdp.version_ = "0";
local_sdp.username_ = RTMP_SIG_SRS_SERVER;

@ -223,9 +223,9 @@ srs_error_t SrsTcpListener::cycle()
return srs_error_new(ERROR_SOCKET_ACCEPT, "accept at fd=%d", srs_netfd_fileno(lfd));
}
if ((err = srs_fd_closeexec(srs_netfd_fileno(fd))) != srs_success) {
return srs_error_wrap(err, "set closeexec");
}
if ((err = srs_fd_closeexec(srs_netfd_fileno(fd))) != srs_success) {
return srs_error_wrap(err, "set closeexec");
}
if ((err = handler->on_tcp_client(fd)) != srs_success) {
return srs_error_wrap(err, "handle fd=%d", srs_netfd_fileno(fd));
@ -283,7 +283,7 @@ int SrsUdpMuxSocket::recvfrom(srs_utime_t timeout)
if (nread > 0) {
// TODO: FIXME: Maybe we should not covert to string for each packet.
char address_string[64];
char address_string[64];
char port_string[16];
if (getnameinfo((sockaddr*)&from, fromlen,
(char*)&address_string, sizeof(address_string),
@ -293,7 +293,7 @@ int SrsUdpMuxSocket::recvfrom(srs_utime_t timeout)
}
peer_ip = std::string(address_string);
peer_port = atoi(port_string);
peer_port = atoi(port_string);
}
return nread;
@ -305,7 +305,7 @@ srs_error_t SrsUdpMuxSocket::sendto(void* data, int size, srs_utime_t timeout)
int nb_write = srs_sendto(lfd, data, size, (sockaddr*)&from, fromlen, timeout);
if (nb_write <= 0) {
if (nb_write <= 0) {
if (nb_write < 0 && errno == ETIME) {
return srs_error_new(ERROR_SOCKET_TIMEOUT, "sendto timeout %d ms", srsu2msi(timeout));
}
@ -421,7 +421,7 @@ void SrsUdpMuxListener::set_socket_buffer()
srs_error_t SrsUdpMuxListener::cycle()
{
srs_error_t err = srs_success;
srs_error_t err = srs_success;
while (true) {
if ((err = trd->pull()) != srs_success) {

@ -62,12 +62,12 @@ static bool is_stun(const uint8_t* data, const int size)
static bool is_dtls(const uint8_t* data, size_t len)
{
return (len >= 13 && (data[0] > 19 && data[0] < 64));
return (len >= 13 && (data[0] > 19 && data[0] < 64));
}
static bool is_rtp_or_rtcp(const uint8_t* data, size_t len)
{
return (len >= 12 && (data[0] & 0xC0) == 0x80);
return (len >= 12 && (data[0] & 0xC0) == 0x80);
}
static bool is_rtcp(const uint8_t* data, size_t len)
@ -178,7 +178,7 @@ srs_error_t SrsDtlsSession::handshake(SrsUdpMuxSocket* udp_mux_skt)
{
srs_error_t err = srs_success;
int ret = SSL_do_handshake(dtls);
int ret = SSL_do_handshake(dtls);
unsigned char *out_bio_data;
int out_bio_len = BIO_get_mem_data(bio_out, &out_bio_data);
@ -217,7 +217,7 @@ srs_error_t SrsDtlsSession::handshake(SrsUdpMuxSocket* udp_mux_skt)
srs_error_t SrsDtlsSession::on_dtls(SrsUdpMuxSocket* udp_mux_skt)
{
srs_error_t err = srs_success;
if (BIO_reset(bio_in) != 1) {
if (BIO_reset(bio_in) != 1) {
return srs_error_new(ERROR_OpenSslBIOReset, "BIO_reset");
}
if (BIO_reset(bio_out) != 1) {
@ -244,7 +244,7 @@ srs_error_t SrsDtlsSession::on_dtls(SrsUdpMuxSocket* udp_mux_skt)
}
}
return err;
return err;
}
srs_error_t SrsDtlsSession::on_dtls_handshake_done(SrsUdpMuxSocket* udp_mux_skt)
@ -273,24 +273,24 @@ srs_error_t SrsDtlsSession::srtp_initialize()
{
srs_error_t err = srs_success;
unsigned char material[SRTP_MASTER_KEY_LEN * 2] = {0}; // client(SRTP_MASTER_KEY_KEY_LEN + SRTP_MASTER_KEY_SALT_LEN) + server
static const string dtls_srtp_lable = "EXTRACTOR-dtls_srtp";
if (! SSL_export_keying_material(dtls, material, sizeof(material), dtls_srtp_lable.c_str(), dtls_srtp_lable.size(), NULL, 0, 0)) {
unsigned char material[SRTP_MASTER_KEY_LEN * 2] = {0}; // client(SRTP_MASTER_KEY_KEY_LEN + SRTP_MASTER_KEY_SALT_LEN) + server
static const string dtls_srtp_lable = "EXTRACTOR-dtls_srtp";
if (! SSL_export_keying_material(dtls, material, sizeof(material), dtls_srtp_lable.c_str(), dtls_srtp_lable.size(), NULL, 0, 0)) {
return srs_error_new(ERROR_RTC_SRTP_INIT, "SSL_export_keying_material failed");
}
}
size_t offset = 0;
size_t offset = 0;
std::string client_master_key(reinterpret_cast<char*>(material), SRTP_MASTER_KEY_KEY_LEN);
offset += SRTP_MASTER_KEY_KEY_LEN;
std::string server_master_key(reinterpret_cast<char*>(material + offset), SRTP_MASTER_KEY_KEY_LEN);
offset += SRTP_MASTER_KEY_KEY_LEN;
std::string client_master_salt(reinterpret_cast<char*>(material + offset), SRTP_MASTER_KEY_SALT_LEN);
offset += SRTP_MASTER_KEY_SALT_LEN;
std::string server_master_salt(reinterpret_cast<char*>(material + offset), SRTP_MASTER_KEY_SALT_LEN);
std::string client_master_key(reinterpret_cast<char*>(material), SRTP_MASTER_KEY_KEY_LEN);
offset += SRTP_MASTER_KEY_KEY_LEN;
std::string server_master_key(reinterpret_cast<char*>(material + offset), SRTP_MASTER_KEY_KEY_LEN);
offset += SRTP_MASTER_KEY_KEY_LEN;
std::string client_master_salt(reinterpret_cast<char*>(material + offset), SRTP_MASTER_KEY_SALT_LEN);
offset += SRTP_MASTER_KEY_SALT_LEN;
std::string server_master_salt(reinterpret_cast<char*>(material + offset), SRTP_MASTER_KEY_SALT_LEN);
client_key = client_master_key + client_master_salt;
server_key = server_master_key + server_master_salt;
client_key = client_master_key + client_master_salt;
server_key = server_master_key + server_master_salt;
if ((err = srtp_send_init()) != srs_success) {
return srs_error_wrap(err, "srtp send init failed");
@ -497,7 +497,7 @@ srs_error_t SrsRtcSenderThread::cycle()
{
srs_error_t err = srs_success;
SrsSource* source = NULL;
SrsSource* source = NULL;
// TODO: FIXME: Should refactor it, directly use http server as handler.
ISrsSourceHandler* handler = _srs_hybrid->srs()->instance();
@ -508,7 +508,7 @@ srs_error_t SrsRtcSenderThread::cycle()
srs_trace("source url=%s, source_id=[%d][%d], encrypt=%d",
rtc_session->request.get_stream_url().c_str(), ::getpid(), source->source_id(), rtc_session->encrypt);
SrsConsumer* consumer = NULL;
SrsConsumer* consumer = NULL;
SrsAutoFree(SrsConsumer, consumer);
if ((err = source->create_consumer(NULL, consumer)) != srs_success) {
return srs_error_wrap(err, "rtc create consumer, source url=%s", rtc_session->request.get_stream_url().c_str());
@ -525,13 +525,13 @@ srs_error_t SrsRtcSenderThread::cycle()
SrsAutoFree(SrsPithyPrint, pprint);
while (true) {
if ((err = trd->pull()) != srs_success) {
if ((err = trd->pull()) != srs_success) {
return srs_error_wrap(err, "rtc sender thread");
}
pprint->elapse();
if (pprint->can_print()) {
if (pprint->can_print()) {
// TODO: FIXME:
// Print stat like frame/s, packet/s, loss_packets.
}
@ -577,7 +577,7 @@ void SrsRtcSenderThread::send_and_free_messages(SrsSharedPtrMessage** msgs, int
srs_error_t err = srs_success;
vector<mmsghdr> mhdrs;
for (int i = 0; i < nb_msgs; i++) {
for (int i = 0; i < nb_msgs; i++) {
SrsSharedPtrMessage* msg = msgs[i];
for (int i = 0; i < (int)msg->rtp_packets.size(); ++i) {
@ -771,7 +771,7 @@ srs_error_t SrsRtcSession::on_rtcp_feedback(char* buf, int nb_buf, SrsUdpMuxSock
// @see: https://tools.ietf.org/html/rfc4585#section-6.1
/*
0 1 2 3
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|V=2|P| FMT | PT | length |
@ -794,12 +794,12 @@ srs_error_t SrsRtcSession::on_rtcp_feedback(char* buf, int nb_buf, SrsUdpMuxSock
/*uint32_t ssrc_of_media_source = */stream->read_4bytes();
/*
0 1 2 3
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| PID | BLP |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
*/
uint16_t pid = stream->read_2bytes();
int blp = stream->read_2bytes();
@ -910,7 +910,7 @@ srs_error_t SrsRtcSession::on_rtcp_receiver_report(char* buf, int nb_buf, SrsUdp
// @see: https://tools.ietf.org/html/rfc3550#section-6.4.2
/*
0 1 2 3
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
header |V=2|P| RC | PT=RR=201 | length |

@ -80,7 +80,7 @@ class SrsDtlsSession
private:
SrsRtcSession* rtc_session;
SSL* dtls;
SSL* dtls;
BIO* bio_in;
BIO* bio_out;

@ -107,7 +107,7 @@ srs_error_t srs_fd_reuseaddr(int fd)
return srs_error_new(ERROR_SOCKET_SETREUSEADDR, "SO_REUSEADDR fd=%v", fd);
}
return srs_success;
return srs_success;
}
srs_error_t srs_fd_reuseport(int fd)
@ -127,7 +127,7 @@ srs_error_t srs_fd_reuseport(int fd)
srs_warn("SO_REUSEPORT is not supported util Linux kernel 3.9");
#endif
return srs_success;
return srs_success;
}
srs_error_t srs_fd_keepalive(int fd)
@ -139,7 +139,7 @@ srs_error_t srs_fd_keepalive(int fd)
}
#endif
return srs_success;
return srs_success;
}
srs_thread_t srs_thread_self()
@ -194,7 +194,7 @@ srs_error_t srs_tcp_connect(string server, int port, srs_utime_t tm, srs_netfd_t
srs_error_t do_srs_tcp_listen(int fd, addrinfo* r, srs_netfd_t* pfd)
{
srs_error_t err = srs_success;
srs_error_t err = srs_success;
// Detect alive for TCP connection.
// @see https://github.com/ossrs/srs/issues/1044
@ -231,7 +231,7 @@ srs_error_t do_srs_tcp_listen(int fd, addrinfo* r, srs_netfd_t* pfd)
srs_error_t srs_tcp_listen(std::string ip, int port, srs_netfd_t* pfd)
{
srs_error_t err = srs_success;
srs_error_t err = srs_success;
char sport[8];
snprintf(sport, sizeof(sport), "%d", port);
@ -265,7 +265,7 @@ srs_error_t srs_tcp_listen(std::string ip, int port, srs_netfd_t* pfd)
srs_error_t do_srs_udp_listen(int fd, addrinfo* r, srs_netfd_t* pfd)
{
srs_error_t err = srs_success;
srs_error_t err = srs_success;
if ((err = srs_fd_closeexec(fd)) != srs_success) {
return srs_error_wrap(err, "set closeexec");
@ -292,7 +292,7 @@ srs_error_t do_srs_udp_listen(int fd, addrinfo* r, srs_netfd_t* pfd)
srs_error_t srs_udp_listen(std::string ip, int port, srs_netfd_t* pfd)
{
srs_error_t err = srs_success;
srs_error_t err = srs_success;
char sport[8];
snprintf(sport, sizeof(sport), "%d", port);
@ -310,7 +310,7 @@ srs_error_t srs_udp_listen(std::string ip, int port, srs_netfd_t* pfd)
hints.ai_family, hints.ai_socktype, hints.ai_flags);
}
int fd = 0;
int fd = 0;
if ((fd = socket(r->ai_family, r->ai_socktype, r->ai_protocol)) == -1) {
return srs_error_new(ERROR_SOCKET_CREATE, "socket domain=%d, type=%d, protocol=%d",
r->ai_family, r->ai_socktype, r->ai_protocol);

Loading…
Cancel
Save