Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can a custom receiver use the "ramp" namespace or can I modify the sample apps to use a custom namespace without re-writing support for RAMP?

How can a custom receiver use the "ramp" namespace or how can I modify the sample apps to use a custom namespace without re-writing support ( MediaProtocolMessageStream in Android or GCKMediaProtocolMessageStream in iOS ) for the RAMP protocol?

I have been unable to make either the Android or iOS Chromecast sample apps communicate with a custom receiver based off dash.js ( the reference client implementation for the playback of MPEG DASH via Javascript - https://github.com/Dash-Industry-Forum/dash.js ). It appears to be due to the namespace of "ramp" being hardcoded ( final const ) on the Android / iOS Chromecast SDKs and the dash.js receiver being unable to use the namespace of "ramp" for some reason ( per http://www.digitalprimates.net/author/tapper/2013/08/27/chromecast_dash/ )

I am able to cast MPEG-DASH just fine from a Javascript sender in Chrome when using the namespace dash.js uses by default. When attempting to interact with my custom receiver via Android or iOS, the Chromecast device loads the receiver page just fine but never receives the load command containing the media URL. This even happens when the custom receiver is set to use a namespace of "ramp" ( the default for media playback ). In addition, my custom receiver stops working in Chrome when the namespace is set to "ramp".

like image 672
James Bobowski Avatar asked Oct 02 '13 21:10

James Bobowski


1 Answers

It's unfortunate that the Dash.js receiver won't let you use the RAMP namespace, but their current implementation isn't quite correct RAMP anyway (You're going to have to change a few things on the receiver end). Documentation on RAMP is pretty scarce and it's rather frustrating that Google hasn't released the source for their Chromecast libraries for iOS and Android. However, I decompiled the Android library using Java Decompiler (http://jd.benow.ca/) to learn some of the details. You can also bring up your whitelisted Chromecast device in the browser and watch the Web Sockets to see what kinds of RAMP messages it's sending and receiving.

However, everything you want to modify in MediaProtocolMessageStream is final which means a perfect RAMP implementation for your sender is just outside your grasp. You could write your own MessageStream using the decompiled code as guidance, but I chose to use reflection hacking to force change the namespace in MediaProtocolMessageStream.

public class CustomMediaProtocolMessageStream extends MediaProtocolMessageStream {

    private static final String NAMESPACE = "org.dashif.dashjs";

    public CustomMediaProtocolMessageStream() {
        super();
        // Hack Google's hardcoded namespace which doesn't work with the DASH receiver.
        try {
            // This is the field where MessageStream stores the namespace.  If you decompile the jar you can see it's named 'b'.
            Field field = MessageStream.class.getDeclaredField("b");
            field.setAccessible(true);
            field.set(this, NAMESPACE);
        } catch (Exception e) {
            Log.e(TAG, "problem changing namespace:" + e.getMessage());
        }
    }
}
like image 72
ActiveApathy Avatar answered Nov 23 '22 19:11

ActiveApathy