I'm trying to use Vitamio to run RTSP video stream, I'm using Vitamio-sample after updating it to run the stream through VideoViewDemo
activity:
public class VideoViewDemo extends Activity {
/**
* TODO: Set the path variable to a streaming video URL or a local media file
* path.
*/
private String path = "rtsp://user:password@<stream-ip>:554";
private VideoView mVideoView;
private EditText mEditText;
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
if (!LibsChecker.checkVitamioLibs(this))
return;
setContentView(R.layout.videoview);
mEditText = (EditText) findViewById(R.id.url);
mVideoView = (VideoView) findViewById(R.id.surface_view);
if (path == "") {
// Tell the user to provide a media file URL/path.
Toast.makeText(VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
return;
} else {
/*
* Alternatively,for streaming media you can use
* mVideoView.setVideoURI(Uri.parse(URLstring));
*/
mVideoView.setVideoPath(path);
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
//mVideoView.setVideoURI(Uri.parse(path));
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
// optional need Vitamio 4.0
mediaPlayer.setPlaybackSpeed(1.0f);
}
});
}
}
public void startPlay(View view) {
String url = mEditText.getText().toString();
path = url;
if (!TextUtils.isEmpty(url)) {
mVideoView.setVideoPath(url);
}
}
public void openVideo(View View) {
mVideoView.setVideoPath(path);
}
}
But after running it, it only run for a very little time(which gives me only the first video frame [a fixed photo] ) and then the app crashes and give me app not responding message without printing any error messages in the log:
08-03 15:45:37.224: I/Vitamio[4.2.1][Player](27585): META AUDIO: 1. und, META SUBTITLE:
08-03 15:45:37.234: I/Vitamio[4.2.1][Player](27585): WOW: BRILLIANT C COUNT 4
08-03 15:45:37.234: I/Vitamio[4.2.1][Player](27585): OPEN STREAM AUDIO BEGIN
08-03 15:45:37.234: I/Vitamio[4.2.1][Player](27585): Copyright (c) YIXIA (http://yixia.com).
08-03 15:45:37.234: I/Vitamio[4.2.1][Player](27585): THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com)
08-03 15:45:37.234: I/Vitamio[4.2.1][Player](27585): Application package name: io.vov.vitamio.demo
08-03 15:45:37.234: I/Vitamio[4.2.1][Player](27585): 2, 48000, 0
08-03 15:45:37.234: V/AudioPolicyManagerBase(273): getOutput() device 2, stream 3, samplingRate 0, format 0, channelMask 3, flags 0
08-03 15:45:37.234: V/AudioPolicyManagerBase(273): getOutputsForDevice device 0002 -> 0002
08-03 15:45:37.234: V/AudioPolicyManagerBase(273): getOutput() returns output 2
08-03 15:45:37.234: V/AudioPolicyManagerBase(273): getOutput() device 2, stream 3, samplingRate 0, format 0, channelMask 3, flags 0
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): OPEN STREAM AUDIO END
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): Copyright (c) YIXIA (http://yixia.com).
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com)
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): Application package name: io.vov.vitamio.demo
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): WOW: BRILLIANT C COUNT 4
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): OPEN STREAM VIDEO BEGIN
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): OPEN STREAM VIDEO END
08-03 15:45:37.244: D/Vitamio[Player](27585): onVideoSizeChanged: (704x576)
08-03 15:45:37.244: V/audio_hw_primary(273): start_output_stream: enter: usecase(0: deep-buffer-playback) devices(0x2)
08-03 15:45:37.244: V/audio_hw_primary(273): select_devices: ENTER
08-03 15:45:37.244: V/audio_hw_primary(273): select_devices: usecase(normal)
08-03 15:45:37.244: V/audio_hw_primary(273): select_devices: usecase(PCM_PLAYBACK)
08-03 15:45:37.244: V/msm8974_platform(273): platform_get_output_snd_device: enter: output devices(0x2)
08-03 15:45:37.244: V/msm8974_platform(273): get_OUTPUT_snd_device: for Normal Playback
08-03 15:45:37.244: V/msm8974_platform(273): platform_get_output_snd_device: exit: snd_device(speaker)
08-03 15:45:37.244: D/audio_hw_primary(273): select_devices: out_snd_device(2: speaker)
08-03 15:45:37.244: D/audio_hw_primary(273): select_devices: in_snd_device(0: dummy)
08-03 15:45:37.244: V/audio_hw_primary(273): enable_snd_device: snd_device(2: speaker)
08-03 15:45:37.244: D/ACDB-LOADER(273): ACDB -> send_audio_cal, acdb_id = 15, path = 0
08-03 15:45:37.244: D/ACDB-LOADER(273): ACDB -> send_adm_topology
08-03 15:45:37.244: D/ACDB-LOADER(273): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TOPOLOGY_ID
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): THREAD PREPARE DETTACHED, ret = 0
08-03 15:45:37.244: I/Vitamio[4.2.1][Player](27585): THREAD PREPARE END
08-03 15:45:37.254: I/Vitamio[4.2.1][Player](27585): CC: SwsScale c
08-03 15:45:37.254: V/audio_hw_primary(273): start_output_stream: Opening PCM device card_id(0) device_id(0)
08-03 15:45:37.254: D/Vitamio[Player](27585): VIDEO: 704x576x1.222222, Surface: 704x576, LP: 1080x883, Window: 1080x1920x0.562500
08-03 15:45:37.264: E/Vitamio[4.2.1][Player](27585): [h264 @ 0x783fac40] Missing reference picture, default is 0
08-03 15:45:37.264: E/Vitamio[4.2.1][Player](27585): [h264 @ 0x783fac40] decode_slice_header error
08-03 15:45:37.304: I/Vitamio[Player](27585): Info (701, 0)
08-03 15:45:37.304: D/Vitamio[Player](27585): onInfo: (701, 0)
08-03 15:45:37.354: W/dalvikvm(27585): Invalid indirect reference 0x4309aa58 in decodeIndirectRef
08-03 15:45:37.354: I/dalvikvm(27585): "Thread-26042" prio=5 tid=19 RUNNABLE
08-03 15:45:37.354: I/dalvikvm(27585): | group="main" sCount=0 dsCount=0 obj=0x4306fca0 self=0x7b3ab4a8
08-03 15:45:37.354: I/dalvikvm(27585): | sysTid=28521 nice=0 sched=0/0 cgrp=apps handle=2016853936
08-03 15:45:37.354: I/dalvikvm(27585): | state=R schedstat=( 32461510 66037500 298 ) utm=2 stm=1 core=3
08-03 15:45:37.354: I/dalvikvm(27585): at dalvik.system.NativeStart.run(Native Method)
08-03 15:45:37.354: E/dalvikvm(27585): VM aborting
08-03 15:45:37.354: A/libc(27585): Fatal signal 6 (SIGABRT) at 0x00006bc1 (code=-6), thread 28521 (ov.vitamio.demo)
And later in the log I got the following message:
08-03 15:45:37.744: W/ActivityManager(852): Force finishing activity io.vov.vitamio.demo/.VideoViewDemo
08-03 15:45:37.754: W/ContextImpl(852): Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1469 com.android.server.am.ActivityStack.startPausingLocked:1002 com.android.server.am.ActivityStack.finishActivityLocked:3147 com.android.server.am.ActivityStack.finishTopRunningActivityLocked:2994 com.android.server.am.ActivityStackSupervisor.finishTopRunningActivityLocked:3093
08-03 15:45:37.764: W/ApplicationPackageManager(852): getCSCPackageItemText()
After scanning a lot of near similar problems, I figured that it's may be because it demands to has ACCESS_NETWORK_STATE
permission, although the log didn't tell me that but as it tells me it's not a qualified user to perform this process which means the user must be given the permission to be qualified for that, So, I added this permission:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
So, to run an authorized RTSP live stream using Vitamio, you need to register all of the following permissions:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />