I am implementing WebRTC natively into Android. I was able to compile and run the code as described here http://www.webrtc.org/native-code/android, but I ran into an issue where apprtc.appspot.com apparently does not return a channel token as supposed:
01-05 20:01:51.230 15488-15488/org.appspot.apprtc E/AppRTCDemoActivity﹕ Fatal error: Missing channelToken in HTML: <!DOCTYPE html>
<!--
* Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree.
-->
<html>
<head>
<title>WebRTC Reference App</title>
<meta charset="utf-8">
<meta name="description" content="WebRTC reference app">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
<script type='text/javascript'>window.mod_pagespeed_start = Number(new Date());</script><link rel="canonical" href="https://apprtc.appspot.com/room/42272483?r=fh">
<link rel="stylesheet" href="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/css/A.main.css.pagespeed.cf.mluzaRyZGPUUQu3CIFwW.css">
</head>
<body><noscript><meta HTTP-EQUIV="refresh" content="0;url='https://apprtc.appspot.com/r/42272483?r=fh&PageSpeed=noscript'" /><style><!--table,div,span,font,p{display:none} --></style><div style="display:block">Please click <a href="https://apprtc.appspot.com/r/42272483?r=fh&PageSpeed=noscript">here</a> if you are not redirected within a few seconds.</div></noscript>
<div id="videos">
<video id="mini-video" autoplay muted></video>
<canvas id="remote-canvas"></canvas>
<video id="remote-video" autoplay></video>
<video id="local-video" autoplay muted></video>
</div>
<footer>
<div id="sharing">
<div id="room-link">Waiting for someone to join this room: <a href="https://apprtc.appspot.com/room/42272483?r=fh" target="_blank">https://apprtc.appspot.com/room/42272483?r=fh</a></div>
</div>
<div id="info"></div>
<div id="status"></div>
</footer>
<script src="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/js/stats.js.pagespeed.jm.A-w15PL7V0sRNC026ANH.js"></script>
<script src="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/js/signaling.js.pagespeed.jm.QZ7VRUXKfNhiyV7jHkmW.js"></script>
<script src="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/js/infobox.js.pagespeed.jm.C9t_78UyYtO6bMRljt_L.js"></script>
<script src="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/js/sdputils.js.pagespeed.jm.DWy54ENwSOTLQKw10p1o.js"></script>
<script src="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/js/util.js.pagespeed.jm.q3iuB_S1TC2eBJC_RFlb.js"></script>
<script src="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/js/main.js.pagespeed.jm.mR4sH1O_ReNLDaNiS3o_.js"></script>
<script src="https://1-ps.googleusercontent.com/sxk/j1xSZgZ8VRf8QgCJPihVzk5mBR/s.apprtc.appspot.com/apprtc.appspot.com/js/adapter.js.pagespeed.jm.-Ip1bBjviqtsxeGluAGS.js"></script>
<script type="text/javascript">var params={errorMessages:[],isLoopback:false,roomId:'42272483',roomLink:'https://apprtc.appspot.com/room/42272483?r=fh',mediaConstraints:{"audio":true,"video":true},offerConstraints:{"optional":[],"mandatory":{}},peerConnectionConfig:{"iceServers":[]},peerConnectionConstraints:{"optional":[{"googImprovedWifiBwe":true}]},turnRequestUrl:'https://computeengineondemand.appspot.com/turn?username=280585048&key=4080218913',turnTransports:'',audioSendBitrate:'',audioSendCodec:'',audioRecvBitrate:'',audioRecvCodec:'',isStereoscopic:'',opusMaxPbr:'',opusFec:'',opusStereo:'',videoSendBitrate:'',videoSendInitialBitrate:'',videoSendCodec:'',videoRecvBitrate:'',videoRecvCodec:'',wssUrl:'wss://apprtc-ws.webrtc.org:443/ws',wssPostUrl:'https://apprtc-ws.webrtc.org:443'};initialize();</script>
<script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.cr
When inspecting the source code of AppRTCClient.java here https://code.google.com/p/webrtc/source/browse/trunk/talk/examples/android/src/org/appspot/apprtc/AppRTCClient.java?r=5847 I found a funny comment at line 234ff, exactly the function where the app fails:
// Fetches |url| and fishes the signaling parameters out of the HTML via
// regular expressions.
//
// TODO(fischman): replace this hackery with a dedicated JSON-serving URL in
// apprtc so that this isn't necessary (here and in other future apps that
// want to interop with apprtc).
private AppRTCSignalingParameters getParametersForRoomUrl(String url)
throws IOException {
// ...
}
In the function happens a lot of parsing of html code and it seems the channel token is not correctly parsed from the response html returned by the server (no wonder).
I did not further investigate if the channel token is there or not and/or if it is correct. Instead, I suspected the code (trunk!) could be outdated, googled and found this project on Github: https://github.com/pristineio/webrtc-android
The same function, here at line 232ff, passes in &t=json as parameter, supposedly because it expects the server to return Json. The function then fails when parsing the Json, guess why. Bingo! Because the same html page is returned, with or without the parameter.
// Fetches |url| and fishes the signaling parameters out of the JSON.
private AppRTCSignalingParameters getParametersForRoomUrl(String url)
throws IOException, JSONException {
url = url + "&t=json";
// ...
}
For the sake of completeness the full URL that fails:
https://apprtc.appspot.com/?r=00000000&t=json
where 00000000 is the room number.
So it seems Mr. Fischman at Google has updated the code in the meantime, but the code at webrtc is not current, and pristineio/webrtc-android at Github seems to know the parameter that once made apprtc.appspot.com return Json instead of html, but it no longer does so.
I googled but coudln't find the server code for apprtc.appspot.com but I remember to have seen it before (I believe it was a Python project).
- Does anybody have the link to that source code?
Then I searched for parameters for that URL and I found two pages where these were listed, including http://samdutton.github.io/webrtc/samples/web/content/apprtc/params.html, but none of them showed a parameter or alternative URL to request the result as Json.
- Does anybody know what the correct parameter (or url) is?
- Or does anybody know were the full specs are?
- Or does anybody have a link to the most current and working source code of AppRTCClient.Java?
Thanks!