Search Unity

Video streaming via WebRTC?

Discussion in 'Scripting' started by weizenhuhn, Jan 2, 2017.

  1. weizenhuhn

    weizenhuhn

    Joined:
    Dec 5, 2016
    Posts:
    7
    Hello there,

    i'm creating currently a movie drone simulator, in which the drone got a pilot camera. The thing is now to watch the "output" of the camera on my android phone in real time. So i was thinking about 3 Steps:

    1. First i guess i have to render the video in a buffer on my pc
    2. Then i have to transfer this data over Network (i was thinking about WebRTC, to do this stuff)
    3. At the end i want to play this video at my smartphone

    Optional, if the data is too big, i have to compress the files first and later decompress on the phone again.
    All of this sounds quite tricky to me, because i'm no expert in Android and network coding.

    For the second point, i installed already WebRTC Network from the Asset Store. But i don't know how i should start. Does anybody have experience in this technologies and is able to give me some tips?
     

    Attached Files:

  2. weizenhuhn

    weizenhuhn

    Joined:
    Dec 5, 2016
    Posts:
    7
    I found now another solution for my purpose with these steps:

    1. Read the screen pixels to an empty Texture2D using Texture2D.ReadPixels

    2. Encode the Texture2D using EncodeToJPG or EncodeToPNG

    3. Send the encoded bytes to the device (through a socket to the device; or with this WebRTC solution)

    4. On the device: read the bytes into an image(using a combination of ByteArrayInputStream and BitmapFactory for example)

    I finished already the first two steps, but the third step is kinda trickey. I have no idea how to work with sockets, so I'm using now WebRTC. But how can i implement the JavaScript Code in my Unity Project? Can someone help me with that?
     
    Last edited: Jan 19, 2017