Hello
I am trying to write a MJPEG stream receiver/decoder with B4A.
I have code that connects to the cameras, logs in, and recives the stream of data chunks, I am current displaying the data in a label.
The next part "Should" be simple and something I have coded on different platforms before. BUT I can not process the data in B4A. Normally I would use a string (the decoding is all string operations) and in the socket data received event:
Sub TcpStreams_NewData (buffer() As Byte)
BufferString = BufferString & BytesToString(buffer, 0, buffer.Length, "UTF8")
But this generates a huge memory leak, thats because the strings in B4A are imputable so a new string is used each time.
Next I tried using string builder and the append method, which generates the same memory issue, and now I am at a loss as to which structure I should use. This process is going to be run at least 25 times per second (thats how fast the label updates with the data), and perhaps 100 times per second depending on how the data is "chunked". Using a massive byte array, while maintaining a pointer might work but the string conversions would be too slow.
Can anyone help me out with some advice, I am new to B4A ?
Thanks
Huw
I am trying to write a MJPEG stream receiver/decoder with B4A.
I have code that connects to the cameras, logs in, and recives the stream of data chunks, I am current displaying the data in a label.
The next part "Should" be simple and something I have coded on different platforms before. BUT I can not process the data in B4A. Normally I would use a string (the decoding is all string operations) and in the socket data received event:
Sub TcpStreams_NewData (buffer() As Byte)
BufferString = BufferString & BytesToString(buffer, 0, buffer.Length, "UTF8")
But this generates a huge memory leak, thats because the strings in B4A are imputable so a new string is used each time.
Next I tried using string builder and the append method, which generates the same memory issue, and now I am at a loss as to which structure I should use. This process is going to be run at least 25 times per second (thats how fast the label updates with the data), and perhaps 100 times per second depending on how the data is "chunked". Using a massive byte array, while maintaining a pointer might work but the string conversions would be too slow.
Can anyone help me out with some advice, I am new to B4A ?
Thanks
Huw