2013-03-17 07:45:21 +08:00
|
|
|
//
|
|
|
|
// ZoneMinder SDP Class Interface, $Date: 2009-02-16 18:21:50 +0000 (Mon, 16 Feb 2009) $, $Revision: 2765 $
|
|
|
|
// Copyright (C) 2001-2008 Philip Coombes
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program; if not, write to the Free Software
|
2016-12-26 23:23:16 +08:00
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2013-03-17 07:45:21 +08:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef ZM_SDP_H
|
|
|
|
#define ZM_SDP_H
|
|
|
|
|
|
|
|
#include "zm_ffmpeg.h"
|
2021-02-04 11:47:28 +08:00
|
|
|
#include "zm_utils.h"
|
2013-03-17 07:45:21 +08:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2017-11-08 10:21:51 +08:00
|
|
|
class SessionDescriptor {
|
2013-03-17 07:45:21 +08:00
|
|
|
protected:
|
2016-04-04 22:11:48 +08:00
|
|
|
enum { PAYLOAD_TYPE_DYNAMIC=96 };
|
2013-03-17 07:45:21 +08:00
|
|
|
|
2017-11-08 10:21:51 +08:00
|
|
|
struct StaticPayloadDesc {
|
2016-04-04 22:11:48 +08:00
|
|
|
int payloadType;
|
|
|
|
const char payloadName[6];
|
2015-05-29 23:38:02 +08:00
|
|
|
#if (LIBAVCODEC_VERSION_CHECK(52, 64, 0, 64, 0) || LIBAVUTIL_VERSION_CHECK(50, 14, 0, 14, 0))
|
2016-04-04 22:11:48 +08:00
|
|
|
AVMediaType codecType;
|
2013-04-27 08:17:11 +08:00
|
|
|
#else
|
2016-04-04 22:11:48 +08:00
|
|
|
enum CodecType codecType;
|
2013-04-27 08:17:11 +08:00
|
|
|
#endif
|
2016-04-04 22:11:48 +08:00
|
|
|
_AVCODECID codecId;
|
|
|
|
int clockRate;
|
|
|
|
int autoChannels;
|
|
|
|
};
|
|
|
|
|
2017-11-08 10:21:51 +08:00
|
|
|
struct DynamicPayloadDesc {
|
2016-04-04 22:11:48 +08:00
|
|
|
const char payloadName[32];
|
2015-05-29 23:38:02 +08:00
|
|
|
#if (LIBAVCODEC_VERSION_CHECK(52, 64, 0, 64, 0) || LIBAVUTIL_VERSION_CHECK(50, 14, 0, 14, 0))
|
2016-04-04 22:11:48 +08:00
|
|
|
AVMediaType codecType;
|
2014-04-26 04:12:58 +08:00
|
|
|
#else
|
2016-04-04 22:11:48 +08:00
|
|
|
enum CodecType codecType;
|
2014-04-26 04:12:58 +08:00
|
|
|
#endif
|
2016-04-04 22:11:48 +08:00
|
|
|
_AVCODECID codecId;
|
2013-04-27 08:17:11 +08:00
|
|
|
|
2016-04-04 22:11:48 +08:00
|
|
|
//int clockRate;
|
|
|
|
//int autoChannels;
|
|
|
|
};
|
2013-03-17 07:45:21 +08:00
|
|
|
|
|
|
|
public:
|
2017-11-08 10:21:51 +08:00
|
|
|
class ConnInfo {
|
2016-04-04 22:11:48 +08:00
|
|
|
protected:
|
|
|
|
std::string mNetworkType;
|
|
|
|
std::string mAddressType;
|
|
|
|
std::string mAddress;
|
|
|
|
int mTtl;
|
|
|
|
int mNoAddresses;
|
|
|
|
|
|
|
|
public:
|
2017-11-17 20:52:26 +08:00
|
|
|
explicit ConnInfo( const std::string &connInfo );
|
2016-04-04 22:11:48 +08:00
|
|
|
};
|
|
|
|
|
2017-11-08 10:21:51 +08:00
|
|
|
class BandInfo {
|
2016-04-04 22:11:48 +08:00
|
|
|
protected:
|
|
|
|
std::string mType;
|
|
|
|
int mValue;
|
|
|
|
|
|
|
|
public:
|
2017-11-17 20:52:26 +08:00
|
|
|
explicit BandInfo( const std::string &bandInfo );
|
2016-04-04 22:11:48 +08:00
|
|
|
};
|
|
|
|
|
2017-11-08 10:21:51 +08:00
|
|
|
class MediaDescriptor {
|
2016-04-04 22:11:48 +08:00
|
|
|
protected:
|
|
|
|
std::string mType;
|
|
|
|
int mPort;
|
|
|
|
int mNumPorts;
|
|
|
|
std::string mTransport;
|
|
|
|
int mPayloadType;
|
|
|
|
|
|
|
|
std::string mPayloadDesc;
|
|
|
|
std::string mControlUrl;
|
|
|
|
double mFrameRate;
|
|
|
|
int mClock;
|
|
|
|
int mWidth;
|
|
|
|
int mHeight;
|
|
|
|
std::string mSprops;
|
2013-03-17 07:45:21 +08:00
|
|
|
|
2016-04-04 22:11:48 +08:00
|
|
|
ConnInfo *mConnInfo;
|
2013-03-17 07:45:21 +08:00
|
|
|
|
2016-04-04 22:11:48 +08:00
|
|
|
public:
|
|
|
|
MediaDescriptor( const std::string &type, int port, int numPorts, const std::string &transport, int payloadType );
|
2013-03-17 07:45:21 +08:00
|
|
|
|
2016-04-04 22:11:48 +08:00
|
|
|
const std::string &getType() const
|
|
|
|
{
|
|
|
|
return( mType );
|
|
|
|
}
|
|
|
|
int getPort() const
|
|
|
|
{
|
|
|
|
return( mPort );
|
|
|
|
}
|
|
|
|
int getNumPorts() const
|
|
|
|
{
|
|
|
|
return( mNumPorts );
|
|
|
|
}
|
|
|
|
const std::string &getTransport() const
|
|
|
|
{
|
|
|
|
return( mTransport );
|
|
|
|
}
|
|
|
|
const int getPayloadType() const
|
|
|
|
{
|
|
|
|
return( mPayloadType );
|
|
|
|
}
|
2013-03-17 07:45:21 +08:00
|
|
|
|
2016-04-04 22:11:48 +08:00
|
|
|
const std::string &getPayloadDesc() const
|
|
|
|
{
|
|
|
|
return( mPayloadDesc );
|
|
|
|
}
|
|
|
|
void setPayloadDesc( const std::string &payloadDesc )
|
|
|
|
{
|
|
|
|
mPayloadDesc = payloadDesc;
|
|
|
|
}
|
2013-03-17 07:45:21 +08:00
|
|
|
|
2016-04-04 22:11:48 +08:00
|
|
|
const std::string &getControlUrl() const
|
|
|
|
{
|
|
|
|
return( mControlUrl );
|
|
|
|
}
|
2017-11-17 20:52:26 +08:00
|
|
|
void setControlUrl( const std::string &controlUrl ) {
|
2016-04-04 22:11:48 +08:00
|
|
|
mControlUrl = controlUrl;
|
|
|
|
}
|
2013-03-17 07:45:21 +08:00
|
|
|
|
2017-11-17 20:52:26 +08:00
|
|
|
const int getClock() const {
|
2016-04-04 22:11:48 +08:00
|
|
|
return( mClock );
|
|
|
|
}
|
2017-11-17 20:52:26 +08:00
|
|
|
void setClock( int clock ) {
|
2016-04-04 22:11:48 +08:00
|
|
|
mClock = clock;
|
|
|
|
}
|
2013-03-17 07:45:21 +08:00
|
|
|
|
2017-11-17 20:52:26 +08:00
|
|
|
void setFrameSize( int width, int height ) {
|
2016-04-04 22:11:48 +08:00
|
|
|
mWidth = width;
|
|
|
|
mHeight = height;
|
|
|
|
}
|
2017-11-17 20:52:26 +08:00
|
|
|
int getWidth() const {
|
2016-04-04 22:11:48 +08:00
|
|
|
return( mWidth );
|
|
|
|
}
|
2017-11-17 20:52:26 +08:00
|
|
|
int getHeight() const {
|
2016-04-04 22:11:48 +08:00
|
|
|
return( mHeight );
|
2013-03-17 07:45:21 +08:00
|
|
|
}
|
|
|
|
|
2017-11-17 20:52:26 +08:00
|
|
|
void setSprops(const std::string &props) {
|
2016-04-04 22:11:48 +08:00
|
|
|
mSprops = props;
|
2013-03-17 07:45:21 +08:00
|
|
|
}
|
2017-11-17 20:52:26 +08:00
|
|
|
const std::string getSprops() const {
|
2016-04-04 22:11:48 +08:00
|
|
|
return ( mSprops );
|
2013-03-17 07:45:21 +08:00
|
|
|
}
|
2017-11-17 20:52:26 +08:00
|
|
|
const double getFrameRate() const {
|
2016-04-04 22:11:48 +08:00
|
|
|
return( mFrameRate );
|
|
|
|
}
|
2017-11-17 20:52:26 +08:00
|
|
|
void setFrameRate( double frameRate ) {
|
2016-04-04 22:11:48 +08:00
|
|
|
mFrameRate = frameRate;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<MediaDescriptor *> MediaList;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static StaticPayloadDesc smStaticPayloads[];
|
|
|
|
static DynamicPayloadDesc smDynamicPayloads[];
|
2013-03-17 07:45:21 +08:00
|
|
|
|
2016-04-04 22:11:48 +08:00
|
|
|
protected:
|
|
|
|
std::string mUrl;
|
|
|
|
|
|
|
|
std::string mVersion;
|
|
|
|
std::string mOwner;
|
|
|
|
std::string mName;
|
|
|
|
std::string mInfo;
|
|
|
|
|
|
|
|
ConnInfo *mConnInfo;
|
|
|
|
BandInfo *mBandInfo;
|
|
|
|
std::string mTimeInfo;
|
|
|
|
StringVector mAttributes;
|
|
|
|
|
|
|
|
MediaList mMediaList;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SessionDescriptor( const std::string &url, const std::string &sdp );
|
|
|
|
~SessionDescriptor();
|
|
|
|
|
|
|
|
const std::string &getUrl() const
|
|
|
|
{
|
|
|
|
return( mUrl );
|
|
|
|
}
|
|
|
|
|
|
|
|
int getNumStreams() const
|
|
|
|
{
|
|
|
|
return( mMediaList.size() );
|
|
|
|
}
|
|
|
|
MediaDescriptor *getStream( int index )
|
|
|
|
{
|
|
|
|
if ( index < 0 || (unsigned int)index >= mMediaList.size() )
|
2020-08-26 07:45:48 +08:00
|
|
|
return nullptr;
|
2016-04-04 22:11:48 +08:00
|
|
|
return( mMediaList[index] );
|
|
|
|
}
|
|
|
|
|
|
|
|
AVFormatContext *generateFormatContext() const;
|
2013-03-17 07:45:21 +08:00
|
|
|
};
|
|
|
|
#if 0
|
|
|
|
v=0
|
|
|
|
o=- 1239719297054659 1239719297054674 IN IP4 192.168.1.11
|
|
|
|
s=Media Presentation
|
|
|
|
e=NONE
|
|
|
|
c=IN IP4 0.0.0.0
|
|
|
|
b=AS:174
|
|
|
|
t=0 0
|
|
|
|
a=control:*
|
|
|
|
a=range:npt=now-
|
|
|
|
a=mpeg4-iod: "data:application/mpeg4-iod;base64,AoEAAE8BAf73AQOAkwABQHRkYXRhOmFwcGxpY2F0aW9uL21wZWc0LW9kLWF1O2Jhc2U2NCxBVGdCR3dVZkF4Y0F5U1FBWlFRTklCRUVrK0FBQWEyd0FBR3RzQVlCQkFFWkFwOERGUUJsQlFRTlFCVUFDN2dBQVBvQUFBRDZBQVlCQXc9PQQNAQUABAAAAAAAAAAAAAYJAQAAAAAAAAAAA0IAAkA+ZGF0YTphcHBsaWNhdGlvbi9tcGVnNC1iaWZzLWF1O2Jhc2U2NCx3QkFTZ1RBcUJYSmhCSWhRUlFVL0FBPT0EEgINAAACAAAAAAAAAAAFAwAAQAYJAQAAAAAAAAAA"
|
|
|
|
m=video 0 RTP/AVP 96
|
|
|
|
b=AS:110
|
|
|
|
a=framerate:5.0
|
|
|
|
a=control:trackID=1
|
|
|
|
a=rtpmap:96 MP4V-ES/90000
|
|
|
|
a=fmtp:96 profile-level-id=247; config=000001B0F7000001B509000001000000012008D48D8803250F042D14440F
|
|
|
|
a=mpeg4-esid:201
|
|
|
|
m=audio 0 RTP/AVP 0
|
|
|
|
b=AS:64
|
|
|
|
a=control:trackID=2
|
2016-04-04 22:11:48 +08:00
|
|
|
|
2013-03-17 07:45:21 +08:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // ZM_SDP_H
|