TeamNewPipe/PipeCast

I would like to revive this project

Closed this issue · 19 comments

I would love to have ChromeCast support on NewPipe, so I want to work on it. I have found the chromecast-java-api-v2 library that (I think) is completely open-source, but only supports Chromcasts. From what I understand PipeCast (and NewPipe) aims to support every UPnP device, while the lib above doesn't, so I don't think it is suitable.

Given the above, I would like to see a revival of this repo. I would be pleased to work on it, but I don't know where to start.

  • I don't know how the UPnP protocol works, but it is always good to learn new things. Could you point me to some resources explaining in depth how it works (i.e. the ones you used)? Is this ok?
  • The current code in this library is not much, but probably there was a plan on how the library should grow. Could you please explain the plan and the design philosophy behind this repo?

@wb9688

In Jellyfin chat someone recommended to use this hardcoded profiles to improve their DLNA implementation, besides of implementing getProfile(), so maybe they can be useful:

https://github.com/UniversalMediaServer/UniversalMediaServer/tree/master/src/main/external-resources/renderers

Hey @Stypox, fell free to contribute to PipeCast. With all respect to @wb9688, but there was plenty of time to create a PR or push some changes.

FYI to play a MP3 over UPNP A/V, you have to do a POST request to for example http://192.168.1.124:49495/upnp/control/rendertransport1 (I think the URL is in the manifest or whatever, and it's a SOAP API), with the following headers:

Content-Type: text/xml;charset=utf-8
Soapaction: "urn:schemas-upnp-org:service:AVTransport:1#SetAVTransportURI"

And the following body:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <u:SetAVTransportURI
            xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
            <InstanceID>0</InstanceID>
            <CurrentURI>https://url/to/video</CurrentURI>
            <CurrentURIMetaData>&lt;DIDL-Lite
                xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"
                xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"
                xmlns:dc="http://purl.org/dc/elements/1.1/"
                xmlns:dlna="urn:schemas-dlna-org:metadata-1-0/"
                xmlns:sec="http://www.sec.co.kr/"
                xmlns:pv="http://www.pv.com/pvns/"&gt;&lt;item id="/path/to/123" parentID="/path/to" restricted="1"&gt;&lt;upnp:class&gt;object.item.audioItem.musicTrack&lt;/upnp:class&gt;&lt;dc:title&gt;Name of Song&lt;/dc:title&gt;&lt;dc:creator&gt;&amp;lt;Creator&amp;gt;&lt;/dc:creator&gt;&lt;upnp:artist&gt;&amp;lt;Artist&amp;gt;&lt;/upnp:artist&gt;&lt;upnp:albumArtURI&gt;http://url/to/album/art.jpg&lt;/upnp:albumArtURI&gt;&lt;upnp:album&gt;Name of Album&lt;/upnp:album&gt;&lt;res protocolInfo="http-get:*:audio/mpeg:DLNA.ORG_PN=MP3;DLNA.ORG_OP=01;DLNA.ORG_FLAGS=01700000000000000000000000000000" size="length_in_bytes"&gt;https://url/to/video&lt;/res&gt;&lt;/item&gt;&lt;/DIDL-Lite&gt;
            </CurrentURIMetaData>
        </u:SetAVTransportURI>
    </s:Body>
</s:Envelope>

After that, to actually let it start playing, you have to make a similar request, but with Soapaction set to "urn:schemas-upnp-org:service:AVTransport:1#Play" and the following body:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Body>
        <u:Play
            xmlns:u="urn:schemas-upnp-org:service:AVTransport:1">
            <InstanceID>0</InstanceID>
            <Speed>1</Speed>
        </u:Play>
    </s:Body>
</s:Envelope>

Edit: I think that GMRender-Resurrect (which I'm using for testing) doesn't really care if the metadata is correct, as long as it could correctly parse it.

@Stypox: I pushed a commit with support for playback of videos. I still need to add suppport for pausing, queueing, etc. I also don't really have error handling yet. I'm working on it though and I'll probably much further in about a month. I've also sent an e-mail to SpireSpark International to obtain the DLNA Guidelines. DLNA adds some stuff on top of UPnP A/V and are stricter on certain things. I'll also need to test on more devices, since now I've only tested it with GMRender-Resurrect, and I've heard that especially PlayStations are troublesome.

Ok, thank you :-D
I have a Playstation at home if needed for testing ;-)

@TobiGr: I implemented seeing what formats are supported by the MediaRenderer in ecbba74. Is there any format that we need that's not listed yet in MediaFormat.java? I know there's MP4 videos, but I'm not sure what DLNA Media Format Profile that would be. Btw I got the DLNA Guidelines after contacting SpireSpark International, I'm just not allowed to share them publicly unfortunately.

@Stypox: Please download ssdp.jar.zip, rename it to ssdp.jar, and then run it with java -jar ssdp.jar in a terminal while your PlayStation is on and ready to be discovered. I want to know its output (just the lines from the PlayStation, I don't need to know the rest). I also want the .xml file it links to after LOCATION: . Thanks in advance.

@wb9688 unfortunately after trying many ways I was not able to enable UPnP on the PlayStation 3. Under settings it says that UPnP is not available, even after I enabled it in the modem. 😢
Some other devices answered to your script, such as a ChromeCast and a Panasonic Viera TV, if you want I can attach the LOCATION: xml for those

@Stypox: Hmm… strange. Please do not enable UPnP on your modem though, that's not related to your problem and enables a UPnP service that would allow any device/software on your network to set up port forwarding, which is not something you want. I'd like to receive that XML from your TV, and preferably also the SCPD XMLs that XML is linking to.

Sure, here are all the things I could collect @wb9688

  • Output of ssdp.jar, it contains a bunch of responses from the TV, I removed all unrelated things: ssdp_jar_output.txt

From the various TV answers I could find two unique LOCATIONs, which I will call dmr and nrc:

@yausername: Tobias thought I should ask you. I need to implement GENA (General Event Notification Architecture). For GENA, I need to send a HTTP request to a MediaRenderer to subscribe (and every x amount of time to renew the subscription), and then the MediaRenderer will send NOTIFY requests to the HTTP server running on the ControlPoint (i.e. PipeCast). What would be the best way to implement that HTTP server that accepts NOTIFY requests in Java?

@yausername: Tobias thought I should ask you

I have worked a bit with spring and sparkjava but those are more aimed at REST architecture.
You could try nanohttpd or https://dzone.com/articles/simple-http-server-in-java

@Stypox @wb9688 whats our status? The last message is already nearly a year ago.
My goal: Help bringing Chromecast support into NewPipe. How can we revive development and make this happen?

EDIT: Also found https://github.com/ofmooseandmen/wire, maybe it helps.

I would have liked to revive this a year ago but then didn't since @wb9688 said he was going to push more code. When he did (June 2020) I was busy and didn't notice it, so I never started working on this (sorry :-|). Since I have never read the code and neither have I seen it into action, I think we'd need some explanation from @wb9688 about how the library is structured and designed, in order to be able to contribute on it coherently.

@dasois: @wb9688 told me this on IRC:

It's not ready for usage at all
And I kinda lost interest
Partially because UPnP A/V kind of is a stupid protocol
There is not enough stuff implemented yet and I have some WIP stuff lying around locally iirc
Also, he wants Cast v2, while so far only UPnP A/V has been implemented a bit

@Stypox thanks for asking! To me this sounds like we should for the moment forget about UPnP A/V and just try to somehow get Cast v2 working.

@dasois I found this app on F-Droid, maybe it can turn out useful: https://github.com/m3sv/PlainUPnP