Comments (1)
经过添加log发现是由于连接异常断开,导致出现崩溃。更换网络环境后,没有出现奔溃,可能是连接断开情况下,上层依然往下层push数据导致堆栈溢出。
public class EasyRTMP implements Pusher {
private boolean isRTMPConnectNormal = false; // 用于标记连接是否正常
@OverRide
public synchronized void initPush(final String url, final Context context, final InitCallback callback, int fps) {
/*
*本Key为3个月临时授权License,如需商业使用,请邮件至[email protected]申请此产品的授权。
*/
Log.e(TAG, "startpush begin");
mPusherObj = init(url, RTMP_KEY, context, new OnInitPusherCallback() {
int code = Integer.MAX_VALUE;
@OverRide
public void onCallback(int code) {
if (code != this.code) {
this.code = code;
switch (code) {
case EasyRTMP.OnInitPusherCallback.CODE.EASY_ACTIVATE_INVALID_KEY:
// sendMessage("无效Key");
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_ACTIVATE_SUCCESS:
// sendMessage("激活成功");
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_RTMP_STATE_CONNECTING:
// sendMessage("连接中");
isRTMPConnectNormal = false; // 标记连接断开
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_RTMP_STATE_CONNECTED:
// sendMessage("连接成功");
isRTMPConnectNormal = true; // 标记连接成功
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_RTMP_STATE_CONNECT_FAILED:
// sendMessage("连接失败");
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_RTMP_STATE_CONNECT_ABORT:
// sendMessage("连接异常中断");
isRTMPConnectNormal = false; // 标记连接断开
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_RTMP_STATE_PUSHING:
// sendMessage("推流中");
isRTMPConnectNormal = true; // 标记连接成功
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_RTMP_STATE_DISCONNECTED:
// sendMessage("断开连接");
isRTMPConnectNormal = false; // 标记连接断开
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_ACTIVATE_PLATFORM_ERR:
// sendMessage("平台不匹配");
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_ACTIVATE_COMPANY_ID_LEN_ERR:
// sendMessage("断授权使用商不匹配");
break;
case EasyRTMP.OnInitPusherCallback.CODE.EASY_ACTIVATE_PROCESS_NAME_LEN_ERR:
// sendMessage("进程名称长度不匹配");
break;
}
Log.e("cclin", "RTMP 当前连接状态:"+isRTMPConnectNormal);
if (callback != null) callback.onCallback(code);
}
}
},
fps);
Log.e(TAG, "startpush end");
}
public synchronized void push(byte[] data, int offset, int length, long timestamp, int type){
mTotal += length;
if (type == 1){
mTotalFrms++;
}
long interval = System.currentTimeMillis() - pPreviewTS;
if (interval >= 3000){
long bps = mTotal * 1000 / (interval);
long fps = mTotalFrms * 1000 / (interval);
Log.i(TAG, String.format("bps:%d, fps:%d", fps, bps)+" myTid = "+android.os.Process.myTid());
pPreviewTS = System.currentTimeMillis();
mTotal = 0;
mTotalFrms = 0;
if (mCameraId == Camera.CameraInfo.CAMERA_FACING_BACK)
BUS.post(new StreamStatBack((int)fps, (int)bps));
else
BUS.post(new StreamStatFront((int)fps, (int)bps));
}
if (mPusherObj == 0 || !isRTMPConnectNormal) return;
push(mPusherObj, data, offset, length, timestamp,type);
}
不知这样修改,是否能够优化push逻辑呢?
from easyrtmp.
Related Issues (15)
- 缺少一个类 RTSP_FRAME_INFO HOT 1
- 问题
- 后台录制,推流就停止了,是什么原因那
- EASY_ACTIVATE_VALIDITY_PERIOD_ERR HOT 1
- 出现异常”烫烫烫烫“
- rtmps支持吗
- EasyRTMP_Activate Easy_NotAModule
- EasyRTMP(Android)v1.2.17.0511修改配置不生效
- 拜托上点心吧,连demo都跑不通 HOT 1
- Mac系统 执行./Buildit rtsp x64 报错
- Qt 运行 EasyRTMP_RTSP Linux x64 demo程序失败 HOT 1
- 关于libeasyrtmp.a与libeasypusher.a库冲突
- 支持RTP over UDP并且RTP的Payload是PS类型的数据直接推RTMP吗? HOT 1
- 推送的视频有办法加logo么?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easyrtmp.