From b5dd5021036fdf3597c5c7d2df3f17102bf39267 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 17 Mar 2020 09:16:52 +0800 Subject: [PATCH] For #1638, #307, fix build warnings --- trunk/src/app/srs_app_dtls.cpp | 5 ++- trunk/src/app/srs_app_http_api.cpp | 3 +- trunk/src/app/srs_app_rtc_conn.cpp | 55 ++++++++++++++------------- trunk/src/app/srs_app_rtp.cpp | 3 -- trunk/src/app/srs_app_source.cpp | 2 +- trunk/src/kernel/srs_kernel_flv.cpp | 4 +- trunk/src/protocol/srs_stun_stack.cpp | 1 - 7 files changed, 36 insertions(+), 37 deletions(-) diff --git a/trunk/src/app/srs_app_dtls.cpp b/trunk/src/app/srs_app_dtls.cpp index 4a863fd924..f4e50e1bfa 100644 --- a/trunk/src/app/srs_app_dtls.cpp +++ b/trunk/src/app/srs_app_dtls.cpp @@ -118,8 +118,9 @@ void SrsDtls::init() char *p = fp; unsigned char md[EVP_MAX_MD_SIZE]; unsigned int n = 0; - - int r = X509_digest(dtls_cert, EVP_sha256(), md, &n); + + // TODO: FIXME: Unused variable. + /*int r = */X509_digest(dtls_cert, EVP_sha256(), md, &n); for (unsigned int i = 0; i < n; i++, ++p) { sprintf(p, "%02X", md[i]); diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp index 1b4b37f45f..96cde96dd7 100644 --- a/trunk/src/app/srs_app_http_api.cpp +++ b/trunk/src/app/srs_app_http_api.cpp @@ -835,7 +835,8 @@ srs_error_t SrsGoApiSdp::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* request.app = app; request.stream = stream_name; SrsSdp local_sdp; - SrsRtcSession* rtc_session = rtc_server->create_rtc_session(request, remote_sdp, local_sdp); + // TODO: FIXME: Maybe need a better name? + /*SrsRtcSession* rtc_session = */rtc_server->create_rtc_session(request, remote_sdp, local_sdp); string local_sdp_str = ""; if ((err = local_sdp.encode(local_sdp_str)) != srs_success) { diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index b20af7ce95..2361b721b9 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -102,7 +102,7 @@ std::vector SrsCandidate::get_candidate_ips() string candidate = _srs_config->get_rtc_candidates(); if (candidate == "*" || candidate == "0.0.0.0") { std::vector tmp = srs_get_local_ips(); - for (int i = 0; i < tmp.size(); ++i) { + for (int i = 0; i < (int)tmp.size(); ++i) { if (tmp[i] != "127.0.0.1") { candidate_ips.push_back(tmp[i]); } @@ -185,7 +185,7 @@ srs_error_t SrsSdp::encode(string& sdp_str) string candidate_lines = ""; std::vector candidate_ips = SrsCandidate::get_candidate_ips(); - for (int i = 0; i < candidate_ips.size(); ++i) { + for (int i = 0; i < (int)candidate_ips.size(); ++i) { ostringstream os; os << "a=candidate:10 1 udp 2115783679 " << candidate_ips[i] << " " << _srs_config->get_rtc_listen() <<" typ host generation 0\\r\\n"; candidate_lines += os.str(); @@ -257,7 +257,7 @@ srs_error_t SrsSdp::parse_attr(const string& line) string key = ""; string val = ""; string* p = &key; - for (int i = 2; i < line.size(); ++i) { + for (int i = 2; i < (int)line.size(); ++i) { if (line[i] == ':' && p == &key) { p = &val; } else { @@ -701,7 +701,7 @@ void SrsRtcSenderThread::send_and_free_messages(SrsSharedPtrMessage** msgs, int for (int i = 0; i < nb_msgs; i++) { SrsSharedPtrMessage* msg = msgs[i]; - for (int i = 0; i < msg->rtp_packets.size(); ++i) { + for (int i = 0; i < (int)msg->rtp_packets.size(); ++i) { if (rtc_session->dtls_session) { char protected_buf[kRtpPacketSize]; int nb_protected_buf = msg->rtp_packets[i]->size; @@ -828,15 +828,15 @@ srs_error_t SrsRtcSession::on_rtcp_feedback(char* buf, int nb_buf, SrsUdpMuxSock : Feedback Control Information (FCI) : : : */ - uint8_t first = stream->read_1bytes(); - uint8_t version = first & 0xC0; - uint8_t padding = first & 0x20; - uint8_t fmt = first & 0x1F; + /*uint8_t first = */stream->read_1bytes(); + //uint8_t version = first & 0xC0; + //uint8_t padding = first & 0x20; + //uint8_t fmt = first & 0x1F; - uint8_t payload_type = stream->read_1bytes(); - uint16_t length = stream->read_2bytes(); - uint32_t ssrc_of_sender = stream->read_4bytes(); - uint32_t ssrc_of_media_source = stream->read_4bytes(); + /*uint8_t payload_type = */stream->read_1bytes(); + /*uint16_t length = */stream->read_2bytes(); + /*uint32_t ssrc_of_sender = */stream->read_4bytes(); + /*uint32_t ssrc_of_media_source = */stream->read_4bytes(); /* 0 1 2 3 @@ -878,7 +878,7 @@ srs_error_t SrsRtcSession::on_rtcp_feedback(char* buf, int nb_buf, SrsUdpMuxSock resend_pkts.push_back(pkt); } - for (int i = 0; i < resend_pkts.size(); ++i) { + for (int i = 0; i < (int)resend_pkts.size(); ++i) { if (dtls_session) { char protected_buf[kRtpPacketSize]; int nb_protected_buf = resend_pkts[i]->size; @@ -905,14 +905,15 @@ srs_error_t SrsRtcSession::on_rtcp_ps_feedback(char* buf, int nb_buf, SrsUdpMuxS SrsAutoFree(SrsBuffer, stream); uint8_t first = stream->read_1bytes(); - uint8_t version = first & 0xC0; - uint8_t padding = first & 0x20; + //uint8_t version = first & 0xC0; + //uint8_t padding = first & 0x20; uint8_t fmt = first & 0x1F; - uint8_t payload_type = stream->read_1bytes(); - uint16_t length = stream->read_2bytes(); - uint32_t ssrc_of_sender = stream->read_4bytes(); - uint32_t ssrc_of_media_source = stream->read_4bytes(); + // TODO: FIXME: Dead code? + /*uint8_t payload_type = */stream->read_1bytes(); + /*uint16_t length = */stream->read_2bytes(); + /*uint32_t ssrc_of_sender = */stream->read_4bytes(); + /*uint32_t ssrc_of_media_source = */stream->read_4bytes(); switch (fmt) { case kPLI: { @@ -979,13 +980,13 @@ block +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ uint8_t first = stream->read_1bytes(); - uint8_t version = first & 0xC0; - uint8_t padding = first & 0x20; + //uint8_t version = first & 0xC0; + //uint8_t padding = first & 0x20; uint8_t rc = first & 0x1F; - uint8_t payload_type = stream->read_1bytes(); + /*uint8_t payload_type = */stream->read_1bytes(); uint16_t length = stream->read_2bytes(); - uint32_t ssrc_of_sender = stream->read_4bytes(); + /*uint32_t ssrc_of_sender = */stream->read_4bytes(); if (((length + 1) * 4) != (rc * 24 + 8)) { return srs_error_wrap(err, "invalid rtcp receiver packet, length=%u, rc=%u", length, rc); @@ -1000,6 +1001,7 @@ block +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ uint32_t lst = stream->read_4bytes(); uint32_t dlsr = stream->read_4bytes(); + (void)ssrc; (void)fraction_lost; (void)cumulative_number_of_packets_lost; (void)highest_seq; (void)jitter; (void)lst; (void)dlsr; srs_verbose("ssrc=%u, fraction_lost=%u, cumulative_number_of_packets_lost=%u, highest_seq=%u, jitter=%u, lst=%u, dlst=%u", ssrc, fraction_lost, cumulative_number_of_packets_lost, highest_seq, jitter, lst, dlsr); } @@ -1073,18 +1075,19 @@ srs_error_t SrsRtcSession::on_rtp(SrsUdpMuxSocket* udp_mux_skt) uint32_t timestamp = stream->read_4bytes(); uint32_t ssrc = stream->read_4bytes(); + (void)padding; (void)marker; (void)sequence; (void)timestamp; (void)ssrc; srs_verbose("sequence=%u, timestamp=%u, ssrc=%u, padding=%d, ext=%d, cc=%u, marker=%d, payload_type=%u", sequence, timestamp, ssrc, padding, ext, cc, marker, payload_type); for (uint8_t i = 0; i < cc; ++i) { - uint32_t csrc = 0; - csrc = stream->read_4bytes(); + /*uint32_t csrc = */stream->read_4bytes(); } if (ext) { uint16_t extern_profile = stream->read_2bytes(); uint16_t extern_length = stream->read_2bytes(); + (void)extern_profile; (void)extern_length; srs_verbose("extern_profile=%u, extern_length=%u", extern_profile, extern_length); stream->read_string(extern_length * 4); @@ -1258,8 +1261,6 @@ srs_error_t SrsRtcServer::on_stun(SrsUdpMuxSocket* udp_mux_skt) srs_error_t SrsRtcServer::on_dtls(SrsUdpMuxSocket* udp_mux_skt) { - srs_error_t err = srs_success; - SrsRtcSession* rtc_session = find_rtc_session_by_peer_id(udp_mux_skt->get_peer_id()); if (rtc_session == NULL) { diff --git a/trunk/src/app/srs_app_rtp.cpp b/trunk/src/app/srs_app_rtp.cpp index f8cf2e7c59..7acbab24d0 100644 --- a/trunk/src/app/srs_app_rtp.cpp +++ b/trunk/src/app/srs_app_rtp.cpp @@ -115,7 +115,6 @@ srs_error_t SrsRtpMuxer::packet_fu_a(SrsSharedPtrMessage* shared_frame, SrsForma } int num_of_packet = (sample->size - 1 + max_payload_size) / max_payload_size; - int avg_packet_size = sample->size / num_of_packet; for (int i = 0; i < num_of_packet; ++i) { char* buf = new char[kRtpPacketSize]; SrsBuffer* stream = new SrsBuffer(buf, kRtpPacketSize); @@ -312,8 +311,6 @@ srs_error_t SrsRtp::on_publish() void SrsRtp::on_unpublish() { - srs_error_t err = srs_success; - // support multiple unpublish. if (!enabled) { return; diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 48716296d8..bccf5aae79 100755 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -836,7 +836,7 @@ void SrsRtpPacketQueue::clear() void SrsRtpPacketQueue::push(std::vector& pkts) { - for (int i = 0; i < pkts.size(); ++i) { + for (int i = 0; i < (int)pkts.size(); ++i) { insert(pkts[i]->sequence, pkts[i]); } } diff --git a/trunk/src/kernel/srs_kernel_flv.cpp b/trunk/src/kernel/srs_kernel_flv.cpp index 5996b60b5a..be4e808e2c 100644 --- a/trunk/src/kernel/srs_kernel_flv.cpp +++ b/trunk/src/kernel/srs_kernel_flv.cpp @@ -230,7 +230,7 @@ SrsSharedPtrMessage::~SrsSharedPtrMessage() } } - for (int i = 0; i < rtp_packets.size(); ++i) { + for (int i = 0; i < (int)rtp_packets.size(); ++i) { srs_freep(rtp_packets[i]); } } @@ -351,7 +351,7 @@ SrsSharedPtrMessage* SrsSharedPtrMessage::copy() copy->payload = ptr->payload; copy->size = ptr->size; - for (int i = 0; i < rtp_packets.size(); ++i) { + for (int i = 0; i < (int)rtp_packets.size(); ++i) { copy->rtp_packets.push_back(rtp_packets[i]->copy()); } diff --git a/trunk/src/protocol/srs_stun_stack.cpp b/trunk/src/protocol/srs_stun_stack.cpp index ee81f5363d..4330c92f79 100644 --- a/trunk/src/protocol/srs_stun_stack.cpp +++ b/trunk/src/protocol/srs_stun_stack.cpp @@ -128,7 +128,6 @@ srs_error_t SrsStunPacket::decode(const char* buf, const int nb_buf) srs_error_t SrsStunPacket::encode(const string& pwd, SrsBuffer* stream) { - srs_error_t err = srs_success; if (is_binding_response()) { return encode_binding_response(pwd, stream); }