全面整理代码,去除编译警告

This commit is contained in:
xia-chu
2021-01-17 18:31:50 +08:00
parent fb1e35a39a
commit b6cbc87712
272 changed files with 936 additions and 933 deletions

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -59,8 +59,8 @@ void FlvMuxer::start(const EventPoller::Ptr &poller,const RtmpMediaSource::Ptr &
return;
}
int i = 0;
int size = pkt->size();
size_t i = 0;
auto size = pkt->size();
pkt->for_each([&](const RtmpPacket::Ptr &rtmp){
strongSelf->onWriteRtmp(rtmp, ++i == size);
});
@@ -140,14 +140,14 @@ void FlvMuxer::onWriteFlvTag(const RtmpPacket::Ptr &pkt, uint32_t time_stamp , b
void FlvMuxer::onWriteFlvTag(uint8_t type, const Buffer::Ptr &buffer, uint32_t time_stamp, bool flush) {
RtmpTagHeader header;
header.type = type;
set_be24(header.data_size, buffer->size());
set_be24(header.data_size, (uint32_t)buffer->size());
header.timestamp_ex = (uint8_t) ((time_stamp >> 24) & 0xff);
set_be24(header.timestamp, time_stamp & 0xFFFFFF);
//tag header
onWrite(std::make_shared<BufferRaw>((char *)&header, sizeof(header)), false);
//tag data
onWrite(buffer, false);
auto size = htonl((buffer->size() + sizeof(header)));
uint32_t size = htonl((uint32_t)(buffer->size() + sizeof(header)));
//PreviousTagSize
onWrite(std::make_shared<BufferRaw>((char *)&size,4), flush);
}
@@ -155,7 +155,7 @@ void FlvMuxer::onWriteFlvTag(uint8_t type, const Buffer::Ptr &buffer, uint32_t t
void FlvMuxer::onWriteRtmp(const RtmpPacket::Ptr &pkt,bool flush) {
int64_t dts_out;
_stamp[pkt->type_id % 2].revise(pkt->time_stamp, 0, dts_out, dts_out);
onWriteFlvTag(pkt, dts_out,flush);
onWriteFlvTag(pkt, (uint32_t)dts_out,flush);
}
void FlvMuxer::stop() {

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -129,20 +129,20 @@ public:
class RtmpPacket : public Buffer{
public:
typedef std::shared_ptr<RtmpPacket> Ptr;
uint8_t type_id;
uint32_t body_size = 0;
uint32_t time_stamp = 0;
bool is_abs_stamp = false;
uint8_t type_id;
uint32_t time_stamp = 0;
uint32_t ts_field = 0;
uint32_t stream_index;
uint32_t chunk_id;
size_t body_size = 0;
BufferLikeString buffer;
public:
char *data() const override{
return (char*)buffer.data();
}
uint32_t size() const override {
size_t size() const override {
return buffer.size();
}
@@ -242,7 +242,7 @@ public:
typedef std::shared_ptr<TitleMeta> Ptr;
TitleMeta(float dur_sec = 0,
uint64_t fileSize = 0,
size_t fileSize = 0,
const map<string,string> &header = map<string,string>()){
_metadata.set("duration", dur_sec);
_metadata.set("fileSize", 0);

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -25,7 +25,7 @@ bool RtmpDemuxer::loadMetaData(const AMFValue &val){
const AMFValue *videocodecid = nullptr;
val.object_for_each([&](const string &key, const AMFValue &val) {
if (key == "duration") {
_fDuration = val.as_number();
_fDuration = (float)val.as_number();
return;
}
if (key == "audiosamplerate") {

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -72,7 +72,7 @@ void RtmpPlayer::play(const string &strUrl) {
}
weak_ptr<RtmpPlayer> weak_self = dynamic_pointer_cast<RtmpPlayer>(shared_from_this());
float play_timeout_sec = (*this)[kTimeoutMS].as<int>() / 1000.0;
float play_timeout_sec = (*this)[kTimeoutMS].as<int>() / 1000.0f;
_play_timer.reset(new Timer(play_timeout_sec, [weak_self]() {
auto strong_self = weak_self.lock();
if (!strong_self) {
@@ -131,7 +131,7 @@ void RtmpPlayer::onPlayResult_l(const SockException &ex, bool handshake_done) {
return true;
};
//创建rtmp数据接收超时检测定时器
_rtmp_recv_timer = std::make_shared<Timer>(timeout_ms / 2000.0, lam, getPoller());
_rtmp_recv_timer = std::make_shared<Timer>(timeout_ms / 2000.0f, lam, getPoller());
} else {
shutdown(SockException(Err_shutdown,"teardown"));
}
@@ -253,12 +253,12 @@ inline void RtmpPlayer::send_pause(bool pause) {
_beat_timer.reset();
if (pause) {
weak_ptr<RtmpPlayer> weakSelf = dynamic_pointer_cast<RtmpPlayer>(shared_from_this());
_beat_timer.reset(new Timer((*this)[kBeatIntervalMS].as<int>() / 1000.0, [weakSelf]() {
_beat_timer.reset(new Timer((*this)[kBeatIntervalMS].as<int>() / 1000.0f, [weakSelf]() {
auto strongSelf = weakSelf.lock();
if (!strongSelf) {
return false;
}
uint32_t timeStamp = ::time(NULL);
uint32_t timeStamp = (uint32_t)::time(NULL);
strongSelf->sendUserControl(CONTROL_PING_REQUEST, timeStamp);
return true;
}, getPoller()));

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -43,7 +43,7 @@ public:
void seekTo(float fProgress) override {
fProgress = MAX(float(0), MIN(fProgress, float(1.0)));
seekToMilliSecond(fProgress * getDuration() * 1000);
seekToMilliSecond((uint32_t)(fProgress * getDuration() * 1000));
}
void play(const string &strUrl) override {

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -29,7 +29,7 @@ using namespace toolkit;
#include <openssl/hmac.h>
#include <openssl/opensslv.h>
static string openssl_HMACsha256(const void *key, unsigned int key_len, const void *data,unsigned int data_len){
static string openssl_HMACsha256(const void *key, size_t key_len, const void *data, size_t data_len){
std::shared_ptr<char> out(new char[32], [](char *ptr) { delete[] ptr; });
unsigned int out_len;
@@ -37,7 +37,7 @@ static string openssl_HMACsha256(const void *key, unsigned int key_len, const vo
//openssl 1.1.0新增api老版本api作废
HMAC_CTX *ctx = HMAC_CTX_new();
HMAC_CTX_reset(ctx);
HMAC_Init_ex(ctx, key, key_len, EVP_sha256(), NULL);
HMAC_Init_ex(ctx, key, (int)key_len, EVP_sha256(), NULL);
HMAC_Update(ctx, (unsigned char*)data, data_len);
HMAC_Final(ctx, (unsigned char *)out.get(), &out_len);
HMAC_CTX_reset(ctx);
@@ -57,7 +57,7 @@ static string openssl_HMACsha256(const void *key, unsigned int key_len, const vo
namespace mediakit {
RtmpProtocol::RtmpProtocol() {
_next_step_func = [this](const char *data, uint64_t len) {
_next_step_func = [this](const char *data, size_t len) {
return handle_C0C1(data, len);
};
}
@@ -86,7 +86,7 @@ void RtmpProtocol::reset() {
//////////Rtmp parser//////////
HttpRequestSplitter::reset();
_stream_index = STREAM_CONTROL;
_next_step_func = [this](const char *data, uint64_t len) {
_next_step_func = [this](const char *data, size_t len) {
return handle_C0C1(data, len);
};
}
@@ -172,7 +172,7 @@ void RtmpProtocol::sendRequest(int cmd, const string& str) {
class BufferPartial : public Buffer {
public:
BufferPartial(const Buffer::Ptr &buffer, uint32_t offset, uint32_t size){
BufferPartial(const Buffer::Ptr &buffer, size_t offset, size_t size){
_buffer = buffer;
_data = buffer->data() + offset;
_size = size;
@@ -184,13 +184,13 @@ public:
return _data;
}
uint32_t size() const override{
size_t size() const override{
return _size;
}
private:
char *_data;
uint32_t _size;
size_t _size;
Buffer::Ptr _buffer;
};
@@ -215,7 +215,7 @@ void RtmpProtocol::sendRtmp(uint8_t type, uint32_t stream_index, const Buffer::P
header->flags = (chunk_id & 0x3f) | (0 << 6);
header->type_id = type;
set_be24(header->time_stamp, ext_stamp ? 0xFFFFFF : stamp);
set_be24(header->body_size, buf->size());
set_be24(header->body_size, (uint32_t)buf->size());
set_le32(header->stream_index, stream_index);
//发送rtmp头
onSendRawData(std::move(buffer_header));
@@ -237,7 +237,7 @@ void RtmpProtocol::sendRtmp(uint8_t type, uint32_t stream_index, const Buffer::P
buffer_flags->data()[0] = (chunk_id & 0x3f) | (3 << 6);
size_t offset = 0;
uint32_t totalSize = sizeof(RtmpHeader);
size_t totalSize = sizeof(RtmpHeader);
while (offset < buf->size()) {
if (offset) {
onSendRawData(buffer_flags);
@@ -253,18 +253,18 @@ void RtmpProtocol::sendRtmp(uint8_t type, uint32_t stream_index, const Buffer::P
totalSize += chunk;
offset += chunk;
}
_bytes_sent += totalSize;
_bytes_sent += (uint32_t)totalSize;
if (_windows_size > 0 && _bytes_sent - _bytes_sent_last >= _windows_size) {
_bytes_sent_last = _bytes_sent;
sendAcknowledgement(_bytes_sent);
}
}
void RtmpProtocol::onParseRtmp(const char *data, uint64_t size) {
void RtmpProtocol::onParseRtmp(const char *data, size_t size) {
input(data, size);
}
const char *RtmpProtocol::onSearchPacketTail(const char *data,uint64_t len){
const char *RtmpProtocol::onSearchPacketTail(const char *data,size_t len){
//移动拷贝提高性能
auto next_step_func(std::move(_next_step_func));
//执行下一步
@@ -283,13 +283,13 @@ void RtmpProtocol::startClientSession(const function<void()> &func) {
onSendRawData(obtainBuffer(&handshake_head, 1));
RtmpHandshake c1(0);
onSendRawData(obtainBuffer((char *) (&c1), sizeof(c1)));
_next_step_func = [this, func](const char *data, uint64_t len) {
_next_step_func = [this, func](const char *data, size_t len) {
//等待 S0+S1+S2
return handle_S0S1S2(data, len, func);
};
}
const char* RtmpProtocol::handle_S0S1S2(const char *data, uint64_t len, const function<void()> &func) {
const char* RtmpProtocol::handle_S0S1S2(const char *data, size_t len, const function<void()> &func) {
if (len < 1 + 2 * C1_HANDSHARK_SIZE) {
//数据不够
return nullptr;
@@ -301,7 +301,7 @@ const char* RtmpProtocol::handle_S0S1S2(const char *data, uint64_t len, const fu
const char *pcC2 = data + 1;
onSendRawData(obtainBuffer(pcC2, C1_HANDSHARK_SIZE));
//握手结束
_next_step_func = [this](const char *data, uint64_t len) {
_next_step_func = [this](const char *data, size_t len) {
//握手结束并且开始进入解析命令模式
return handle_rtmp(data, len);
};
@@ -310,7 +310,7 @@ const char* RtmpProtocol::handle_S0S1S2(const char *data, uint64_t len, const fu
}
////for server ////
const char * RtmpProtocol::handle_C0C1(const char *data, uint64_t len) {
const char * RtmpProtocol::handle_C0C1(const char *data, size_t len) {
if (len < 1 + C1_HANDSHARK_SIZE) {
//need more data!
return nullptr;
@@ -343,7 +343,7 @@ void RtmpProtocol::handle_C1_simple(const char *data){
//发送S2
onSendRawData(obtainBuffer(data + 1, C1_HANDSHARK_SIZE));
//等待C2
_next_step_func = [this](const char *data, uint64_t len) {
_next_step_func = [this](const char *data, size_t len) {
//握手结束并且开始进入解析命令模式
return handle_C2(data, len);
};
@@ -370,7 +370,7 @@ void RtmpProtocol::handle_C1_complex(const char *data){
send_complex_S0S1S2(0, digest);
// InfoL << "schema0";
} catch (std::exception &ex) {
} catch (std::exception &) {
//貌似flash从来都不用schema1
// WarnL << "try rtmp complex schema0 failed:" << ex.what();
try {
@@ -387,7 +387,7 @@ void RtmpProtocol::handle_C1_complex(const char *data){
send_complex_S0S1S2(1, digest);
// InfoL << "schema1";
} catch (std::exception &ex) {
} catch (std::exception &) {
// WarnL << "try rtmp complex schema1 failed:" << ex.what();
handle_C1_simple(data);
}
@@ -506,18 +506,18 @@ void RtmpProtocol::send_complex_S0S1S2(int schemeType,const string &digest){
memcpy((char *) &s2 + C1_HANDSHARK_SIZE - C1_DIGEST_SIZE, s2_digest.data(), C1_DIGEST_SIZE);
onSendRawData(obtainBuffer((char *) &s2, sizeof(s2)));
//等待C2
_next_step_func = [this](const char *data, uint64_t len) {
_next_step_func = [this](const char *data, size_t len) {
return handle_C2(data, len);
};
}
#endif //ENABLE_OPENSSL
const char* RtmpProtocol::handle_C2(const char *data, uint64_t len) {
const char* RtmpProtocol::handle_C2(const char *data, size_t len) {
if (len < C1_HANDSHARK_SIZE) {
//need more data!
return nullptr;
}
_next_step_func = [this](const char *data, uint64_t len) {
_next_step_func = [this](const char *data, size_t len) {
return handle_rtmp(data, len);
};
@@ -527,7 +527,7 @@ const char* RtmpProtocol::handle_C2(const char *data, uint64_t len) {
static const size_t HEADER_LENGTH[] = {12, 8, 4, 1};
const char* RtmpProtocol::handle_rtmp(const char *data, uint64_t len) {
const char* RtmpProtocol::handle_rtmp(const char *data, size_t len) {
auto ptr = data;
while (len) {
int offset = 0;
@@ -757,7 +757,7 @@ BufferRaw::Ptr RtmpProtocol::obtainBuffer() {
return std::make_shared<BufferRaw>() ;//_bufferPool.obtain();
}
BufferRaw::Ptr RtmpProtocol::obtainBuffer(const void *data, int len) {
BufferRaw::Ptr RtmpProtocol::obtainBuffer(const void *data, size_t len) {
auto buffer = obtainBuffer();
buffer->assign((const char *) data, len);
return buffer;

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -33,7 +33,7 @@ public:
RtmpProtocol();
virtual ~RtmpProtocol();
void onParseRtmp(const char *data, uint64_t size);
void onParseRtmp(const char *data, size_t size);
//作为客户端发送c0c1等待s0s1s2并且回调
void startClientSession(const function<void()> &cb);
@@ -48,13 +48,13 @@ protected:
protected:
//// HttpRequestSplitter override ////
int64_t onRecvHeader(const char *data,uint64_t len) override { return 0; }
const char *onSearchPacketTail(const char *data,uint64_t len) override;
size_t onRecvHeader(const char *data, size_t len) override { return 0; }
const char *onSearchPacketTail(const char *data, size_t len) override;
protected:
void reset();
BufferRaw::Ptr obtainBuffer();
BufferRaw::Ptr obtainBuffer(const void *data, int len);
BufferRaw::Ptr obtainBuffer(const void *data, size_t len);
void sendAcknowledgement(uint32_t size);
void sendAcknowledgementSize(uint32_t size);
@@ -81,10 +81,10 @@ private:
void send_complex_S0S1S2(int schemeType,const string &digest);
#endif //ENABLE_OPENSSL
const char* handle_S0S1S2(const char *data, uint64_t len, const function<void()> &func);
const char* handle_C0C1(const char *data, uint64_t len);
const char* handle_C2(const char *data, uint64_t len);
const char* handle_rtmp(const char *data, uint64_t len);
const char* handle_S0S1S2(const char *data, size_t len, const function<void()> &func);
const char* handle_C0C1(const char *data, size_t len);
const char* handle_C2(const char *data, size_t len);
const char* handle_rtmp(const char *data, size_t len);
void handle_chunk(RtmpPacket &chunk_data);
protected:
@@ -106,7 +106,7 @@ private:
uint32_t _bandwidth = 2500000;
uint8_t _band_limit_type = 2;
//////////Rtmp parser//////////
function<const char * (const char *data, uint64_t len)> _next_step_func;
function<const char * (const char *data, size_t len)> _next_step_func;
////////////Chunk////////////
unordered_map<int, RtmpPacket> _map_chunk_data;
};

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -92,7 +92,7 @@ void RtmpPusher::publish(const string &url) {
}
weak_ptr<RtmpPusher> weakSelf = dynamic_pointer_cast<RtmpPusher>(shared_from_this());
float publishTimeOutSec = (*this)[kTimeoutMS].as<int>() / 1000.0;
float publishTimeOutSec = (*this)[kTimeoutMS].as<int>() / 1000.0f;
_publish_timer.reset(new Timer(publishTimeOutSec, [weakSelf]() {
auto strongSelf = weakSelf.lock();
if (!strongSelf) {
@@ -210,8 +210,8 @@ inline void RtmpPusher::send_metaData(){
return;
}
int i = 0;
int size = pkt->size();
size_t i = 0;
auto size = pkt->size();
strong_self->setSendFlushFlag(false);
pkt->for_each([&](const RtmpPacket::Ptr &rtmp) {
if (++i == size) {

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -277,8 +277,8 @@ void RtmpSession::sendPlayResponse(const string &err,const RtmpMediaSource::Ptr
if(strongSelf->_paused){
return;
}
int i = 0;
int size = pkt->size();
size_t i = 0;
auto size = pkt->size();
strongSelf->setSendFlushFlag(false);
pkt->for_each([&](const RtmpPacket::Ptr &rtmp){
if(++i == size){
@@ -482,7 +482,7 @@ void RtmpSession::onRtmpChunk(RtmpPacket &chunk_data) {
if (rtmp_modify_stamp) {
int64_t dts_out;
_stamp[chunk_data.type_id % 2].revise(chunk_data.time_stamp, chunk_data.time_stamp, dts_out, dts_out, true);
chunk_data.time_stamp = dts_out;
chunk_data.time_stamp = (uint32_t)dts_out;
}
if (!_set_meta_data && !chunk_data.isCfgFrame()) {
@@ -508,7 +508,7 @@ void RtmpSession::onCmd_seek(AMFDecoder &dec) {
status.set("description", "Seeking.");
sendReply("onStatus", nullptr, status);
auto milliSeconds = dec.load<AMFValue>().as_number();
auto milliSeconds = (uint32_t)(dec.load<AMFValue>().as_number());
InfoP(this) << "rtmp seekTo(ms):" << milliSeconds;
auto strong_src = _player_src.lock();
if (strong_src) {
@@ -520,7 +520,7 @@ void RtmpSession::onSendMedia(const RtmpPacket::Ptr &pkt) {
//rtmp播放器时间戳从零开始
int64_t dts_out;
_stamp[pkt->type_id % 2].revise(pkt->time_stamp, 0, dts_out, dts_out);
sendRtmp(pkt->type_id, pkt->stream_index, pkt, dts_out, pkt->chunk_id);
sendRtmp(pkt->type_id, pkt->stream_index, pkt, (uint32_t)dts_out, pkt->chunk_id);
}

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors
@@ -178,7 +178,7 @@ double AMFValue::as_number() const {
int AMFValue::as_integer() const {
switch (_type) {
case AMF_NUMBER:
return _value.number;
return (int)_value.number;
case AMF_INTEGER:
return _value.integer;
case AMF_BOOLEAN:
@@ -319,7 +319,9 @@ enum {
AMFEncoder & AMFEncoder::operator <<(const char *s) {
if (s) {
buf += char(AMF0_STRING);
uint16_t str_len = htons(strlen(s));
auto len = strlen(s);
assert(len <= 0xFFFF);
uint16_t str_len = htons((uint16_t)len);
buf.append((char *) &str_len, 2);
buf += s;
} else {
@@ -331,7 +333,8 @@ AMFEncoder & AMFEncoder::operator <<(const char *s) {
AMFEncoder & AMFEncoder::operator <<(const std::string &s) {
if (!s.empty()) {
buf += char(AMF0_STRING);
uint16_t str_len = htons(s.size());
assert(s.size() <= 0xFFFF);
uint16_t str_len = htons((uint16_t)s.size());
buf.append((char *) &str_len, 2);
buf += s;
} else {
@@ -361,7 +364,7 @@ AMFEncoder & AMFEncoder::operator <<(const double n) {
memcpy(&encoded, &n, 8);
uint32_t val = htonl(encoded >> 32);
buf.append((char *) &val, 4);
val = htonl(encoded);
val = htonl(encoded & 0xFFFFFFFF);
buf.append((char *) &val, 4);
return *this;
}
@@ -398,7 +401,7 @@ AMFEncoder & AMFEncoder::operator <<(const AMFValue& value) {
break;
case AMF_ECMA_ARRAY: {
buf += char(AMF0_ECMA_ARRAY);
uint32_t sz = htonl(value.getMap().size());
uint32_t sz = htonl((uint32_t)value.getMap().size());
buf.append((char *) &sz, 4);
for (auto &pr : value.getMap()) {
write_key(pr.first);
@@ -416,7 +419,7 @@ AMFEncoder & AMFEncoder::operator <<(const AMFValue& value) {
break;
case AMF_STRICT_ARRAY: {
buf += char(AMF0_STRICT_ARRAY);
uint32_t sz = htonl(value.getArr().size());
uint32_t sz = htonl((uint32_t)value.getArr().size());
buf.append((char *) &sz, 4);
for (auto &val : value.getArr()) {
*this << val;
@@ -431,7 +434,8 @@ AMFEncoder & AMFEncoder::operator <<(const AMFValue& value) {
}
void AMFEncoder::write_key(const std::string& s) {
uint16_t str_len = htons(s.size());
assert(s.size() <= 0xFFFF);
uint16_t str_len = htons((uint16_t)s.size());
buf.append((char *) &str_len, 2);
buf += s;
}
@@ -510,9 +514,9 @@ unsigned int AMFDecoder::load<unsigned int>() {
template<>
int AMFDecoder::load<int>() {
if (version == 3) {
return load<unsigned int>();
return (int)load<unsigned int>();
} else {
return load<double>();
return (int)load<double>();
}
}

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors

View File

@@ -1,7 +1,7 @@
/*
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
*
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
*
* Use of this source code is governed by MIT license that can be found in the
* LICENSE file in the root of the source tree. All contributing project authors