Fix compile on old avcodec

This commit is contained in:
Isaac Connor 2021-03-02 16:30:40 -05:00 committed by Isaac Connor
parent dcd1804b4d
commit 0550e69224
3 changed files with 28 additions and 11 deletions

View File

@ -34,7 +34,13 @@ ADTS_ZoneMinderDeviceSource::ADTS_ZoneMinderDeviceSource(
:
ZoneMinderDeviceSource(env, std::move(monitor), stream, queueSize),
samplingFrequencyIndex(0),
channels(stream->codecpar->channels)
channels(
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
stream->codecpar->channels
#else
stream->codec->channels
#endif
)
{
std::ostringstream os;
os <<

View File

@ -28,8 +28,6 @@ class ADTS_ZoneMinderDeviceSource : public ZoneMinderDeviceSource {
AVStream * stream,
unsigned int queueSize
) {
Debug(1, "m_stream %p codecpar %p channels %d",
stream, stream->codecpar, stream->codecpar->channels);
return new ADTS_ZoneMinderDeviceSource(env, std::move(monitor), stream, queueSize);
};
protected:
@ -47,15 +45,16 @@ class ADTS_ZoneMinderDeviceSource : public ZoneMinderDeviceSource {
virtual unsigned char* findMarker(unsigned char *frame, size_t size, size_t &length);
*/
public:
int samplingFrequency() { return m_stream->codecpar->sample_rate; };
int samplingFrequency() { return
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
m_stream->codecpar->sample_rate;
#else
m_stream->codec->sample_rate;
#endif
};
const char *configStr() { return config.c_str(); };
int numChannels() {
Debug(1, "this %p m_stream %p channels %d",
this, m_stream, channels);
Debug(1, "m_stream %p codecpar %p channels %d => %d",
m_stream, m_stream->codecpar, m_stream->codecpar->channels, channels);
return channels;
return m_stream->codecpar->channels;
}
protected:

View File

@ -32,7 +32,13 @@ H264_ZoneMinderDeviceSource::H264_ZoneMinderDeviceSource(
: H26X_ZoneMinderDeviceSource(env, std::move(monitor), stream, queueSize, repeatConfig, keepMarker)
{
// extradata appears to simply be the SPS and PPS NAL's
this->splitFrames(m_stream->codecpar->extradata, m_stream->codecpar->extradata_size);
this->splitFrames(
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
m_stream->codecpar->extradata, m_stream->codecpar->extradata_size
#else
m_stream->codec->extradata, m_stream->codec->extradata_size
#endif
);
}
// split packet into frames
@ -97,7 +103,13 @@ H265_ZoneMinderDeviceSource::H265_ZoneMinderDeviceSource(
: H26X_ZoneMinderDeviceSource(env, std::move(monitor), stream, queueSize, repeatConfig, keepMarker)
{
// extradata appears to simply be the SPS and PPS NAL's
this->splitFrames(m_stream->codecpar->extradata, m_stream->codecpar->extradata_size);
this->splitFrames(
#if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
m_stream->codecpar->extradata, m_stream->codecpar->extradata_size
#else
m_stream->codec->extradata, m_stream->codec->extradata_size
#endif
);
}
// split packet in frames