need arpa/inet for reverse lookups

This commit is contained in:
Isaac Connor 2016-08-10 12:19:53 -04:00
parent 6ac1a70b9c
commit 1277f3c792
8 changed files with 29 additions and 20 deletions

View File

@ -20,8 +20,8 @@
#include "zm.h" #include "zm.h"
#include "zm_camera.h" #include "zm_camera.h"
Camera::Camera( int p_id, SourceType p_type, int p_width, 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 ) : Camera::Camera( unsigned int p_monitor_id, SourceType p_type, int p_width, 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 ) :
id( p_id ), monitor_id( p_monitor_id ),
type( p_type ), type( p_type ),
width( p_width), width( p_width),
height( p_height ), height( p_height ),
@ -37,7 +37,7 @@ Camera::Camera( int p_id, SourceType p_type, int p_width, int p_height, int p_co
pixels = width * height; pixels = width * height;
imagesize = pixels * colours; imagesize = pixels * colours;
Debug(2,"New camera id: %d width: %d height: %d colours: %d subpixelorder: %d capture: %d",id,width,height,colours,subpixelorder,capture); Debug(2,"New camera id: %d width: %d height: %d colours: %d subpixelorder: %d capture: %d",monitor_id,width,height,colours,subpixelorder,capture);
/* Because many loops are unrolled and work on 16 colours/time or 4 pixels/time, we have to meet requirements */ /* Because many loops are unrolled and work on 16 colours/time or 4 pixels/time, we have to meet requirements */
if((colours == ZM_COLOUR_GRAY8 || colours == ZM_COLOUR_RGB32) && (imagesize % 16) != 0) { if((colours == ZM_COLOUR_GRAY8 || colours == ZM_COLOUR_RGB32) && (imagesize % 16) != 0) {
@ -52,6 +52,6 @@ Camera::~Camera() {
Monitor *Camera::getMonitor() { Monitor *Camera::getMonitor() {
if ( ! monitor ) if ( ! monitor )
monitor = Monitor::Load( id, false, Monitor::QUERY ); monitor = Monitor::Load( monitor_id, false, Monitor::QUERY );
return monitor; return monitor;
} }

View File

@ -38,7 +38,7 @@ class Camera
protected: protected:
typedef enum { LOCAL_SRC, REMOTE_SRC, FILE_SRC, FFMPEG_SRC, LIBVLC_SRC, CURL_SRC } SourceType; typedef enum { LOCAL_SRC, REMOTE_SRC, FILE_SRC, FFMPEG_SRC, LIBVLC_SRC, CURL_SRC } SourceType;
int id; // This is actually monitor id unsigned int monitor_id;
Monitor * monitor; // Null on instantiation, set as soon as possible. Monitor * monitor; // Null on instantiation, set as soon as possible.
SourceType type; SourceType type;
unsigned int width; unsigned int width;
@ -55,10 +55,10 @@ protected:
bool record_audio; bool record_audio;
public: public:
Camera( int p_id, SourceType p_type, int p_width, 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 ); Camera( unsigned int p_monitor_id, SourceType p_type, int p_width, 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(); virtual ~Camera();
int getId() const { return( id ); } unsigned int getId() const { return( monitor_id ); }
Monitor *getMonitor(); Monitor *getMonitor();
SourceType Type() const { return( type ); } SourceType Type() const { return( type ); }
bool IsLocal() const { return( type == LOCAL_SRC ); } bool IsLocal() const { return( type == LOCAL_SRC ); }

View File

@ -22,7 +22,7 @@
#include "zm_utils.h" #include "zm_utils.h"
RemoteCamera::RemoteCamera( RemoteCamera::RemoteCamera(
int p_id, unsigned int p_monitor_id,
const std::string &p_protocol, const std::string &p_protocol,
const std::string &p_host, const std::string &p_host,
const std::string &p_port, const std::string &p_port,
@ -37,7 +37,7 @@ RemoteCamera::RemoteCamera(
bool p_capture, bool p_capture,
bool p_record_audio bool p_record_audio
) : ) :
Camera( p_id, REMOTE_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture, p_record_audio ), Camera( p_monitor_id, REMOTE_SRC, p_width, p_height, p_colours, ZM_SUBPIX_ORDER_DEFAULT_FOR_COLOUR(p_colours), p_brightness, p_contrast, p_hue, p_colour, p_capture, p_record_audio ),
protocol( p_protocol ), protocol( p_protocol ),
host( p_host ), host( p_host ),
port( p_port ), port( p_port ),

View File

@ -27,6 +27,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netdb.h> #include <netdb.h>
#include <arpa/inet.h>
// //
// Class representing 'remote' cameras, i.e. those which are // Class representing 'remote' cameras, i.e. those which are
@ -56,7 +57,7 @@ protected:
public: public:
RemoteCamera( RemoteCamera(
int p_id, unsigned int p_monitor_id,
const std::string &p_proto, const std::string &p_proto,
const std::string &p_host, const std::string &p_host,
const std::string &p_port, const std::string &p_port,

View File

@ -30,9 +30,12 @@
#ifdef SOLARIS #ifdef SOLARIS
#include <sys/filio.h> // FIONREAD and friends #include <sys/filio.h> // FIONREAD and friends
#endif #endif
#ifdef __FreeBSD__
#include <netinet/in.h>
#endif
RemoteCameraHttp::RemoteCameraHttp( RemoteCameraHttp::RemoteCameraHttp(
int p_id, unsigned int p_monitor_id,
const std::string &p_method, const std::string &p_method,
const std::string &p_host, const std::string &p_host,
const std::string &p_port, const std::string &p_port,
@ -46,7 +49,7 @@ RemoteCameraHttp::RemoteCameraHttp(
bool p_capture, bool p_capture,
bool p_record_audio ) : bool p_record_audio ) :
RemoteCamera( RemoteCamera(
p_id, p_monitor_id,
"http", "http",
p_host, p_host,
p_port, p_port,
@ -71,7 +74,7 @@ RemoteCameraHttp::RemoteCameraHttp(
else if ( p_method == "regexp" ) else if ( p_method == "regexp" )
method = REGEXP; method = REGEXP;
else else
Fatal( "Unrecognised method '%s' when creating HTTP camera %d", p_method.c_str(), id ); Fatal( "Unrecognised method '%s' when creating HTTP camera %d", p_method.c_str(), monitor_id );
if ( capture ) if ( capture )
{ {
Initialise(); Initialise();
@ -135,7 +138,12 @@ int RemoteCameraHttp::Connect()
{ {
close(sd); close(sd);
sd = -1; sd = -1;
Warning("Can't connect to remote camera: %s", strerror(errno) ); char buf[sizeof(struct in6_addr)];
struct sockaddr_in *addr;
addr = (struct sockaddr_in *)p->ai_addr;
inet_ntop( AF_INET, &(addr->sin_addr), buf, INET6_ADDRSTRLEN );
Warning("Can't connect to remote camera mid: %d at %s: %s", monitor_id, buf, strerror(errno) );
continue; continue;
} }

View File

@ -45,7 +45,7 @@ protected:
enum { SIMPLE, REGEXP } method; enum { SIMPLE, REGEXP } method;
public: public:
RemoteCameraHttp(int p_id, const std::string &method, const std::string &host, const std::string &port, const std::string &path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio ); RemoteCameraHttp( unsigned int p_monitor_id, const std::string &method, const std::string &host, const std::string &port, const std::string &path, int p_width, int p_height, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio );
~RemoteCameraHttp(); ~RemoteCameraHttp();
void Initialise(); void Initialise();

View File

@ -28,8 +28,8 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
RemoteCameraRtsp::RemoteCameraRtsp( int p_id, const std::string &p_method, const std::string &p_host, const std::string &p_port, const std::string &p_path, int p_width, int p_height, bool p_rtsp_describe, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio ) : RemoteCameraRtsp::RemoteCameraRtsp( unsigned int p_monitor_id, const std::string &p_method, const std::string &p_host, const std::string &p_port, const std::string &p_path, int p_width, int p_height, bool p_rtsp_describe, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio ) :
RemoteCamera( p_id, "rtsp", p_host, p_port, p_path, p_width, p_height, p_colours, p_brightness, p_contrast, p_hue, p_colour, p_capture, p_record_audio ), RemoteCamera( p_monitor_id, "rtsp", p_host, p_port, p_path, p_width, p_height, p_colours, p_brightness, p_contrast, p_hue, p_colour, p_capture, p_record_audio ),
rtsp_describe( p_rtsp_describe ), rtsp_describe( p_rtsp_describe ),
rtspThread( 0 ) rtspThread( 0 )
@ -43,7 +43,7 @@ RemoteCameraRtsp::RemoteCameraRtsp( int p_id, const std::string &p_method, const
else if ( p_method == "rtpRtspHttp" ) else if ( p_method == "rtpRtspHttp" )
method = RtspThread::RTP_RTSP_HTTP; method = RtspThread::RTP_RTSP_HTTP;
else else
Fatal( "Unrecognised method '%s' when creating RTSP camera %d", p_method.c_str(), id ); Fatal( "Unrecognised method '%s' when creating RTSP camera %d", p_method.c_str(), monitor_id );
if ( capture ) if ( capture )
{ {
@ -137,7 +137,7 @@ void RemoteCameraRtsp::Terminate()
int RemoteCameraRtsp::Connect() int RemoteCameraRtsp::Connect()
{ {
rtspThread = new RtspThread( id, method, protocol, host, port, path, auth, rtsp_describe ); rtspThread = new RtspThread( monitor_id, method, protocol, host, port, path, auth, rtsp_describe );
rtspThread->start(); rtspThread->start();

View File

@ -73,7 +73,7 @@ protected:
#endif #endif
public: public:
RemoteCameraRtsp( int p_id, const std::string &method, const std::string &host, const std::string &port, const std::string &path, int p_width, int p_height, bool p_rtsp_describe, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio ); RemoteCameraRtsp( unsigned int p_monitor_id, const std::string &method, const std::string &host, const std::string &port, const std::string &path, int p_width, int p_height, bool p_rtsp_describe, int p_colours, int p_brightness, int p_contrast, int p_hue, int p_colour, bool p_capture, bool p_record_audio );
~RemoteCameraRtsp(); ~RemoteCameraRtsp();
void Initialise(); void Initialise();