mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-11-30 20:26:05 -05:00
Ffmpeg reaches the same network cameras libvlc did, so carrying a second streaming library -- with its own threading, its own bugs and its own build dependency -- buys nothing. The preceding migration moves existing monitors to Ffmpeg first, so Monitor::Load cannot meet a type it no longer recognises, which is Fatal and would stop zmc rather than skip the monitor. Drops LibvlcCamera, the LIBVLC camera type and its parse and construction arms, LIBVLC_SRC and Camera::IsLibvlc, the ZM_NO_LIBVLC option and the libvlc probe, and the HAVE_LIBVLC and HAVE_VLC_VLC_H defines. Since the camera resolved libvlc through dlopen rather than linking it, this removes a headers-only build dependency and a runtime one, and nothing else needed relinking. kOptionSeparators stays -- the Ffmpeg path still parses the Options field with it -- but it is no longer a contract shared between two readers, so its comment and the test that pins its behaviour are reworded rather than removed. Built clean from a fresh cmake configure, which no longer lists libVLC among optional libraries; unit suite passes (147 cases, 12531 assertions); no libvlc strings remain in zmc. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Y6FieTwEXuLhhR4e2yiax
144 lines
4.7 KiB
C++
144 lines
4.7 KiB
C++
//
|
|
// ZoneMinder Camera Class Interface, $Date$, $Revision$
|
|
// 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
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
//
|
|
|
|
#ifndef ZM_CAMERA_H
|
|
#define ZM_CAMERA_H
|
|
|
|
#include "zm_image.h"
|
|
#include "zm_pixformat.h"
|
|
#include <sys/ioctl.h>
|
|
#include <sys/types.h>
|
|
|
|
#include <memory>
|
|
|
|
class Monitor;
|
|
class ZMPacket;
|
|
|
|
//
|
|
// Abstract base class for cameras. This is intended just to express
|
|
// common attributes
|
|
//
|
|
class Camera {
|
|
protected:
|
|
typedef enum { LOCAL_SRC, REMOTE_SRC, FILE_SRC, FFMPEG_SRC, CURL_SRC, VNC_SRC } SourceType;
|
|
|
|
const Monitor *monitor;
|
|
SourceType type;
|
|
uint16_t width;
|
|
uint16_t height;
|
|
unsigned int linesize;
|
|
unsigned int colours; // DEPRECATED: use pixelFormat
|
|
unsigned int subpixelorder; // DEPRECATED: use pixelFormat
|
|
AVPixelFormat pixelFormat;
|
|
unsigned int pixels;
|
|
unsigned long long imagesize;
|
|
int brightness;
|
|
int hue;
|
|
int colour;
|
|
int contrast;
|
|
bool capture;
|
|
bool record_audio;
|
|
int mVideoStreamId;
|
|
int mAudioStreamId;
|
|
// No decoders here at all. The monitor opens the video decoder against
|
|
// mVideoStream; audio is decoded by whoever needs it, from the stream's
|
|
// codecpar. A camera finds streams and produces packets.
|
|
AVStream *mVideoStream;
|
|
AVStream *mAudioStream;
|
|
AVFormatContext *mFormatContext; // One for video, one for audio
|
|
AVFormatContext *mSecondFormatContext; // One for video, one for audio
|
|
int64_t mFirstVideoPTS;
|
|
int64_t mFirstAudioPTS;
|
|
int64_t mLastVideoPTS;
|
|
int64_t mLastAudioPTS;
|
|
int64_t mLastVideoDTS;
|
|
int64_t mLastAudioDTS;
|
|
unsigned int bytes;
|
|
bool mIsPrimed;
|
|
|
|
public:
|
|
Camera(
|
|
const Monitor* monitor,
|
|
SourceType p_type,
|
|
unsigned int p_width,
|
|
unsigned int p_height,
|
|
int p_colours,
|
|
int p_subpixelorder,
|
|
int p_brightness,
|
|
int p_contrast,
|
|
int p_hue,
|
|
int p_colour,
|
|
bool p_capture,
|
|
bool p_record_audio
|
|
);
|
|
virtual ~Camera();
|
|
|
|
SourceType Type() const { return type; }
|
|
bool isPrimed() const { return mIsPrimed; }
|
|
bool IsLocal() const { return type == LOCAL_SRC; }
|
|
bool IsRemote() const { return type == REMOTE_SRC; }
|
|
bool IsFile() const { return type == FILE_SRC; }
|
|
bool IsFfmpeg() const { return type == FFMPEG_SRC; }
|
|
bool IscURL() const { return type == CURL_SRC; }
|
|
bool IsVNC() const { return type == VNC_SRC; }
|
|
unsigned int Width() const { return width; }
|
|
unsigned int LineSize() const { return linesize; }
|
|
unsigned int Height() const { return height; }
|
|
unsigned int Colours() const { return colours; } // DEPRECATED
|
|
unsigned int SubpixelOrder() const { return subpixelorder; } // DEPRECATED
|
|
AVPixelFormat PixelFormat() const { return pixelFormat; }
|
|
unsigned int Pixels() const { return pixels; }
|
|
unsigned long long ImageSize() const { return imagesize; }
|
|
unsigned int Bytes() const { return bytes; };
|
|
int getFrequency() { return mAudioStream ? mAudioStream->codecpar->sample_rate : -1; }
|
|
int getChannels() {
|
|
#if LIBAVUTIL_VERSION_CHECK(57, 28, 100, 28, 0)
|
|
return mAudioStream ? mAudioStream->codecpar->ch_layout.nb_channels : -1;
|
|
}
|
|
#else
|
|
return mAudioStream ? mAudioStream->codecpar->channels : -1;
|
|
}
|
|
#endif
|
|
|
|
virtual int Brightness( int/*p_brightness*/=-1 ) { return -1; }
|
|
virtual int Hue( int/*p_hue*/=-1 ) { return -1; }
|
|
virtual int Colour( int/*p_colour*/=-1 ) { return -1; }
|
|
virtual int Contrast( int/*p_contrast*/=-1 ) { return -1; }
|
|
|
|
bool CanCapture() const { return capture; }
|
|
|
|
bool SupportsNativeVideo() const {
|
|
return (type == FFMPEG_SRC);
|
|
//return (type == FFMPEG_SRC )||(type == REMOTE_SRC);
|
|
}
|
|
|
|
virtual AVStream *getVideoStream();
|
|
virtual AVStream *getAudioStream() { return mAudioStream; };
|
|
int getVideoStreamId() { return mVideoStreamId; };
|
|
int getAudioStreamId() { return mAudioStreamId; };
|
|
|
|
virtual int PrimeCapture() { return 0; }
|
|
virtual int PreCapture() = 0;
|
|
virtual int Capture(std::shared_ptr<ZMPacket> &p) = 0;
|
|
virtual int PostCapture() = 0;
|
|
virtual int Close() = 0;
|
|
};
|
|
|
|
#endif // ZM_CAMERA_H
|