Android Question cctv CAMERA

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
hello all
i have downloaded the cctv b4a client and b4j server they connected and run fine,
when i open the android app it gives the following error
Logger connected to: Xiaomi Redmi 6 Pro
--------- beginning of system
--------- beginning of crash
--------- beginning of main
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (communicator) Create ***
Connecting to: 10.0.0.203:17178
** Service (communicator) Start **
Client_Connected: true
90, 90
Supported sizes:
4000x3000
4000x2250
4000x2250
4000x2000
3840x2160
3264x2448
3200x2400
2976x2976
2592x1944
2688x1512
2592x1458
2592x1296
2048x1536
1920x1080
1920x960
1600x1200
1440x1080
1280x960
1280x768
1280x720
1280x640
1200x1200
1024x768
800x600
864x480
800x480
720x480
640x480
640x360
480x640
480x360
480x320
352x288
320x240
java.lang.Exception: Sub astreams_newdata was not found.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:202)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Unknown Source:2)
at android.os.Handler.dispatchMessage(Unknown Source:4)
at android.os.Looper.loop(Unknown Source:155)
at android.app.ActivityThread.main(Unknown Source:65)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
at com.android.internal.os.ZygoteInit.main(Unknown Source:345)
java.lang.RuntimeException: java.lang.Exception: Sub astreams_newdata was not found.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:233)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Unknown Source:2)
at android.os.Handler.dispatchMessage(Unknown Source:4)
at android.os.Looper.loop(Unknown Source:155)
at android.app.ActivityThread.main(Unknown Source:65)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
at com.android.internal.os.ZygoteInit.main(Unknown Source:345)
Caused by: java.lang.Exception: Sub astreams_newdata was not found.
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:202)
... 8 more
the downloaded example code b4a client as following
ok:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: False
    #ApplicationLabel: Camera example
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region
#Region  Activity Attributes
    #FullScreen: True
'    #IncludeTitle: True
      #BridgeLogger: True
#End Region
'Activity module
Sub Process_Globals
    Private frontCamera As Boolean = False
    Public ServerIp As String = "10.0.0.203"
    Public ServerPort As Int = 17178
    Private IntervalMs As Int = 150
    Private lastPreviewSaved As Long
End Sub

Sub Globals
    Private Panel1 As Panel
    Private camEx As CameraExClass
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    StartService(Communicator)
End Sub

Sub Activity_Resume
    InitializeCamera
End Sub

Private Sub InitializeCamera
    camEx.Initialize(Panel1, frontCamera, Me, "Camera1")
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    camEx.Release
End Sub

Sub Camera1_Ready (Success As Boolean)
    If Success Then
        camEx.StartPreview
        Log("Supported sizes:")
        For Each size As CameraSize In camEx.GetSupportedPicturesSizes
            Log(size.Width & "x" & size.Height)
        Next
        camEx.SetJpegQuality(40)
        Log(camEx.GetSupportedFlashModes)
        camEx.CommitParameters
    Else
        ToastMessageShow("Cannot open camera.", True)
    End If
End Sub

Sub btnTakePicture_Click
    camEx.TakePicture
End Sub

Sub Camera1_Preview (PreviewPic() As Byte)
    If DateTime.Now > lastPreviewSaved + IntervalMs Then
        Dim jpeg() As Byte = camEx.PreviewImageToJpeg(PreviewPic, 70)
        lastPreviewSaved = DateTime.Now
        CallSubDelayed2(Communicator, "Send", jpeg)
    End If
End Sub

Sub Camera1_PictureTaken (Data() As Byte)
    camEx.SavePictureToFile(Data, File.DirRootExternal, "1.jpg")
    camEx.StartPreview
End Sub

Sub btnEffect_Click
    Dim effects() As String = Array As String("aqua", "blackboard", "mono", "negative", "posterize", _
        "sepia", "solarize", "whiteboard")
    Dim effect As String = effects(Rnd(0, effects.Length))
    camEx.SetColorEffect(effect)
    ToastMessageShow(effect, False)
    camEx.CommitParameters
End Sub

Sub ChangeCamera_Click
    camEx.Release
    frontCamera = Not(frontCamera)
    InitializeCamera
End Sub
and the b4j server code id
main:
'Non-UI application (console application)
#Region  Project Attributes
    #CommandLineArgs:
    #MergeLibraries: False
#End Region

Sub Process_Globals
    Private srvr As Server
    Public images As Map
End Sub

Sub AppStart (Args() As String)
    srvr.Initialize("")
    srvr.Port = 17178

    srvr.AddHandler("/SendImage", "SendImage", False)
    srvr.AddHandler("/GetImages", "GetImages", False)
    srvr.AddHandler("/GetImage", "GetImage", False)
    srvr.Start
    images = srvr.CreateThreadSafeMap
    StartMessageLoop
End Sub
<<<<<<
server b4j error is
Waiting for debugger to connect...
Program started.
2020-01-22 19:15:27.524:INFO::main: Logging initialized @609ms to org.eclipse.jetty.util.log.StdErrLog
2020-01-22 19:15:27.691:INFO:eek:ejs.Server:main: jetty-9.4.z-SNAPSHOT
2020-01-22 19:15:27.757:INFO:eek:ejs.session:main: DefaultSessionIdManager workerName=node0
2020-01-22 19:15:27.757:INFO:eek:ejs.session:main: No SessionScavenger set, using defaults
2020-01-22 19:15:27.760:INFO:eek:ejs.session:main: Scavenging every 660000ms
2020-01-22 19:15:27.768:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@4909b8da{/,file:///C:/Users/ali/Desktop/CCTVServer/CCTVServer/Objects/www/,AVAILABLE}
2020-01-22 19:15:27.778:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened C:\Users\ali\Desktop\CCTVServer\CCTVServer\Objects\logs\b4j-2020_01_23.request.log
2020-01-22 19:15:27.802:INFO:eek:ejs.AbstractConnector:main: Started ServerConnector@430bdd6a{HTTP/1.1,[http/1.1]}{0.0.0.0:17178}
2020-01-22 19:15:27.802:INFO:eek:ejs.Server:main: Started @892ms
Emulated network latency: 100ms
2020-01-22 19:16:37.700:WARN:eek:ejh.HttpParser:qtp933699219-13: Illegal character 0xF2 in state=METHOD for buffer HeapByteBuffer@69e17e53[p=2,l=4,c=8192,r=2]={U\xF2<<<\x00\x00>>>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
2020-01-22 19:17:01.987:WARN:eek:ejh.HttpParser:qtp933699219-15: Illegal character 0xF0 in state=METHOD for buffer HeapByteBuffer@69e17e53[p=2,l=4,c=8192,r=2]={f\xF0<<<\x00\x00>>>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
2020-01-22 19:52:44.659:WARN:eek:ejh.HttpParser:qtp933699219-25: Illegal character 0xF in state=START for buffer HeapByteBuffer@69e17e53[p=1,l=4,c=8192,r=3]={\x0f<<<\xCe\x00\x00>>>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
2020-01-22 19:55:01.804:WARN:eek:ejh.HttpParser:qtp933699219-14: Illegal character 0xAC in state=METHOD for buffer HeapByteBuffer@69e17e53[p=2,l=4,c=8192,r=2]={`\xAc<<<\x00\x00>>>\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00...\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00}
i'd like to note that my camera lib version is 2.20,
i searched a lot but i did not find the error of( Sub astreams_newdata was not found.) in the forum,
i hope to solve that ,
thank you in advance.
 
Last edited:
Top