0

I am capturing jpegs from an IP camera. I upload it to my server via web service. I then render the image to a canvas. A User can then view the motion via a browser.

I had been using 4 ip cameras at a resolution of 360x288 each channel. The byte array size is typically 15kb.

Switching to the single ip camera with a resolution of 720x576 increaes the payload of the byte array to 4 times the single camera of 360x288.

I had noticed this question and answer here:

Splitting a byte[] into multiple byte[] arrays in C#

The person who gave the ticked answer suggests do not use a byte array at all. Just stream it. Currently, I am using WCF TCP binding and I was wondering how could I implement this streaming option in this setup?

How would I use this for consecutive images (as opposed to a single video file)?

What would the code look like? I am googling as I type but would it not be better to split the large byte array into 2 smaller ones and upload seperalty and then recombine on the server?

I am using c#

Community
  • 1
  • 1
Andrew Simpson
  • 6,883
  • 11
  • 79
  • 179

1 Answers1

1

I would suggest the streaming approach as it is much simpler than going through all of the work in reconstructing the image file on the server side.

NetTcpBinding supports the TransferMode of Streamed. The main limitation is that you cannot use the SecurityMode of Message.

You would configure it as such:

<configuration>
    <system.serviceModel>
        <services>
            <service name="PhotoUploadService">
                <endpoint name="" binding="netTcpBinding"
                    address="net.tcp://localhost:8000"
                    contract="IPhotoUploadService"
                    bindingConfiguration="streamedTcpBinding" />
            </service>
        </services>
        <bindings>
            <netTcpBinding>
                <binding name="streamedTcpBinding" 
                  transferMode="Streamed" 
                  maxReceivedMessageSize="2147483647"
                  maxBufferSize="65536" />
            </netTcpBinding>
        </bindings>
    </system.serviceModel>
</configuration>
Derek W
  • 9,708
  • 5
  • 58
  • 67