iOS Tutorial MJPEG / CCTV Server

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.


SS-2016-12-04_15.35.36.jpg
 

Attachments

  • CCTV.zip
    3.9 KB · Views: 896
Last edited:

Hypnos

Active Member
Licensed User
Longtime 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:

Hypnos

Active Member
Licensed User
Longtime User
Does it happen when there are less clients connected?

Are you running it in debug mode or release mode?

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:

Hypnos

Active Member
Licensed User
Longtime User
Are you running it in debug mode or release mode?

Are you checking the logs?

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
 

Hypnos

Active Member
Licensed User
Longtime User
There is no error in these logs.

You will need to add iReleaseLogger and hopefully it will provide more information.
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
)
 

Hypnos

Active Member
Licensed User
Longtime User
Seems removed the following line the app won't quit, any idea how to fix ?

mManager.ClientDisconnected(Me)
 

Hypnos

Active Member
Licensed User
Longtime 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.

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

Hypnos

Active Member
Licensed User
Longtime User
Do you get the same error?

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:
D

Deleted member 103

Guest
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
 
D

Deleted member 103

Guest
Hard to say. Have you tried to kill Safari and connect again?
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:
 
D

Deleted member 103

Guest
I see it as well. Not sure why it happens. A possible workaround is to create your own decoder.
[B4X] [class] MJPEG decoder
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?
 
Top