refine code, fix bug of hls, following jetbrains clion code-inspector. 0.9.215
正在显示
21 个修改的文件
包含
70 行增加
和
81 行删除
| @@ -177,7 +177,7 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample | @@ -177,7 +177,7 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample | ||
| 177 | return ret; | 177 | return ret; |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | - if ((ret = stream->initialize((char*)data, size)) != ERROR_SUCCESS) { | 180 | + if ((ret = stream->initialize(data, size)) != ERROR_SUCCESS) { |
| 181 | return ret; | 181 | return ret; |
| 182 | } | 182 | } |
| 183 | 183 | ||
| @@ -300,6 +300,8 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample | @@ -300,6 +300,8 @@ int SrsAvcAacCodec::audio_aac_demux(char* data, int size, SrsCodecSample* sample | ||
| 300 | case 44100: | 300 | case 44100: |
| 301 | sample->sound_rate = SrsCodecAudioSampleRate44100; | 301 | sample->sound_rate = SrsCodecAudioSampleRate44100; |
| 302 | break; | 302 | break; |
| 303 | + default: | ||
| 304 | + break; | ||
| 303 | }; | 305 | }; |
| 304 | } | 306 | } |
| 305 | 307 | ||
| @@ -320,7 +322,7 @@ int SrsAvcAacCodec::video_avc_demux(char* data, int size, SrsCodecSample* sample | @@ -320,7 +322,7 @@ int SrsAvcAacCodec::video_avc_demux(char* data, int size, SrsCodecSample* sample | ||
| 320 | return ret; | 322 | return ret; |
| 321 | } | 323 | } |
| 322 | 324 | ||
| 323 | - if ((ret = stream->initialize((char*)data, size)) != ERROR_SUCCESS) { | 325 | + if ((ret = stream->initialize(data, size)) != ERROR_SUCCESS) { |
| 324 | return ret; | 326 | return ret; |
| 325 | } | 327 | } |
| 326 | 328 | ||
| @@ -467,9 +469,9 @@ int SrsAvcAacCodec::video_avc_demux(char* data, int size, SrsCodecSample* sample | @@ -467,9 +469,9 @@ int SrsAvcAacCodec::video_avc_demux(char* data, int size, SrsCodecSample* sample | ||
| 467 | int32_t NALUnitLength = 0; | 469 | int32_t NALUnitLength = 0; |
| 468 | if (NAL_unit_length == 3) { | 470 | if (NAL_unit_length == 3) { |
| 469 | NALUnitLength = stream->read_4bytes(); | 471 | NALUnitLength = stream->read_4bytes(); |
| 470 | - } else if (NALUnitLength == 2) { | 472 | + } else if (NAL_unit_length == 2) { |
| 471 | NALUnitLength = stream->read_3bytes(); | 473 | NALUnitLength = stream->read_3bytes(); |
| 472 | - } else if (NALUnitLength == 1) { | 474 | + } else if (NAL_unit_length == 1) { |
| 473 | NALUnitLength = stream->read_2bytes(); | 475 | NALUnitLength = stream->read_2bytes(); |
| 474 | } else { | 476 | } else { |
| 475 | NALUnitLength = stream->read_1bytes(); | 477 | NALUnitLength = stream->read_1bytes(); |
| @@ -57,8 +57,8 @@ SrsBandwidthSample::~SrsBandwidthSample() | @@ -57,8 +57,8 @@ SrsBandwidthSample::~SrsBandwidthSample() | ||
| 57 | 57 | ||
| 58 | void SrsBandwidthSample::calc_kbps(int _bytes, int _duration) | 58 | void SrsBandwidthSample::calc_kbps(int _bytes, int _duration) |
| 59 | { | 59 | { |
| 60 | - bytes = (int)_bytes; | ||
| 61 | - actual_duration_ms = (int)_duration; | 60 | + bytes = _bytes; |
| 61 | + actual_duration_ms = _duration; | ||
| 62 | 62 | ||
| 63 | if (actual_duration_ms <= 0) { | 63 | if (actual_duration_ms <= 0) { |
| 64 | return; | 64 | return; |
| @@ -21,8 +21,8 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | @@ -21,8 +21,8 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | -#ifndef SRS_APP_CONIFG_HPP | ||
| 25 | -#define SRS_APP_CONIFG_HPP | 24 | +#ifndef SRS_APP_CONFIG_HPP |
| 25 | +#define SRS_APP_CONFIG_HPP | ||
| 26 | 26 | ||
| 27 | /* | 27 | /* |
| 28 | #include <srs_app_config.hpp> | 28 | #include <srs_app_config.hpp> |
| @@ -214,8 +214,8 @@ int SrsDvrPlan::on_audio(SrsSharedPtrMessage* audio) | @@ -214,8 +214,8 @@ int SrsDvrPlan::on_audio(SrsSharedPtrMessage* audio) | ||
| 214 | return ret; | 214 | return ret; |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | - char* payload = (char*)audio->payload; | ||
| 218 | - int size = (int)audio->size; | 217 | + char* payload = audio->payload; |
| 218 | + int size = audio->size; | ||
| 219 | int64_t timestamp = filter_timestamp(audio->header.timestamp); | 219 | int64_t timestamp = filter_timestamp(audio->header.timestamp); |
| 220 | if ((ret = enc->write_audio(timestamp, payload, size)) != ERROR_SUCCESS) { | 220 | if ((ret = enc->write_audio(timestamp, payload, size)) != ERROR_SUCCESS) { |
| 221 | return ret; | 221 | return ret; |
| @@ -236,8 +236,8 @@ int SrsDvrPlan::on_video(SrsSharedPtrMessage* video) | @@ -236,8 +236,8 @@ int SrsDvrPlan::on_video(SrsSharedPtrMessage* video) | ||
| 236 | return ret; | 236 | return ret; |
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | - char* payload = (char*)video->payload; | ||
| 240 | - int size = (int)video->size; | 239 | + char* payload = video->payload; |
| 240 | + int size = video->size; | ||
| 241 | 241 | ||
| 242 | #ifdef SRS_AUTO_HTTP_CALLBACK | 242 | #ifdef SRS_AUTO_HTTP_CALLBACK |
| 243 | bool is_key_frame = SrsFlvCodec::video_is_h264(payload, size) | 243 | bool is_key_frame = SrsFlvCodec::video_is_h264(payload, size) |
| @@ -492,8 +492,8 @@ int SrsDvrSegmentPlan::update_duration(SrsSharedPtrMessage* msg) | @@ -492,8 +492,8 @@ int SrsDvrSegmentPlan::update_duration(SrsSharedPtrMessage* msg) | ||
| 492 | return ret; | 492 | return ret; |
| 493 | } | 493 | } |
| 494 | 494 | ||
| 495 | - char* payload = (char*)msg->payload; | ||
| 496 | - int size = (int)msg->size; | 495 | + char* payload = msg->payload; |
| 496 | + int size = msg->size; | ||
| 497 | bool is_key_frame = SrsFlvCodec::video_is_h264(payload, size) | 497 | bool is_key_frame = SrsFlvCodec::video_is_h264(payload, size) |
| 498 | && SrsFlvCodec::video_is_keyframe(payload, size) | 498 | && SrsFlvCodec::video_is_keyframe(payload, size) |
| 499 | && !SrsFlvCodec::video_is_sequence_header(payload, size); | 499 | && !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 | @@ -21,8 +21,8 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | 21 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | -#ifndef SRS_APP_EMPYTY_HPP | ||
| 25 | -#define SRS_APP_EMPYTY_HPP | 24 | +#ifndef SRS_APP_EMPTY_HPP |
| 25 | +#define SRS_APP_EMPTY_HPP | ||
| 26 | 26 | ||
| 27 | /* | 27 | /* |
| 28 | #include <srs_app_empty.hpp> | 28 | #include <srs_app_empty.hpp> |
| @@ -141,10 +141,10 @@ void SrsEncoder::clear_engines() | @@ -141,10 +141,10 @@ void SrsEncoder::clear_engines() | ||
| 141 | 141 | ||
| 142 | std::string output = ffmpeg->output(); | 142 | std::string output = ffmpeg->output(); |
| 143 | 143 | ||
| 144 | - std::vector<std::string>::iterator it; | ||
| 145 | - it = std::find(_transcoded_url.begin(), _transcoded_url.end(), output); | ||
| 146 | - if (it != _transcoded_url.end()) { | ||
| 147 | - _transcoded_url.erase(it); | 144 | + std::vector<std::string>::iterator tu_it; |
| 145 | + tu_it = std::find(_transcoded_url.begin(), _transcoded_url.end(), output); | ||
| 146 | + if (tu_it != _transcoded_url.end()) { | ||
| 147 | + _transcoded_url.erase(tu_it); | ||
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | srs_freep(ffmpeg); | 150 | srs_freep(ffmpeg); |
| @@ -163,8 +163,6 @@ bool SrsHttpVhost::is_handler_valid(SrsHttpMessage* req, int& status_code, std:: | @@ -163,8 +163,6 @@ bool SrsHttpVhost::is_handler_valid(SrsHttpMessage* req, int& status_code, std:: | ||
| 163 | 163 | ||
| 164 | int SrsHttpVhost::do_process_request(SrsStSocket* skt, SrsHttpMessage* req) | 164 | int SrsHttpVhost::do_process_request(SrsStSocket* skt, SrsHttpMessage* req) |
| 165 | { | 165 | { |
| 166 | - int ret = ERROR_SUCCESS; | ||
| 167 | - | ||
| 168 | std::string fullpath = get_request_file(req); | 166 | std::string fullpath = get_request_file(req); |
| 169 | 167 | ||
| 170 | // TODO: FIXME: support mp4, @see https://github.com/winlinvip/simple-rtmp-server/issues/174 | 168 | // 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) | @@ -182,11 +180,9 @@ int SrsHttpVhost::do_process_request(SrsStSocket* skt, SrsHttpMessage* req) | ||
| 182 | } | 180 | } |
| 183 | 181 | ||
| 184 | return response_flv_file2(skt, req, fullpath, offset); | 182 | return response_flv_file2(skt, req, fullpath, offset); |
| 185 | - } else { | ||
| 186 | - return response_regular_file(skt, req, fullpath); | ||
| 187 | } | 183 | } |
| 188 | 184 | ||
| 189 | - return ret; | 185 | + return response_regular_file(skt, req, fullpath); |
| 190 | } | 186 | } |
| 191 | 187 | ||
| 192 | int SrsHttpVhost::response_regular_file(SrsStSocket* skt, SrsHttpMessage* req, string fullpath) | 188 | int SrsHttpVhost::response_regular_file(SrsStSocket* skt, SrsHttpMessage* req, string fullpath) |
| @@ -302,8 +302,6 @@ int SrsRtmpConn::service_cycle() | @@ -302,8 +302,6 @@ int SrsRtmpConn::service_cycle() | ||
| 302 | srs_error("control message(%d) reject as error. ret=%d", ret, ret); | 302 | srs_error("control message(%d) reject as error. ret=%d", ret, ret); |
| 303 | return ret; | 303 | return ret; |
| 304 | } | 304 | } |
| 305 | - | ||
| 306 | - return ret; | ||
| 307 | } | 305 | } |
| 308 | 306 | ||
| 309 | int SrsRtmpConn::stream_service_cycle() | 307 | int SrsRtmpConn::stream_service_cycle() |
| @@ -851,8 +851,8 @@ int SrsSource::on_dvr_request_sh() | @@ -851,8 +851,8 @@ int SrsSource::on_dvr_request_sh() | ||
| 851 | // when reload to start dvr, dvr will never get the sequence header in stream, | 851 | // when reload to start dvr, dvr will never get the sequence header in stream, |
| 852 | // use the SrsSource.on_dvr_request_sh to push the sequence header to DVR. | 852 | // use the SrsSource.on_dvr_request_sh to push the sequence header to DVR. |
| 853 | if (cache_metadata) { | 853 | if (cache_metadata) { |
| 854 | - char* payload = (char*)cache_metadata->payload; | ||
| 855 | - int size = (int)cache_metadata->size; | 854 | + char* payload = cache_metadata->payload; |
| 855 | + int size = cache_metadata->size; | ||
| 856 | 856 | ||
| 857 | SrsStream stream; | 857 | SrsStream stream; |
| 858 | if ((ret = stream.initialize(payload, size)) != ERROR_SUCCESS) { | 858 | if ((ret = stream.initialize(payload, size)) != ERROR_SUCCESS) { |
| @@ -1253,7 +1253,7 @@ int SrsSource::on_aggregate(SrsMessage* msg) | @@ -1253,7 +1253,7 @@ int SrsSource::on_aggregate(SrsMessage* msg) | ||
| 1253 | int ret = ERROR_SUCCESS; | 1253 | int ret = ERROR_SUCCESS; |
| 1254 | 1254 | ||
| 1255 | SrsStream* stream = aggregate_stream; | 1255 | SrsStream* stream = aggregate_stream; |
| 1256 | - if ((ret = stream->initialize((char*)msg->payload, msg->size)) != ERROR_SUCCESS) { | 1256 | + if ((ret = stream->initialize(msg->payload, msg->size)) != ERROR_SUCCESS) { |
| 1257 | return ret; | 1257 | return ret; |
| 1258 | } | 1258 | } |
| 1259 | 1259 |
| @@ -93,7 +93,7 @@ public: | @@ -93,7 +93,7 @@ public: | ||
| 93 | // state %c One character from the string "RSDZTW" where R is running, S is sleeping in an interruptible wait, D | 93 | // state %c One character from the string "RSDZTW" where R is running, S is sleeping in an interruptible wait, D |
| 94 | // is waiting in uninterruptible disk sleep, Z is zombie, T is traced or stopped (on a signal), and W is | 94 | // is waiting in uninterruptible disk sleep, Z is zombie, T is traced or stopped (on a signal), and W is |
| 95 | // paging. | 95 | // paging. |
| 96 | - char state; | 96 | + unsigned char state; |
| 97 | // ppid %d The PID of the parent. | 97 | // ppid %d The PID of the parent. |
| 98 | int ppid; | 98 | int ppid; |
| 99 | // pgrp %d The process group ID of the process. | 99 | // pgrp %d The process group ID of the process. |
| @@ -455,12 +455,12 @@ public: | @@ -455,12 +455,12 @@ public: | ||
| 455 | // = MemFree + Buffers + Cached | 455 | // = MemFree + Buffers + Cached |
| 456 | u_int64_t NotInUse; | 456 | u_int64_t NotInUse; |
| 457 | 457 | ||
| 458 | - u_int64_t MemTotal; | ||
| 459 | - u_int64_t MemFree; | ||
| 460 | - u_int64_t Buffers; | ||
| 461 | - u_int64_t Cached; | ||
| 462 | - u_int64_t SwapTotal; | ||
| 463 | - u_int64_t SwapFree; | 458 | + unsigned long MemTotal; |
| 459 | + unsigned long MemFree; | ||
| 460 | + unsigned long Buffers; | ||
| 461 | + unsigned long Cached; | ||
| 462 | + unsigned long SwapTotal; | ||
| 463 | + unsigned long SwapFree; | ||
| 464 | 464 | ||
| 465 | public: | 465 | public: |
| 466 | SrsMemInfo(); | 466 | SrsMemInfo(); |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR "0" | 32 | #define VERSION_MAJOR "0" |
| 33 | #define VERSION_MINOR "9" | 33 | #define VERSION_MINOR "9" |
| 34 | -#define VERSION_REVISION "214" | 34 | +#define VERSION_REVISION "215" |
| 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION | 35 | #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION |
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
| @@ -46,7 +46,7 @@ bool SrsFlvCodec::video_is_keyframe(char* data, int size) | @@ -46,7 +46,7 @@ bool SrsFlvCodec::video_is_keyframe(char* data, int size) | ||
| 46 | return false; | 46 | return false; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | - char frame_type = *(char*)data; | 49 | + char frame_type = data[0]; |
| 50 | frame_type = (frame_type >> 4) & 0x0F; | 50 | frame_type = (frame_type >> 4) & 0x0F; |
| 51 | 51 | ||
| 52 | return frame_type == SrsCodecVideoAVCFrameKeyFrame; | 52 | return frame_type == SrsCodecVideoAVCFrameKeyFrame; |
| @@ -64,10 +64,10 @@ bool SrsFlvCodec::video_is_sequence_header(char* data, int size) | @@ -64,10 +64,10 @@ bool SrsFlvCodec::video_is_sequence_header(char* data, int size) | ||
| 64 | return false; | 64 | return false; |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | - char frame_type = *(char*)data; | 67 | + char frame_type = data[0]; |
| 68 | frame_type = (frame_type >> 4) & 0x0F; | 68 | frame_type = (frame_type >> 4) & 0x0F; |
| 69 | 69 | ||
| 70 | - char avc_packet_type = *(char*)(data + 1); | 70 | + char avc_packet_type = data[1]; |
| 71 | 71 | ||
| 72 | return frame_type == SrsCodecVideoAVCFrameKeyFrame | 72 | return frame_type == SrsCodecVideoAVCFrameKeyFrame |
| 73 | && avc_packet_type == SrsCodecVideoAVCTypeSequenceHeader; | 73 | && avc_packet_type == SrsCodecVideoAVCTypeSequenceHeader; |
| @@ -85,7 +85,7 @@ bool SrsFlvCodec::audio_is_sequence_header(char* data, int size) | @@ -85,7 +85,7 @@ bool SrsFlvCodec::audio_is_sequence_header(char* data, int size) | ||
| 85 | return false; | 85 | return false; |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | - char aac_packet_type = *(char*)(data + 1); | 88 | + char aac_packet_type = data[1]; |
| 89 | 89 | ||
| 90 | return aac_packet_type == SrsCodecAudioTypeSequenceHeader; | 90 | return aac_packet_type == SrsCodecAudioTypeSequenceHeader; |
| 91 | } | 91 | } |
| @@ -97,7 +97,7 @@ bool SrsFlvCodec::video_is_h264(char* data, int size) | @@ -97,7 +97,7 @@ bool SrsFlvCodec::video_is_h264(char* data, int size) | ||
| 97 | return false; | 97 | return false; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | - char codec_id = *(char*)data; | 100 | + char codec_id = data[0]; |
| 101 | codec_id = codec_id & 0x0F; | 101 | codec_id = codec_id & 0x0F; |
| 102 | 102 | ||
| 103 | return codec_id == SrsCodecVideoAVC; | 103 | return codec_id == SrsCodecVideoAVC; |
| @@ -110,7 +110,7 @@ bool SrsFlvCodec::audio_is_aac(char* data, int size) | @@ -110,7 +110,7 @@ bool SrsFlvCodec::audio_is_aac(char* data, int size) | ||
| 110 | return false; | 110 | return false; |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | - char sound_format = *(char*)data; | 113 | + char sound_format = data[0]; |
| 114 | sound_format = (sound_format >> 4) & 0x0F; | 114 | sound_format = (sound_format >> 4) & 0x0F; |
| 115 | 115 | ||
| 116 | return sound_format == SrsCodecAudioAAC; | 116 | return sound_format == SrsCodecAudioAAC; |
| @@ -310,7 +310,7 @@ int SrsFlvDecoder::read_tag_header(char* ptype, int32_t* pdata_size, u_int32_t* | @@ -310,7 +310,7 @@ int SrsFlvDecoder::read_tag_header(char* ptype, int32_t* pdata_size, u_int32_t* | ||
| 310 | // Reserved UB [2] | 310 | // Reserved UB [2] |
| 311 | // Filter UB [1] | 311 | // Filter UB [1] |
| 312 | // TagType UB [5] | 312 | // TagType UB [5] |
| 313 | - *ptype = (int)(th[0] & 0x1F); | 313 | + *ptype = (th[0] & 0x1F); |
| 314 | 314 | ||
| 315 | // DataSize UI24 | 315 | // DataSize UI24 |
| 316 | char* pp = (char*)pdata_size; | 316 | char* pp = (char*)pdata_size; |
| @@ -222,7 +222,6 @@ int run() | @@ -222,7 +222,6 @@ int run() | ||
| 222 | } | 222 | } |
| 223 | srs_trace("grandpa process exit."); | 223 | srs_trace("grandpa process exit."); |
| 224 | exit(0); | 224 | exit(0); |
| 225 | - return 0; | ||
| 226 | } | 225 | } |
| 227 | 226 | ||
| 228 | // father | 227 | // father |
| @@ -236,7 +235,6 @@ int run() | @@ -236,7 +235,6 @@ int run() | ||
| 236 | if(pid > 0) { | 235 | if(pid > 0) { |
| 237 | srs_trace("father process exit. ret=0"); | 236 | srs_trace("father process exit. ret=0"); |
| 238 | exit(0); | 237 | exit(0); |
| 239 | - return 0; | ||
| 240 | } | 238 | } |
| 241 | 239 | ||
| 242 | // son | 240 | // son |
| @@ -367,8 +367,6 @@ int SrsAmf0Any::discovery(SrsStream* stream, SrsAmf0Any** ppvalue) | @@ -367,8 +367,6 @@ int SrsAmf0Any::discovery(SrsStream* stream, SrsAmf0Any** ppvalue) | ||
| 367 | return ret; | 367 | return ret; |
| 368 | } | 368 | } |
| 369 | } | 369 | } |
| 370 | - | ||
| 371 | - return ret; | ||
| 372 | } | 370 | } |
| 373 | 371 | ||
| 374 | SrsUnSortedHashtable::SrsUnSortedHashtable() | 372 | SrsUnSortedHashtable::SrsUnSortedHashtable() |
| @@ -1428,11 +1426,7 @@ int srs_amf0_read_boolean(SrsStream* stream, bool& value) | @@ -1428,11 +1426,7 @@ int srs_amf0_read_boolean(SrsStream* stream, bool& value) | ||
| 1428 | return ret; | 1426 | return ret; |
| 1429 | } | 1427 | } |
| 1430 | 1428 | ||
| 1431 | - if (stream->read_1bytes() == 0) { | ||
| 1432 | - value = false; | ||
| 1433 | - } else { | ||
| 1434 | - value = true; | ||
| 1435 | - } | 1429 | + value = (stream->read_1bytes() != 0); |
| 1436 | 1430 | ||
| 1437 | srs_verbose("amf0 read bool value success. value=%d", value); | 1431 | srs_verbose("amf0 read bool value success. value=%d", value); |
| 1438 | 1432 |
| @@ -947,7 +947,7 @@ namespace _srs_internal | @@ -947,7 +947,7 @@ namespace _srs_internal | ||
| 947 | // directly generate the public key. | 947 | // directly generate the public key. |
| 948 | // @see: https://github.com/winlinvip/simple-rtmp-server/issues/148 | 948 | // @see: https://github.com/winlinvip/simple-rtmp-server/issues/148 |
| 949 | int pkey_size = 128; | 949 | int pkey_size = 128; |
| 950 | - if ((ret = dh.copy_public_key((char*)block0.key.key, pkey_size)) != ERROR_SUCCESS) { | 950 | + if ((ret = dh.copy_public_key(block0.key.key, pkey_size)) != ERROR_SUCCESS) { |
| 951 | srs_error("calc s1 key failed. ret=%d", ret); | 951 | srs_error("calc s1 key failed. ret=%d", ret); |
| 952 | return ret; | 952 | return ret; |
| 953 | } | 953 | } |
| @@ -959,7 +959,7 @@ namespace _srs_internal | @@ -959,7 +959,7 @@ namespace _srs_internal | ||
| 959 | // directly generate the public key. | 959 | // directly generate the public key. |
| 960 | // @see: https://github.com/winlinvip/simple-rtmp-server/issues/148 | 960 | // @see: https://github.com/winlinvip/simple-rtmp-server/issues/148 |
| 961 | int pkey_size = 128; | 961 | int pkey_size = 128; |
| 962 | - if ((ret = dh.copy_public_key((char*)block1.key.key, pkey_size)) != ERROR_SUCCESS) { | 962 | + if ((ret = dh.copy_public_key(block1.key.key, pkey_size)) != ERROR_SUCCESS) { |
| 963 | srs_error("calc s1 key failed. ret=%d", ret); | 963 | srs_error("calc s1 key failed. ret=%d", ret); |
| 964 | return ret; | 964 | return ret; |
| 965 | } | 965 | } |
| @@ -172,7 +172,6 @@ string srs_client_type_string(SrsRtmpConnType type) | @@ -172,7 +172,6 @@ string srs_client_type_string(SrsRtmpConnType type) | ||
| 172 | case SrsRtmpConnFMLEPublish: return "publish(FMLEPublish)"; | 172 | case SrsRtmpConnFMLEPublish: return "publish(FMLEPublish)"; |
| 173 | default: return "Unknown"; | 173 | default: return "Unknown"; |
| 174 | } | 174 | } |
| 175 | - return "Unknown"; | ||
| 176 | } | 175 | } |
| 177 | 176 | ||
| 178 | SrsHandshakeBytes::SrsHandshakeBytes() | 177 | SrsHandshakeBytes::SrsHandshakeBytes() |
| @@ -517,7 +517,7 @@ int SrsProtocol::decode_message(SrsMessage* msg, SrsPacket** ppacket) | @@ -517,7 +517,7 @@ int SrsProtocol::decode_message(SrsMessage* msg, SrsPacket** ppacket) | ||
| 517 | 517 | ||
| 518 | // initialize the decode stream for all message, | 518 | // initialize the decode stream for all message, |
| 519 | // it's ok for the initialize if fast and without memory copy. | 519 | // it's ok for the initialize if fast and without memory copy. |
| 520 | - if ((ret = stream.initialize((char*)(msg->payload), msg->size)) != ERROR_SUCCESS) { | 520 | + if ((ret = stream.initialize(msg->payload, msg->size)) != ERROR_SUCCESS) { |
| 521 | srs_error("initialize stream failed. ret=%d", ret); | 521 | srs_error("initialize stream failed. ret=%d", ret); |
| 522 | return ret; | 522 | return ret; |
| 523 | } | 523 | } |
| @@ -552,7 +552,7 @@ int SrsProtocol::do_send_message(SrsMessage* msg, SrsPacket* packet) | @@ -552,7 +552,7 @@ int SrsProtocol::do_send_message(SrsMessage* msg, SrsPacket* packet) | ||
| 552 | 552 | ||
| 553 | // p set to current write position, | 553 | // p set to current write position, |
| 554 | // it's ok when payload is NULL and size is 0. | 554 | // it's ok when payload is NULL and size is 0. |
| 555 | - char* p = (char*)msg->payload; | 555 | + char* p = msg->payload; |
| 556 | // to directly set the field. | 556 | // to directly set the field. |
| 557 | char* pp = NULL; | 557 | char* pp = NULL; |
| 558 | 558 | ||
| @@ -561,7 +561,7 @@ int SrsProtocol::do_send_message(SrsMessage* msg, SrsPacket* packet) | @@ -561,7 +561,7 @@ int SrsProtocol::do_send_message(SrsMessage* msg, SrsPacket* packet) | ||
| 561 | // generate the header. | 561 | // generate the header. |
| 562 | char* pheader = out_header_cache; | 562 | char* pheader = out_header_cache; |
| 563 | 563 | ||
| 564 | - if (p == (char*)msg->payload) { | 564 | + if (p == msg->payload) { |
| 565 | // write new chunk stream header, fmt is 0 | 565 | // write new chunk stream header, fmt is 0 |
| 566 | *pheader++ = 0x00 | (msg->header.perfer_cid & 0x3F); | 566 | *pheader++ = 0x00 | (msg->header.perfer_cid & 0x3F); |
| 567 | 567 | ||
| @@ -634,7 +634,7 @@ int SrsProtocol::do_send_message(SrsMessage* msg, SrsPacket* packet) | @@ -634,7 +634,7 @@ int SrsProtocol::do_send_message(SrsMessage* msg, SrsPacket* packet) | ||
| 634 | 634 | ||
| 635 | // sendout header and payload by writev. | 635 | // sendout header and payload by writev. |
| 636 | // decrease the sys invoke count to get higher performance. | 636 | // decrease the sys invoke count to get higher performance. |
| 637 | - int payload_size = msg->size - (p - (char*)msg->payload); | 637 | + int payload_size = msg->size - (p - msg->payload); |
| 638 | payload_size = srs_min(payload_size, out_chunk_size); | 638 | payload_size = srs_min(payload_size, out_chunk_size); |
| 639 | 639 | ||
| 640 | // always has header | 640 | // always has header |
| @@ -658,7 +658,7 @@ int SrsProtocol::do_send_message(SrsMessage* msg, SrsPacket* packet) | @@ -658,7 +658,7 @@ int SrsProtocol::do_send_message(SrsMessage* msg, SrsPacket* packet) | ||
| 658 | if (msg->payload && msg->size > 0) { | 658 | if (msg->payload && msg->size > 0) { |
| 659 | p += payload_size; | 659 | p += payload_size; |
| 660 | } | 660 | } |
| 661 | - } while (p < (char*)msg->payload + msg->size); | 661 | + } while (p < msg->payload + msg->size); |
| 662 | 662 | ||
| 663 | // only process the callback event when with packet | 663 | // only process the callback event when with packet |
| 664 | if (packet && (ret = on_send_packet(msg, packet)) != ERROR_SUCCESS) { | 664 | 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) | @@ -878,7 +878,7 @@ int SrsProtocol::send_and_free_packet(SrsPacket* packet, int stream_id) | ||
| 878 | msg->header.payload_length = size; | 878 | msg->header.payload_length = size; |
| 879 | msg->header.message_type = packet->get_message_type(); | 879 | msg->header.message_type = packet->get_message_type(); |
| 880 | msg->header.stream_id = stream_id; | 880 | msg->header.stream_id = stream_id; |
| 881 | - msg->header.perfer_cid = packet->get_perfer_cid(); | 881 | + msg->header.perfer_cid = packet->get_prefer_cid(); |
| 882 | 882 | ||
| 883 | // donot use the auto free to free the msg, | 883 | // donot use the auto free to free the msg, |
| 884 | // for performance issue. | 884 | // for performance issue. |
| @@ -1527,6 +1527,8 @@ int SrsProtocol::on_recv_message(SrsMessage* msg) | @@ -1527,6 +1527,8 @@ int SrsProtocol::on_recv_message(SrsMessage* msg) | ||
| 1527 | } | 1527 | } |
| 1528 | break; | 1528 | break; |
| 1529 | } | 1529 | } |
| 1530 | + default: | ||
| 1531 | + break; | ||
| 1530 | } | 1532 | } |
| 1531 | 1533 | ||
| 1532 | return ret; | 1534 | return ret; |
| @@ -1574,6 +1576,8 @@ int SrsProtocol::on_send_packet(SrsMessage* msg, SrsPacket* packet) | @@ -1574,6 +1576,8 @@ int SrsProtocol::on_send_packet(SrsMessage* msg, SrsPacket* packet) | ||
| 1574 | } | 1576 | } |
| 1575 | break; | 1577 | break; |
| 1576 | } | 1578 | } |
| 1579 | + default: | ||
| 1580 | + break; | ||
| 1577 | } | 1581 | } |
| 1578 | 1582 | ||
| 1579 | return ret; | 1583 | return ret; |
| @@ -1669,7 +1673,7 @@ int SrsSharedPtrMessage::create(SrsMessage* msg) | @@ -1669,7 +1673,7 @@ int SrsSharedPtrMessage::create(SrsMessage* msg) | ||
| 1669 | { | 1673 | { |
| 1670 | int ret = ERROR_SUCCESS; | 1674 | int ret = ERROR_SUCCESS; |
| 1671 | 1675 | ||
| 1672 | - if ((ret = create(&msg->header, (char*)msg->payload, msg->size)) != ERROR_SUCCESS) { | 1676 | + if ((ret = create(&msg->header, msg->payload, msg->size)) != ERROR_SUCCESS) { |
| 1673 | return ret; | 1677 | return ret; |
| 1674 | } | 1678 | } |
| 1675 | 1679 | ||
| @@ -1786,7 +1790,7 @@ int SrsPacket::decode(SrsStream* stream) | @@ -1786,7 +1790,7 @@ int SrsPacket::decode(SrsStream* stream) | ||
| 1786 | return ret; | 1790 | return ret; |
| 1787 | } | 1791 | } |
| 1788 | 1792 | ||
| 1789 | -int SrsPacket::get_perfer_cid() | 1793 | +int SrsPacket::get_prefer_cid() |
| 1790 | { | 1794 | { |
| 1791 | return 0; | 1795 | return 0; |
| 1792 | } | 1796 | } |
| @@ -2914,7 +2918,7 @@ int SrsPlayPacket::decode(SrsStream* stream) | @@ -2914,7 +2918,7 @@ int SrsPlayPacket::decode(SrsStream* stream) | ||
| 2914 | if (reset_value->is_boolean()) { | 2918 | if (reset_value->is_boolean()) { |
| 2915 | reset = reset_value->to_boolean(); | 2919 | reset = reset_value->to_boolean(); |
| 2916 | } else if (reset_value->is_number()) { | 2920 | } else if (reset_value->is_number()) { |
| 2917 | - reset = (reset_value->to_number() == 0 ? false : true); | 2921 | + reset = (reset_value->to_number() != 0); |
| 2918 | } else { | 2922 | } else { |
| 2919 | ret = ERROR_RTMP_AMF0_DECODE; | 2923 | ret = ERROR_RTMP_AMF0_DECODE; |
| 2920 | srs_error("amf0 invalid type=%#x, requires number or bool, ret=%d", reset_value->marker, ret); | 2924 | 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) | @@ -3565,7 +3569,7 @@ int SrsOnMetaDataPacket::decode(SrsStream* stream) | ||
| 3565 | return ret; | 3569 | return ret; |
| 3566 | } | 3570 | } |
| 3567 | 3571 | ||
| 3568 | -int SrsOnMetaDataPacket::get_perfer_cid() | 3572 | +int SrsOnMetaDataPacket::get_prefer_cid() |
| 3569 | { | 3573 | { |
| 3570 | return RTMP_CID_OverConnection2; | 3574 | return RTMP_CID_OverConnection2; |
| 3571 | } | 3575 | } |
| @@ -3625,7 +3629,7 @@ int SrsSetWindowAckSizePacket::decode(SrsStream* stream) | @@ -3625,7 +3629,7 @@ int SrsSetWindowAckSizePacket::decode(SrsStream* stream) | ||
| 3625 | return ret; | 3629 | return ret; |
| 3626 | } | 3630 | } |
| 3627 | 3631 | ||
| 3628 | -int SrsSetWindowAckSizePacket::get_perfer_cid() | 3632 | +int SrsSetWindowAckSizePacket::get_prefer_cid() |
| 3629 | { | 3633 | { |
| 3630 | return RTMP_CID_ProtocolControl; | 3634 | return RTMP_CID_ProtocolControl; |
| 3631 | } | 3635 | } |
| @@ -3667,7 +3671,7 @@ SrsAcknowledgementPacket::~SrsAcknowledgementPacket() | @@ -3667,7 +3671,7 @@ SrsAcknowledgementPacket::~SrsAcknowledgementPacket() | ||
| 3667 | { | 3671 | { |
| 3668 | } | 3672 | } |
| 3669 | 3673 | ||
| 3670 | -int SrsAcknowledgementPacket::get_perfer_cid() | 3674 | +int SrsAcknowledgementPacket::get_prefer_cid() |
| 3671 | { | 3675 | { |
| 3672 | return RTMP_CID_ProtocolControl; | 3676 | return RTMP_CID_ProtocolControl; |
| 3673 | } | 3677 | } |
| @@ -3725,7 +3729,7 @@ int SrsSetChunkSizePacket::decode(SrsStream* stream) | @@ -3725,7 +3729,7 @@ int SrsSetChunkSizePacket::decode(SrsStream* stream) | ||
| 3725 | return ret; | 3729 | return ret; |
| 3726 | } | 3730 | } |
| 3727 | 3731 | ||
| 3728 | -int SrsSetChunkSizePacket::get_perfer_cid() | 3732 | +int SrsSetChunkSizePacket::get_prefer_cid() |
| 3729 | { | 3733 | { |
| 3730 | return RTMP_CID_ProtocolControl; | 3734 | return RTMP_CID_ProtocolControl; |
| 3731 | } | 3735 | } |
| @@ -3767,7 +3771,7 @@ SrsSetPeerBandwidthPacket::~SrsSetPeerBandwidthPacket() | @@ -3767,7 +3771,7 @@ SrsSetPeerBandwidthPacket::~SrsSetPeerBandwidthPacket() | ||
| 3767 | { | 3771 | { |
| 3768 | } | 3772 | } |
| 3769 | 3773 | ||
| 3770 | -int SrsSetPeerBandwidthPacket::get_perfer_cid() | 3774 | +int SrsSetPeerBandwidthPacket::get_prefer_cid() |
| 3771 | { | 3775 | { |
| 3772 | return RTMP_CID_ProtocolControl; | 3776 | return RTMP_CID_ProtocolControl; |
| 3773 | } | 3777 | } |
| @@ -3841,7 +3845,7 @@ int SrsUserControlPacket::decode(SrsStream* stream) | @@ -3841,7 +3845,7 @@ int SrsUserControlPacket::decode(SrsStream* stream) | ||
| 3841 | return ret; | 3845 | return ret; |
| 3842 | } | 3846 | } |
| 3843 | 3847 | ||
| 3844 | -int SrsUserControlPacket::get_perfer_cid() | 3848 | +int SrsUserControlPacket::get_prefer_cid() |
| 3845 | { | 3849 | { |
| 3846 | return RTMP_CID_ProtocolControl; | 3850 | return RTMP_CID_ProtocolControl; |
| 3847 | } | 3851 | } |
| @@ -534,7 +534,7 @@ public: | @@ -534,7 +534,7 @@ public: | ||
| 534 | * all protocol control messages perfer RTMP_CID_ProtocolControl, | 534 | * all protocol control messages perfer RTMP_CID_ProtocolControl, |
| 535 | * SrsSetWindowAckSizePacket is protocol control message. | 535 | * SrsSetWindowAckSizePacket is protocol control message. |
| 536 | */ | 536 | */ |
| 537 | - virtual int get_perfer_cid(); | 537 | + virtual int get_prefer_cid(); |
| 538 | /** | 538 | /** |
| 539 | * subpacket must override to provide the right message type. | 539 | * subpacket must override to provide the right message type. |
| 540 | * the message type set the RTMP message type in header. | 540 | * the message type set the RTMP message type in header. |
| @@ -1311,7 +1311,7 @@ public: | @@ -1311,7 +1311,7 @@ public: | ||
| 1311 | virtual int decode(SrsStream* stream); | 1311 | virtual int decode(SrsStream* stream); |
| 1312 | // encode functions for concrete packet to override. | 1312 | // encode functions for concrete packet to override. |
| 1313 | public: | 1313 | public: |
| 1314 | - virtual int get_perfer_cid(); | 1314 | + virtual int get_prefer_cid(); |
| 1315 | virtual int get_message_type(); | 1315 | virtual int get_message_type(); |
| 1316 | protected: | 1316 | protected: |
| 1317 | virtual int get_size(); | 1317 | virtual int get_size(); |
| @@ -1335,7 +1335,7 @@ public: | @@ -1335,7 +1335,7 @@ public: | ||
| 1335 | virtual int decode(SrsStream* stream); | 1335 | virtual int decode(SrsStream* stream); |
| 1336 | // encode functions for concrete packet to override. | 1336 | // encode functions for concrete packet to override. |
| 1337 | public: | 1337 | public: |
| 1338 | - virtual int get_perfer_cid(); | 1338 | + virtual int get_prefer_cid(); |
| 1339 | virtual int get_message_type(); | 1339 | virtual int get_message_type(); |
| 1340 | protected: | 1340 | protected: |
| 1341 | virtual int get_size(); | 1341 | virtual int get_size(); |
| @@ -1356,7 +1356,7 @@ public: | @@ -1356,7 +1356,7 @@ public: | ||
| 1356 | virtual ~SrsAcknowledgementPacket(); | 1356 | virtual ~SrsAcknowledgementPacket(); |
| 1357 | // encode functions for concrete packet to override. | 1357 | // encode functions for concrete packet to override. |
| 1358 | public: | 1358 | public: |
| 1359 | - virtual int get_perfer_cid(); | 1359 | + virtual int get_prefer_cid(); |
| 1360 | virtual int get_message_type(); | 1360 | virtual int get_message_type(); |
| 1361 | protected: | 1361 | protected: |
| 1362 | virtual int get_size(); | 1362 | virtual int get_size(); |
| @@ -1384,7 +1384,7 @@ public: | @@ -1384,7 +1384,7 @@ public: | ||
| 1384 | virtual int decode(SrsStream* stream); | 1384 | virtual int decode(SrsStream* stream); |
| 1385 | // encode functions for concrete packet to override. | 1385 | // encode functions for concrete packet to override. |
| 1386 | public: | 1386 | public: |
| 1387 | - virtual int get_perfer_cid(); | 1387 | + virtual int get_prefer_cid(); |
| 1388 | virtual int get_message_type(); | 1388 | virtual int get_message_type(); |
| 1389 | protected: | 1389 | protected: |
| 1390 | virtual int get_size(); | 1390 | virtual int get_size(); |
| @@ -1417,7 +1417,7 @@ public: | @@ -1417,7 +1417,7 @@ public: | ||
| 1417 | virtual ~SrsSetPeerBandwidthPacket(); | 1417 | virtual ~SrsSetPeerBandwidthPacket(); |
| 1418 | // encode functions for concrete packet to override. | 1418 | // encode functions for concrete packet to override. |
| 1419 | public: | 1419 | public: |
| 1420 | - virtual int get_perfer_cid(); | 1420 | + virtual int get_prefer_cid(); |
| 1421 | virtual int get_message_type(); | 1421 | virtual int get_message_type(); |
| 1422 | protected: | 1422 | protected: |
| 1423 | virtual int get_size(); | 1423 | virtual int get_size(); |
| @@ -1540,7 +1540,7 @@ public: | @@ -1540,7 +1540,7 @@ public: | ||
| 1540 | virtual int decode(SrsStream* stream); | 1540 | virtual int decode(SrsStream* stream); |
| 1541 | // encode functions for concrete packet to override. | 1541 | // encode functions for concrete packet to override. |
| 1542 | public: | 1542 | public: |
| 1543 | - virtual int get_perfer_cid(); | 1543 | + virtual int get_prefer_cid(); |
| 1544 | virtual int get_message_type(); | 1544 | virtual int get_message_type(); |
| 1545 | protected: | 1545 | protected: |
| 1546 | virtual int get_size(); | 1546 | virtual int get_size(); |
-
请 注册 或 登录 后发表评论