支持是否修改rtmp时间戳配置 修改对象命名

This commit is contained in:
xiongziliang 2018-06-21 14:14:05 +08:00
parent ca885013af
commit 806cf29eac
4 changed files with 14 additions and 6 deletions

View File

@ -174,9 +174,11 @@ namespace Rtmp {
#define RTMP_PORT 1935 #define RTMP_PORT 1935
const char kPort[] = RTMP_FIELD"port"; const char kPort[] = RTMP_FIELD"port";
const char kModifyStamp[] = RTMP_FIELD"modifyStamp";
onceToken token([](){ onceToken token([](){
mINI::Instance()[kPort] = RTMP_PORT; mINI::Instance()[kPort] = RTMP_PORT;
mINI::Instance()[kModifyStamp] = true;
},nullptr); },nullptr);
} //namespace RTMP } //namespace RTMP

View File

@ -181,6 +181,8 @@ extern const char kAuthBasic[];
////////////RTMP服务器配置/////////// ////////////RTMP服务器配置///////////
namespace Rtmp { namespace Rtmp {
extern const char kPort[]; extern const char kPort[];
extern const char kModifyStamp[];
} //namespace RTMP } //namespace RTMP

View File

@ -71,13 +71,13 @@ public:
virtual Buffer::Ptr readData() = 0; virtual Buffer::Ptr readData() = 0;
}; };
class HttpBodyString : public HttpBody{ class HttpStringBody : public HttpBody{
public: public:
typedef std::shared_ptr<HttpBodyString> Ptr; typedef std::shared_ptr<HttpStringBody> Ptr;
HttpBodyString(const string &str){ HttpStringBody(const string &str){
_str = str; _str = str;
} }
virtual ~HttpBodyString(){} virtual ~HttpStringBody(){}
uint64_t remainSize() override { uint64_t remainSize() override {
return _str.size(); return _str.size();
@ -229,7 +229,7 @@ public:
return *this; return *this;
} }
void setBody(const string &body){ void setBody(const string &body){
_body.reset(new HttpBodyString(body)); _body.reset(new HttpStringBody(body));
} }
void setBody(const HttpBody::Ptr &body){ void setBody(const HttpBody::Ptr &body){
_body = body; _body = body;

View File

@ -26,6 +26,7 @@
#include "RtmpSession.h" #include "RtmpSession.h"
#include "Common/config.h"
#include "Util/onceToken.h" #include "Util/onceToken.h"
namespace ZL { namespace ZL {
@ -435,7 +436,10 @@ void RtmpSession::onRtmpChunk(RtmpPacket &chunkData) {
if (!m_pPublisherSrc) { if (!m_pPublisherSrc) {
throw std::runtime_error("Not a rtmp publisher!"); throw std::runtime_error("Not a rtmp publisher!");
} }
chunkData.timeStamp = m_stampTicker[chunkData.typeId % 2].elapsedTime(); GET_CONFIG_AND_REGISTER(bool,rtmp_modify_stamp,Config::Rtmp::kModifyStamp);
if(rtmp_modify_stamp){
chunkData.timeStamp = m_stampTicker[chunkData.typeId % 2].elapsedTime();
}
m_pPublisherSrc->onGetMedia(std::make_shared<RtmpPacket>(chunkData)); m_pPublisherSrc->onGetMedia(std::make_shared<RtmpPacket>(chunkData));
if(!m_bPublisherSrcRegisted && m_pPublisherSrc->ready()){ if(!m_bPublisherSrcRegisted && m_pPublisherSrc->ready()){
m_bPublisherSrcRegisted = true; m_bPublisherSrcRegisted = true;