2018-10-25 10:00:17 +08:00
|
|
|
|
/*
|
|
|
|
|
* MIT License
|
|
|
|
|
*
|
2019-05-08 15:40:07 +08:00
|
|
|
|
* Copyright (c) 2016-2019 xiongziliang <771730766@qq.com>
|
2018-10-25 10:00:17 +08:00
|
|
|
|
*
|
|
|
|
|
* This file is part of ZLMediaKit(https://github.com/xiongziliang/ZLMediaKit).
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
* SOFTWARE.
|
|
|
|
|
*/
|
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"
|
2018-10-24 22:03:17 +08:00
|
|
|
|
#include "RtspMuxer/RtpCodec.h"
|
|
|
|
|
#include "RtmpMuxer/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
|
|
|
|
|
2018-10-24 09:23:57 +08:00
|
|
|
|
/**
|
2018-10-25 09:15:46 +08:00
|
|
|
|
* 根据CodecId获取Track,该Track的ready()状态一般都为false
|
|
|
|
|
* @param codecId 编解码器id
|
|
|
|
|
* @return
|
2018-10-24 09:23:57 +08:00
|
|
|
|
*/
|
2018-10-24 18:41:37 +08:00
|
|
|
|
static Track::Ptr getTrackByCodecId(CodecId codecId);
|
|
|
|
|
|
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
|
|
|
|
* @return
|
|
|
|
|
*/
|
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解包器
|
|
|
|
|
* @param track
|
2018-10-24 09:23:57 +08:00
|
|
|
|
* @return
|
|
|
|
|
*/
|
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
|
|
|
|
/**
|
|
|
|
|
* 根据amf对象获取响应的Track
|
|
|
|
|
* @param amf rtmp metedata中的videocodecid或audiocodecid的值
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2018-10-24 22:03:17 +08:00
|
|
|
|
static Track::Ptr getTrackByAmf(const AMFValue &amf);
|
2018-10-25 09:15:46 +08:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据amf对象获取相应的CodecId
|
|
|
|
|
* @param val rtmp metedata中的videocodecid或audiocodecid的值
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2018-10-24 22:03:17 +08:00
|
|
|
|
static CodecId getCodecIdByAmf(const AMFValue &val);
|
2018-10-25 09:15:46 +08:00
|
|
|
|
|
|
|
|
|
/**
|
2018-10-25 14:16:40 +08:00
|
|
|
|
* 根据Track获取Rtmp的编解码器
|
|
|
|
|
* @param track 媒体描述对象
|
2018-10-25 09:15:46 +08:00
|
|
|
|
* @return
|
|
|
|
|
*/
|
2018-10-25 14:16:40 +08:00
|
|
|
|
static RtmpCodec::Ptr getRtmpCodecByTrack(const Track::Ptr &track);
|
2018-10-25 14:49:47 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据codecId获取rtmp的codec描述
|
|
|
|
|
* @param codecId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
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
|