winlin

refine code, fix bug of hls, following jetbrains clion code-inspector. 0.9.215

... ... @@ -177,7 +177,7 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample
return ret;
}
if ((ret = stream->initialize((char*)data, size)) != ERROR_SUCCESS) {
if ((ret = stream->initialize(data, size)) != ERROR_SUCCESS) {
return ret;
}
... ... @@ -300,6 +300,8 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample
case 44100:
sample->sound_rate = SrsCodecAudioSampleRate44100;
break;
default:
break;
};
}
... ... @@ -320,7 +322,7 @@ int SrsAvcAacCodec::video_avc_demux(char* data, int size, SrsCodecSample* sample
return ret;
}
if ((ret = stream->initialize((char*)data, size)) != ERROR_SUCCESS) {
if ((ret = stream->initialize(data, size)) != ERROR_SUCCESS) {
return ret;
}
... ... @@ -467,9 +469,9 @@ int SrsAvcAacCodec::video_avc_demux(char* data, int size, SrsCodecSample* sample
int32_t NALUnitLength = 0;
if (NAL_unit_length == 3) {
NALUnitLength = stream->read_4bytes();
} else if (NALUnitLength == 2) {
} else if (NAL_unit_length == 2) {
NALUnitLength = stream->read_3bytes();
} else if (NALUnitLength == 1) {
} else if (NAL_unit_length == 1) {
NALUnitLength = stream->read_2bytes();
} else {
NALUnitLength = stream->read_1bytes();
... ...
... ... @@ -57,8 +57,8 @@ SrsBandwidthSample::~SrsBandwidthSample()
void SrsBandwidthSample::calc_kbps(int _bytes, int _duration)
{
bytes = (int)_bytes;
actual_duration_ms = (int)_duration;
bytes = _bytes;
actual_duration_ms = _duration;
if (actual_duration_ms <= 0) {
return;
... ...
... ... @@ -21,8 +21,8 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_APP_CONIFG_HPP
#define SRS_APP_CONIFG_HPP
#ifndef SRS_APP_CONFIG_HPP
#define SRS_APP_CONFIG_HPP
/*
#include <srs_app_config.hpp>
... ...
... ... @@ -214,8 +214,8 @@ int SrsDvrPlan::on_audio(SrsSharedPtrMessage* audio)
return ret;
}
char* payload = (char*)audio->payload;
int size = (int)audio->size;
char* payload = audio->payload;
int size = audio->size;
int64_t timestamp = filter_timestamp(audio->header.timestamp);
if ((ret = enc->write_audio(timestamp, payload, size)) != ERROR_SUCCESS) {
return ret;
... ... @@ -236,8 +236,8 @@ int SrsDvrPlan::on_video(SrsSharedPtrMessage* video)
return ret;
}
char* payload = (char*)video->payload;
int size = (int)video->size;
char* payload = video->payload;
int size = video->size;
#ifdef SRS_AUTO_HTTP_CALLBACK
bool is_key_frame = SrsFlvCodec::video_is_h264(payload, size)
... ... @@ -492,8 +492,8 @@ int SrsDvrSegmentPlan::update_duration(SrsSharedPtrMessage* msg)
return ret;
}
char* payload = (char*)msg->payload;
int size = (int)msg->size;
char* payload = msg->payload;
int size = msg->size;
bool is_key_frame = SrsFlvCodec::video_is_h264(payload, size)
&& SrsFlvCodec::video_is_keyframe(payload, size)
&& !SrsFlvCodec::video_is_sequence_header(payload, size);
... ...
... ... @@ -21,8 +21,8 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_APP_EMPYTY_HPP
#define SRS_APP_EMPYTY_HPP
#ifndef SRS_APP_EMPTY_HPP
#define SRS_APP_EMPTY_HPP
/*
#include <srs_app_empty.hpp>
... ...
... ... @@ -141,10 +141,10 @@ void SrsEncoder::clear_engines()
std::string output = ffmpeg->output();
std::vector<std::string>::iterator it;
it = std::find(_transcoded_url.begin(), _transcoded_url.end(), output);
if (it != _transcoded_url.end()) {
_transcoded_url.erase(it);
std::vector<std::string>::iterator tu_it;
tu_it = std::find(_transcoded_url.begin(), _transcoded_url.end(), output);
if (tu_it != _transcoded_url.end()) {
_transcoded_url.erase(tu_it);
}
srs_freep(ffmpeg);
... ...
... ... @@ -42,8 +42,6 @@ public:
virtual ~SrsHttpHeartbeat();
public:
virtual void heartbeat();
public:
static void update_local_ipv4_ips();
};
#endif
... ...
... ... @@ -163,8 +163,6 @@ bool SrsHttpVhost::is_handler_valid(SrsHttpMessage* req, int& status_code, std::
int SrsHttpVhost::do_process_request(SrsStSocket* skt, SrsHttpMessage* req)
{
int ret = ERROR_SUCCESS;
std::string fullpath = get_request_file(req);
// TODO: FIXME: support mp4, @see https://github.com/winlinvip/simple-rtmp-server/issues/174
... ... @@ -182,11 +180,9 @@ int SrsHttpVhost::do_process_request(SrsStSocket* skt, SrsHttpMessage* req)
}
return response_flv_file2(skt, req, fullpath, offset);
} else {
return response_regular_file(skt, req, fullpath);
}
return ret;
return response_regular_file(skt, req, fullpath);
}
int SrsHttpVhost::response_regular_file(SrsStSocket* skt, SrsHttpMessage* req, string fullpath)
... ...
... ... @@ -302,8 +302,6 @@ int SrsRtmpConn::service_cycle()
srs_error("control message(%d) reject as error. ret=%d", ret, ret);
return ret;
}
return ret;
}
int SrsRtmpConn::stream_service_cycle()
... ... @@ -462,7 +460,7 @@ int SrsRtmpConn::stream_service_cycle()
return ret;
}
}
return ret;
}
... ...
... ... @@ -851,8 +851,8 @@ int SrsSource::on_dvr_request_sh()
// when reload to start dvr, dvr will never get the sequence header in stream,
// use the SrsSource.on_dvr_request_sh to push the sequence header to DVR.
if (cache_metadata) {
char* payload = (char*)cache_metadata->payload;
int size = (int)cache_metadata->size;
char* payload = cache_metadata->payload;
int size = cache_metadata->size;
SrsStream stream;
if ((ret = stream.initialize(payload, size)) != ERROR_SUCCESS) {
... ... @@ -1253,7 +1253,7 @@ int SrsSource::on_aggregate(SrsMessage* msg)
int ret = ERROR_SUCCESS;
SrsStream* stream = aggregate_stream;
if ((ret = stream->initialize((char*)msg->payload, msg->size)) != ERROR_SUCCESS) {
if ((ret = stream->initialize(msg->payload, msg->size)) != ERROR_SUCCESS) {
return ret;
}
... ...
... ... @@ -761,7 +761,7 @@ void srs_update_network_devices()
// @see: read_net_dev() from https://github.com/sysstat/sysstat/blob/master/rd_stats.c#L786
// @remark, we use our algorithm, not sysstat.
sscanf(buf, "%6[^:]:%llu %lu %lu %lu %lu %lu %lu %lu %llu %lu %lu %lu %lu %lu %lu %lu\n",
sscanf(buf, "%6[^:]:%llu %lu %lu %lu %lu %lu %lu %lu %llu %lu %lu %lu %lu %lu %lu %lu\n",
r.name, &r.rbytes, &r.rpackets, &r.rerrs, &r.rdrop, &r.rfifo, &r.rframe, &r.rcompressed, &r.rmulticast,
&r.sbytes, &r.spackets, &r.serrs, &r.sdrop, &r.sfifo, &r.scolls, &r.scarrier, &r.scompressed);
... ...
... ... @@ -93,7 +93,7 @@ public:
// state %c One character from the string "RSDZTW" where R is running, S is sleeping in an interruptible wait, D
// is waiting in uninterruptible disk sleep, Z is zombie, T is traced or stopped (on a signal), and W is
// paging.
char state;
unsigned char state;
// ppid %d The PID of the parent.
int ppid;
// pgrp %d The process group ID of the process.
... ... @@ -455,12 +455,12 @@ public:
// = MemFree + Buffers + Cached
u_int64_t NotInUse;
u_int64_t MemTotal;
u_int64_t MemFree;
u_int64_t Buffers;
u_int64_t Cached;
u_int64_t SwapTotal;
u_int64_t SwapFree;
unsigned long MemTotal;
unsigned long MemFree;
unsigned long Buffers;
unsigned long Cached;
unsigned long SwapTotal;
unsigned long SwapFree;
public:
SrsMemInfo();
... ...
... ... @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR "0"
#define VERSION_MINOR "9"
#define VERSION_REVISION "214"
#define VERSION_REVISION "215"
#define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
... ...
... ... @@ -46,7 +46,7 @@ bool SrsFlvCodec::video_is_keyframe(char* data, int size)
return false;
}
char frame_type = *(char*)data;
char frame_type = data[0];
frame_type = (frame_type >> 4) & 0x0F;
return frame_type == SrsCodecVideoAVCFrameKeyFrame;
... ... @@ -64,10 +64,10 @@ bool SrsFlvCodec::video_is_sequence_header(char* data, int size)
return false;
}
char frame_type = *(char*)data;
char frame_type = data[0];
frame_type = (frame_type >> 4) & 0x0F;
char avc_packet_type = *(char*)(data + 1);
char avc_packet_type = data[1];
return frame_type == SrsCodecVideoAVCFrameKeyFrame
&& avc_packet_type == SrsCodecVideoAVCTypeSequenceHeader;
... ... @@ -85,7 +85,7 @@ bool SrsFlvCodec::audio_is_sequence_header(char* data, int size)
return false;
}
char aac_packet_type = *(char*)(data + 1);
char aac_packet_type = data[1];
return aac_packet_type == SrsCodecAudioTypeSequenceHeader;
}
... ... @@ -97,7 +97,7 @@ bool SrsFlvCodec::video_is_h264(char* data, int size)
return false;
}
char codec_id = *(char*)data;
char codec_id = data[0];
codec_id = codec_id & 0x0F;
return codec_id == SrsCodecVideoAVC;
... ... @@ -110,7 +110,7 @@ bool SrsFlvCodec::audio_is_aac(char* data, int size)
return false;
}
char sound_format = *(char*)data;
char sound_format = data[0];
sound_format = (sound_format >> 4) & 0x0F;
return sound_format == SrsCodecAudioAAC;
... ...
... ... @@ -310,7 +310,7 @@ int SrsFlvDecoder::read_tag_header(char* ptype, int32_t* pdata_size, u_int32_t*
// Reserved UB [2]
// Filter UB [1]
// TagType UB [5]
*ptype = (int)(th[0] & 0x1F);
*ptype = (th[0] & 0x1F);
// DataSize UI24
char* pp = (char*)pdata_size;
... ...
... ... @@ -222,7 +222,6 @@ int run()
}
srs_trace("grandpa process exit.");
exit(0);
return 0;
}
// father
... ... @@ -236,7 +235,6 @@ int run()
if(pid > 0) {
srs_trace("father process exit. ret=0");
exit(0);
return 0;
}
// son
... ...
... ... @@ -367,8 +367,6 @@ int SrsAmf0Any::discovery(SrsStream* stream, SrsAmf0Any** ppvalue)
return ret;
}
}
return ret;
}
SrsUnSortedHashtable::SrsUnSortedHashtable()
... ... @@ -1428,11 +1426,7 @@ int srs_amf0_read_boolean(SrsStream* stream, bool& value)
return ret;
}
if (stream->read_1bytes() == 0) {
value = false;
} else {
value = true;
}
value = (stream->read_1bytes() != 0);
srs_verbose("amf0 read bool value success. value=%d", value);
... ...
... ... @@ -947,7 +947,7 @@ namespace _srs_internal
// directly generate the public key.
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/148
int pkey_size = 128;
if ((ret = dh.copy_public_key((char*)block0.key.key, pkey_size)) != ERROR_SUCCESS) {
if ((ret = dh.copy_public_key(block0.key.key, pkey_size)) != ERROR_SUCCESS) {
srs_error("calc s1 key failed. ret=%d", ret);
return ret;
}
... ... @@ -959,7 +959,7 @@ namespace _srs_internal
// directly generate the public key.
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/148
int pkey_size = 128;
if ((ret = dh.copy_public_key((char*)block1.key.key, pkey_size)) != ERROR_SUCCESS) {
if ((ret = dh.copy_public_key(block1.key.key, pkey_size)) != ERROR_SUCCESS) {
srs_error("calc s1 key failed. ret=%d", ret);
return ret;
}
... ...
... ... @@ -172,7 +172,6 @@ string srs_client_type_string(SrsRtmpConnType type)
case SrsRtmpConnFMLEPublish: return "publish(FMLEPublish)";
default: return "Unknown";
}
return "Unknown";
}
SrsHandshakeBytes::SrsHandshakeBytes()
... ...
... ... @@ -517,7 +517,7 @@ int SrsProtocol::decode_message(SrsMessage* msg, SrsPacket** ppacket)
// initialize the decode stream for all message,
// it's ok for the initialize if fast and without memory copy.
if ((ret = stream.initialize((char*)(msg->payload), msg->size)) != ERROR_SUCCESS) {
if ((ret = stream.initialize(msg->payload, msg->size)) != ERROR_SUCCESS) {
srs_error("initialize stream failed. ret=%d", ret);
return ret;
}
... ... @@ -552,7 +552,7 @@ int SrsProtocol::do_send_message(SrsMessage* msg, SrsPacket* packet)
// p set to current write position,
// it's ok when payload is NULL and size is 0.
char* p = (char*)msg->payload;
char* p = msg->payload;
// to directly set the field.
char* pp = NULL;
... ... @@ -561,7 +561,7 @@ int SrsProtocol::do_send_message(SrsMessage* msg, SrsPacket* packet)
// generate the header.
char* pheader = out_header_cache;
if (p == (char*)msg->payload) {
if (p == msg->payload) {
// write new chunk stream header, fmt is 0
*pheader++ = 0x00 | (msg->header.perfer_cid & 0x3F);
... ... @@ -634,7 +634,7 @@ int SrsProtocol::do_send_message(SrsMessage* msg, SrsPacket* packet)
// sendout header and payload by writev.
// decrease the sys invoke count to get higher performance.
int payload_size = msg->size - (p - (char*)msg->payload);
int payload_size = msg->size - (p - msg->payload);
payload_size = srs_min(payload_size, out_chunk_size);
// always has header
... ... @@ -658,7 +658,7 @@ int SrsProtocol::do_send_message(SrsMessage* msg, SrsPacket* packet)
if (msg->payload && msg->size > 0) {
p += payload_size;
}
} while (p < (char*)msg->payload + msg->size);
} while (p < msg->payload + msg->size);
// only process the callback event when with packet
if (packet && (ret = on_send_packet(msg, packet)) != ERROR_SUCCESS) {
... ... @@ -878,7 +878,7 @@ int SrsProtocol::send_and_free_packet(SrsPacket* packet, int stream_id)
msg->header.payload_length = size;
msg->header.message_type = packet->get_message_type();
msg->header.stream_id = stream_id;
msg->header.perfer_cid = packet->get_perfer_cid();
msg->header.perfer_cid = packet->get_prefer_cid();
// donot use the auto free to free the msg,
// for performance issue.
... ... @@ -1527,6 +1527,8 @@ int SrsProtocol::on_recv_message(SrsMessage* msg)
}
break;
}
default:
break;
}
return ret;
... ... @@ -1574,6 +1576,8 @@ int SrsProtocol::on_send_packet(SrsMessage* msg, SrsPacket* packet)
}
break;
}
default:
break;
}
return ret;
... ... @@ -1669,7 +1673,7 @@ int SrsSharedPtrMessage::create(SrsMessage* msg)
{
int ret = ERROR_SUCCESS;
if ((ret = create(&msg->header, (char*)msg->payload, msg->size)) != ERROR_SUCCESS) {
if ((ret = create(&msg->header, msg->payload, msg->size)) != ERROR_SUCCESS) {
return ret;
}
... ... @@ -1786,7 +1790,7 @@ int SrsPacket::decode(SrsStream* stream)
return ret;
}
int SrsPacket::get_perfer_cid()
int SrsPacket::get_prefer_cid()
{
return 0;
}
... ... @@ -2914,7 +2918,7 @@ int SrsPlayPacket::decode(SrsStream* stream)
if (reset_value->is_boolean()) {
reset = reset_value->to_boolean();
} else if (reset_value->is_number()) {
reset = (reset_value->to_number() == 0 ? false : true);
reset = (reset_value->to_number() != 0);
} else {
ret = ERROR_RTMP_AMF0_DECODE;
srs_error("amf0 invalid type=%#x, requires number or bool, ret=%d", reset_value->marker, ret);
... ... @@ -3565,7 +3569,7 @@ int SrsOnMetaDataPacket::decode(SrsStream* stream)
return ret;
}
int SrsOnMetaDataPacket::get_perfer_cid()
int SrsOnMetaDataPacket::get_prefer_cid()
{
return RTMP_CID_OverConnection2;
}
... ... @@ -3625,7 +3629,7 @@ int SrsSetWindowAckSizePacket::decode(SrsStream* stream)
return ret;
}
int SrsSetWindowAckSizePacket::get_perfer_cid()
int SrsSetWindowAckSizePacket::get_prefer_cid()
{
return RTMP_CID_ProtocolControl;
}
... ... @@ -3667,7 +3671,7 @@ SrsAcknowledgementPacket::~SrsAcknowledgementPacket()
{
}
int SrsAcknowledgementPacket::get_perfer_cid()
int SrsAcknowledgementPacket::get_prefer_cid()
{
return RTMP_CID_ProtocolControl;
}
... ... @@ -3725,7 +3729,7 @@ int SrsSetChunkSizePacket::decode(SrsStream* stream)
return ret;
}
int SrsSetChunkSizePacket::get_perfer_cid()
int SrsSetChunkSizePacket::get_prefer_cid()
{
return RTMP_CID_ProtocolControl;
}
... ... @@ -3767,7 +3771,7 @@ SrsSetPeerBandwidthPacket::~SrsSetPeerBandwidthPacket()
{
}
int SrsSetPeerBandwidthPacket::get_perfer_cid()
int SrsSetPeerBandwidthPacket::get_prefer_cid()
{
return RTMP_CID_ProtocolControl;
}
... ... @@ -3841,7 +3845,7 @@ int SrsUserControlPacket::decode(SrsStream* stream)
return ret;
}
int SrsUserControlPacket::get_perfer_cid()
int SrsUserControlPacket::get_prefer_cid()
{
return RTMP_CID_ProtocolControl;
}
... ...
... ... @@ -534,7 +534,7 @@ public:
* all protocol control messages perfer RTMP_CID_ProtocolControl,
* SrsSetWindowAckSizePacket is protocol control message.
*/
virtual int get_perfer_cid();
virtual int get_prefer_cid();
/**
* subpacket must override to provide the right message type.
* the message type set the RTMP message type in header.
... ... @@ -1311,7 +1311,7 @@ public:
virtual int decode(SrsStream* stream);
// encode functions for concrete packet to override.
public:
virtual int get_perfer_cid();
virtual int get_prefer_cid();
virtual int get_message_type();
protected:
virtual int get_size();
... ... @@ -1335,7 +1335,7 @@ public:
virtual int decode(SrsStream* stream);
// encode functions for concrete packet to override.
public:
virtual int get_perfer_cid();
virtual int get_prefer_cid();
virtual int get_message_type();
protected:
virtual int get_size();
... ... @@ -1356,7 +1356,7 @@ public:
virtual ~SrsAcknowledgementPacket();
// encode functions for concrete packet to override.
public:
virtual int get_perfer_cid();
virtual int get_prefer_cid();
virtual int get_message_type();
protected:
virtual int get_size();
... ... @@ -1384,7 +1384,7 @@ public:
virtual int decode(SrsStream* stream);
// encode functions for concrete packet to override.
public:
virtual int get_perfer_cid();
virtual int get_prefer_cid();
virtual int get_message_type();
protected:
virtual int get_size();
... ... @@ -1417,7 +1417,7 @@ public:
virtual ~SrsSetPeerBandwidthPacket();
// encode functions for concrete packet to override.
public:
virtual int get_perfer_cid();
virtual int get_prefer_cid();
virtual int get_message_type();
protected:
virtual int get_size();
... ... @@ -1540,7 +1540,7 @@ public:
virtual int decode(SrsStream* stream);
// encode functions for concrete packet to override.
public:
virtual int get_perfer_cid();
virtual int get_prefer_cid();
virtual int get_message_type();
protected:
virtual int get_size();
... ...