我检查了此问题,但找不到任何解决方案。
我正在Android中实现RTSP播放器,并且为此使用了Easy Player。使用此播放器,我已经实现了我的演示应用程序并输入了rtsp://
URL。
问题:当我在库示例代码中输入相同的URL时,它可以正常工作,但是当我尝试使用Demo应用程序时,应用程序会随着stackTrace崩溃。
04-20 16:13:57.189 26834-26834/com.easydrawindemo A/libc: Fatal signal 11 (SIGSEGV) at 0x00000005 (code=1), thread 26834 (.easydrawindemo)
04-20 16:13:57.219 1163-1163/? D/BubblePopupHelper: isShowingBubblePopup : false
04-20 16:13:57.289 292-292/? I/DEBUG: [04-20 16:13:57.295]
04-20 16:13:57.289 292-292/? I/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
04-20 16:13:57.289 292-292/? I/DEBUG: Build fingerprint: 'lge/g3_global_com/g3:4.4.2/KVT49L.D85510i/D85510i.1403169216:user/release-keys'
04-20 16:13:57.289 292-292/? I/DEBUG: Revision: '10'
04-20 16:13:57.289 292-292/? I/DEBUG: pid: 26834, tid: 26834, name: .easydrawindemo >>> com.easydrawindemo <<<
04-20 16:13:57.289 292-292/? I/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000005
04-20 16:13:57.289 971-1151/? D/WifiStateMachine: handleMessage: E msg.what=131155
04-20 16:13:57.289 971-1151/? D/WifiStateMachine: processMsg: ConnectedState
04-20 16:13:57.289 971-1151/? D/WifiStateMachine: processMsg: L2ConnectedState
04-20 16:13:57.289 971-1151/? D/WifiNative-wlan0: doString: SIGNAL_POLL
04-20 16:13:57.289 971-1182/? W/NativeCrashListener: Couldn't find ProcessRecord for pid 1529885741
这是我的片段类:
public class PlayerFragment extends Fragment implements TextureView.SurfaceTextureListener, PhotoViewAttacher.OnMatrixChangedListener {
private TextureView videoSurfaceView;
private ProgressBar pBarVideo;
private String videoUrl;
private int transType;
protected EasyRTSPClient mStreamRender;
protected ResultReceiver mResultReceiver;
private MediaScannerConnection mScanner;
private int mWidth, mHeight;
private PhotoViewAttacher mAttacher;
private static final String TAG = "PlayerFragment";
public static final int RESULT_REND_STARTED = 1;
public static final int RESULT_REND_VIDEO_DISPLAYED = 2;
public static final int RESULT_REND_STOPED = -1;
private ResultReceiver mRR;
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setLandscapeOrientation();
Log.i(TAG, "onCreate called");
if (getArguments() != null) {
Log.i(TAG, "onCreate if called");
videoUrl = getArguments().getString(Constants.KEY_VIDEO_URL);
transType = getArguments().getInt(Constants.KEY_PROTOCOL_TYPE);
mRR = getArguments().getParcelable(Constants.KEY_RESULT_RECEIVER);
}
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_player, container, false);
Log.i(TAG, "onCreateView called");
videoSurfaceView = (TextureView) view.findViewById(R.id.videoSurfaceView);
videoSurfaceView.setOpaque(false);
videoSurfaceView.setSurfaceTextureListener(this);
pBarVideo = (ProgressBar) view.findViewById(R.id.pBarVideo);
return view;
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Log.i(TAG, "onViewCreated called");
mResultReceiver = new ResultReceiver(new Handler()) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
super.onReceiveResult(resultCode, resultData);
PlayerActivity activity = (PlayerActivity) getActivity();
if (activity == null)return;
if (resultCode == EasyRTSPClient.RESULT_VIDEO_DISPLAYED) {
Log.i(TAG, "ResultReceiver RESULT_VIDEO_DISPLAYED called");
// onVideoDisplayed();
}
else if (resultCode == EasyRTSPClient.RESULT_VIDEO_SIZE) {
Log.i(TAG, "ResultReceiver RESULT_VIDEO_SIZE called");
mWidth = resultData.getInt(EasyRTSPClient.EXTRA_VIDEO_WIDTH);
mHeight = resultData.getInt(EasyRTSPClient.EXTRA_VIDEO_HEIGHT);
// onVideoSizeChange();
}
else if (resultCode == EasyRTSPClient.RESULT_TIMEOUT) {
Log.i(TAG, "ResultReceiver RESULT_TIMEOUT called");
new AlertDialog.Builder(getActivity()).setMessage("Timeout").setTitle("SORRY").setPositiveButton(android.R.string.ok, null).show();
}
else if (resultCode == EasyRTSPClient.RESULT_UNSUPPORTED_AUDIO) {
Log.i(TAG, "ResultReceiver RESULT_UNSUPPORTED_AUDIO called");
new AlertDialog.Builder(getActivity()).setMessage("Unsupported Audio").setTitle("SORRY").setPositiveButton(android.R.string.ok, null).show();
}
else if (resultCode == EasyRTSPClient.RESULT_UNSUPPORTED_VIDEO) {
Log.i(TAG, "ResultReceiver RESULT_UNSUPPORTED_VIDEO called");
new AlertDialog.Builder(getActivity()).setMessage("Unsupported Video").setTitle("SORRY").setPositiveButton(android.R.string.ok, null).show();
}
else if (resultCode == EasyRTSPClient.RESULT_EVENT){
Log.i(TAG, "ResultReceiver RESULT_EVENT called");
int errorcode = resultData.getInt("errorcode");
if (errorcode != 0){
stopRendering();
}
// activity.onEvent(PlayFragment.this, errorcode,resultData.getString("event-msg"));
}
// else if (resultCode == EasyRTSPClient.RESULT_RECORD_BEGIN){
// activity.onRecordState(1);
// }
// else if (resultCode == EasyRTSPClient.RESULT_RECORD_END){
// activity.onRecordState(-1);
// }
}
};
if (mAttacher != null) {
mAttacher.cleanup();
}
mAttacher = new PhotoViewAttacher(videoSurfaceView, mWidth, mHeight);
mAttacher.setScaleType(ImageView.ScaleType.CENTER_CROP);
mAttacher.setOnMatrixChangeListener(PlayerFragment.this);
mAttacher.update();
}
public static PlayerFragment getInstance(String URL, int type, ResultReceiver rr) {
Log.i(TAG, "getInstance called");
PlayerFragment playerFragment = new PlayerFragment();
Bundle bundle = new Bundle();
bundle.putString(Constants.KEY_VIDEO_URL, URL);
bundle.putInt(Constants.KEY_PROTOCOL_TYPE, type);
bundle.putParcelable(Constants.KEY_RESULT_RECEIVER, rr);
playerFragment.setArguments(bundle);
return playerFragment;
}
private void setLandscapeOrientation() {
Log.i(TAG, "setLandscapeOrientation called");
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int i, int i1) {
Log.i(TAG, "onSurfaceTextureAvailable called");
startRendering(surfaceTexture);
}
@Override
public void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int i, int i1) {
Log.i(TAG, "onSurfaceTextureSizeChanged called");
}
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surfaceTexture) {
Log.i(TAG, "onSurfaceTextureDestroyed called");
stopRendering();
return true;
}
@Override
public void onSurfaceTextureUpdated(SurfaceTexture surfaceTexture) {
Log.i(TAG, "onSurfaceTextureUpdated called");
}
private void startRendering(SurfaceTexture surface) {
Log.i(TAG, "startRendering called");
mStreamRender = new EasyRTSPClient(getActivity(), "79393674363536526D343241654D7859707A4F484A655A76636D63755A57467A65575268636E64706269356C59584E356347786865575679567778576F502B6C34456468646D6C754A6B4A68596D397A595541794D4445325257467A65555268636E6470626C526C5957316C59584E35", surface, mResultReceiver);
// boolean autoRecord = PreferenceManager.getDefaultSharedPreferences(getContext()).getBoolean("auto_record", false);
// File f = new File(TheApp.sMoviePath);
// f.mkdirs();
try {
mStreamRender.start(videoUrl, transType, RTSPClient.EASY_SDK_VIDEO_FRAME_FLAG | RTSPClient.EASY_SDK_AUDIO_FRAME_FLAG, "", "", null);
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(getContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
// mStreamRender.start2(mUrl, mType);
mRR.send(RESULT_REND_STARTED, null);
}
private void stopRendering() {
Log.i(TAG, "stopRendering called");
if (mStreamRender != null) {
mRR.send(RESULT_REND_STOPED, null);
mStreamRender.stop();
mStreamRender = null;
}
}
@Override
public void onMatrixChanged(RectF rectF) {
Log.i(TAG, "onMatrixChanged called");
}
}
我尝试了几乎所有事情,但找不到解决方案。如果我做错了什么并为我提供解决方案,请纠正我。
预先感谢。
我发现了我的错误,在Easy Player中,为每个软件包名称生成一个唯一的密钥,在我的情况下,键是不正确的。我不知道为什么它会给无效的键带来内存泄漏错误!更换包装名称并解决了此问题。奇怪但真实。