完善代码

This commit is contained in:
xiongziliang 2018-10-26 22:10:46 +08:00
parent affc98f927
commit 1629d1f63a
4 changed files with 10 additions and 9 deletions

View File

@ -49,9 +49,8 @@ public:
* @param track
*/
void addTrack(const Track::Ptr & track) {
//克隆track的目的是防止inputFrame时由于用的同一个track而导致写入两次数据
_rtmp->addTrack(track->clone());
_rtsp->addTrack(track->clone());
_rtmp->addTrack(track);
_rtsp->addTrack(track);
}
/**
@ -59,7 +58,6 @@ public:
* @param frame
*/
void inputFrame(const Frame::Ptr &frame) override {
//_rtmp和_rtsp对象不能使用相同的Track否则会触发两次inputFrame操作
_rtmp->inputFrame(frame);
_rtsp->inputFrame(frame);
}

View File

@ -179,7 +179,7 @@ void PlayerProxy::onPlaySuccess() {
auto videoTrack = getTrack(TrackVideo);
if(videoTrack){
//添加视频
_pChn->addTrack(videoTrack->clone());
_pChn->addTrack(videoTrack);
//视频数据写入_pChn
videoTrack->addDelegate(_pChn);
}
@ -187,7 +187,7 @@ void PlayerProxy::onPlaySuccess() {
auto audioTrack = getTrack(TrackAudio);
if(audioTrack){
//添加音频
_pChn->addTrack(audioTrack->clone());
_pChn->addTrack(audioTrack);
//音频数据写入_pChn
audioTrack->addDelegate(_pChn);
}else if(videoTrack){

View File

@ -28,8 +28,9 @@
namespace mediakit {
void RtmpMuxer::addTrack(const Track::Ptr &track) {
//记录该Track
void RtmpMuxer::addTrack(const Track::Ptr &track_in) {
//克隆Track只拷贝其数据不拷贝其数据转发关系
auto track = track_in->clone();
auto codec_id = track->getCodecId();
_track_map[codec_id] = track;

View File

@ -29,7 +29,9 @@
namespace mediakit {
void RtspMuxer::addTrack(const Track::Ptr &track, uint32_t ssrc, int mtu) {
void RtspMuxer::addTrack(const Track::Ptr &track_in, uint32_t ssrc, int mtu) {
//克隆Track只拷贝其数据不拷贝其数据转发关系
auto track = track_in->clone();
auto codec_id = track->getCodecId();
_track_map[codec_id] = track;
if(mtu == 0){