Coder Social home page Coder Social logo

castscreen's Introduction

CastScreen

Cast Android screen via WiFi or USB

Demo video: https://youtu.be/D_DSuvFz_sg

Requirments

  • Gstreamer 1.0 with H264 decoder (h264parse, avdec_h264)
  • adb for mirror via USB

With native receiver

  • If you are not on an ARM machine, ignore outputs from *_arm targets, or remove them from the Makefile.
  • Compile the receiver
$ cd receiver
$ make

Via WiFi

  1. Launch receiver
$ cd receiver
$ ./cs_receiver autovideosink
  1. Open CastScreen APP
  2. Wait the receiver to appear on the list
  3. Select the receiver
  4. Tap Start on right corner

Via USB

  1. Enable debug mode on the Android device
  2. Make sure adb is available on your PC
  3. Open CastScreen APP
  4. Select Server mode
  5. Tap Start on right corner
  6. Launch receiver
$ cd receiver
$ ./wait_adb.sh

With python receiver

Via WiFi

  1. Launch receiver
$ cd receiver
$ python cs_receiver.py
  1. Open CastScreen APP
  2. Wait the receiver to appear on the list
  3. Select the receiver
  4. Tap Start on right corner

Via USB

  1. Enable debug mode on the Android device
  2. Make sure adb is available on your PC
  3. Open CastScreen APP
  4. Select Server mode
  5. Tap Start on right corner
  6. Launch receiver
$ cd receiver
$ adb forward tcp:53516 tcp:53515
$ python cs_receiver_conn.py

Closing receivers

Ubuntu

Open system monitor, look up using the word receiver, and kill the process.

Using an alternative app.

You can use the receiver with the All Cast Receiver App as well. Just start a receiver as described above (the native receiver is faster than the python one).

License

Copyright (c) 2015-2016 Jones Chi. Code released under the Apache License.

castscreen's People

Contributors

botcyborg avatar chris-hatton avatar joneschi avatar vvasuki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

castscreen's Issues

你好 adb 没有reverse

由于大陆版的马自达悦联的openssl是1.0的,所以adb 需要重新编译.
我在本地编译adb 都没有reverse 这个参数 请问能提供下包含这个参数的adb 源地址么?

How do you actually get it to show?

So I have them connected and the console says it too but I cant see the screen?

Im on linux - rasbian.

I get this error too:


Exception happened during processing of request from ('192.168.0.3', 57524)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/lib/python2.7/SocketServer.py", line 655, in init
self.handle()
File "cs_receiver.py", line 38, in handle
p = Popen(['ffplay', '-framerate', '30', '-'], stdin=PIPE, stdout=PIPE)
File "/usr/lib/python2.7/subprocess.py", line 710, in init
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

Pipe to video0

For my needs i dont need to play the stream. The plan is to pipe it to video0 using videoloopback and then capture frames of it and do some other stuff.

Somebody ideas of modifying the receiver???

with something like this:

sudo gst-launch-1.0 -vv -e udpsrc host=IP-Adresse port=Port Nummer ! "video/x-raw,width=640,height=480,framerate=60/1" ! queue ! omxh264enc ! h264parse ! rtph264pay ! v4l2sink device=/dev/video0

RaspberryPi

Did you try this on raspberry pi ? I was executing it in pi zero w and the streaming didn't commence past first few frames. Any idea regarding this ?

CastScreen crashes immediately when run on Android 7.0+ because of a NetworkOnMainThreadException

Greetings,

Several people have reported crashes with CastScreen when it's been run on Android Nougat (7.0+). I did some looking around this evening and discovered that the error is due to a NetworkOnMainThreadException. According to this thread the issue has something to do with a change in the way strict mode checks are run (I'm not an Android developer, so you should probably read the thread rather than take my word for it.

Anyway, I was able to perform a workaround by using the code sample in comment #17. I put it just under super.onCreate() in the onCreate method, did a build, and CastScreen stopped crashing and worked properly on my Google Pixel.

This is what my onCreate method looked like after the change:

    @Override
    public void onCreate() {
        super.onCreate();
        StrictMode.ThreadPolicy policy =
                new StrictMode.ThreadPolicy.Builder()
                        .permitAll()
                        .penaltyLog()
                        .build();
        StrictMode.setThreadPolicy(policy);
        mMediaProjectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE);
        mBroadcastIntentFilter = new IntentFilter();
        mBroadcastIntentFilter.addAction(Common.ACTION_STOP_CAST);
        registerReceiver(mBroadcastReceiver, mBroadcastIntentFilter);
    }

There might be a more elegant or better solution to the problem, but if you're looking for something easy, apparently those 6 lines of code may allow people using Android 7.0 to use CastScreen again.

Receiver not seen on android App

Performed the steps for native receiver.
As was not on an ARM machine, removed *_arm targets from the Makefile.
Compiled the receiver.
Ran below commands:-
$ cd receiver
$ ./cs_receiver autovideosink
Opened cast screen app but no receiver appeared in list.

Unable to connect with python receiver via USB

Hi,
We are getting following error when we are trying to connect with python receiver via USB.

Connecting to localhost port 53516
Sending mirror cmd
Traceback (most recent call last):
File "cs_receiver_conn.py", line 70, in
connect_to_server()
File "cs_receiver_conn.py", line 46, in connect_to_server
data = sock.recv(bufferSize)
socket.error: [Errno 104] Connection reset by peer
root@santosh-HP-Pro-3330-MT:/CastScreen-master/receiver# ffplay version N-80901-gfebc862 Copyright (c) 2003-2016 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1
14.04.3)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Simple media player
usage: ffplay [options] input_file

An input file must be specified
Use -h to get full help or, even better, run 'man ffplay'

advance thanks,Awaiting your reply

server mode casting does not work.

Here is my wait_adb output:

/wait_adb.sh 
cs_receiver: no process found
wait adb device
Using sink: autovideosink
adb device presents, reverse port
got dev
Receive broadcast msg: hello from: 192.168.1.3:42014
Receive discover msg: hello, from: 192.168.1.3
Response discover msg with local ip: 192.168.1.4
got dev
Receive broadcast msg: hello from: 192.168.1.3:42014
Receive discover msg: hello, from: 192.168.1.3
Response discover msg with local ip: 192.168.1.4
got dev
Receive broadcast msg: hello from: 192.168.1.3:42014
Receive discover msg: hello, from: 192.168.1.3
Response discover msg with local ip: 192.168.1.4
got dev
Receive broadcast msg: hello from: 192.168.1.3:42014
Receive discover msg: hello, from: 192.168.1.3
Response discover msg with local ip: 192.168.1.4
got dev

,and my adb log is here.

via wifi issue

Using sink: autovideosink
Receive broadcast msg: hello from: 192.168.1.12:51297
Receive discover msg: hello, from: 192.168.1.12
Response discover msg with local ip: 192.168.1.33
Receive broadcast msg: hello from: 192.168.1.12:60473
Receive discover msg: hello, from: 192.168.1.12
Response discover msg with local ip: 192.168.1.33
Accept peer addr: 192.168.1.12:53308
Receive control data(79): POST /api/v1/h264 HTTP/1.1
Connection: close
X-WIDTH: 1280
X-HEIGHT: 720
width: 1280
height: 720
gst pid: 8402
gst in fp: 11
WARNING: erroneous pipeline: no element "autovideosink"
WARNING: erroneous pipeline: no element "autovideosink"

two warnings, no gui

Window 7

I am not able to connect device to desktop. I have on list of server mode. I want to connect using usb.

Closes after ~5 mins (Mazda Binary)

Seems recently you committed Fix socket closed by wrong no-data state .

I'm wondering if this solves the issue. The screen cast works brilliantly for about mins or so and just stops without warning. Rebooting the infotainment system is only thing that works for me. Does your latest commit solve this issue?

If it does, would you mind compiling another binary I can drop into my Mazda? I don't know how to compile for arm.

Thanks a ton for your work on this!

Unable to press "start now". logs and video attached.

Android log here.

Video here - nothing happens on pressing "start now".

wait_adb output:

~/CastScreen/receiver$ ./wait_adb.sh 
wait adb device
Using sink: autovideosink
adb server is out of date.  killing...
* daemon started successfully *
adb device presents, reverse port
got dev
got dev
got dev

Failing to Connect to Socket From Client Side

In android client i am trying to make connection with IP address of the system which is running server not "localhost" by editing the textfield near Input Receiver.
But when i Try to connect the socket it throws IOException.

06-22 19:04:28.355 20642-20660/com.yschi.castscreen:remote E/CastService:android.system.ErrnoException: connect failed: ETIMEDOUT (Connection timed out)
06-22 19:04:28.366 20642-20660/com.yschi.castscreen:remote W/System.err:     at java.net.Socket.<init>(Socket.java:248)
        at com.yschi.castscreen.CastService$5.run(CastService.java:536)
        at java.lang.Thread.run(Thread.java:764)
06-22 19:04:28.368 20642-20642/com.yschi.castscreen:remote E/CastService: Failed to create socket to receiver, ip: XX.XXX.X.XXX

CastScreen Resolution

Is there anyway to force 16:9 aspect ratio on this app. Reason being that the Galaxy S8 has a 18:5:9 ratio and it causes black bars to appear on the top and bottom of a good part of the screen.

Supported Phone Model ?

I installed CastScreen on MZD Connect with MZD-AIO-TI 2.3.7 and installed the castscreen-1.0.apk on my phones.
It's working on HTC J One (Japanese M7) via USB but not via WiFi.
And it's not working on HTC One A9 either via USB or WiFi.
Is it about the phone model? What phone Models are supported?

我也是台灣人所以另外用中文表達,以免你看不懂我的英文 XDD
我用MZD-AIO-TI 2.3.7去安裝了CastScreen到我的MZD Connect上
然後也在手機上安裝了 castscreen-1.0.apk
我有2支手機:HTC J One(日本版的M7) 及 HTC One A9
結果HTC J One 的USB可以鏡像但WiFi沒反應
HTC One A9則是USB或WiFi都沒反應
請問是因為CastScreen會挑手機嗎? 哪些手機是可以的?

另外因為用WiFi兩支手機都不行 所以我補上WiFi的開啟步驟 如果是我操作錯誤麻煩鞭我XDD
1.開啟手機熱點
2.開啟MZD的WiFi連上手機熱點,並從手機上看到MZD的IP:192.168.1.164
3.在手機上開啟CastScreen App,Input Receiver輸入192.168.1.164,按Input Receiver按鈕
4.按Start
(然後手機及MZD都沒變化,包括手機的通知欄也沒跑出CastScreen)

touch input

My android mirrors correctly, but when I touch my mazda 3 (2014 sgt) touchscreen, no input is registered to the phone. Is there a way to get it working? If not, any hints on where in the code should I look to implement this functionality?

Don't connect

Does Not authorize device and can't connect (just on second I see Cast Screen icon and then it hiding)
Mircomax Q415, not root (Android 5.1.1)

predefined_h264_header

Hello

thanks for publishing your code. What i want is to stream with low latency.
To lower down the latency i will try to change resolution, framerate and bitrate.

Could you help me? Like i see to change this, is to declare a new specific prefinded header for.
But dont find out yet, maybe you have some tips for me to do changes.

Thanks and best regards
Rudi

Can I download app for android 4.4?

Can I download app for android 4.4?
My phone is kinda old school.

Actually, I tweaked my Mazda infortainment as like Mazda AIO.
I realized my tab of android 6.0 can be installed but my phone is not.

Cannot start streaming in windows

Hello,
After doing everything right, and setting up fplay,the receiver does not start.

I am stuck at this message :
Recv control data: b'POST /api/v1/h264 HTTP/1.1\r\nConnection: close\r\nX-WIDTH: 1280\r\nX-HEIGHT: 720\r\n\r\n'

Please help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.