【实例简介】
android实现spydroid-ipcamera-master,h264进行硬编译,rstp进行传输,在电脑端成功播放
【实例截图】
public class SpydroidActivity extends FragmentActivity {
static final public String TAG = "SpydroidActivity";
public final int HANDSET = 0x01;
public final int TABLET = 0x02;
// We assume that the device is a phone
public int device = HANDSET;
private ViewPager mViewPager;
private PowerManager.WakeLock mWakeLock;
private SectionsPagerAdapter mAdapter;
private SurfaceView mSurfaceView;
private SpydroidApplication mApplication;
private CustomHttpServer mHttpServer;
private RtspServer mRtspServer;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mApplication = (SpydroidApplication) getApplication();
setContentView(R.layout.spydroid);
if (findViewById(R.id.handset_pager) != null) {
// Handset detected !
mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.handset_pager);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
mSurfaceView = (SurfaceView)findViewById(R.id.handset_camera_view);
SessionBuilder.getInstance().setSurfaceView(mSurfaceView);
SessionBuilder.getInstance().setPreviewOrientation(90);
} else {
// Tablet detected !
device = TABLET;
mAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
mViewPager = (ViewPager) findViewById(R.id.tablet_pager);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
SessionBuilder.getInstance().setPreviewOrientation(0);
}
mViewPager.setAdapter(mAdapter);
// Remove the ads if this is the donate version of the app.
if (mApplication.DONATE_VERSION) {
((LinearLayout)findViewById(R.id.adcontainer)).removeAllViews();
}
// Prevents the phone from going to sleep mode
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
mWakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "net.majorkernelpanic.spydroid.wakelock");
// Starts the service of the HTTP server
this.startService(new Intent(this,CustomHttpServer.class));
// Starts the service of the RTSP server
this.startService(new Intent(this,CustomRtspServer.class));
}
public

本文介绍了如何在Android平台上实现IP Camera应用——Spydroid-IPCamera,通过H264硬编码和RTP进行传输,确保在电脑端能够流畅播放。详细讲解了关键代码,包括SurfaceView的使用、HTTP和RTSP服务器的启动等。
最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



