rtang
Posts: 49
Joined: Mon Oct 08, 2012 6:27 am

Piracast (Miracast on Pi) Beta Release

Mon Nov 11, 2013 6:46 pm

This is a post on the Piracast project, source code released under GPL: https://github.com/codemonkeyricky/piracast
To compile and run, see README in the repository.

Limitations:
- Only works with TP-LINK TL-WN725N (Miracast requires hardware support, so it can't run on all Wifi dongles. I've only included the driver for this specific dongle). The specific one I have is a V2 (version 2).
- Only works with the 2014-01-07 (also work with 2013-12-20) Wheezy Raspbian image. The application will NOT work with previous version of the images because the driver has kernel version dependencies.
- Video only comes out of HDMI, audio only comes out of 3.5mm port (audio from HDMI will be in later release - ran out time).
- Does not support HDCP (the Pi doesn't provide an interface for HDCP decrypt).

Note:
- You MUST use the wifi dongle driver provided by the project. The provided driver has wifi-direct display support compiled in.
- The installation package installs a DHCP server and configures a static IP address on your wireless interface. If you don't know what that means, then you probably want to perform the next bullet.
- Exercise caution and back up your image if you are unfamiliar with Linux

Instruction & Demo Videos

Video of Piracast running:
http://www.youtube.com/watch?v=_xt3gBUbOvw&t=1m19s

Confirmed working based on feedback:
- Nexus 4
- Nexus 10
- LG G-Pad (LG-V500)

May or may not work:
- Samsung phones. Samsung patches the Android OS to include additional value adds. From what I was told depending on the firmware some Samsung phones only connects if HDCP is enabled (the Pi doesn't provide an interface for HDCP decrypt). Some users have reported getting their Galaxy S4 working, some reported otherwise. I personally tried a Galaxy Note and couldn't get it to work.

Confirmed NOT working based on feedback:
- Asus T100
- Galaxy s4

Releases: I have removed all release packages. Please refer to README in the github repository for installation instruction.
- 02/01/2014 Update: I've made some update based on feedbacks from user baumi (huge thanks), and addressed some asserts associated with m2ts interpretation. Hopefully this will address some of the issues some users are experiencing.

Please let me know if you have any questions or feedbacks.

Thank you,

Richard
Last edited by rtang on Sun Feb 02, 2014 10:44 pm, edited 32 times in total.

futaris
Posts: 6
Joined: Wed Sep 28, 2011 1:50 am

Re: Piracast (Miracast on Pi) Beta Release

Tue Nov 12, 2013 12:11 am

I think you mean the TP-LINK TL-WN725N ...

rtang
Posts: 49
Joined: Mon Oct 08, 2012 6:27 am

Re: Piracast (Miracast on Pi) Beta Release

Tue Nov 12, 2013 1:15 am

futaris wrote:I think you mean the TP-LINK TL-WN725N ...
Yes, you are right. I have updated the original post. Thanks.

davidte
Posts: 3
Joined: Wed Nov 13, 2013 1:27 pm

Re: Piracast (Miracast on Pi) Beta Release

Wed Nov 13, 2013 1:33 pm

I have a problem!
When the smartphone are connecting to piracast, after of "Wireless display negotiation completed"

Code: Select all

Traceback (most recent call last)
  File "usr/local/lib/python2.7/dist-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
  File "main.py", line 45, in <module>
  File "main.py", line 17, in leased_ip_get
IndexError: list index out of range.
Tested with with nexus 4, xperita tablet z, lg g2, same error.
Thank for your work!

rtang
Posts: 49
Joined: Mon Oct 08, 2012 6:27 am

Re: Piracast (Miracast on Pi) Beta Release

Wed Nov 13, 2013 3:30 pm

davidte wrote:I have a problem!
When the smartphone are connecting to piracast, after of "Wireless display negotiation completed"

Code: Select all

Traceback (most recent call last)
  File "usr/local/lib/python2.7/dist-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
  File "main.py", line 45, in <module>
  File "main.py", line 17, in leased_ip_get
IndexError: list index out of range.
Tested with with nexus 4, xperita tablet z, lg g2, same error.
Thank for your work!
Thanks for trying the app. Three questions:

1. Is your dhcp lease saved to the following location?
/var/lib/dhcp/dhcpd.leases
2. Can you post the content of the file?
3. What's the version of the python installed?

The app determines what IP was leased by looking at the file, then it uses the [-1] index to get the latest entry. The application is for whatever reason reporting index is out of bound (possibly due to parsing failure).

davidte
Posts: 3
Joined: Wed Nov 13, 2013 1:27 pm

Re: Piracast (Miracast on Pi) Beta Release

Thu Nov 14, 2013 1:48 pm

1º & 2º - No, the dhcpd.leases is empty
Only this:

Code: Select all

#The format of this file is documented in the dhcpd.leases(5) manual page.
#This lease file was written by isc-dhcp-4.2.2
3º Python version 2.7.3

Is a new install of 2013-09-25 Wheezy Raspbian image
With LG G2 never goes out of
"read_all_sta"

davidte
Posts: 3
Joined: Wed Nov 13, 2013 1:27 pm

Re: Piracast (Miracast on Pi) Beta Release

Thu Nov 14, 2013 2:56 pm

Now with Nexus 4 work fine.
With Xperia tablet z after "wps passed!"

Code: Select all

read_all_sta:
read_all_sta:
read_all_sta:
Wireless display negotitation completed!
Leasd IP: 192.168.2.30
Reveived 'OPTIONS * RTSP/1.0\r\nCSeq: 0\r\nRequire: org.wfa.wfda1.0\r\n\r\n'
[...]
Traceback (most recent call last):
 File "usr/local/lib/python2.7/dist-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
  File "main.py", line 50, in <module>
  File "sink.py" line 127, in source_connect
AttributeError: 'NoneType' object has no attribute 'group'


rtang
Posts: 49
Joined: Mon Oct 08, 2012 6:27 am

Re: Piracast (Miracast on Pi) Beta Release

Thu Nov 14, 2013 3:30 pm

davidte wrote:Now with Nexus 4 work fine.
With Xperia tablet z after "wps passed!"

Code: Select all

read_all_sta:
read_all_sta:
read_all_sta:
Wireless display negotitation completed!
Leasd IP: 192.168.2.30
Reveived 'OPTIONS * RTSP/1.0\r\nCSeq: 0\r\nRequire: org.wfa.wfda1.0\r\n\r\n'
[...]
Traceback (most recent call last):
 File "usr/local/lib/python2.7/dist-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
  File "main.py", line 50, in <module>
  File "sink.py" line 127, in source_connect
AttributeError: 'NoneType' object has no attribute 'group'

Uhm. I wrote the negotiation portion of the code based on the transaction with a Nexus 4. Seems like Xperia tablet may be returning a slightly different payload (and is causing the parsing to fail). I will attempt to include a transaction logger in the next release to help debugging these scenarios.

Just to confirm, so you were able to successfully setup Miracast with the Pi using a Nexus 4 (looking for some positive reinforcement here)?

la_tristesse
Posts: 17
Joined: Sun Jun 24, 2012 1:17 pm

Re: Piracast (Miracast on Pi) Beta Release

Fri Nov 15, 2013 9:17 am

I'm setting up my pi as soon as the wlan stick arrives. I'm using a Asus T100 (Windows 8.1 Tablet) and will post the results here.

segator
Posts: 3
Joined: Fri Nov 15, 2013 10:34 am

Re: Piracast (Miracast on Pi) Beta Release

Fri Nov 15, 2013 10:40 am

yesterday i was test your application, it works well, as you were saying in the video i test sometimes takes several times to work.

I found the following:
-The image sometimes has graphical glitches
-There are at least 2 second delay between nexus 4 actions and TV
- Sometimes error connecting jumps (need detail?)
The sound does not work (missing configuration?)

you're doing a great job! keep it up
if I can help in any way, I'm here

rtang
Posts: 49
Joined: Mon Oct 08, 2012 6:27 am

Re: Piracast (Miracast on Pi) Beta Release

Fri Nov 15, 2013 4:59 pm

segator wrote:yesterday i was test your application, it works well, as you were saying in the video i test sometimes takes several times to work.

I found the following:
-The image sometimes has graphical glitches
-There are at least 2 second delay between nexus 4 actions and TV
- Sometimes error connecting jumps (need detail?)
The sound does not work (missing configuration?)

you're doing a great job! keep it up
if I can help in any way, I'm here
Thanks for the feedback.

Are you using a single HDMI connection to the TV? In this version audio only works through the 3.5mm jack right now.

segator
Posts: 3
Joined: Fri Nov 15, 2013 10:34 am

Re: Piracast (Miracast on Pi) Beta Release

Sat Nov 16, 2013 11:47 am

I did not read your message, with jack works well.
I think the next step is to implement an addon for raspbmc!

good job, impatiently await your updates ;)

la_tristesse
Posts: 17
Joined: Sun Jun 24, 2012 1:17 pm

Re: Piracast (Miracast on Pi) Beta Release

Sun Nov 17, 2013 7:25 pm

How do I connect the rasspberry pi to my network if the network is set to a static ip? Do I have to connect the pi with ethernet cable or do I have to setup something else?

Here's my terminal output after doing "sudo ./main"

Code: Select all

Increase rmem_default
Kill running applications
app: no process found
p2p_get_status...
Peer status: 0
Enable p2p ...
p2p_get_status...
p2p_status_get:
Peer status: 2

ad infinitum

segator
Posts: 3
Joined: Fri Nov 15, 2013 10:34 am

Re: Piracast (Miracast on Pi) Beta Release

Mon Nov 18, 2013 2:39 pm

la_tristesse wrote:How do I connect the rasspberry pi to my network if the network is set to a static ip? Do I have to connect the pi with ethernet cable or do I have to setup something else?

Here's my terminal output after doing "sudo ./main"

Code: Select all

Increase rmem_default
Kill running applications
app: no process found
p2p_get_status...
Peer status: 0
Enable p2p ...
p2p_get_status...
p2p_status_get:
Peer status: 2

ad infinitum
piracast use Wi-Di(Wifi Direct)
This means that you do not use your router to connect your devices, this system conect directly the devices.
The configuration of the raspberry to your network is indifferent to piracast.

la_tristesse
Posts: 17
Joined: Sun Jun 24, 2012 1:17 pm

Re: Piracast (Miracast on Pi) Beta Release

Mon Nov 18, 2013 3:02 pm

segator wrote: This means that you do not use your router to connect your devices, this system conect directly the devices.
The configuration of the raspberry to your network is indifferent to piracast.
So how do I connect my device (asus t100 windows 8.1) to the raspberry pi if they arent on the same network?

rtang
Posts: 49
Joined: Mon Oct 08, 2012 6:27 am

Re: Piracast (Miracast on Pi) Beta Release

Mon Nov 18, 2013 3:34 pm

la_tristesse wrote:
segator wrote: This means that you do not use your router to connect your devices, this system conect directly the devices.
The configuration of the raspberry to your network is indifferent to piracast.
So how do I connect my device (asus t100 windows 8.1) to the raspberry pi if they arent on the same network?
As indicated by segator, in a Miracast session the two wireless endpoints connect to each other 'directly' without going through a router (via Wifi-direct). Once a wifi connection is bridged between the two wireless endpoints, one of the wifi endpoints 'acts' as a router and issue IP address to another. In a Miracast session, the receiver (eg. Piracast) issues the IP to the sender (Asus T100).

This is also why Piracast requires a specific Wifi dongle, because Wifi-Direct requires hardware support.

Getting back to your question, my guess is that devices support Miracast either has two network interfaces, or the same interface can operate in both modes concurrently (which I have not explored yet).

So to install Piracast, you will need a connection to begin with (wired or wireless), allowing you to access the internet and install DHCP. If you followed through the instruction, you'll set static IP address on your wireless interface afterwards. After you set static IP to the wireless interface, the OS will no longer be able to access the public internet with the wireless interface, but may still get access via the wired interface. However at this point the OS may get confused about which interface to use to access the public internet, resulting in limited internet access (this is another issue I need to address).

la_tristesse
Posts: 17
Joined: Sun Jun 24, 2012 1:17 pm

Re: Piracast (Miracast on Pi) Beta Release

Mon Nov 18, 2013 4:10 pm

Thanks for your detailed answer. My sender (asus t100) doesnt find the the receiver (raspberry pi). I did everything as describes and watched the video tutorials serval times. Heres are screenshot from the terminal output after I started piracast.

Image

https://dl.dropboxusercontent.com/u/118 ... G_1499.JPG

Maybe the issue is related to "wpa_supplicant: no process found" or "hoastapd: no process found"

rtang
Posts: 49
Joined: Mon Oct 08, 2012 6:27 am

Re: Piracast (Miracast on Pi) Beta Release

Tue Nov 19, 2013 3:28 pm

la_tristesse wrote:Thanks for your detailed answer. My sender (asus t100) doesnt find the the receiver (raspberry pi). I did everything as describes and watched the video tutorials serval times. Heres are screenshot from the terminal output after I started piracast.

Image

https://dl.dropboxusercontent.com/u/118 ... G_1499.JPG

Maybe the issue is related to "wpa_supplicant: no process found" or "hoastapd: no process found"
Don't worry about the no process found errors - that was me being lazy and always kills relevant processes on start up. Since nothing is launched, the OS will report those errors.

If:
1. You are using this the exactly specified dongle dongle TP-LINK TL-WN725N
2. And you executed setup.py using sudo (have to be in superuser mode to install driver)
3. And you are using the September 25, 2013 raspberry Pi image (the driver ONLY works with this image. I had to re-compile the driver for this image due to kernel dependencies. I caught this when I tested against the image from May 2013. If you are using earlier image you may get 'unknown symbols table' or 'symbol insertion failed' or the likes during driver installation)

Then I don't know what it could be. The Miracast receivers appends certain information in the wifi broadcast frame to indicate its wifi display support capabilities. This is also how the Nexus 4 and other phones pick up Piracast as an available wifi display. Perhaps the Asus T100 is looking for certain information that the Piracast receiver is not advertising, and decides to filter Piracast out.

Exand_0
Posts: 5
Joined: Wed Nov 20, 2013 2:48 pm

Re: Piracast (Miracast on Pi) Beta Release

Wed Nov 20, 2013 2:55 pm

This project is really awesome. Works perfect with Nexus 10. I would appreciate, if you could extend time, when piracast is staying connected.
Also is it somehow possible to make piracast be avialable over wlan?

rtang
Posts: 49
Joined: Mon Oct 08, 2012 6:27 am

Re: Piracast (Miracast on Pi) Beta Release

Wed Nov 20, 2013 3:39 pm

Exand_0 wrote:This project is really awesome. Works perfect with Nexus 10. I would appreciate, if you could extend time, when piracast is staying connected.
Also is it somehow possible to make piracast be avialable over wlan?
Thanks for the feedback. Good to know that it works well for you.

As much as I'd like to make Piracast available over wlan, the wifi-direct requirement (and the hardware support) comes from the Miracast definition, and I can't change that. Unless they release a wlan friendly version of the protocol, and Android also implements the new revision, there's nothing a receiver implementation can do to enable wlan support.

Aside from AirPlay (proprietary) and Miracast (works over wifi-direct), I'm not aware of any other popular, well-supported protocols that works over wlan. If there was, I wouldn't mind spending the time investigating potential support on the Pi, as the Pi should have enough horse power to perform these types of tasks.

thtpark
Posts: 3
Joined: Thu Nov 21, 2013 2:30 am

Re: Piracast (Miracast on Pi) Beta Release

Thu Nov 21, 2013 2:36 am

I have a LG G-pad (LG-V500) and I got the following output.

Code: Select all

Increase rmem_default...
Kill running application...
app: no process found
wpa_supplicant: no process found
p2p_get status...
p2p_status_get:
Peer status: 0
Enable p2p...
p2p_get status...
p2p_status_get:
Peer status: 2
p2p_get status...
p2p_status_get:
Peer status: 2
p2p_get status...
p2p_status_get:
Peer status: 2
p2p_get status...
p2p_status_get:
Peer status: 11
wlan0     Scan completed :
          Cell 01 - Address: BE:F5:AC:DA:4B:68
                    ESSID:"DIRECT-"
                    Protocol:IEEE 802.11g
                    Frequency:2.437 GHz (Channel 6)
                    Encryption key:on
                    Bit Rates:54 Mb/s
                    IE: Unknown: DD760050F204104A0001101044000101101200020004103B0001001047001055B7F6F4E6B954F48721F61049794A74102100012010230001201024000120104200012010540008000A0050F204000510110015ED839CEC9881EC9790EC8AA4EC9794EC9790EC8AA41008000243881049000600372A000120
                    Quality=0/100  Signal level=96/100


p2p_get status...
p2p_status_get:
Peer status: 2
p2p_get status...
p2p_status_get:
Peer status: 8
Breaking out of loop
p2p_peer_devaddr_get:
peer_devaddr:  BE:F5:AC:DA:4B:68
p2p_req_cm_get:
wlan0     p2p_get:

CM=pbc


p2p_wpsinfo:
p2p_status_get:
peer_status:  8
p2p_set_nego:
mac:  BE:F5:AC:DA:4B:68
p2p_status_get:
peer_status:  10
Negotiation suceeded!
p2p_role_get:
Role:  2
p2p_opch_get:
---------------------------
wlan0     p2p_get:

---------------------------
Configuration file: p2p_hostapd.conf
drv->ifindex=3
l2_sock_recv==l2_sock_xmit=0x0x1a33630
Failed to request a scan of neighboring BSSes
+rtl871x_sta_deauth_ops, ff:ff:ff:ff:ff:ff is deauth, reason=2
rtl871x_set_key_ops
rtl871x_set_key_ops
rtl871x_set_key_ops
rtl871x_set_key_ops
Using interface wlan0 with hwaddr 64:66:b3:1e:7f:9b and ssid 'DIRECT-RT'
rtl871x_set_beacon_ops
rtl871x_set_hidden_ssid_ops
rtl871x_set_wps_assoc_resp_ie
rtl871x_set_wps_beacon_ie
rtl871x_set_wps_probe_resp_ie
rtl871x_set_key_ops
rtl871x_set_beacon_ops
rtl871x_set_hidden_ssid_ops
do_wps
Selected interface 'wlan0'
OK

wps passed!
read_all_sta:
read_all_sta:
read_all_sta:
For some reason, it doesn't successfully connect (but it does show "Piracast" under the Wi-Fi direct setting.
Any idea?

la_tristesse
Posts: 17
Joined: Sun Jun 24, 2012 1:17 pm

Re: Piracast (Miracast on Pi) Beta Release

Thu Nov 21, 2013 10:37 am

rtang wrote: If:
1. You are using this the exactly specified dongle dongle TP-LINK TL-WN725N
2. And you executed setup.py using sudo (have to be in superuser mode to install driver)
3. And you are using the September 25, 2013 raspberry Pi image (the driver ONLY works with this image. I had to re-compile the driver for this image due to kernel dependencies. I caught this when I tested against the image from May 2013. If you are using earlier image you may get 'unknown symbols table' or 'symbol insertion failed' or the likes during driver installation
1. Check
2. Check
3. Check

I'm clueless. Must be related to the receiver device. Also the Asus T100 is confirmed to be miracast compatible: http://www.transformerforums.com/forum/ ... pport.html
Intel WiDi is intigated in Win8.1 no special Drivers needed.
Also Miracast is supported on Intel BayTrail Processors.

For me it works best with a Netgear PTV3000.
http://software.intel.com/en-us/articles/4th-generation-intel-atom-processor-based-tablet-overview wrote:Intel® Wireless Display benefits on Intel Atom processor
Intel® WiDi enables content-protected HD streaming and interactive usages between tablets and TVs. It supports full 1080p video and low latency gaming, and is Miracast compliant Intel® WiDi can be used to link health indicators as well. A few of the capabilities of Miracast-enabled apps are:

Share & Enjoy: use a big screen HDTV to enjoy and share media with family and friends
Wireless: quickly and securely connect with standard Wi-Fi to a TV without cables
Easy Set-up: simple user interface makes it easy to connect; no additional remote controls
Portable: adapter is small and light, so solution can move with you

Minz0r
Posts: 10
Joined: Tue Aug 14, 2012 1:16 pm

Re: Piracast (Miracast on Pi) Beta Release

Thu Nov 21, 2013 3:04 pm

thtpark wrote:I have a LG G-pad (LG-V500) and I got the following output.


wps passed!
read_all_sta:
read_all_sta:
read_all_sta:
[/code]

For some reason, it doesn't successfully connect (but it does show "Piracast" under the Wi-Fi direct setting.
Any idea?
I got Piracast to work at home!

After several read_all_sta: messages my S4 got accepted.
But if I try this setup at the Office it gets not further than read_all_sta.
At the Office there were several Devices that are Miracast enabled, perhaps Piracast could not select the right Device to enable the Stream.

rtang
Posts: 49
Joined: Mon Oct 08, 2012 6:27 am

Re: Piracast (Miracast on Pi) Beta Release

Fri Nov 22, 2013 3:25 pm

la_tristesse wrote:
rtang wrote: If:
1. You are using this the exactly specified dongle dongle TP-LINK TL-WN725N
2. And you executed setup.py using sudo (have to be in superuser mode to install driver)
3. And you are using the September 25, 2013 raspberry Pi image (the driver ONLY works with this image. I had to re-compile the driver for this image due to kernel dependencies. I caught this when I tested against the image from May 2013. If you are using earlier image you may get 'unknown symbols table' or 'symbol insertion failed' or the likes during driver installation
1. Check
2. Check
3. Check

I'm clueless. Must be related to the receiver device. Also the Asus T100 is confirmed to be miracast compatible: http://www.transformerforums.com/forum/ ... pport.html
Intel WiDi is intigated in Win8.1 no special Drivers needed.
Also Miracast is supported on Intel BayTrail Processors.

For me it works best with a Netgear PTV3000.
http://software.intel.com/en-us/articles/4th-generation-intel-atom-processor-based-tablet-overview wrote:Intel® Wireless Display benefits on Intel Atom processor
Intel® WiDi enables content-protected HD streaming and interactive usages between tablets and TVs. It supports full 1080p video and low latency gaming, and is Miracast compliant Intel® WiDi can be used to link health indicators as well. A few of the capabilities of Miracast-enabled apps are:

Share & Enjoy: use a big screen HDTV to enjoy and share media with family and friends
Wireless: quickly and securely connect with standard Wi-Fi to a TV without cables
Easy Set-up: simple user interface makes it easy to connect; no additional remote controls
Portable: adapter is small and light, so solution can move with you
Yeah sorry, I don't know what it would be then.

My guess is the Piracast driver is failing to advertise certain key attribute the Asus is looking for that most other tablets aren't. I don't have access to a Asus T100, or any Windows 8 laptop for that matter at the moment. I will take a look at it when I do get my hands on one (though I don't know when that will be).

Thanks for trying though!

rtang
Posts: 49
Joined: Mon Oct 08, 2012 6:27 am

Re: Piracast (Miracast on Pi) Beta Release

Fri Nov 22, 2013 3:27 pm

Minz0r wrote:
thtpark wrote:I have a LG G-pad (LG-V500) and I got the following output.


wps passed!
read_all_sta:
read_all_sta:
read_all_sta:
[/code]

For some reason, it doesn't successfully connect (but it does show "Piracast" under the Wi-Fi direct setting.
Any idea?
I got Piracast to work at home!

After several read_all_sta: messages my S4 got accepted.
But if I try this setup at the Office it gets not further than read_all_sta.
At the Office there were several Devices that are Miracast enabled, perhaps Piracast could not select the right Device to enable the Stream.
Thank you. That's a very valuable piece of information. I've been lazy and assumed there's only one Miracast enabled device present in the Piracast code. I'll incorporate this feedback into future revisions.

Return to “Media centres”

Who is online

Users browsing this forum: No registered users and 12 guests