ZLMediaKit/src/Extension/Track.h

166 lines
4.2 KiB
C++
Raw Normal View History

2018-10-30 14:59:42 +08:00
/*
* MIT License
*
2019-05-08 15:40:07 +08:00
* Copyright (c) 2016-2019 xiongziliang <771730766@qq.com>
2018-10-30 14:59:42 +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.
*/
#ifndef ZLMEDIAKIT_TRACK_H
#define ZLMEDIAKIT_TRACK_H
#include <memory>
#include <string>
#include "Frame.h"
#include "Util/RingBuffer.h"
#include "Rtsp/Rtsp.h"
using namespace toolkit;
namespace mediakit{
/**
*
*/
class Track : public FrameRingInterfaceDelegate , public CodecInfo{
public:
typedef std::shared_ptr<Track> Ptr;
Track(){}
virtual ~Track(){}
/**
* sps pps等信息
* @return
*/
virtual bool ready() = 0;
/**
*
*
*
* @return
*/
virtual Track::Ptr clone() = 0;
2019-06-28 16:12:39 +08:00
/**
* sdp
* @return sdp对象
*/
virtual Sdp::Ptr getSdp() = 0;
2018-10-30 14:59:42 +08:00
/**
*
*
* @param that
*/
Track(const Track &that){}
};
/**
* Track类fps信息
*/
class VideoTrack : public Track {
public:
typedef std::shared_ptr<VideoTrack> Ptr;
TrackType getTrackType() const override { return TrackVideo;};
/**
*
* @return
*/
virtual int getVideoHeight() const {return 0;};
2018-10-30 14:59:42 +08:00
/**
*
* @return
*/
virtual int getVideoWidth() const {return 0;};
2018-10-30 14:59:42 +08:00
/**
* fps
* @return
*/
virtual float getVideoFps() const {return 0;};
2018-10-30 14:59:42 +08:00
};
/**
* Track派生类
*/
class AudioTrack : public Track {
public:
typedef std::shared_ptr<AudioTrack> Ptr;
TrackType getTrackType() const override { return TrackAudio;};
/**
*
* @return
*/
virtual int getAudioSampleRate() const {return 0;};
2018-10-30 14:59:42 +08:00
/**
* 168
* @return
*/
virtual int getAudioSampleBit() const {return 0;};
2018-10-30 14:59:42 +08:00
/**
*
* @return
*/
virtual int getAudioChannel() const {return 0;};
2018-10-30 14:59:42 +08:00
};
2019-12-03 12:32:57 +08:00
class TrackSource{
public:
TrackSource(){}
virtual ~TrackSource(){}
/**
* Track
* @param trackReady Track
* @return
*/
2019-12-03 16:10:02 +08:00
virtual vector<Track::Ptr> getTracks(bool trackReady = true) const = 0;
2019-12-03 12:32:57 +08:00
/**
* Track
* @param type track类型
* @param trackReady Track
* @return
*/
Track::Ptr getTrack(TrackType type , bool trackReady = true) const {
auto tracks = getTracks(trackReady);
for(auto &track : tracks){
if(track->getTrackType() == type){
return track;
}
}
return nullptr;
}
};
2018-10-30 14:59:42 +08:00
}//namespace mediakit
#endif //ZLMEDIAKIT_TRACK_H