Factory.h 3.06 KB
Newer Older
1 2 3
/*
 * MIT License
 *
xiongziliang committed
4
 * Copyright (c) 2016-2019 xiongziliang <771730766@qq.com>
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 * 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.
 */
26 27 28 29 30

#ifndef ZLMEDIAKIT_FACTORY_H
#define ZLMEDIAKIT_FACTORY_H

#include <string>
31
#include "Rtmp/amf.h"
32
#include "Extension/Track.h"
xiongziliang committed
33 34
#include "Rtsp/RtpCodec.h"
#include "Rtmp/RtmpCodec.h"
35 36

using namespace std;
xiongziliang committed
37 38 39
using namespace toolkit;

namespace mediakit{
40 41 42

class Factory {
public:
xiongziliang committed
43

44
    /**
xiongziliang committed
45 46 47
     * 根据CodecId获取Track,该Track的ready()状态一般都为false
     * @param codecId 编解码器id
     * @return
48
     */
49 50
    static Track::Ptr getTrackByCodecId(CodecId codecId);

xiongziliang committed
51 52 53 54
    ////////////////////////////////rtsp相关//////////////////////////////////
    /**
     * 根据sdp生成Track对象
     */
xiongziliang committed
55
    static Track::Ptr getTrackBySdp(const SdpTrack::Ptr &track);
56 57

    /**
xiongziliang committed
58 59
     * 根据sdp生成rtp编码器
     * @param sdp sdp对象
60 61
     * @return
     */
xiongziliang committed
62
    static RtpCodec::Ptr getRtpEncoderBySdp(const Sdp::Ptr &sdp);
63 64

    /**
65 66
     * 根据Track生成Rtp解包器
     * @param track
67 68
     * @return
     */
69
    static RtpCodec::Ptr getRtpDecoderByTrack(const Track::Ptr &track);
xiongziliang committed
70 71


xiongziliang committed
72
    ////////////////////////////////rtmp相关//////////////////////////////////
xiongziliang committed
73

xiongziliang committed
74 75 76 77 78
    /**
     * 根据amf对象获取响应的Track
     * @param amf rtmp metedata中的videocodecid或audiocodecid的值
     * @return
     */
xiongziliang committed
79
    static Track::Ptr getTrackByAmf(const AMFValue &amf);
xiongziliang committed
80 81 82 83 84 85

    /**
     * 根据amf对象获取相应的CodecId
     * @param val rtmp metedata中的videocodecid或audiocodecid的值
     * @return
     */
xiongziliang committed
86
    static CodecId getCodecIdByAmf(const AMFValue &val);
xiongziliang committed
87 88

    /**
89 90
     * 根据Track获取Rtmp的编解码器
     * @param track 媒体描述对象
xiongziliang committed
91 92
     * @return
     */
93
    static RtmpCodec::Ptr getRtmpCodecByTrack(const Track::Ptr &track);
94 95 96 97 98 99 100 101


    /**
     * 根据codecId获取rtmp的codec描述
     * @param codecId
     * @return
     */
    static AMFValue getAmfByCodecId(CodecId codecId);
102 103
};

xiongziliang committed
104
}//namespace mediakit
105 106

#endif //ZLMEDIAKIT_FACTORY_H