Syntax error (C++) in a function call

Hello i’m getting “no matching function for call to…”
here’s the ino code with the error on line 22:

#include "..\..\src\OV2640.h"
#include <WiFi.h>
#include <WiFiClient.h>
#include "..\..\src\OV2640Streamer.h"
#include "..\..\src\CRtspSession.h"
#include "wifikeys.h"

OV2640 cam;
WiFiServer rtspServer(8554);
CStreamer *streamer;

void setup() {
    cam.init(esp32cam_config);

    IPAddress ip;
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {}
    ip = WiFi.localIP();

    rtspServer.begin();
    streamer = new OV2640Streamer(cam); // <--- "no matching function for call to 'OV2640Streamer::OV2640Streamer(OV2640&)'"
}

void loop() {
    WiFiClient rtspClient = rtspServer.accept();
    if(rtspClient) { streamer->addSession(rtspClient); }
}

here’s the include file OV2640Streamer.cpp

#include "OV2640Streamer.h"
#include <assert.h>

OV2640Streamer::OV2640Streamer(OV2640 *cam) : CStreamer(cam->getWidth(), cam->getHeight()), m_cam(cam)
{
    printf("Created streamer width=%d, height=%d\n", cam->getWidth(), cam->getHeight());
}

void OV2640Streamer::streamImage(uint32_t curMsec)
{
    m_cam->run();// queue up a read for next time

    BufPtr bytes = m_cam->getfb();
    streamFrame(bytes, m_cam->getSize(), curMsec);
    m_cam->done();
}

Please post the verbose error log in code tags.

do you need to pass it a ptr to an OV2640 object?

here’s the whole console output. don’t know what most of it means


C:\store\dev\repos\Micro-RTSPx\examples\ESP32-devcamX\ESP32-devcamX.ino: In function 'void setup()':
ESP32-devcamX:23:38: error: no matching function for call to 'OV2640Streamer::OV2640Streamer(OV2640&)'
   23 |     streamer = new OV2640Streamer(cam);             // our streamer for UDP/TCP based RTP transport
      |                                      ^
In file included from C:\store\dev\repos\Micro-RTSPx\examples\ESP32-devcamX\ESP32-devcamX.ino:4:
C:/store/dev/repos/Micro-RTSPx/src/OV2640Streamer.h:12:5: note: candidate: 'OV2640Streamer::OV2640Streamer(OV2640*)'
   12 |     OV2640Streamer(OV2640 *cam);
      |     ^~~~~~~~~~~~~~
C:/store/dev/repos/Micro-RTSPx/src/OV2640Streamer.h:12:28: note:   no known conversion for argument 1 from 'OV2640' to 'OV2640*'
   12 |     OV2640Streamer(OV2640 *cam);
      |                    ~~~~~~~~^~~
C:/store/dev/repos/Micro-RTSPx/src/OV2640Streamer.h:6:7: note: candidate: 'OV2640Streamer::OV2640Streamer(const OV2640Streamer&)'
    6 | class OV2640Streamer : public CStreamer
      |       ^~~~~~~~~~~~~~
C:/store/dev/repos/Micro-RTSPx/src/OV2640Streamer.h:6:7: note:   no known conversion for argument 1 from 'OV2640' to 'const OV2640Streamer&'
C:/store/dev/repos/Micro-RTSPx/src/OV2640Streamer.h:6:7: note: candidate: 'OV2640Streamer::OV2640Streamer(OV2640Streamer&&)'
C:/store/dev/repos/Micro-RTSPx/src/OV2640Streamer.h:6:7: note:   no known conversion for argument 1 from 'OV2640' to 'OV2640Streamer&&'
C:\store\dev\repos\Micro-RTSPx\examples\ESP32-devcamX\ESP32-devcamX.ino: In function 'void loop()':
ESP32-devcamX:29:43: error: cannot convert 'WiFiClient' {aka 'NetworkClient'} to 'SOCKET' {aka 'NetworkClient*'}
   29 |     if(rtspClient) { streamer->addSession(rtspClient); }
      |                                           ^~~~~~~~~~
      |                                           |
      |                                           WiFiClient {aka NetworkClient}
In file included from C:/store/dev/repos/Micro-RTSPx/src/OV2640Streamer.h:3:
C:/store/dev/repos/Micro-RTSPx/src/CStreamer.h:16:38: note:   initializing argument 1 of 'CRtspSession* CStreamer::addSession(SOCKET)'
   16 |     CRtspSession *addSession( SOCKET aClient );
      |                               ~~~~~~~^~~~~~~
Multiple libraries were found for "WiFi.h"
 Used: C:\Users\Admin\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.2\libraries\WiFi
 Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
exit status 1
no matching function for call to 'OV2640Streamer::OV2640Streamer(OV2640&)'

A couple of your includes look unusual. Is there no a library for the OV2640? I just use esp32cam.

The output is hard to read with the long paths and line and column numbers (needed if you need to find that specific location). But there are only two errors, each with one or more notes. The first

  • error: no matching function for call to OV2640Streamer::OV2640Streamer(OV2640&)
    • note: candidate: OV2640Streamer::OV2640Streamer(OV2640*)
    • note: candidate: OV2640Streamer::OV2640Streamer(const OV2640Streamer&)

You tried to pass a OV2640&, but that's not a valid option. Two close matches, but "no known conversion" from that to either of those.

The second is similar, and offers a simpler clue

  • error: cannot convert WiFiClient {aka NetworkClient} to SOCKET {aka NetworkClient*}

In both cases, you got a "thing", but you need to pass "thing*" -- a "pointer to" that thing. So use the & as the address-of operator to get that pointer. For example

streamer->addSession(&rtspClient)

@mikewax
If your contructor expects a pointer OV2640*

why do you try to call it with object OV2640 ?

this is taken from ESP32-RTSP/lib/Micro-RTSP at master · circuitrocks/ESP32-RTSP

the libraries are
OV2640Streamer.cpp
OV2640Streamer.h
OV2640.cpp
OV2640.h

i’m just tryin to setup a rtsp server over my house wifi on an ESP32-CAM, but i don’t know anything about OOP. I trimmed down the code to the absolute essentials enough to show the compile error

ok thanks for that i changed the references to
streamer = new OV2640Streamer(&cam);
and that error went away. But couldn’t figure out the
”cannot convert 'WiFiClient' {aka 'NetworkClient'} to 'SOCKET' {aka 'NetworkClient*'}”*
i tried both & and * and still got more errors like
”no match for 'operator*' (operand type is 'WiFiClient' {aka 'NetworkClient'})”

Those may be the contents of the library, but your actual library is

And here is the Basic example (minus 2 includes)

#include <WiFi.h>
#include <ESP32-RTSPServer.h>
#include "esp_camera.h"

// Reference: Camera pin definitions and setup adapted from MJPEG2SD project by s60sc (https://github.com/s60sc/ESP32-CAM_MJPEG2SD)
// ===================
// Select camera model
// ===================
// User's ESP32 cam board
#if defined(CONFIG_IDF_TARGET_ESP32)
#define CAMERA_MODEL_AI_THINKER 
//#define CAMERA_MODEL_WROVER_KIT 
//#define CAMERA_MODEL_ESP_EYE 
//#define CAMERA_MODEL_M5STACK_PSRAM 
//#define CAMERA_MODEL_M5STACK_V2_PSRAM 
//#define CAMERA_MODEL_M5STACK_WIDE 
//#define CAMERA_MODEL_M5STACK_ESP32CAM
//#define CAMERA_MODEL_M5STACK_UNITCAM
//#define CAMERA_MODEL_TTGO_T_JOURNAL 
//#define CAMERA_MODEL_ESP32_CAM_BOARD
//#define CAMERA_MODEL_TTGO_T_CAMERA_PLUS
//#define CAMERA_MODEL_UICPAL_ESP32
//#define AUXILIARY

// User's ESP32S3 cam board
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#define CAMERA_MODEL_FREENOVE_ESP32S3_CAM
//#define CAMERA_MODEL_PCBFUN_ESP32S3_CAM
//#define CAMERA_MODEL_XIAO_ESP32S3 
//#define CAMERA_MODEL_NEW_ESPS3_RE1_0
//#define CAMERA_MODEL_M5STACK_CAMS3_UNIT
//#define CAMERA_MODEL_ESP32S3_EYE 
//#define CAMERA_MODEL_ESP32S3_CAM_LCD
//#define CAMERA_MODEL_DFRobot_FireBeetle2_ESP32S3
//#define CAMERA_MODEL_DFRobot_Romeo_ESP32S3
//#define CAMERA_MODEL_XENOIONEX
//#define CAMERA_MODEL_Waveshare_ESP32_S3_ETH
//#define CAMERA_MODEL_DFRobot_ESP32_S3_AI_CAM
#endif
#include "camera_pins.h"

// ===========================
// Enter your WiFi credentials
// ===========================
const char *ssid = "**********";
const char *password = "**********";

// RTSPServer instance
RTSPServer rtspServer;

// Variable to hold quality for RTSP frame
int quality;
// Task handles
TaskHandle_t videoTaskHandle = NULL; 

/** 
 * @brief Sets up the camera with the specified configuration. 
*/
// Camera setup function
bool setupCamera() {
  camera_config_t config;
  config.ledc_channel = LEDC_CHANNEL_0;
  config.ledc_timer = LEDC_TIMER_0;
  config.pin_d0 = Y2_GPIO_NUM;
  config.pin_d1 = Y3_GPIO_NUM;
  config.pin_d2 = Y4_GPIO_NUM;
  config.pin_d3 = Y5_GPIO_NUM;
  config.pin_d4 = Y6_GPIO_NUM;
  config.pin_d5 = Y7_GPIO_NUM;
  config.pin_d6 = Y8_GPIO_NUM;
  config.pin_d7 = Y9_GPIO_NUM;
  config.pin_xclk = XCLK_GPIO_NUM;
  config.pin_pclk = PCLK_GPIO_NUM;
  config.pin_vsync = VSYNC_GPIO_NUM;
  config.pin_href = HREF_GPIO_NUM;
  config.pin_sccb_sda = SIOD_GPIO_NUM;
  config.pin_sccb_scl = SIOC_GPIO_NUM;
  config.pin_pwdn = PWDN_GPIO_NUM;
  config.pin_reset = RESET_GPIO_NUM;
  config.xclk_freq_hz = 20000000;
  config.frame_size = FRAMESIZE_UXGA;
  config.pixel_format = PIXFORMAT_JPEG;  // for streaming
  config.grab_mode = CAMERA_GRAB_LATEST;
  config.fb_location = CAMERA_FB_IN_PSRAM;
  config.jpeg_quality = 10;
  config.fb_count = 2;

  // if PSRAM IC present, init with UXGA resolution and higher JPEG quality
  // for larger pre-allocated frame buffer.
  if (config.pixel_format == PIXFORMAT_JPEG) {
    if (psramFound()) {
      config.jpeg_quality = 10;
      config.fb_count = 2;
      config.grab_mode = CAMERA_GRAB_LATEST;
    } else {
      // Limit the frame size when PSRAM is not available
      config.frame_size = FRAMESIZE_SVGA;
      config.fb_location = CAMERA_FB_IN_DRAM;
    }
  } else {
    // Best option for face detection/recognition
    config.frame_size = FRAMESIZE_240X240;
#if CONFIG_IDF_TARGET_ESP32S3
    config.fb_count = 2;
#endif
  }

#if defined(CAMERA_MODEL_ESP_EYE)
  pinMode(13, INPUT_PULLUP);
  pinMode(14, INPUT_PULLUP);
#endif

  // Initialize camera
  esp_err_t err = esp_camera_init(&config);
  if (err != ESP_OK) {
    Serial.printf("Camera init failed with error 0x%x\n", err);
    return false;
  }

  sensor_t *s = esp_camera_sensor_get();
  // initial sensors are flipped vertically and colors are a bit saturated
  if (s->id.PID == OV3660_PID) {
    s->set_vflip(s, 1);        // flip it back
    s->set_brightness(s, 1);   // up the brightness just a bit
    s->set_saturation(s, -2);  // lower the saturation
  }
  // drop down frame size for higher initial frame rate
  if (config.pixel_format == PIXFORMAT_JPEG) {
    s->set_framesize(s, FRAMESIZE_QVGA);
  }

#if defined(CAMERA_MODEL_M5STACK_WIDE) || defined(CAMERA_MODEL_M5STACK_ESP32CAM)
  s->set_vflip(s, 1);
  s->set_hmirror(s, 1);
#endif

#if defined(CAMERA_MODEL_ESP32S3_EYE)
  s->set_vflip(s, 1);
#endif
  Serial.println("Camera Setup Complete");
  return true;
}

/** 
 * @brief Retrieves the current frame quality from the camera. 
*/
void getFrameQuality() { 
  sensor_t * s = esp_camera_sensor_get(); 
  quality = s->status.quality; 
  Serial.printf("Camera Quality is: %d\n", quality);
}

/** 
 * @brief Task to send jpeg frames via RTP. 
*/
void sendVideo(void* pvParameters) { 
  while (true) { 
    // Send frame via RTP
    if(rtspServer.readyToSendFrame()) {
      camera_fb_t* fb = esp_camera_fb_get();
      rtspServer.sendRTSPFrame(fb->buf, fb->len, quality, fb->width, fb->height);
      esp_camera_fb_return(fb);
    }
    vTaskDelay(pdMS_TO_TICKS(1)); 
  }
}

void setup() {
  // Initialize serial communication
  Serial.begin(115200);

  // Set ESP32 core debug level to Info for verbose logging
  esp_log_level_set("*", ESP_LOG_INFO);

  // Connect to WiFi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi...");
  }
  Serial.println("Connected to WiFi");

  // Setup camera
  if (!setupCamera()) {
    Serial.println("Camera setup failed. Halting.");
    while (true);
  }
  getFrameQuality();
  
  if (rtspServer.init()) { 
    Serial.printf("RTSP server started successfully using default values, Connect to rtsp://%s:554/\n", WiFi.localIP().toString().c_str());
  } else { 
    Serial.println("Failed to start RTSP server"); 
  }
  
  // Create tasks for sending video, and subtitles
  xTaskCreate(sendVideo, "Video", 8192, NULL, 9, &videoTaskHandle);
}

void loop() {
  delay(1000);
  vTaskDelete(NULL); // free 8k ram and delete the loop
}

im doing just cloning and compiling from ESP32-RTSP/lib/Micro-RTSP at master · circuitrocks/ESP32-RTSP

i don’t know anything about OOP, but i did change the reference to “&cam” and that error went away.

ok thanx i’ll try that…..

You may want to read the documentation about installing libraries. This one was tricky; the zip contained another zip in a folder called Arduino. I could see the first zip wasn't a valid library, so I opened the Arduino folder, which contained a proper library zip. I included the zip, and it installed and has 2 example sketches.
https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries/

I don't know much about OOP either, but you don;t need to, you just need to install the actual library. What you are attempting is an unknown procedure. I installed the library and compiled the sample code with no errors.

THANX

And thank God for Kooky Marvin. His repo doesn’t have that zip file, but it has a sketch called BasicVideo which compiled and executed right away. I just gotta get the wifi connection working. i think there’s an antenna jumper i have to connect, but it’s a @!#$ing 0402-size jumper, that’s fun

That is where I got the zip file from, you have to open the first zip file, then open the Arduino folder and open that zip.

ok i’ll check ….

Actually, don't open the 2nd zip, just install it as follows

then just navigate to the 2nd zip file and select it. It will install in the Library Manager with the two sample files.