this example is based to all cctv Erel's examples and i was able to resolve the error i submit here https://www.b4x.com/android/forum/threads/camera-preview-memory-leak.73321/#post-485143
the fix was Camera example that use libraries Camera,Core,Phone,Reflection and the class CameraEx
as server i use xampp or external php+mysql hosting
how i said in the link above you must install in database test the table:
CREATE TABLE `chezzeina_video` ( `id` INT NULL AUTO_INCREMENT , `pic` LONGBLOB NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;
if you have xampp with password edit put.php and get.php and change the password you have.
the quick generate table is open localhost/phpmyadmin/ click on left on test then in the middle up to sql then paste that then push 'go'.
localhost is 127.0.0.1 so you must have the phone and the pc (or any other seccond device) in the same network(connected to the same router,or conected by bluetooth tethering and internet sharing, or wireless tethering with internet sharing or the last : wifi direct from pc with the pc connected by lan,wifi key adapter,.....any method).so go to pc to find out your ip ,basicly in windows 10 go to Network Connections (in my case i am connected via wireless) so click right over Wi-Fi ,status, detailes and see the ip4 address.
if you are advanced see ipconfig /all with the same results..
in my case my lan ip is 192.168.43.227 you can see it in client b4a 's source.
the php code had in index a style part what will rotate 90 degrees your image.
using this method i have no more errors ,no more green images no memory leaks like the guy report that in the link i provide in the header of this post.
Thanks to Erel for camera and cctv posts and i hope someone much advanced in java and b4a will discover how to arround that error to obtain more efficients.
if will not use as server these php files you can use the server of Erel's example one of them :
my php version of server part had blinks because jquery methods to load frames have some delays from pic's time loading (the blink will be increased by internet speed too and the speed of downloading of the host where you put that =lan/external).
for external hosting you may set the mysql password in the way i said and to upload the files via ftp over your hosted php plan(that will allow you even you have restrictions cause this method reads from posts a frame and it's send it to mysql blob reccord , so is a very basic stuff ,common nothing special).
IN XAMPP CASE ON WINDOWS / LINUX UBUNTU OVER A PC I HOPE YOU UNDERSTAND WHAT IS MEAN ADD FIREWALL EXCEPTIONS FOR XAMPP.IF YOU DON'T KNOW THIS PART I SUGEST YOU GOOGLEIZE OR YOUTUBIZE A FIREWALL EXCEPTION TO SEE MORE..
i know what was wrong with that cctv examples and why i got green images.
i check images stored in mysql i found the size is increase. so i put in main of b4a pasting from Erel's examples setpreviewsize parts and the sub in cameraex sub as well
Sub Camera1_Ready (Success As Boolean) If Success Then camEx.StartPreview camEx.SetJpegQuality(100) camEx.SetPreviewSize(640, 480) camEx.CommitParameters Else ToastMessageShow("Cannot open camera.", True) End If End Sub
Public Sub SetPreviewSize(Width As Int, Height As Int) r.target = parameters r.RunMethod3("setPreviewSize", Width, "java.lang.int", Height, "java.lang.int") End Sub
mades these modifies will results again in green images.it's this the source of errors i have with other examples
DONE ! DONE ! DONE ! DONE !
Sub Camera1_Ready (Success As Boolean)
If Success Then
ToastMessageShow(640 & "x" & 480, False)
' I THINK THIS IS WORKING LIKE A
' SMALL DELAY AND HAD MILISECCONDS TIME TO PUT
' THERE INFO BEFORE COMIT
ToastMessageShow("Cannot open camera.", True)
so the final is
put this part in main
Sub Camera1_Ready (Success As Boolean) If Success Then camEx.StartPreview camEx.SetPictureSize(640, 480) camEx.delay(100) camEx.SetJpegQuality(100) camEx.CommitParameters Else ToastMessageShow("Cannot open camera.", True) End If End Sub
and in CameraExClass put this
public Sub delay(lG_SleepEndMs As Long) Do While (DateTime.Now < lG_SleepEndMs) Loop End Sub
thank you briaoh https://www.b4x.com/android/forum/threads/sleep-for-milliseconds.69984/#post-444262
done ! no more image blinks !!!
modify index.php to
the best results i got i uploaded on update3_all_b4a_cctv_plus+php.zip
i have no more errors,no blinkin images,i can set any resolution
thanks Erel and all who posting to help everybody
Update 3 hot
you can now streaming images and audio in the same time or not.
is like walkie talkie but video!
you may drop/update old table from the last update and run this new code in phpmyadmin
now are 2 tables first for images and the seccond you guess .. for audio small wavs..
CREATE TABLE `chezzeina_video` ( `id` INT NULL AUTO_INCREMENT , `pic` LONGBLOB NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB; CREATE TABLE `chezzeina_audio` ( `id` INT NULL AUTO_INCREMENT , `audio` longblob NOT NULL, `viewed` varchar(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE = InnoDB;
i had troubles to redirect direct Audiostreamer to external audio player (because i had limited experience with b4a and cause is raw audio and i don't know how to apply wav header direct to a audiostreamer buffers() Byte . )
Update 4 better
register audio how much you want(you may experiment yourself the max lenght for audio)
the database will not be filled by a lot of content anymore(will delete old views)
the image you can put it anywhere on page see php part
all these modifies in Update4.zip