livepeer / go-PPSPP

Go implementation of the Peer-to-Peer Streaming Peer Protocol (rfc7574)
MIT License
11 stars 4 forks source link

PPSPP Interface #1

Open ericxtang opened 7 years ago

ericxtang commented 7 years ago

I think this implementation should adhere to a generic interface in Livepeer that handles broadcasting / subscribing to video streams - so we can swap out the underlining transport protocol.

Here is the proposal: https://github.com/livepeer/go-livepeer/pull/43/files

ericxtang commented 7 years ago

After talking about it more, it makes more sense for the interface to be generic (instead of Livepeer-specific). For integration with Livepeer, we can import go-PPSPP in Livepeer, implement a PPSPP_broadcaster and PPSPP_subscriber.

For PPSPP, we should have a constructor for creating a PPSPP node from a libp2p Swarm. The PPSPP node should allow data to be broadcasted into the node, and also to be received from the node.

ericxtang commented 7 years ago

This ticket is about defining an interface for this PPSPP package. Section 2 of the PPSPP RFC describes how the protocol works on a high level, and we can use that to inform our decision here.

We will use this interface to implement a PPSPP version of the Livepeer VideoNetwork, but we should keep the interface generic so anyone can use it as a reference implementation of PPSPP.

Note - there are 2 partial implementations of PPSPP: swirl and PYPPSPP that might be helpful as we are thinking about go-ppspp.

To start, I think the interface should allow anyone to:

derekchiang commented 7 years ago

Looking at the code that we currently have (the Protocol API and the example), I think the Protocol interface already supports everything that you specified, with two caveats:

So in my mind, we have two paths forward:

I'm personally leaning towards the first approach as that would keep go-PPSPP a low-level, pure implementation of PPSPP, while minimizing the duplication between go-PPSPP and go-livepeer. However I don't have a strong opinion either way.

sricketts commented 7 years ago

I don't have a strong opinion here yet (just starting to think about it). But one thing to note is that @derekchiang's first proposal would be useful internally for testing go-PPSPP. Right now there are a handful of tests that use sleep to wait on messages.

So if we want to remove the non-determinism from those tests, we would want to build some kind of notification thingie anyway.

dob commented 7 years ago

I like the idea of PPSPP remaining pure, but keep in mind we'll likely be extending it to support things like webRTC transport anyway. Pure to me means that other PPSPP clients could potentially interact with clients running our version, but our version can potentially do more as well when speaking to other Livepeer clients. So, for example, extending protocol to support passing in a channel to be notified on received data seems reasonable.

Quick note on peer discovery, I think you already referenced two issues in which we shared some thoughts on it. My current thinking is that in the Livepeer protocol, as a subscribe request is routed towards the broadcaster, either the broadcaster passes a tracker back through the relay nodes to the subscriber which contains a peer list, or any intermediate relay node who already has their own peer list for this swarm could provide the tracker without going all the way upstream to the broadcaster. The node would take the tracker and join the swarm and make peer connections with some of the nodes in the tracker, and then proceed with whatever in-swarm peer discovery algorithm we decide to use.

Also take a look at this rfc which is the complement to PPSPP and describes the tracker protocol. I'm not familiar enough with it yet to know if we'd want to use it. I'd imagine maybe we'd borrow the format, but not the discovery mechanisms.

derekchiang commented 7 years ago

Had a chat with @ericxtang to scope out the "MVP" for this project. Basically we think there are two things left to be done:

We will keep this project minimal in that it will not be aware of Livepeer in any way. To interface with Livepeer, we will create a go-livepeer-ppspp project wherein we will have an implementation of the Tracker interface that finds peers via the broadcaster, and an implementation of VideoNetwork using this project.

P.S. @dob we might implement the tracker RFC at some point, but for the purpose of delivering an MVP we will probably go for something a lot simpler.