Git Product home page Git Product logo

Comments (2)

tosiara avatar tosiara commented on August 24, 2024

What if motion is built with rtsp support, but the stream URL is malformed?

from motion.

arseni-mourzenko avatar arseni-mourzenko commented on August 24, 2024

I can see four possible situations:

  1. There is RTSP support and the URI is correct.
  2. There is RTSP support and the URI is malformed.
  3. RTSP support is missing and the URI is correct and doesn't start by rtsp://.
  4. RTSP support is missing and the URI is correct and starts with rtsp://.
  5. RTSP support is missing and the URI is malformed.

Currently, the cases 2, 4 and 5 produce all the same “Invalid netcam_url” error. Especially at the level of regular expressions, as currently implemented, there is no way to differentiate the case 4 and 5.

What I suggest is only to make an additional check for the prefix only in the situation where regular expressions fail and the support for RTSP is missing, thus differentiating the case 4 from the case 5. Regular expressions remain unchanged.

I imagine that instead of:

if (!url.host) {
    MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, "%s: Invalid netcam_url (%s)", 
               cnt->conf.netcam_url);
    netcam_url_free(&url);
    return -1;
}

the changed code will look like this (I haven't written C for the last ten years, so I have no idea about the exact syntax; otherwise I would have forked the project to do the change myself):

if (!url.host) {
    char[] error_pattern = "%s: Invalid netcam_url (%s)";
    #ifndef have_av_get_media_type_string
    // RTSP support is missing.
    if (strncmp("rtsp://", tolower(cnt->conf.netcam_url)) == 0) {
        error_pattern = "%s: Invalid netcam_url (%s). RTSP is not supported by the current build; consider compiling the application with have_av_get_media_type_string option.";
    }
    #ifndef
    MOTION_LOG(CRT, TYPE_NETCAM, NO_ERRNO, error_pattern, 
               cnt->conf.netcam_url);
    netcam_url_free(&url);
    return -1;
}

So:

What if motion is built with rtsp support, but the stream URL is malformed?

This situation is not concerned: only the case where RTSP support is missing is.

from motion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.