iOS Tutorial MJPEG / CCTV Server

Discussion in 'iOS Tutorials' started by Erel, Dec 5, 2016.

  1. Erel

    Erel Administrator Staff Member Licensed User

    This is a port of this example to B4i: https://www.b4x.com/android/forum/threads/mjpeg-cctv-server.73792/

    The code is almost identical.

    It turns the iOS device into a CCTV server. You can connect to the device from one or more browsers to see the captured video.

    The frame rate is currently set to 6 frames per second. You can change it by modifying IntervalMS. Set it to 50 (1000 / 50 = 20 fps) and it will look much better.


    [​IMG]
     

    Attached Files:

    Last edited: Dec 5, 2016
  2. Hypnos

    Hypnos Active Member Licensed User

    The B4I example sometimes quit automatically when I press the reload/stop button on my browser when view it. how can I handle this error?

    Thanks!
     
    Last edited: Dec 26, 2016
  3. Erel

    Erel Administrator Staff Member Licensed User

    Does it happen when there are less clients connected?

    Are you running it in debug mode or release mode?
     
  4. Hypnos

    Hypnos Active Member Licensed User

    Yes, it happen when there are less clients connects, still try to figure it out and I'm running on release mode. (seems no problem on debug mode)
     
    Last edited: Dec 25, 2016
  5. Erel

    Erel Administrator Staff Member Licensed User

    Are you running it in debug mode or release mode?

    Are you checking the logs?
     
  6. Hypnos

    Hypnos Active Member Licensed User

    I'm running on release mode.

    In Debug mode I got some error / new connection in log if I press the browser stop/reload button, but the app won't quit.

    The log like this in debug:

    Application_Start
    Application_Active
    New connection
    Error
    New connection
    GET /favicon.ico HTTP/1.1
    New connection
    Error
    New connection
    GET /favicon.ico HTTP/1.1
    New connection
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    There is no error in these logs.

    You will need to add iReleaseLogger and hopefully it will provide more information.
     
  8. Hypnos

    Hypnos Active Member Licensed User

    Hi Erel,

    Here is the Error Log:

    GET /favicon.ico HTTP/1.1

    New connection
    New connection

    Error
    Class (b4i_client) instance released.
    Target is null. Method called: _astream_error
    Stack Trace: (
    CoreFoundation <redacted> + 148
    libobjc.A.dylib objc_exception_throw + 56
    CoreFoundation <redacted> + 0
    CCTV +[B4I runDynamicMethod:method:throwErrorIfMissing:args:]
    + 192
    CCTV -[B4I raiseEvent:event:params:] + 464
    CCTV __50-[B4I raiseEventFromDifferentThread:event:params:]_bl
    ock_invoke + 60
    libdispatch.dylib <redacted> + 24
    libdispatch.dylib <redacted> + 16
    libdispatch.dylib _dispatch_main_queue_callback_4CF + 1000
    CoreFoundation <redacted> + 12
    CoreFoundation <redacted> + 1660
    CoreFoundation CFRunLoopRunSpecific + 444
    GraphicsServices GSEventRunModal + 180
    UIKit <redacted> + 684
    UIKit UIApplicationMain + 208
    CCTV main + 124
    libdyld.dylib <redacted> + 4
    )
     
  9. Hypnos

    Hypnos Active Member Licensed User

    Seems removed the following line the app won't quit, any idea how to fix ?

    mManager.ClientDisconnected(Me)
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    I've uploaded a new version. It uses CallSubUtils to add a delay before the client is removed from the list. This solves issues related to the fact that AsyncStreams_Error event can be raised multiple times.
     
    Hypnos likes this.
  11. Hypnos

    Hypnos Active Member Licensed User

    Thank you Erel, it's better than before but I still got some crash. :(
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    Do you get the same error?
     
  13. Hypnos

    Hypnos Active Member Licensed User

    The strange thing is if I enable the iRelease Logger, the app won't crash... (maybe the logger make some delay of the connection??), I will upload the log here if I can able to get the error log later).

    Not sure Andriod version also need the CallSubUtils?

    Thanks Erel!
     
    Last edited: Dec 28, 2016
  14. Erel

    Erel Administrator Staff Member Licensed User

    No.

    Are you using the latest B4i version? It might solve this issue.
     
  15. Hypnos

    Hypnos Active Member Licensed User

    I'm using B4i v3.01, and I will try it v3.50 later.
     
  16. Filippo

    Filippo Expert Licensed User

    Hi,

    I have a strange behavior in my iPad mini (iOS version 11.3), the Safari browser does not show pictures (see photo).
    Only the Safari on my iPhone with iOS version 10.3.3 works.
    20180501_082738.jpg
     
  17. Erel

    Erel Administrator Staff Member Licensed User

    Hard to say. Have you tried to kill Safari and connect again?
     
  18. Filippo

    Filippo Expert Licensed User

    I have already tried with 3 iOS devices, it works with none.
    1) iPad mini
    2) iPhone 6+
    3) iPhone 6
    All 3 devices have iOS version 11+

    Only with my old iPhone 5 with iOS version 10 works.

    I have already tried many settings, all without success. :(

    Apple! :mad::mad::mad:
     
  19. Erel

    Erel Administrator Staff Member Licensed User

  20. Filippo

    Filippo Expert Licensed User

    Hi Erel,
    I have tested your decoder with B4i.
    After the connection, however, only the first picture is displayed and the transfer is terminated.
    I do not think that's normal, right?
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice