2015-01-06 14 views
7

Tôi đang triển khai WebRTC tự nhiên vào Android. Tôi đã có thể biên dịch và chạy các mã như mô tả ở đây http://www.webrtc.org/native-code/android, nhưng tôi chạy vào một vấn đề mà apprtc.appspot.com dường như không trả lại một mã thông báo kênh như vụ:Máy chủ AppRTC trả về html thay vì Json

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&amp;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&amp;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 

Khi kiểm tra mã nguồn của AppRTCClient java đây https://code.google.com/p/webrtc/source/browse/trunk/talk/examples/android/src/org/appspot/apprtc/AppRTCClient.java?r=5847 tôi tìm thấy một bình luận hài hước tại dòng 234ff, chính xác các chức năng mà ứng dụng bị lỗi:

// 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 { 

    // ... 

} 

trong chức năng sẽ xảy ra rất nhiều phân tích cú pháp của mã html và có vẻ như token kênh không được phân tích một cách chính xác từ phản hồi html được trả về bởi máy chủ (không có thắc mắc).

Tôi không điều tra thêm nếu mã thông báo kênh có ở đó hay không và/hoặc nếu thông tin chính xác. Thay vào đó, tôi nghi ngờ mã (trunk!) Có thể đã lỗi thời, googled và tìm thấy dự án này trên Github: https://github.com/pristineio/webrtc-android

Chức năng tương tự, tại dòng 232ff, chuyển trong & t = json làm tham số, được cho là vì nó mong đợi máy chủ để trả lại Json. Hàm này sau đó không thành công khi phân tích cú pháp Json, hãy đoán tại sao. Chơi lô tô! Bởi vì cùng một trang html được trả về, có hoặc không có tham số.

// Fetches |url| and fishes the signaling parameters out of the JSON. 
private AppRTCSignalingParameters getParametersForRoomUrl(String url) 
     throws IOException, JSONException { 
    url = url + "&t=json"; 

    // ... 

} 

Vì lợi ích của sự hoàn chỉnh URL đầy đủ mà không:

https://apprtc.appspot.com/?r=00000000&t=json 

nơi 00000000 là số phòng.

Vì vậy, có vẻ như ông Fischman tại Google đã cập nhật mã trong khi chờ đợi, nhưng mã tại webrtc không phải là hiện tại và pristineio/webrtc-android tại Github dường như biết thông số đã từng tạo apprtc.appspot.com trả về Json thay vì html, nhưng nó không còn làm như vậy nữa.

Tôi googled nhưng coudln't tìm thấy mã máy chủ cho apprtc.appspot.com nhưng tôi nhớ đã nhìn thấy nó trước khi (tôi tin rằng nó là một dự án Python).

  • Có ai có liên kết đến mã nguồn đó không?

Sau đó, tôi tìm kiếm thông số cho URL đó và tôi tìm thấy hai trang được liệt kê, bao gồm http://samdutton.github.io/webrtc/samples/web/content/apprtc/params.html, nhưng không ai trong số họ hiển thị thông số hoặc URL thay thế để yêu cầu kết quả là Json.

  • Có ai biết thông số chính xác (hoặc url) là gì không?
  • Hoặc không ai biết đầy đủ thông số kỹ thuật?
  • Hoặc không ai có liên kết tới mã nguồn mới nhất và đang hoạt động của AppRTCClient.Java?

Cảm ơn!

Trả lời

3

Chạy cùng vấn đề với bạn. Tôi tìm thấy đoạn code ở đây:

https://github.com/GoogleChrome/webrtc/tree/master/samples/web/content/apprtc

Hiện nay nhìn qua những thay đổi để xem những gì có thể phá vỡ nó. Ill cập nhật câu trả lời này nếu tôi tìm thấy một cái gì đó.

UPDATE: Hình như họ đã thực hiện một số thay đổi phá vỡ trong cam kết này:

https://github.com/GoogleChrome/webrtc/commit/c36b88475fab8a3e4436a87a7ea84265b0e13a8a#diff-c3e41e94913c93dfe31babd4830c3065

Họ đang di chuyển từ api GAE kênh, một kênh WebSocket.

+1

Khi @Aidamina hiển thị trong liên kết thứ hai, có vẻ như dòng 150ff đã bị xóa để trả lại một Json thay vì html không thành công. Cảm ơn bạn rất nhiều vì đã chỉ cho tôi đến nguồn máy chủ. –

+0

Tôi đã báo cáo sự cố tại Google và nhận được phản hồi sau: "Thay vào đó, bạn sẽ muốn sử dụng apprtc.appspot.com/register API mới." Hy vọng điều này sẽ giúp bất cứ ai ở đây. –

+1

Bạn đã khắc phục nó như thế nào? Bạn có thể chia sẻ dự án làm việc được không? –

Các vấn đề liên quan