anribras / Android-cast-and-control

Cast and control your non-screen(broken or missing or too expensive or whaterver) Android devices in PC
Apache License 2.0
1 stars 2 forks source link

What do those streamer-*.0 files do? #1

Open oujibahei opened 5 years ago

anribras commented 5 years ago

@oujibahei Hi! It's run on Andrid device through adb. To produce screen display image(jpeg), actually.

oujibahei commented 5 years ago

@anribras Hi, you did a really good job.:) And could you please tell me why did you make this choice of producing screen display via stream-*.0 file, instead of using 'adb shell screenrecord'?

anribras commented 5 years ago

@oujibahei It's very close to screenrecord but do more things than it. Firstly It encodes image in jpeg format(screendrecord using raw RGB encoding I remember), secondly it sends the jpeg image out throught TCP over usb(adb forward ) in real-time, while screenrecord only saves file in local.

Burlesque1 commented 5 years ago

@anribras Could you please share the source code of the stream-8.0 file? I would like to do the similar job for Pie.

anribras commented 5 years ago

@Burlesque1 Sorry, for now it 's not convenient to open source ..But a better reference you can check out is in stf-minicap ,and Project STF might be the one you want. By the way @oujibahei are your guys ? Did you run this program in your environment successfully already ?

oujibahei commented 5 years ago

No, we are not together. I can only run the gui but always fails at the if-statement below in client.py, not receiving anything from cell phone.


if header.MsgCommand == ServerCommands.LinkUsable.value[0]:
        # client tell server  its screen paras
        resp = CommandHeader()
        resp.MsgCommand = ClientCommands.UPDATE_MOUSE.value[0]
        resp.MsgParam = ClientParas.Send2PhoneEvent_SetProperty_Display.value[0]
        # view=(1280,720,1280,720,0,0),
        # full weight and height
        resp.unkown = view[0]
        resp.unkown1 = view[1]
        # view
        resp.width = view[2]
        resp.height = view[3]
        # base
        resp.startx = view[4]
        resp.starty = view[5]

        ret = fd.send(StructConverter.decoding(data=resp))
        LOGGER.info('sending paras.')

        resp = CommandHeader()
        # client tell server  to start h264 streamer
        resp.MsgCommand = ClientCommands.StartH264Trans.value[0]

        ret = fd.send(StructConverter.decoding(data=resp))
        LOGGER.info('sending start-streamer.')
        # client prepare for streaming show

        # client prepare a job thread to recv lots of streaming data from 10000
        streamerJob = Job(target=streamer_threading,
                        args=(fd, stream_cbs), loop=True)
        streamerJob.start()
        LOGGER.info('start client streamerJob..')
        streamerJob.join()
        LOGGER.info('client streamerJob done')
    else:
        LOGGER.info('Try again')
        return -1`
oujibahei commented 5 years ago

I found the problem is streamer- file always gets 'permission denied' by system, and the reason is the filesystem has a flag '-noexec' for the format. Is any solution for that?

anribras commented 5 years ago

I found the problem is streamer- file always gets 'permission denied' by system, and the reason is the filesystem has a flag '-noexec' for the format. Is any solution for that?

Details should be in adbwapper.py:

I pushed file into /data/local/tmp ,so you can check that directory and authority is meet or not. Tr

Which Anroid version is on your device ? 8.0 is recommended.

oujibahei commented 5 years ago

I am using Android 8.0 on Samsung S7. I just encounter an error of 'segmentation error' when I execute streamer-8.0 file, same error as I execute minicap.so file. Do you have any idea of it?

oujibahei commented 5 years ago

Here's sth I think might be helpful. I was trying to running server and client separately and it seems the server is OK but the client side not receive correct response.

139|hero2qltechn:/ $ data/local/tmp/streamer-8.0 Streamer start input ports: 010000 accepting...

python client.py [Tue,15 Jan 2019 18:06:08.575][client.py:136][INFO] exec name: streamer-8.0 [Tue,15 Jan 2019 18:06:09.580][client.py:162][INFO] <socket.socket fd=908, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 58543), raddr=('127.0.0.1', 10000)> [Tue,15 Jan 2019 18:06:09.580][client.py:174][INFO] recving... [Tue,15 Jan 2019 18:06:09.592][client.py:176][INFO] recving done [Tue,15 Jan 2019 18:06:09.593][client.py:180][INFO] 1st msgcmd(0) phone w(0) h(0) [Tue,15 Jan 2019 18:06:09.593][client.py:219][INFO] Try again

anribras commented 5 years ago

Here's sth I think might be helpful. I was trying to running server and client separately and it seems the server is OK but the client side not receive correct response.

139|hero2qltechn:/ $ data/local/tmp/streamer-8.0 Streamer start input ports: 010000 accepting...

python client.py [Tue,15 Jan 2019 18:06:08.575][client.py:136][INFO] exec name: streamer-8.0 [Tue,15 Jan 2019 18:06:09.580][client.py:162][INFO] <socket.socket fd=908, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 58543), raddr=('127.0.0.1', 10000)> [Tue,15 Jan 2019 18:06:09.580][client.py:174][INFO] recving... [Tue,15 Jan 2019 18:06:09.592][client.py:176][INFO] recving done [Tue,15 Jan 2019 18:06:09.593][client.py:180][INFO] 1st msgcmd(0) phone w(0) h(0) [Tue,15 Jan 2019 18:06:09.593][client.py:219][INFO] Try again

Try sth like:

/data/local/tmp/streamer-8.0 50 10000 phone 0 & 

Sorry it's been long time since my last updating I am not sure of it.

oujibahei commented 5 years ago

It does move forward a little bit :), but got this 'not supported sFormat' error

255|hero2qltechn:/ $ data/local/tmp/streamer-8.0 50 10000 phone 0 &
[1] 13131
hero2qltechn:/ $ Streamer start
input ports: 010000 accepting...
Accept client 127.0.0.1:55921
New Connect (6)
[Ecolink] EntryLoop
Broadcasting: Intent { act=com.leauto.elink.android.action.CONNECTED flg=0x400000 }
Broadcast completed: result=0
10000 accepting...
sc(x,y) = (1440 2560)
base(x,y) = (0 0)
view(x,y) = (144 256)
Start h264 encoding/trans
thread_encoder allowed
not supported sFormat , program should exit

when the program execute ClientCommands.StartH264Trans.value[0] here in client.py

        # client tell server  to start h264 streamer
        resp.MsgCommand = ClientCommands.StartH264Trans.value[0]
        ret = fd.send(StructConverter.decoding(data=resp))
        LOGGER.info('sending start-streamer.')

Thanks so much for ur patience.

anribras commented 5 years ago

It does move forward a little bit :), but got this 'not supported sFormat' error

255|hero2qltechn:/ $ data/local/tmp/streamer-8.0 50 10000 phone 0 &
[1] 13131
hero2qltechn:/ $ Streamer start
input ports: 010000 accepting...
Accept client 127.0.0.1:55921
New Connect (6)
[Ecolink] EntryLoop
Broadcasting: Intent { act=com.leauto.elink.android.action.CONNECTED flg=0x400000 }
Broadcast completed: result=0
10000 accepting...
sc(x,y) = (1440 2560)
base(x,y) = (0 0)
view(x,y) = (144 256)
Start h264 encoding/trans
thread_encoder allowed
not supported sFormat , program should exit

when the program execute ClientCommands.StartH264Trans.value[0] here in client.py

        # client tell server  to start h264 streamer
        resp.MsgCommand = ClientCommands.StartH264Trans.value[0]
        ret = fd.send(StructConverter.decoding(data=resp))
        LOGGER.info('sending start-streamer.')

Thanks so much for ur patience.

This is a compatibility issue, and Android devices have too many similar problems. I suggest you try another 8.0 device :)

oujibahei commented 5 years ago

I've tried several phones, none of them works. T T Could you please explain the args 'interval(=50)' 'device(=phone)' 'device_id(0)' in data/local/tmp/streamer-8.0 50 10000 phone 0 & for me? thx.

anribras commented 5 years ago

I've tried several phones, none of them works. T T Could you please explain the args 'interval(=50)' 'device(=phone)' 'device_id(0)' in data/local/tmp/streamer-8.0 50 10000 phone 0 & for me? thx.

There are some tricky settings in streamer:

interval ---- one jpeg image sent per `interval` ms by streamer.
device --- it's phone
device_id is for Android display id , default is 0.

are all they the same log like "not supported sFormat"?

I will consider to update this project lately, see if it works then.