mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-01 23:57:37 +08:00
release 8.0
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
@@ -47,8 +47,6 @@ private:
|
||||
class FlvRecorder : public FlvMuxer , public std::enable_shared_from_this<FlvRecorder>{
|
||||
public:
|
||||
using Ptr = std::shared_ptr<FlvRecorder>;
|
||||
FlvRecorder() = default;
|
||||
~FlvRecorder() override = default;
|
||||
|
||||
void startRecord(const toolkit::EventPoller::Ptr &poller, const RtmpMediaSource::Ptr &media, const std::string &file_path);
|
||||
void startRecord(const toolkit::EventPoller::Ptr &poller, const std::string &vhost, const std::string &app, const std::string &stream, const std::string &file_path);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
@@ -20,7 +20,6 @@ namespace mediakit {
|
||||
class FlvPlayer : public PlayerBase, public HttpClientImp, private FlvSplitter {
|
||||
public:
|
||||
FlvPlayer(const toolkit::EventPoller::Ptr &poller);
|
||||
~FlvPlayer() override = default;
|
||||
|
||||
void play(const std::string &url) override;
|
||||
void teardown() override;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
@@ -18,10 +18,6 @@
|
||||
namespace mediakit {
|
||||
|
||||
class FlvSplitter : public HttpRequestSplitter {
|
||||
public:
|
||||
FlvSplitter() = default;
|
||||
~FlvSplitter() = default;
|
||||
|
||||
protected:
|
||||
void onRecvContent(const char *data,size_t len) override;
|
||||
ssize_t onRecvHeader(const char *data,size_t len) override;
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "Rtmp.h"
|
||||
#include "Common/config.h"
|
||||
#include "Extension/Factory.h"
|
||||
|
||||
namespace mediakit {
|
||||
@@ -35,8 +36,7 @@ VideoMeta::VideoMeta(const VideoTrack::Ptr &video) {
|
||||
if (video->getBitRate()) {
|
||||
_metadata.set("videodatarate", video->getBitRate() / 1024);
|
||||
}
|
||||
_codecId = video->getCodecId();
|
||||
_metadata.set("videocodecid", Factory::getAmfByCodecId(_codecId));
|
||||
_metadata.set("videocodecid", Factory::getAmfByCodecId(video->getCodecId()));
|
||||
}
|
||||
|
||||
AudioMeta::AudioMeta(const AudioTrack::Ptr &audio) {
|
||||
@@ -52,8 +52,7 @@ AudioMeta::AudioMeta(const AudioTrack::Ptr &audio) {
|
||||
if (audio->getAudioChannel() > 0) {
|
||||
_metadata.set("stereo", audio->getAudioChannel() > 1);
|
||||
}
|
||||
_codecId = audio->getCodecId();
|
||||
_metadata.set("audiocodecid", Factory::getAmfByCodecId(_codecId));
|
||||
_metadata.set("audiocodecid", Factory::getAmfByCodecId(audio->getCodecId()));
|
||||
}
|
||||
|
||||
uint8_t getAudioRtmpFlags(const Track::Ptr &track) {
|
||||
@@ -259,36 +258,6 @@ void RtmpHandshake::random_generate(char *bytes, int size) {
|
||||
}
|
||||
}
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
struct RtmpVideoHeaderEnhanced {
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
uint8_t enhanced : 1;
|
||||
uint8_t frame_type : 3;
|
||||
uint8_t pkt_type : 4;
|
||||
uint32_t fourcc;
|
||||
#else
|
||||
uint8_t pkt_type : 4;
|
||||
uint8_t frame_type : 3;
|
||||
uint8_t enhanced : 1;
|
||||
uint32_t fourcc;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct RtmpVideoHeaderClassic {
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
uint8_t frame_type : 4;
|
||||
uint8_t codec_id : 4;
|
||||
uint8_t h264_pkt_type;
|
||||
#else
|
||||
uint8_t codec_id : 4;
|
||||
uint8_t frame_type : 4;
|
||||
uint8_t h264_pkt_type;
|
||||
#endif
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
CodecId parseVideoRtmpPacket(const uint8_t *data, size_t size, RtmpPacketInfo *info) {
|
||||
RtmpPacketInfo save;
|
||||
info = info ? info : &save;
|
||||
@@ -298,7 +267,7 @@ CodecId parseVideoRtmpPacket(const uint8_t *data, size_t size, RtmpPacketInfo *i
|
||||
RtmpVideoHeaderEnhanced *enhanced_header = (RtmpVideoHeaderEnhanced *)data;
|
||||
if (enhanced_header->enhanced) {
|
||||
// IsExHeader == 1
|
||||
CHECK(size >= 5, "Invalid rtmp buffer size: ", size);
|
||||
CHECK(size > RtmpPacketInfo::kEnhancedRtmpHeaderSize, "Invalid rtmp buffer size: ", size);
|
||||
info->is_enhanced = true;
|
||||
info->video.frame_type = (RtmpFrameType)(enhanced_header->frame_type);
|
||||
info->video.pkt_type = (RtmpPacketType)(enhanced_header->pkt_type);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
@@ -132,6 +132,32 @@ public:
|
||||
uint8_t streamid[3] = {0}; /* Always 0. */
|
||||
};
|
||||
|
||||
struct RtmpVideoHeaderEnhanced {
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
uint8_t enhanced : 1;
|
||||
uint8_t frame_type : 3;
|
||||
uint8_t pkt_type : 4;
|
||||
uint32_t fourcc;
|
||||
#else
|
||||
uint8_t pkt_type : 4;
|
||||
uint8_t frame_type : 3;
|
||||
uint8_t enhanced : 1;
|
||||
uint32_t fourcc;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct RtmpVideoHeaderClassic {
|
||||
#if __BYTE_ORDER == __BIG_ENDIAN
|
||||
uint8_t frame_type : 4;
|
||||
uint8_t codec_id : 4;
|
||||
uint8_t h264_pkt_type;
|
||||
#else
|
||||
uint8_t codec_id : 4;
|
||||
uint8_t frame_type : 4;
|
||||
uint8_t h264_pkt_type;
|
||||
#endif
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
class RtmpPacket : public toolkit::Buffer{
|
||||
@@ -188,17 +214,17 @@ private:
|
||||
/**
|
||||
* rtmp metadata基类,用于描述rtmp格式信息
|
||||
*/
|
||||
class Metadata : public CodecInfo{
|
||||
class Metadata {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<Metadata>;
|
||||
|
||||
Metadata(): _metadata(AMF_OBJECT) {}
|
||||
virtual ~Metadata() = default;
|
||||
const AMFValue &getMetadata() const{
|
||||
return _metadata;
|
||||
}
|
||||
|
||||
static void addTrack(AMFValue &metadata, const Track::Ptr &track);
|
||||
|
||||
protected:
|
||||
AMFValue _metadata;
|
||||
};
|
||||
@@ -206,7 +232,7 @@ protected:
|
||||
/**
|
||||
* metadata中除音视频外的其他描述部分
|
||||
*/
|
||||
class TitleMeta : public Metadata{
|
||||
class TitleMeta : public Metadata {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<TitleMeta>;
|
||||
|
||||
@@ -214,37 +240,20 @@ public:
|
||||
size_t fileSize = 0,
|
||||
const std::map<std::string, std::string> &header = std::map<std::string, std::string>());
|
||||
|
||||
CodecId getCodecId() const override{
|
||||
return CodecInvalid;
|
||||
}
|
||||
};
|
||||
|
||||
class VideoMeta : public Metadata{
|
||||
class VideoMeta : public Metadata {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<VideoMeta>;
|
||||
|
||||
VideoMeta(const VideoTrack::Ptr &video);
|
||||
virtual ~VideoMeta() = default;
|
||||
|
||||
CodecId getCodecId() const override{
|
||||
return _codecId;
|
||||
}
|
||||
private:
|
||||
CodecId _codecId;
|
||||
};
|
||||
|
||||
class AudioMeta : public Metadata{
|
||||
class AudioMeta : public Metadata {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<AudioMeta>;
|
||||
|
||||
AudioMeta(const AudioTrack::Ptr &audio);
|
||||
virtual ~AudioMeta() = default;
|
||||
|
||||
CodecId getCodecId() const override{
|
||||
return _codecId;
|
||||
}
|
||||
private:
|
||||
CodecId _codecId;
|
||||
};
|
||||
|
||||
//根据音频track获取flags
|
||||
@@ -353,6 +362,8 @@ enum class RtmpAACPacketType : uint8_t {
|
||||
////////////////////////////////////////////
|
||||
|
||||
struct RtmpPacketInfo {
|
||||
enum { kEnhancedRtmpHeaderSize = sizeof(RtmpVideoHeaderEnhanced) };
|
||||
|
||||
CodecId codec = CodecInvalid;
|
||||
bool is_enhanced;
|
||||
union {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
@@ -22,20 +22,12 @@ public:
|
||||
using Ptr = std::shared_ptr<RtmpRing>;
|
||||
using RingType = toolkit::RingBuffer<RtmpPacket::Ptr>;
|
||||
|
||||
RtmpRing() = default;
|
||||
virtual ~RtmpRing() = default;
|
||||
|
||||
/**
|
||||
* 获取rtmp环形缓存
|
||||
*/
|
||||
virtual RingType::Ptr getRtmpRing() const {
|
||||
return _ring;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置rtmp环形缓存
|
||||
*/
|
||||
virtual void setRtmpRing(const RingType::Ptr &ring) {
|
||||
void setRtmpRing(const RingType::Ptr &ring) {
|
||||
_ring = ring;
|
||||
}
|
||||
|
||||
@@ -53,12 +45,19 @@ protected:
|
||||
RingType::Ptr _ring;
|
||||
};
|
||||
|
||||
class RtmpCodec : public RtmpRing, public FrameDispatcher, public CodecInfo {
|
||||
class RtmpCodec : public RtmpRing, public FrameWriterInterface {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<RtmpCodec>;
|
||||
RtmpCodec() = default;
|
||||
~RtmpCodec() override = default;
|
||||
virtual void makeConfigPacket() {};
|
||||
RtmpCodec(Track::Ptr track) { _track = std::move(track); }
|
||||
|
||||
virtual void makeConfigPacket() {}
|
||||
|
||||
bool inputFrame(const Frame::Ptr &frame) override { return _track->inputFrame(frame); }
|
||||
|
||||
const Track::Ptr &getTrack() const { return _track; }
|
||||
|
||||
private:
|
||||
Track::Ptr _track;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
@@ -146,15 +146,13 @@ void RtmpDemuxer::makeVideoTrack(const Track::Ptr &track, int bit_rate) {
|
||||
return;
|
||||
}
|
||||
// 生成rtmpCodec对象以便解码rtmp
|
||||
_video_rtmp_decoder = Factory::getRtmpCodecByTrack(_video_track, false);
|
||||
_video_rtmp_decoder = Factory::getRtmpDecoderByTrack(_video_track);
|
||||
if (!_video_rtmp_decoder) {
|
||||
// 找不到相应的rtmp解码器,该track无效
|
||||
_video_track.reset();
|
||||
return;
|
||||
}
|
||||
_video_track->setBitRate(bit_rate);
|
||||
// 设置rtmp解码器代理,生成的frame写入该Track
|
||||
_video_rtmp_decoder->addDelegate(_video_track);
|
||||
addTrack(_video_track);
|
||||
_try_get_video_track = true;
|
||||
}
|
||||
@@ -169,15 +167,13 @@ void RtmpDemuxer::makeAudioTrack(const AMFValue &audioCodec, int sample_rate, in
|
||||
return;
|
||||
}
|
||||
// 生成rtmpCodec对象以便解码rtmp
|
||||
_audio_rtmp_decoder = Factory::getRtmpCodecByTrack(_audio_track, false);
|
||||
_audio_rtmp_decoder = Factory::getRtmpDecoderByTrack(_audio_track);
|
||||
if (!_audio_rtmp_decoder) {
|
||||
// 找不到相应的rtmp解码器,该track无效
|
||||
_audio_track.reset();
|
||||
return;
|
||||
}
|
||||
_audio_track->setBitRate(bit_rate);
|
||||
// 设置rtmp解码器代理,生成的frame写入该Track
|
||||
_audio_rtmp_decoder->addDelegate(_audio_track);
|
||||
addTrack(_audio_track);
|
||||
_try_get_audio_track = true;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
@@ -24,9 +24,6 @@ class RtmpDemuxer : public Demuxer {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<RtmpDemuxer>;
|
||||
|
||||
RtmpDemuxer() = default;
|
||||
~RtmpDemuxer() override = default;
|
||||
|
||||
static size_t trackCount(const AMFValue &metadata);
|
||||
|
||||
bool loadMetaData(const AMFValue &metadata);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
@@ -105,7 +105,11 @@ void RtmpMediaSourceImp::onWrite(RtmpPacket::Ptr pkt, bool /*= true*/) {
|
||||
// 未获取到所有Track后,或者开启转协议,那么需要解复用rtmp
|
||||
_demuxer->inputRtmp(pkt);
|
||||
}
|
||||
RtmpMediaSource::onWrite(std::move(pkt));
|
||||
GET_CONFIG(bool, directProxy, Rtmp::kDirectProxy);
|
||||
if (directProxy) {
|
||||
//直接代理模式才直接使用原始rtmp
|
||||
RtmpMediaSource::onWrite(std::move(pkt));
|
||||
}
|
||||
}
|
||||
|
||||
int RtmpMediaSourceImp::totalReaderCount() {
|
||||
@@ -113,10 +117,9 @@ int RtmpMediaSourceImp::totalReaderCount() {
|
||||
}
|
||||
|
||||
void RtmpMediaSourceImp::setProtocolOption(const ProtocolOption &option) {
|
||||
// 不重复生成rtmp
|
||||
GET_CONFIG(bool, direct_proxy, Rtmp::kDirectProxy);
|
||||
_option = option;
|
||||
// 不重复生成rtmp协议
|
||||
_option.enable_rtmp = false;
|
||||
_option.enable_rtmp = !direct_proxy;
|
||||
_muxer = std::make_shared<MultiMediaSourceMuxer>(_tuple, _demuxer->getDuration(), _option);
|
||||
_muxer->setMediaListener(getListener());
|
||||
_muxer->setTrackListener(std::static_pointer_cast<RtmpMediaSourceImp>(shared_from_this()));
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
@@ -37,8 +37,6 @@ public:
|
||||
*/
|
||||
RtmpMediaSourceImp(const MediaTuple& tuple, int ringSize = RTMP_GOP_SIZE);
|
||||
|
||||
~RtmpMediaSourceImp() override = default;
|
||||
|
||||
/**
|
||||
* 设置metadata
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
@@ -14,9 +14,9 @@
|
||||
namespace mediakit {
|
||||
|
||||
RtmpMuxer::RtmpMuxer(const TitleMeta::Ptr &title) {
|
||||
if(!title){
|
||||
if (!title) {
|
||||
_metadata = std::make_shared<TitleMeta>()->getMetadata();
|
||||
}else{
|
||||
} else {
|
||||
_metadata = title->getMetadata();
|
||||
}
|
||||
_rtmp_ring = std::make_shared<RtmpRing::RingType>();
|
||||
@@ -24,16 +24,20 @@ RtmpMuxer::RtmpMuxer(const TitleMeta::Ptr &title) {
|
||||
|
||||
bool RtmpMuxer::addTrack(const Track::Ptr &track) {
|
||||
auto &encoder = _encoder[track->getTrackType()];
|
||||
//生成rtmp编码器,克隆该Track,防止循环引用
|
||||
encoder = Factory::getRtmpCodecByTrack(track->clone(), true);
|
||||
if (encoder) {
|
||||
WarnL << "Already add a track kind of: " << track->getTrackTypeStr()
|
||||
<< ", ignore track: " << track->getCodecName();
|
||||
return false;
|
||||
}
|
||||
encoder = Factory::getRtmpEncoderByTrack(track);
|
||||
if (!encoder) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//设置rtmp输出环形缓存
|
||||
// 设置rtmp输出环形缓存
|
||||
encoder->setRtmpRing(_rtmp_ring);
|
||||
|
||||
//添加metadata
|
||||
// 添加metadata
|
||||
Metadata::addTrack(_metadata, track);
|
||||
return true;
|
||||
}
|
||||
@@ -51,9 +55,9 @@ void RtmpMuxer::flush() {
|
||||
}
|
||||
}
|
||||
|
||||
void RtmpMuxer::makeConfigPacket(){
|
||||
for(auto &encoder : _encoder){
|
||||
if(encoder){
|
||||
void RtmpMuxer::makeConfigPacket() {
|
||||
for (auto &encoder : _encoder) {
|
||||
if (encoder) {
|
||||
encoder->makeConfigPacket();
|
||||
}
|
||||
}
|
||||
@@ -69,10 +73,9 @@ RtmpRing::RingType::Ptr RtmpMuxer::getRtmpRing() const {
|
||||
|
||||
void RtmpMuxer::resetTracks() {
|
||||
_metadata.clear();
|
||||
for(auto &encoder : _encoder){
|
||||
for (auto &encoder : _encoder) {
|
||||
encoder = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}/* namespace mediakit */
|
||||
} /* namespace mediakit */
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
@@ -26,7 +26,6 @@ public:
|
||||
* 构造函数
|
||||
*/
|
||||
RtmpMuxer(const TitleMeta::Ptr &title);
|
||||
~RtmpMuxer() override = default;
|
||||
|
||||
/**
|
||||
* 获取完整的SDP字符串
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
@@ -187,8 +187,6 @@ public:
|
||||
_size = size;
|
||||
}
|
||||
|
||||
~BufferPartial() override = default;
|
||||
|
||||
char *data() const override {
|
||||
return _data;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
@@ -22,8 +22,6 @@ RtmpSession::RtmpSession(const Socket::Ptr &sock) : Session(sock) {
|
||||
sock->setSendTimeOutSecond(keep_alive_sec);
|
||||
}
|
||||
|
||||
RtmpSession::~RtmpSession() = default;
|
||||
|
||||
void RtmpSession::onError(const SockException& err) {
|
||||
bool is_player = !_push_src_ownership;
|
||||
uint64_t duration = _ticker.createdTime() / 1000;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
@@ -27,7 +27,6 @@ public:
|
||||
using Ptr = std::shared_ptr<RtmpSession>;
|
||||
|
||||
RtmpSession(const toolkit::Socket::Ptr &sock);
|
||||
~RtmpSession() override;
|
||||
|
||||
void onRecv(const toolkit::Buffer::Ptr &buf) override;
|
||||
void onError(const toolkit::SockException &err) override;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
||||
* Copyright (c) 2016-present The ZLMediaKit project authors. All Rights Reserved.
|
||||
*
|
||||
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
||||
* This file is part of ZLMediaKit(https://github.com/ZLMediaKit/ZLMediaKit).
|
||||
*
|
||||
* Use of this source code is governed by MIT license that can be found in the
|
||||
* Use of this source code is governed by MIT-like license that can be found in the
|
||||
* LICENSE file in the root of the source tree. All contributing project authors
|
||||
* may be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user