Better example is available here: https://www.b4x.com/android/forum/threads/mjpeg-cctv-server.73792/
This example is made of two components:
Client - Basic4android program that takes the camera preview frames and sends them to the server.
Server - C# program that accepts incoming connections and shows the camera frames.
The code of both components is pretty simple and is a good example of creating network based solutions. Note that both the client and server components should overcome network problems and continue to work when the network is again available.
How to run this example
1. Find the desktop ip address (you can run ipconfig from the command line).
2. Set this address in the device program - ServerIp variable.
Most complicated step:
3. By default Windows firewall blocks incoming connection. You need to open the firewall settings and add an exception for port 17178 (TCP).
Windows 7:
Run the desktop program and press Start.
Run the device program and check the logs in the IDE.
The source code of both projects is attached as well as the compiled desktop executable.
This example requires Android 2.2+ as the API that converts the preview image to JPEG is not available on older devices. The reflection library is also required.
Feel free to ask any question about this implementation.
The client code was updated to use CameraEx class. Note that it requires Camera library v2.0+.
This example is made of two components:
Client - Basic4android program that takes the camera preview frames and sends them to the server.
Server - C# program that accepts incoming connections and shows the camera frames.
The code of both components is pretty simple and is a good example of creating network based solutions. Note that both the client and server components should overcome network problems and continue to work when the network is again available.
How to run this example
1. Find the desktop ip address (you can run ipconfig from the command line).
2. Set this address in the device program - ServerIp variable.
Most complicated step:
3. By default Windows firewall blocks incoming connection. You need to open the firewall settings and add an exception for port 17178 (TCP).
Windows 7:
Run the desktop program and press Start.
Run the device program and check the logs in the IDE.
The source code of both projects is attached as well as the compiled desktop executable.
This example requires Android 2.2+ as the API that converts the preview image to JPEG is not available on older devices. The reflection library is also required.
Feel free to ask any question about this implementation.
The client code was updated to use CameraEx class. Note that it requires Camera library v2.0+.
Attachments
Last edited: