Compartilhar via


ChatterBox VoIP WP8.1 sample app

The sample code can be downloaded from https://code.msdn.microsoft.com/windowsapps/ChatterBox-VoIP-WP81-64921ad4

This sample is a Windows Phone VoIP WP8.1 app that demonstrates call management, audio and video capture and render, push notifications, and VoIP background agents. 

It shows you how to:

  • Structure a VoIP app for Windows Phone.
  • Capture and render audio and video.
  • Integrate streaming video into the app’s UI.
  • Implement the VoIP background agents and manage the background process life cycle.
  • Set up a Microsoft Push Notification Service channel and use it to initiate a VoIP call.
  • Enable inter-process communication using the Windows Phone Runtime.
  • Use the Windows Phone Runtime VoIP APIs, including:
    • VideoRenderer
    • VoipPhoneCall
    • VoipCallCoordinator
    • AudioRoutingManager

Run the sample

  1. Before running the sample, you must set the UI project to be the startup project. In Solution Explorer, right-click the UI project icon and then choose Set as Startup Project.
  2. To debug the app and then run it, press F5 or use Debug >Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.
  3. The main screen has four buttons:
  • Make out going call – Takes you first to a dialing screen and, after you click Dial, takes you to the VoIP call experience. This example doesn’t actually dial an external number. Instead, it uses loopback video that streams the video being captured by the camera back to the UI with a slight delay. You will need a physical device to view actual video, but the emulator simulates camera input so the app can still be used on the emulator.
  • Simulate incoming call – Takes you to a screen that lets you simulate an incoming call by sending a push notification to the app. When the push notification is received on the phone, the built-in phone UI launches and prompts you to answer the call with audio, or with audio and video. Once you accept the call, you return to the VoIP app and the simulated call with loopback video.
  • View call status – Takes you to the active call UI. This button is only enabled when a call is active.
  • Email push uri – Emails the URI that’s used to send incoming call notifications to the phone. This will allow you to initiate VoIP calls from another machine. You must have an email account set up on the device or emulator before you can send the URI.
  1. The app’s call in progress screen is the screen users will see when they are in a video call. At the top of the screen are buttons to switch the audio routing to different end points. At the bottom of the screen are buttons to end the call, put the call on hold, or switch video input between the front camera and the back camera. Behind the UI, the live video feed from the camera is shown in a small inset rectangle. Behind this, loopback video simulating incoming network video is shown.
  2. Exiting the app while a call is in progress will demonstrate how the VoIP call status is displayed in the phone UI.

Sample description

The ChatterBox VoIP sample solution is made up of four projects:

  • UI – This project implements the main foreground app that provides the UI for the app. This is a typical Windows Phone app that uses XAML and managed code. The foreground app also is responsible for setting up the push notifications channel and launching the background process.
  • Agents – This project implements the background agents that help manage the background process. These agents are written in managed code and run at various stages of the VoIP app life cycle such as when an incoming call arrives or when the foreground app is running.
  • BackEnd – This project performs the work of managing call state, integrating with the phone’s built-in phone call processes, and managing audio and video streams. This project is written using the Windows Phone Runtime VoIP APIs like the VoIPCallCoordinator and the AudioRoutingManager.
  • BackEndProxyStub – This is an out-of-process server written in C that enables communication between the foreground app and the background process.

 

简体中文版

话匣子是使用环回音频和视频演示Windows Phone8.1的VoIP功能的应用程序。此示例演示如何:

  • 构建Windows Phone的VoIP应用程序。
  • 捕捉和呈现音频和视频。
  • 集成视频流到应用程序的UI。
  • 实现VoIP的后台代理和管理后台流程的生命周期。
  • 设置Microsoft推送通知服务通道,并用它来启动VoIP呼叫。
  • 启用使用Windows Phone运行的进程间通信。
  • 使用Windows Phone运行时VoIP API,包括:
    • VideoRenderer
    • VoipPhoneCall
    • VoipCallCoordinator
    • AudioRoutingManager

 

运行示例

  1. 在运行该示例前,您必须先设置 UI 项目作为启动项目。在解决方案资源管理器中,用鼠标右键单击UI项目图标,然后选择设置为启动项目。
  2. 调试应用程序,然后运行,请按 F5 键或使用调试 > 开始调试。若要运行该应用程序而不调试,请按 Ctrl + F5 或者使用调试 > 开始执行 (不调试)。
  3. 主屏幕有四个按钮:
  • 模拟呼叫 — — 先展示一个打电话界面,您单击拨号后, 会 将您带到 VoIP 呼叫体验。本示例实际上并没有拨打外部号码。取而代之,它采用环回视频展示由摄像头捕获传回UI的稍有延迟的视频。您需要一个物理设备来查看实际视频,但模拟器模拟了摄像头输入,所以此应用程序仍然可以在模拟器上使用。
  • 模拟来电 — — 展示一个通过向此应用程序发推送通知来模拟来电的界面。当在手机上收到推送通知时,内置手机 UI 启动并提示您接听音频来电,或音频加视频来电。一旦您接听电话,就返回到 VoIP 应用程序和环回视频模拟通话。
  • 查看呼叫状态 — — 带您到当前的通话UI。当呼叫处于活动状态时,才启用此按钮。
  • 电子邮件推送 URI— — 电子邮件发送URI,此URI可发来电通知到手机。这将允许您从另一台机器启动 VoIP 呼叫。但在发送URI前,你必须在手机或模拟器上设置一个电子邮件帐户。
  1. 应用程序的通话界面是正处于视频通话的用户所看见的界面。屏幕顶部的按钮能切换音频路由到不同的输出设备。屏幕底部的按钮可结束通话、保持通话,或切换前置摄像头和后摄像头的视频输入。在UI背后,来自摄像头的实时视频显示在一个小的内嵌矩形。在这后面,显示环回视频模拟传入的网络视频。
  2. 同时在通话过程中退出应用程序,将演示 VoIP 呼叫状态在手机用户界面中的显示方式

 

示例说明 

话匣子 VoIP 示例工程由四个项目组成:

  • UI — —该项目实现了主要的前台应用程序,提供了用户界面。这是一个典型的 Windows Phone 应用程序,使用了 XAML 代码和托管代码。前台应用程序还负责设置推送通知通道和启动后台进程。
  • Agents — — 该项目实现了后台代理,来帮助管理后台进程。这些代理是用托管代码编写的,并运行在VoIP 应用程序生命周期的不同阶段,例如传入呼叫到达时或前台应用程序运行时。
  • BackEnd — — 这个项目主要管理呼叫状态,整合手机的内置呼叫处理流程,及管理音频和视频流。这个项目是使用 Windows Phone 运行时 VoIP Api (如 VoIPCallCoordinator 和 AudioRoutingManager) 编写的。
  • BackEndProxyStub — — 这是个用C 语 言 编写的进程外服务器,它启动了前台应用程序和后台进程之间的通信。