基于android的ipcamera编程,spydroid-ipcamera-master完整实现源码

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

【实例简介】

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值