2018-10-25 10:00:17 +08:00
|
|
|
|
/*
|
2020-04-04 20:30:09 +08:00
|
|
|
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
2018-10-25 10:00:17 +08:00
|
|
|
|
*
|
|
|
|
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
|
|
|
|
*
|
2020-04-04 20:30:09 +08:00
|
|
|
|
* 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
|
|
|
|
|
* may be found in the AUTHORS file in the root of the source tree.
|
2018-10-25 10:00:17 +08:00
|
|
|
|
*/
|
2018-10-24 09:23:57 +08:00
|
|
|
|
|
|
|
|
|
#ifndef ZLMEDIAKIT_FACTORY_H
|
|
|
|
|
#define ZLMEDIAKIT_FACTORY_H
|
|
|
|
|
|
|
|
|
|
#include <string>
|
2018-10-25 10:00:17 +08:00
|
|
|
|
#include "Rtmp/amf.h"
|
2018-10-30 14:59:42 +08:00
|
|
|
|
#include "Extension/Track.h"
|
2019-06-28 17:30:13 +08:00
|
|
|
|
#include "Rtsp/RtpCodec.h"
|
|
|
|
|
#include "Rtmp/RtmpCodec.h"
|
2018-10-24 09:23:57 +08:00
|
|
|
|
|
|
|
|
|
using namespace std;
|
2018-10-24 17:17:55 +08:00
|
|
|
|
using namespace toolkit;
|
|
|
|
|
|
|
|
|
|
namespace mediakit{
|
2018-10-24 09:23:57 +08:00
|
|
|
|
|
|
|
|
|
class Factory {
|
|
|
|
|
public:
|
2018-10-25 09:15:46 +08:00
|
|
|
|
////////////////////////////////rtsp相关//////////////////////////////////
|
|
|
|
|
/**
|
|
|
|
|
* 根据sdp生成Track对象
|
|
|
|
|
*/
|
2018-10-26 09:56:29 +08:00
|
|
|
|
static Track::Ptr getTrackBySdp(const SdpTrack::Ptr &track);
|
2018-10-24 09:23:57 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-06-28 16:12:39 +08:00
|
|
|
|
* 根据sdp生成rtp编码器
|
|
|
|
|
* @param sdp sdp对象
|
2018-10-24 09:23:57 +08:00
|
|
|
|
*/
|
2019-06-28 16:12:39 +08:00
|
|
|
|
static RtpCodec::Ptr getRtpEncoderBySdp(const Sdp::Ptr &sdp);
|
2018-10-24 09:23:57 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2019-01-24 12:21:29 +08:00
|
|
|
|
* 根据Track生成Rtp解包器
|
2018-10-24 09:23:57 +08:00
|
|
|
|
*/
|
2019-01-24 12:21:29 +08:00
|
|
|
|
static RtpCodec::Ptr getRtpDecoderByTrack(const Track::Ptr &track);
|
2018-10-24 22:03:17 +08:00
|
|
|
|
|
|
|
|
|
|
2018-10-25 09:15:46 +08:00
|
|
|
|
////////////////////////////////rtmp相关//////////////////////////////////
|
2018-10-24 22:03:17 +08:00
|
|
|
|
|
2018-10-25 09:15:46 +08:00
|
|
|
|
/**
|
2020-04-17 17:47:10 +08:00
|
|
|
|
* 根据amf对象获取视频相应的Track
|
|
|
|
|
* @param amf rtmp metadata中的videocodecid的值
|
2018-10-25 09:15:46 +08:00
|
|
|
|
*/
|
2020-04-17 17:47:10 +08:00
|
|
|
|
static Track::Ptr getVideoTrackByAmf(const AMFValue &amf);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据amf对象获取音频相应的Track
|
|
|
|
|
* @param amf rtmp metadata中的audiocodecid的值
|
|
|
|
|
*/
|
2020-04-18 22:13:11 +08:00
|
|
|
|
static Track::Ptr getAudioTrackByAmf(const AMFValue& amf, int sample_rate, int channels, int sample_bit);
|
2018-10-25 09:15:46 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2018-10-25 14:16:40 +08:00
|
|
|
|
* 根据Track获取Rtmp的编解码器
|
|
|
|
|
* @param track 媒体描述对象
|
2020-05-28 17:03:12 +08:00
|
|
|
|
* @param is_encode 是否为编码器还是解码器
|
2018-10-25 09:15:46 +08:00
|
|
|
|
*/
|
2020-05-28 17:03:12 +08:00
|
|
|
|
static RtmpCodec::Ptr getRtmpCodecByTrack(const Track::Ptr &track, bool is_encode);
|
2018-10-25 14:49:47 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据codecId获取rtmp的codec描述
|
|
|
|
|
*/
|
|
|
|
|
static AMFValue getAmfByCodecId(CodecId codecId);
|
2018-10-24 09:23:57 +08:00
|
|
|
|
};
|
|
|
|
|
|
2018-10-24 17:17:55 +08:00
|
|
|
|
}//namespace mediakit
|
2018-10-24 09:23:57 +08:00
|
|
|
|
|
|
|
|
|
#endif //ZLMEDIAKIT_FACTORY_H
|