资源简介
基于rtp协议封装的数据收发sdk可用于android工程或修改后用于java项目,对于大量数据实时传输的应用。目前采用pcm格式语音数据做的测试,数据收发稳定
代码片段和文件信息
package com.nixtalk.rtp;
import android.app.Instrumentation;
import android.app.Service;
import android.content.Intent;
import android.hardware.input.InputManager;
import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.view.InputEvent;
import android.view.KeyEvent;
import com.nixtalk.rtp.manager.ServerManager;
import com.nixtalk.sound.multiplex.NettyRecordClient;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.FormatStrategy;
import com.orhanobut.logger.Logger;
import com.orhanobut.logger.PrettyFormatStrategy;
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import bjc.com.smartaudio.SmartAudio;
import xiaofei.library.hermeseventbus.HermesEventBus;
public class RtpService extends Service{
private NettyRecordClient mNettyRecordClient = null;
ServerManager serverManager = new RtpLocalRecever();
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
}
};
public RtpService() {
super();
}
@Override
public void onCreate() {
super.onCreate();
Logger.i(“ onCreate “);
serverManager.setMode(ServerManager.SEVER);
serverManager.setRunning(true);
serverManager.setRecording(true);
Thread sessionThread = new Thread(serverManager);
sessionThread.start();
mNettyRecordClient = new NettyRecordClient(this “com.nixtalk.speech“);
//handler.postAtFrontOfQueue(this);
HermesEventBus.getDefault().register(this);
}
@Override
public IBinder onBind(Intent intent) {
// TODO: Return the communication channel to the service.
throw new UnsupportedOperationException(“Not yet implemented“);
}
@Override
public int onstartCommand(Intent intent int flags int startId) {
return START_STICKY;
}
@Override
public void onDestroy() {
Logger.i( “onDestory“);
HermesEventBus.getDefault().destroy();
// Intent localIntent = new Intent();
// localIntent.setClass(this RtpService.class); // 销毁时重新启动Service
// this.startService(localIntent);
}
class RtpLocalRecever extends ServerManager {
final File pcmFile = new File(Environment.getExternalStorageDirectory()
.getAbsolutePath() + “/test2.pcm“);
DataOutputStream dataOutputStreamInstance;
BufferedOutputStream bufferedStreamInstance = null;
private int memeryWritePositon = 0;
private Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2020-01-06 16:57 com.nixtalk.rtp\
文件 7 2019-06-18 10:07 com.nixtalk.rtp\.gitignore
文件 1608 2019-06-18 10:07 com.nixtalk.rtp\build.gradle
目录 0 2020-01-06 16:57 com.nixtalk.rtp\libs\
文件 284220 2019-06-18 10:07 com.nixtalk.rtp\libs\commons-lang-2.6.jar
文件 641544 2019-06-18 10:07 com.nixtalk.rtp\libs\mina-core-2.0.2.jar
文件 3819730 2019-06-18 10:07 com.nixtalk.rtp\libs\netty-all-4.1.24.Final.jar
文件 382442 2019-06-18 10:07 com.nixtalk.rtp\libs\org.springfr
文件 415607 2019-06-18 10:07 com.nixtalk.rtp\libs\rtmpclient-0.2.jar
文件 32008 2019-06-18 10:07 com.nixtalk.rtp\libs\slf4j-android-1.6.1-RC1.jar
文件 1890605 2019-06-18 10:07 com.nixtalk.rtp\libs\smartaudio-debug.aar
文件 751 2019-06-18 10:07 com.nixtalk.rtp\proguard-rules.pro
目录 0 2020-01-06 16:57 com.nixtalk.rtp\src\
目录 0 2020-01-06 16:57 com.nixtalk.rtp\src\main\
文件 670 2019-06-18 10:07 com.nixtalk.rtp\src\main\AndroidManifest.xm
目录 0 2020-01-06 16:57 com.nixtalk.rtp\src\main\java\
目录 0 2020-01-06 16:57 com.nixtalk.rtp\src\main\java\com\
目录 0 2020-01-06 16:57 com.nixtalk.rtp\src\main\java\com\nixtalk\
目录 0 2020-01-06 16:57 com.nixtalk.rtp\src\main\java\com\nixtalk\rtp\
文件 7839 2019-06-18 10:07 com.nixtalk.rtp\src\main\java\com\nixtalk\rtp\RtpService.java
目录 0 2020-01-06 16:57 com.nixtalk.rtp\src\main\java\com\nixtalk\rtp\io\
文件 307 2019-06-18 10:07 com.nixtalk.rtp\src\main\java\com\nixtalk\rtp\io\Consumer.java
文件 3442 2019-06-18 10:07 com.nixtalk.rtp\src\main\java\com\nixtalk\rtp\io\PcmPla
文件 3760 2019-06-18 10:07 com.nixtalk.rtp\src\main\java\com\nixtalk\rtp\io\PcmRecorder.java
文件 3043 2019-06-18 10:07 com.nixtalk.rtp\src\main\java\com\nixtalk\rtp\io\PcmWriter.java
目录 0 2020-01-06 16:57 com.nixtalk.rtp\src\main\java\com\nixtalk\rtp\jlibrtp\
文件 3491 2019-06-18 10:07 com.nixtalk.rtp\src\main\java\com\nixtalk\rtp\jlibrtp\AppCallerThread.java
文件 8009 2019-06-18 10:07 com.nixtalk.rtp\src\main\java\com\nixtalk\rtp\jlibrtp\CompRtcpPkt.java
文件 8125 2019-06-18 10:07 com.nixtalk.rtp\src\main\java\com\nixtalk\rtp\jlibrtp\Datafr
文件 2982 2019-06-18 10:07 com.nixtalk.rtp\src\main\java\com\nixtalk\rtp\jlibrtp\DebugAppIntf.java
文件 25926 2019-06-18 10:07 com.nixtalk.rtp\src\main\java\com\nixtalk\rtp\jlibrtp\LICENSE.txt
............此处省略39个文件信息
- 上一篇:CXF接口所有所需jar包
- 下一篇:Android studio 百度地图定位
评论
共有 条评论