简体   繁体   English

从Android录制和传输音频的设计

[英]Design for recording and transmitting audio from Android

I have two Android devices (Phone A & Phone B) and a server with a MySQL database. 我有两个Android设备(电话A和电话B)和一个带有MySQL数据库的服务器。 I want to send an audio message using a microphone, from Phone A to Phone B, through the server. 我想使用麦克风通过服务器从电话A到电话B发送音频消息。

One idea is to: 一种想法是:

  • use the microphone from the Phone A 使用电话A上的麦克风
  • record audio to a file in SD card 将音频录制到SD卡中的文件
  • get bytes of this file and send to server as a simple text message 获取此文件的字节并作为简单文本消息发送到服务器
  • the server stores this data in the database 服务器将此数据存储在数据库中
  • Phone B will poll server and receive this data 电话B将轮询服务器并接收此数据
  • then write the bytes to a new file 然后将字节写入新文件
  • then play it with MediaPlayer 然后用MediaPlayer播放

    1. Is this correct? 这个对吗?
    2. Does bytes have special characters ? 字节有特殊字符吗?

you need to capture the audio on phone A, and send it as binary data to the server. 您需要捕获电话A上的音频,并将其作为二进制数据发送到服务器。 You can use a simple POST request to do so. 您可以使用简单的POST请求来执行此操作。

The server should store that to a file, not the database -- the database should only contain the filename and path, plus an id. 服务器应将其存储到文件中,而不是数据库中,数据库应仅包含文件名和路径以及ID。

Phone B polls / gets push notification about the file. 电话B轮询/获取有关文件的推送通知。 Server uses ID to get filename from database and uses passthru to serve the file. 服务器使用ID从数据库获取文件名,并使用passthru来提供文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM