package org.libsdl.app;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import android.app.*;
import android.content.*;
import android.content.res.Configuration;
import android.text.TextUtils;
import android.view.*;
import android.view.inputmethod.BaseInputConnection;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputMethodManager;
import android.widget.AbsoluteLayout;
import android.os.*;
import android.util.Log;
import android.graphics.*;
import android.media.*;
import android.hardware.*;
import android.widget.Toast;
/**
* SDL Activity
*/
public class SDLActivity extends Activity {
private static final String TAG = "SDL";
// Keep track of the paused state
public static boolean mIsPaused, mIsSurfaceReady, mHasFocus;
public static boolean mExitCalledFromJava;
// Main components
protected static SDLActivity mSingleton;
protected static SDLSurface mSurface;
protected static View mTextEdit;
protected static ViewGroup mLayout;
protected static SDLJoystickHandler mJoystickHandler;
// This is what SDL runs in. It invokes SDL_main(), eventually
protected static Thread mSDLThread;
// Audio
protected static AudioTrack mAudioTrack;
// rtsp address
protected static String rtspAddress;
// progress
private static ProgressDialog progressDialog;
private static Handler handler;
// Load the .so
static {
System.loadLibrary("play_rtsp");
System.loadLibrary("ffmpeg");
System.loadLibrary("SDL2");
System.loadLibrary("SDL2main");
}
public static void initialize() {
// The static nature of the singleton and Android quirkyness force us to initialize everything here
// Otherwise, when exiting the app and returning to it, these variables *keep* their pre exit values
mSingleton = null;
mSurface = null;
mTextEdit = null;
mLayout = null;
mJoystickHandler = null;
mSDLThread = null;
mAudioTrack = null;
rtspAddress = null;
progressDialog = null;
handler = null;
mExitCalledFromJava = false;
mIsPaused = false;
mIsSurfaceReady = false;
mHasFocus = true;
}
// Setup
@Override
protected void onCreate(Bundle savedInstanceState) {
Log.v("SDL", "onCreate():" + mSingleton);
super.onCreate(savedInstanceState);
SDLActivity.initialize();
rtspAddress = getIntent().getStringExtra("data");
if (TextUtils.isEmpty(rtspAddress)) {
finish();
return;
}
progressDialog = new ProgressDialog(this);
progressDialog.setCanceledOnTouchOutside(false);
handler = new MyHandler();
// So we can call stuff from static callbacks
mSingleton = this;
// Set up the surface
mSurface = new SDLSurface(getApplication());
if (Build.VERSION.SDK_INT >= 12) {
mJoystickHandler = new SDLJoystickHandler_API12();
} else {
mJoystickHandler = new SDLJoystickHandler();
}
mLayout = new AbsoluteLayout(this);
mLayout.addView(mSurface);
setContentView(mLayout);
}
class MyHandler extends Handler {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 1:
if (progressDialog != null) {
progressDialog.setMessage("...");
if (!isFinishing() && !isDestroyed() && !progressDialog.isShowing()) {
progressDialog.show();
}
}
break;
case 2:
if (progressDialog != null && !isFinishing() && !isDestroyed()) {
progressDialog.dismiss();
}
break;
case 3:
if (!isFinishing() && !isDestroyed()) {
Toast.makeText(mSingleton, msg.obj.toString(), Toast.LENGTH_SHORT).show();
}
break;
}
}
}
//c调用
public static void jniProgress(int what) {
Log.i(TAG, "what:" + what);
handler.sendEmptyMessage(what);
}
//c调用
public static void jniToast(String msg) {
Log.i(TAG, "msg:" + msg);
Message message = Message.obtain();
message.what = 3;
message.obj = msg;
handler.sendMessage(message);
}
// Events
@Override
protected void onPause() {
Log.v("SDL", "onPause()");
super.onPause();
SDLActivity.handlePause();
}
@Override
protected void onResume() {
Log.v("SDL", "onResume()");
super.onResume();
SDLActivity.handleResume();
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
Log.v("SDL", "onWindowFocusChanged(): " + hasFocus);
SDLActivity.mHasFocus = hasFocus;
if (hasFocus) {
SDLActivity.handleResume();
}
}
@Override
public void onLowMemory() {
Log.v("SDL", "onLowMemory()");
super.onLowMemory();
SDLActivity.nativeLowMemory();
}
@Override
protected void onDestroy() {
Log.v("SDL", "onDestroy()");
// Send a quit message to the application
SDLActivity.mExitCalledFromJava = true;
SDLActivity.nativeQuit();
// Now wait for the SDL thread to quit
if (SDLActivity.mSDLThread != null) {
try {
SDLActivity.mSDLThread.join();
} catch (Exception e) {
Log.v("SDL", "Problem stopping thread: " + e);
}
SDLActivity.mSDLThread = null;
//Log.v("SDL", "Finished waiting for SDL thread");
}
super.onDestroy();
// Reset everything in case the user re opens the app
SDLActivity.initialize();
android.os.Process.killProcess(android.os.Process.myPid());
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
int keyCode = event.getKeyCode();
if (keyCode == KeyEvent.KEYCODE_BACK) {
handleNativeExit();
}
// Ignore certain special keys so they're handled by Android
if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
keyCode == KeyEvent.KEYCODE_VOLUME_UP ||
keyCode == KeyEvent.KEYCODE_CAMERA ||
keyCode == 168 || /* API 11: KeyEvent.KEYCODE_ZOOM_IN */
keyCode == 169 /* API 11: KeyEvent.KEYCODE_ZOOM_OUT */
) {
return false;
}
return super.dispatchKeyEvent(event);
}
/**
* Called by onPause or surfaceDestroyed. Even if surfaceDestroyed
* is the first to be called, mIsSurfaceReady should still be set
* to 'true' during the call to onPause (in a usual scenario).
*/
public static void handlePause() {
if (!SDLActivity.mIsPaused && SDLActivity.mIsSurfaceReady) {
SDLActivity.mIsPaused = true;
SDLActivity.nativePause();
mSurface.enableSensor(Sensor.TYPE_ACCELEROMETER, false);
}
}
/**
* Called by onResume or surfaceCreated. An actual resume should be done only when the surface is ready.
* Note: Some Android variants may send multiple surfaceChanged events, so we don't need to resume
* every time we get one of those events, only if it comes after surfaceDestroyed
*/
public static void handleResume() {
if (SDLActivity.mIsPaused && SDLActivity.mIsSurfaceReady && SDLActivity.mHasFocus) {
SDLActiv
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
播放rtsp,rtmp视频流安卓代码 (1024个子文件)
resources-arm7-debug.ap_ 30KB
resources-arm7-debug-androidTest.ap_ 761B
app-arm7-debug.apk 4.73MB
app-arm7-debug-unaligned.apk 4.73MB
gradlew.bat 2KB
fileSnapshots.bin 797KB
taskArtifacts.bin 265KB
fileHashes.bin 252KB
compilationState.bin 198KB
outputFileStates.bin 23KB
localClassSetAnalysis.bin 19KB
localJarClasspathSnapshot.bin 18KB
SDL_audiotypecvt.c 605KB
SDL_blit_auto.c 275KB
SDL_test_imageBlitBlend.c 207KB
SDL_malloc.c 188KB
SDL_test_imageBlit.c 113KB
SDL_render_d3d11.c 112KB
SDL_blit_N.c 90KB
SDL_video.c 86KB
SDL_test_font.c 83KB
SDL_dxjoystick.c 66KB
SDL_render_gles2.c 63KB
SDL_render_d3d.c 60KB
SDL_RLEaccel.c 53KB
SDL_syshaptic.c 52KB
SDL_android.c 52KB
SDL_test_common.c 52KB
SDL_render.c 52KB
SDL_test_imagePrimitivesBlend.c 51KB
SDL_windowskeyboard.c 50KB
SDL_render_gl.c 49KB
SDL_x11window.c 47KB
SDL_yuv_sw.c 44KB
SDL_DirectFB_render.c 43KB
SDL_blit_A.c 42KB
SDL_string.c 41KB
SDL_gamecontroller.c 40KB
SDL_syshaptic.c 39KB
SDL_audio.c 37KB
SDL_x11events.c 37KB
SDL_test_imagePrimitives.c 37KB
SDL_render_gles.c 36KB
SDL_audiocvt.c 36KB
SDL_shaders_gles2.c 35KB
SDL_windowsevents.c 33KB
SDL_evdev.c 33KB
SDL_pixels.c 31KB
SDL_syshaptic.c 30KB
SDL_surface.c 30KB
SDL_x11modes.c 29KB
SDL_iconv.c 28KB
SDL_DirectFB_events.c 28KB
SDL_render_psp.c 27KB
SDL_x11opengl.c 27KB
SDL_qsa_audio.c 27KB
SDL_x11messagebox.c 27KB
SDL_pandora.c 26KB
SDL_sysjoystick.c 25KB
SDL_sysjoystick.c 25KB
SDL_windowsopengl.c 24KB
SDL_blendline.c 24KB
SDL_test_harness.c 24KB
SDL_render_sw.c 23KB
imKStoUCS.c 23KB
SDL_windowswindow.c 22KB
SDL_xinputjoystick.c 22KB
SDL_keyboard.c 22KB
SDL_stdlib.c 22KB
SDL_yuv_mmx.c 21KB
SDL_x11video.c 21KB
SDL_joystick.c 21KB
SDL_alsa_audio.c 21KB
SDL_cpuinfo.c 20KB
SDL_gesture.c 20KB
SDL_rwops.c 20KB
SDL_mouse.c 20KB
edid-parse.c 19KB
SDL_wave.c 19KB
SDL_bmp.c 18KB
SDL_haptic.c 18KB
SDL_coreaudio.c 18KB
SDL_paudio.c 18KB
SDL_sysjoystick.c 18KB
SDL_xaudio2.c 17KB
SDL_pulseaudio.c 17KB
SDL_events.c 17KB
SDL_directsound.c 17KB
SDL_DirectFB_window.c 16KB
SDL_test_imageFace.c 16KB
SDL_sysjoystick.c 16KB
SDL_qsort.c 16KB
SDL_egl.c 15KB
SDL_rotate.c 15KB
SDL_DirectFB_video.c 15KB
e_sqrt.c 15KB
SDL_mmjoystick.c 14KB
SDL_test_fuzzer.c 13KB
e_pow.c 13KB
SDL_androidkeyboard.c 13KB
共 1024 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11
cjoo
- 粉丝: 3
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页