From 1277f3c7920b2d84b239d349531edaa82db4edc3 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 10 Aug 2016 12:19:53 -0400 Subject: [PATCH] need arpa/inet for reverse lookups --- src/zm_camera.cpp | 8 ++++---- src/zm_camera.h | 6 +++--- src/zm_remote_camera.cpp | 4 ++-- src/zm_remote_camera.h | 3 ++- src/zm_remote_camera_http.cpp | 16 ++++++++++++---- src/zm_remote_camera_http.h | 2 +- src/zm_remote_camera_rtsp.cpp | 8 ++++---- src/zm_remote_camera_rtsp.h | 2 +- 8 files changed, 29 insertions(+), 20 deletions(-) diff --git a/src/zm_camera.cpp b/src/zm_camera.cpp index 031511f04..55a58ffca 100644 --- a/src/zm_camera.cpp +++ b/src/zm_camera.cpp @@ -20,8 +20,8 @@ #include "zm.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 ) : - id( p_id ), +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 ) : + monitor_id( p_monitor_id ), type( p_type ), width( p_width), 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; 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 */ if((colours == ZM_COLOUR_GRAY8 || colours == ZM_COLOUR_RGB32) && (imagesize % 16) != 0) { @@ -52,6 +52,6 @@ Camera::~Camera() { Monitor *Camera::getMonitor() { if ( ! monitor ) - monitor = Monitor::Load( id, false, Monitor::QUERY ); + monitor = Monitor::Load( monitor_id, false, Monitor::QUERY ); return monitor; } diff --git a/src/zm_camera.h b/src/zm_camera.h index c76b086f3..1a90f037c 100644 --- a/src/zm_camera.h +++ b/src/zm_camera.h @@ -38,7 +38,7 @@ class Camera protected: 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. SourceType type; unsigned int width; @@ -55,10 +55,10 @@ protected: bool record_audio; 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(); - int getId() const { return( id ); } + unsigned int getId() const { return( monitor_id ); } Monitor *getMonitor(); SourceType Type() const { return( type ); } bool IsLocal() const { return( type == LOCAL_SRC ); } diff --git a/src/zm_remote_camera.cpp b/src/zm_remote_camera.cpp index 1ffe5f568..be177c2c6 100644 --- a/src/zm_remote_camera.cpp +++ b/src/zm_remote_camera.cpp @@ -22,7 +22,7 @@ #include "zm_utils.h" RemoteCamera::RemoteCamera( - int p_id, + unsigned int p_monitor_id, const std::string &p_protocol, const std::string &p_host, const std::string &p_port, @@ -37,7 +37,7 @@ RemoteCamera::RemoteCamera( bool p_capture, 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 ), host( p_host ), port( p_port ), diff --git a/src/zm_remote_camera.h b/src/zm_remote_camera.h index 6add0398a..b24d6a68f 100644 --- a/src/zm_remote_camera.h +++ b/src/zm_remote_camera.h @@ -27,6 +27,7 @@ #include #include #include +#include // // Class representing 'remote' cameras, i.e. those which are @@ -56,7 +57,7 @@ protected: public: RemoteCamera( - int p_id, + unsigned int p_monitor_id, const std::string &p_proto, const std::string &p_host, const std::string &p_port, diff --git a/src/zm_remote_camera_http.cpp b/src/zm_remote_camera_http.cpp index 02641632d..17f3969a4 100644 --- a/src/zm_remote_camera_http.cpp +++ b/src/zm_remote_camera_http.cpp @@ -30,9 +30,12 @@ #ifdef SOLARIS #include // FIONREAD and friends #endif +#ifdef __FreeBSD__ +#include +#endif RemoteCameraHttp::RemoteCameraHttp( - int p_id, + unsigned int p_monitor_id, const std::string &p_method, const std::string &p_host, const std::string &p_port, @@ -46,7 +49,7 @@ RemoteCameraHttp::RemoteCameraHttp( bool p_capture, bool p_record_audio ) : RemoteCamera( - p_id, + p_monitor_id, "http", p_host, p_port, @@ -71,7 +74,7 @@ RemoteCameraHttp::RemoteCameraHttp( else if ( p_method == "regexp" ) method = REGEXP; 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 ) { Initialise(); @@ -135,7 +138,12 @@ int RemoteCameraHttp::Connect() { close(sd); 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; } diff --git a/src/zm_remote_camera_http.h b/src/zm_remote_camera_http.h index f0b8a4415..079dd8482 100644 --- a/src/zm_remote_camera_http.h +++ b/src/zm_remote_camera_http.h @@ -45,7 +45,7 @@ protected: enum { SIMPLE, REGEXP } method; 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(); void Initialise(); diff --git a/src/zm_remote_camera_rtsp.cpp b/src/zm_remote_camera_rtsp.cpp index 7281c0512..2e5e4b710 100644 --- a/src/zm_remote_camera_rtsp.cpp +++ b/src/zm_remote_camera_rtsp.cpp @@ -28,8 +28,8 @@ #include #include -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 ) : - 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 ), +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_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 ), rtspThread( 0 ) @@ -43,7 +43,7 @@ RemoteCameraRtsp::RemoteCameraRtsp( int p_id, const std::string &p_method, const else if ( p_method == "rtpRtspHttp" ) method = RtspThread::RTP_RTSP_HTTP; 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 ) { @@ -137,7 +137,7 @@ void RemoteCameraRtsp::Terminate() 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(); diff --git a/src/zm_remote_camera_rtsp.h b/src/zm_remote_camera_rtsp.h index 1a1da6999..3af753fea 100644 --- a/src/zm_remote_camera_rtsp.h +++ b/src/zm_remote_camera_rtsp.h @@ -73,7 +73,7 @@ protected: #endif 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(); void Initialise();