我正在开发一个聊天应用程序并完成它.现在我也想实现视频聊天.经过研究很多,我决定选择"WebRTC"库.
我做了什么?
1)能够在本地服务器上运行AppRtcDemo,并且它在浏览器之间正常工作.
参考:http://www.webrtc.org/reference/getting-started
2)能够构建Android AppRtcDemo.But当我运行时说"Cross origin not support".
经过研究,我在webrtc讨论中发现,为了解决这个问题,我需要设置自己的转向服务器.
3)所以我安装了webrtc推荐的最新rfc5766TurnServer.我成功运行了转向服务器.
参考:http://code.google.com/p/rfc5766-turn-server/
我对ApprtcDemo(web)和(Android)进行了以下更改,以便与我的Turn服务器一起使用
1)apprtc.py
更换:
turn_url = 'https://computeengineondemand.appspot.com/'
turn_url = turn_url + 'turn?' + 'username=' + user + '&key=4080218913'
Run Code Online (Sandbox Code Playgroud)
指向我的转弯服务器:
turn_url = 'http://192.168.5.85:3478/?service=turn&username=biraj'
Run Code Online (Sandbox Code Playgroud)
2)index.html
更换:
var pcConfig = {{ pc_config|safe }};
Run Code Online (Sandbox Code Playgroud)
附:
var pcConfig = {"iceServers": [{"url": "stun:stun.l.google.com:19302"}, {"url":"turn:biraj@192.168.5.85:3479", "credential":"0x5b04123c3eec4cf0be64ab909bb2ff5b"}]};
Run Code Online (Sandbox Code Playgroud)
Android的
1)AppRTCDemoActivity.java
更换:
roomInput.setText("https://apprtc.appspot.com/?r=");
Run Code Online (Sandbox Code Playgroud)
使用我的本地apprtc服务器:
roomInput.setText("http://192.168.5.86:8080/?r=");
Run Code Online (Sandbox Code Playgroud)
2)AppRTCClient.java
在private PeerConnection.IceServer requestTurnServer(String url){}功能上
更换:
connection.addRequestProperty("origin", "https://apprtc.appspot.com");
Run Code Online (Sandbox Code Playgroud)
附:
connection.addRequestProperty("origin", "http://192.168.5.86:8080");
Run Code Online (Sandbox Code Playgroud)
3)/assets/channel.html
更换:
<script src="https://apprtc.appspot.com/_ah/channel/jsapi"></script>
Run Code Online (Sandbox Code Playgroud)
附: …
我需要使用WebRTC for android将特定的裁剪(面部)视频发送到videoChannel.我能够操作CameraRession类WebRTC来裁剪面部.现在我将它设置为ImageView.
listenForBytebufferFrames()的Camera1Session.java
private void listenForBytebufferFrames() {
this.camera.setPreviewCallbackWithBuffer(new PreviewCallback() {
public void onPreviewFrame(byte[] data, Camera callbackCamera) {
Camera1Session.this.checkIsOnCameraThread();
if(callbackCamera != Camera1Session.this.camera) {
Logging.e("Camera1Session", "Callback from a different camera. This should never happen.");
} else if(Camera1Session.this.state != Camera1Session.SessionState.RUNNING) {
Logging.d("Camera1Session", "Bytebuffer frame captured but camera is no longer running.");
} else {
mFrameProcessor.setNextFrame(data, callbackCamera);
long captureTimeNs = TimeUnit.MILLISECONDS.toNanos(SystemClock.elapsedRealtime());
if(!Camera1Session.this.firstFrameReported) {
int startTimeMs = (int)TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - Camera1Session.this.constructionTimeNs);
Camera1Session.camera1StartTimeMsHistogram.addSample(startTimeMs);
Camera1Session.this.firstFrameReported = true;
}
ByteBuffer byteBuffer1 = ByteBuffer.wrap(data); …Run Code Online (Sandbox Code Playgroud) 我正在尝试将音频重定向到AppRTC iOS示例中的扬声器.
我试过了:
AVAudioSession* session = [AVAudioSession sharedInstance];
//error handling
BOOL success;
NSError* error;
//set the audioSession category.
//Needs to be Record or PlayAndRecord to use audioRouteOverride:
success = [session setCategory:AVAudioSessionCategoryPlayAndRecord
error:&error];
if (!success) NSLog(@"AVAudioSession error setting category:%@",error);
//set the audioSession override
success = [session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker
error:&error];
if (!success) NSLog(@"AVAudioSession error overrideOutputAudioPort:%@",error);
//activate the audio session
success = [session setActive:YES error:&error];
if (!success) NSLog(@"AVAudioSession error activating: %@",error);
else NSLog(@"audioSession active");
Run Code Online (Sandbox Code Playgroud)
没有错误,但它不起作用.我怎样才能解决这个问题?
我在android上使用APPRTCdemo应用程序.我试图让它播放来自其他同伴的声音,就像在Android设置中设置音量一样响亮.因此,如果用户将设备静音,则不会听到音频.我几乎尝试了所有Android API调用,但似乎没有任何影响.这些是我尝试的东西:AudioManager audioManager =(AudioManager)_context.getSystemService(Context.AUDIO_SERVICE); int volume = audioManager.getStreamVolume(AudioManager.STREAM_VOICE_CALL);
volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
volume =audioManager.getStreamVolume(AudioManager.STREAM_RING);
volume =audioManager.getStreamVolume(AudioManager.STREAM_ALARM);
volume =audioManager.getStreamVolume(AudioManager.STREAM_NOTIFICATION);
volume =audioManager.getStreamVolume(AudioManager.STREAM_SYSTEM);
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, 0, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
audioManager.setStreamVolume(AudioManager.MODE_IN_COMMUNICATION, 0, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
audioManager.setStreamVolume(AudioManager.STREAM_VOICE_CALL, 0,AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
audioManager.setStreamMute(AudioManager.MODE_IN_COMMUNICATION, true);
audioManager.setStreamMute(AudioManager.STREAM_SYSTEM, true);
audioManager.setStreamMute(AudioManager.STREAM_RING, true);
audioManager.setStreamMute(AudioManager.STREAM_MUSIC, true);
audioManager.setStreamMute(AudioManager.STREAM_NOTIFICATION, true);
Run Code Online (Sandbox Code Playgroud) 我正在将WebRTC本地实现到Android中.我能够编译和运行这里描述的代码http://www.webrtc.org/native-code/android,但我遇到了一个问题,apprtc.appspot.com显然没有按照假设返回一个通道令牌:
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 …Run Code Online (Sandbox Code Playgroud) 最近在研究android中的webrtc。
我想单击SurfaceView A 使其全屏,而另一个SurfaceView B 变小,或者单击 B。但我发现很难在运行时更改两个不同 SurfaceView 的 z 顺序。
这是我的布局
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:showIn="@layout/app_bar_main">
<org.webrtc.PercentFrameLayout
android:id="@+id/remote_video_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.webrtc.SurfaceViewRenderer
android:id="@+id/remote_video_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</org.webrtc.PercentFrameLayout>
<org.webrtc.PercentFrameLayout
android:id="@+id/local_video_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<org.webrtc.SurfaceViewRenderer
android:id="@+id/local_video_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:keepScreenOn="true" />
</org.webrtc.PercentFrameLayout>
Run Code Online (Sandbox Code Playgroud)
PercentFrameLayout 是 ViewGroup 的子类,用于测量屏幕百分比。
我尝试在运行时使用 setZOrderMediaOverlay 但失败了。我发现SDK说
请注意,必须在将表面视图的包含窗口附加到窗口管理器之前设置此项。
那么这是否意味着我无法在运行时更改SurfaceView z 顺序?或者有什么办法可以破解它吗?
对不起,我的英语不好。
编辑1 SurfaceViewRender和PercentFrameLayout
都来自库,SurfaceViewRender是SurfaceView的子类。
简单地说,我将运行本地流行的 WEBRTC 应用程序示例:github.com/webrtc/apprtc
apprtc 已安装,甚至无需转向服务器即可在本地运行(“同源策略”不允许使用 Google TURN 服务器,该服务器仅适用于 apprtc.appspot.com:access-control-allow-origin:” https://apprtc .appspot.com ”)。
但我知道在真实的互联网世界(nats 和防火墙)中,我需要转服务器。所以我决定使用自己的 STUN/TURN 服务器:
code.google.com/p/coturn/
我正在尝试将我的 apprtc 与 coturn 集成:
+apprtc: http://localhost:8080/?wstls=false
+coturn: http://localhost: 3478
Run Code Online (Sandbox Code Playgroud)
我有问题:
a) 我是否需要执行一些在 INSTALL 指南中描述的 turnadmin 命令?或者从示例运行 turnserver 就足够了:my_name@my_machine:~/WEBRTC/turnserver-4.4.5.2/examples/scripts/restapi$ ./secure_relay_secret.sh
其中包含:
if [ -d examples ] ; then
cd examples
fi
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/:/usr/local/mysql/lib/
export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/usr/local/lib/:/usr/local/mysql/lib/
PATH="./bin/:../bin/:../../bin/:${PATH}" turnserver -v --syslog -a -L 127.0.0.1 -L ::1 -E 127.0.0.1 -E ::1 --max-bps=3000000 -f -m 3 --min-port=32355 --max-port=65535 --use-auth-secret --static-auth-secret=logen --realm=north.gov --cert=turn_server_cert.pem --pkey=turn_server_pkey.pem --log-file=stdout -q 100 -Q …Run Code Online (Sandbox Code Playgroud) 用例 - 我正在使用 android 投影 API 来捕获我的 android 设备屏幕。输出显示在 SurfaceView 中。接下来我想使用 Webrtc 将表面视图数据投影到 Web 浏览器。
我见过很多使用设备摄像头并将其输出到网络浏览器的示例。如何将在 SurfaceView/TextureView 上播放的视频流式传输到 Web 浏览器。
我正在尝试在 Android Studio 中使用 webrtc。文件libjingle_peerconnection_so.so放入文件夹src/main/jniLibs/arneabi-v7a中。但是当我放入 Java 文件时:
import org.webrtc.DataChannel;
Run Code Online (Sandbox Code Playgroud)
它告诉我无法解析“无法解析符号 webrtc ”。任何帮助表示赞赏。
java-native-interface android webrtc android-studio apprtcdemo
我目前正在尝试对Swift 中 iOS 版 AppRTC 应用程序中传入的 WebRTC 视频流进行一些修改(该应用程序又基于此Objective-C 版本)。为此,我需要访问存储在类 RTCI420Frame 的帧对象中的数据(这是libWebRTC的 Objective-C 实现的基本类)。特别是,我需要一个字节数组:[UInt8]和帧的大小。该数据将用于进一步处理和添加一些过滤器。
问题是, RTCVideoTrack / RTCEAGLVideoView 上的所有操作都是在预编译的libWebRTC.a的引擎盖下完成的,它是从上面链接的官方 WebRTC 存储库编译的,并且获得它的自定义构建相当复杂,所以我更喜欢使用示例 iOS 项目中可用的构建;根据我的理解,它应该具有所有可用的功能。
我正在研究 RTCVideoChatViewController 类,特别是remoteView / RemoteVideoTrack,但在访问帧本身方面没有成功,花了很多时间研究官方存储库中的 libWebRTC 源代码,但仍然无法解决访问帧的问题框架数据以供自己使用它进行操作。很高兴获得任何帮助!
我正在尝试使用Android上的Crosswalk运行AppRTC HTML5演示.但由于某种原因,我无法让麦克风工作.
我从GitHub获得了AppRTC HTML5演示源,并按照说明进行构建.完成后,我使用生成的Chrome应用输出并编辑了appwindow.html要包含的文件cordova.js,并修复了包含文件的路径.
最后,我使用Cordova和crosswalk插件构建(使用cordova build命令).该应用程序工作并连接到服务器,视频工作得很好,从PC接收音频很好,但不发送来自移动设备的音频.我不确定有什么问题,请帮助修复音频.
下面是Cordova配置文件.
config.xml中
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.test.xapprtc" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>xAppRtc</name>
<description>
AppRTC on crosswalk.
</description>
<author email="test@test.com" href="http://test.com">
Test
</author>
<content src="appwindow.html" />
<preference name="DisallowOverscroll" value="true" />
<preference name="Orientation" value="portrait" />
<preference name="EnableViewportScale" value="true" />
<preference name="StatusBarOverlaysWebView" value="false" />
<plugin name="cordova-plugin-whitelist" version="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform …Run Code Online (Sandbox Code Playgroud) webrtc cordova hybrid-mobile-app apprtcdemo crosswalk-runtime
我指的是并浏览了 AppRTCDemo 的源代码,它是 WebRTC 的演示应用程序。
我正在尝试的是:
https://apprtc.appspot.com/服务器和相关功能。 为了存档以上几点,我想了解 WebRTC 函数调用的基本流程和发出/接收调用的步骤(我需要调用并在那里流动的函数)。
我已经浏览了源代码并理解了一些东西,但是因为代码很难理解,而且没有任何文档。
如果有人提供任何示例或文档来解释拨打/接收 AV 呼叫的步骤(我们如何获取/设置 SDP,如何呈现本地/远程视频等),这将是非常有帮助的。
我看过这些帖子,非常有帮助:
我能够构建和运行 AppRTCDemo 应用程序。
对此的任何帮助都会有很大帮助!
apprtcdemo ×12
webrtc ×12
android ×7
audio ×2
apprtc ×1
avfoundation ×1
cordova ×1
ios ×1
java ×1
stun ×1
surfaceview ×1
swift ×1
z-order ×1