waterfoxfox / RtmpPlayer-Android

low delay easy to use rtmp player for android
1 stars 1 forks source link

执行播放闪退 #3

Open chinanull opened 5 months ago

chinanull commented 5 months ago

[Uploading test_android_pro_052406.zip…]()

测试代码 `package com.mtl.myapplication;

import static com.sd.Constant.SystemStatusType.SYS_NOTIFY_CONNECT_SUCCESS; import static com.sd.Constant.SystemStatusType.SYS_NOTIFY_RECONNECT_START;

import android.content.Context; import android.media.AudioManager; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.util.Log; import android.widget.Toast;

import androidx.activity.EdgeToEdge; import androidx.appcompat.app.AppCompatActivity; import androidx.core.graphics.Insets; import androidx.core.view.ViewCompat; import androidx.core.view.WindowInsetsCompat;

import com.sd.Constant; import com.sd.SDInterface; import com.sd.SDInterfacePlayer;

import org.webrtc.SurfaceViewRenderer;

public class MainActivity extends AppCompatActivity {

//播放窗口
private SurfaceViewRenderer mSurfaceView = null;

//播放API
private SDInterfacePlayer mPlayer = null;

//基础API
private SDInterface mInterface = null;

//待播放的RTMP URL
String mRtmpUrl = "rtmp://192.168.110.101:3343/live/cast?hport=3342&hhost=http.flv";

//播放缓存大小,单位ms
int mJitterBuff = 200;

//是否启动播放
boolean mbPlayStart = false;

//日志文件存放路径
private String mLogfileDir = "/sdcard/mediapro/";

//来自底层消息的处理
private final Handler mHandler = new Handler(){

    @Override
    public void handleMessage(Message msg) {
        super.handleMessage(msg);

        switch (msg.what)
        {
            case SYS_NOTIFY_RECONNECT_START:
                Toast.makeText(MainActivity.this, "网络超时,开始重连服务器...", Toast.LENGTH_SHORT).show();
                break;
            case SYS_NOTIFY_CONNECT_SUCCESS:
                Toast.makeText(MainActivity.this, "连服务器成功", Toast.LENGTH_SHORT).show();
                break;
            default:
                break;
        }
    }

};

private static final String TAG = "SDMedia";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    EdgeToEdge.enable(this);
    setContentView(R.layout.activity_main);
    ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
        Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
        v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
        return insets;
    });
    Log.i(TAG, "0000000000" );

    //播放窗口
    mSurfaceView = (SurfaceViewRenderer) findViewById(R.id.suface_view);

    //AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
    //am.setSpeakerphoneOn(true);

    //初始化基础API、播放API
    initAvResource();

    //连接服务器
    int nRet = startConnect();
   if (nRet == 0)
    {
        //开始播放渲染
        //获得渲染窗口宽高比,以便对底层渲染进行宽高比指导。
        //注意:底层只关心宽高比值,而非精确宽高像素值
        mSurfaceView.post(new Runnable()
                          {
                              @Override
                              public void run() {
                                  int rendHeight = mSurfaceView.getMeasuredHeight();
                                  int rendWidth = mSurfaceView.getMeasuredWidth();
                                  Log.i(TAG, "get render width:" + rendWidth + "  render height:" + rendHeight);

                                  //开始播放
                                  startPlay(rendWidth, rendHeight);
                              }
                          }
        );
    }
}

//初始化基础API、播放API
private void initAvResource()
{
    mInterface = new SDInterface(mHandler);
    mPlayer = new SDInterfacePlayer();

    // 初始化系统,指定服务器IP地址、本地客户端输出日志文件级别和存放路径
    int ret = mInterface.SDsysinit(this.getFilesDir().getPath(), Constant.LogLevel.LOG_LEVEL_DEBUG);
    if(0 != ret)
    {
        Toast.makeText(this, "初始化资源返回错误编码:" + ret, Toast.LENGTH_LONG).show();
        Log.e(TAG, "SDsysinit failed return:" + ret);
    }

    mPlayer.SDplayinit(this, mSurfaceView, false, false);
}

//连接媒体服务器
private int startConnect()
{
    Log.i(TAG, "yyy" );
    Log.i(TAG, mRtmpUrl );
    Log.i(TAG, mJitterBuff+"" );

    int ret = mInterface.SDConnectRtmp(mRtmpUrl, mJitterBuff);
    if (ret != 0)
    {
        Log.e(TAG, "startConnect failed");
        return ret;
    }

    return 0;
}

//开始播放
private void startPlay(int rendWidth, int rendHeight)
{
    mPlayer.SDStartPlay(rendWidth, rendHeight);
    mPlayer.SDSetVolume((float)2.0);
    mbPlayStart = true;
}

}`

2024-05-24 16:19:22.563 27252-27252 SDMedia com.mtl.myapplication I 0000000000 2024-05-24 16:19:22.563 27252-27252 SDMedia com.mtl.myapplication E load library libTerminalSdk.so 2024-05-24 16:19:22.665 27252-27252 org.webrtc.Logging com.mtl.myapplication I EglBase14: SDK version: 25. isEGL14Supported: true 2024-05-24 16:19:22.668 27252-27252 mali_so com.mtl.myapplication I [File] : hardware/arm/maliT760/driver/product/base/src/mali_base_kbase.c; [Line] : 876; [Func] : base_context_deal_with_version_affairs_rk_ext; arm_release_ver of this mali_so is 'r18p0-01rel0', rk_so_ver is '4@0'. 2024-05-24 16:19:22.668 27252-27252 mali_so com.mtl.myapplication D [File] : hardware/arm/maliT760/driver/product/base/src/mali_base_kbase.c; [Line] : 881; [Func] : base_context_deal_with_version_affairs_rk_ext; current process is NOT sf, to bail out. 2024-05-24 16:19:22.686 27252-27252 org.webrtc.Logging com.mtl.myapplication I SurfaceViewRenderer: suface_view: Initializing. 2024-05-24 16:19:22.687 27252-27252 org.webrtc.Logging com.mtl.myapplication I EglBase14: SDK version: 25. isEGL14Supported: true 2024-05-24 16:19:22.691 27252-27252 SDPlayer com.mtl.myapplication D JVM::Initialize nativeInitCtx 2024-05-24 16:19:22.691 27252-27252 JVM com.mtl.myapplication D JVM::Initialize@[tid=27252] 2024-05-24 16:19:22.691 27252-27252 JVM com.mtl.myapplication D JVM::JVM@[tid=27252] 2024-05-24 16:19:22.696 27252-27252 SDMedia com.mtl.myapplication I yyy 2024-05-24 16:19:22.697 27252-27252 SDMedia com.mtl.myapplication I rtmp://192.168.110.101:3343/live/cast?hport=3342&hhost=http.flv 2024-05-24 16:19:22.697 27252-27252 SDMedia com.mtl.myapplication I 200 2024-05-24 16:19:22.740 217-244 SurfaceFlinger surfaceflinger E XYP_DEBUG ==== persist.sys.cutting.width = 0 ==== 2024-05-24 16:19:22.740 217-244 SurfaceFlinger surfaceflinger E XYP_DEBUG ==== persist.sys.cutting.height = 0 ==== 2024-05-24 16:19:22.790 27252-27309 OpenGLRenderer com.mtl.myapplication I Initialized EGL, version 1.4 2024-05-24 16:19:22.790 27252-27309 OpenGLRenderer com.mtl.myapplication D Swap behavior 1 2024-05-24 16:19:22.798 27252-27309 mali_winsys com.mtl.myapplication D EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000 2024-05-24 16:19:22.803 27252-27252 org.webrtc.Logging com.mtl.myapplication I SurfaceViewRenderer: suface_view: Surface created. 2024-05-24 16:19:22.803 27252-27252 org.webrtc.Logging com.mtl.myapplication I SurfaceViewRenderer: suface_view: Surface changed: 1920x972 2024-05-24 16:19:22.804 27252-27252 SDMedia com.mtl.myapplication I get render width:1920 render height:972 2024-05-24 16:19:22.805 27252-27252 SDMedia com.mtl.myapplication I start play video audio with render w:1920 h:972 2024-05-24 16:19:22.805 27252-27252 JVM com.mtl.myapplication D AttachCurrentThreadIfNeeded::ctor@[tid=27252] 2024-05-24 16:19:22.805 27252-27252 JVM com.mtl.myapplication D JVM::environment@[tid=27252] 2024-05-24 16:19:22.805 27252-27252 JVM com.mtl.myapplication D JNIEnvironment::ctor@[tid=27252] 2024-05-24 16:19:22.805 27252-27252 AudioManager com.mtl.myapplication D ctor@[tid=27252] 2024-05-24 16:19:22.805 27252-27252 JVM com.mtl.myapplication D JNIEnvironment::RegisterNatives(org/webrtc/voiceengine/WebRtcAudioManager) 2024-05-24 16:19:22.805 27252-27252 JVM com.mtl.myapplication D NativeRegistration::ctor@[tid=27252] 2024-05-24 16:19:22.805 27252-27252 JVM com.mtl.myapplication D NativeRegistration::NewObject@[tid=27252] 2024-05-24 16:19:22.806 27252-27252 org.webrtc.Logging com.mtl.myapplication I WebRtcAudioManager: ctor@[name=main, id=1] 2024-05-24 16:19:22.807 27252-27252 org.webrtc.Logging com.mtl.myapplication I WebRtcAudioManager: Sample rate is set to 44100 Hz 2024-05-24 16:19:22.809 27252-27298 mali_winsys com.mtl.myapplication D EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, egl_color_buffer_format *, EGLBoolean) returns 0x3000 2024-05-24 16:19:22.816 27252-27252 org.webrtc.Logging com.mtl.myapplication I WebRtcAudioEffects: canUseAcousticEchoCanceler: false 2024-05-24 16:19:22.816 27252-27252 org.webrtc.Logging com.mtl.myapplication I WebRtcAudioEffects: canUseAutomaticGainControl: false 2024-05-24 16:19:22.816 27252-27252 org.webrtc.Logging com.mtl.myapplication I WebRtcAudioEffects: canUseNoiseSuppressor: false 2024-05-24 16:19:22.817 27252-27252 AudioManager com.mtl.myapplication D OnCacheAudioParameters@[tid=27252] 2024-05-24 16:19:22.817 27252-27252 AudioManager com.mtl.myapplication D hardware_aec: 0 2024-05-24 16:19:22.817 27252-27252 AudioManager com.mtl.myapplication D hardware_agc: 0 2024-05-24 16:19:22.817 27252-27252 AudioManager com.mtl.myapplication D hardware_ns: 0 2024-05-24 16:19:22.817 27252-27252 AudioManager com.mtl.myapplication D low_latency_output: 1 2024-05-24 16:19:22.817 27252-27252 AudioManager com.mtl.myapplication D pro_audio: 0 2024-05-24 16:19:22.817 27252-27252 AudioManager com.mtl.myapplication D sample_rate: 44100 2024-05-24 16:19:22.817 27252-27252 AudioManager com.mtl.myapplication D channels: 1 2024-05-24 16:19:22.817 27252-27252 AudioManager com.mtl.myapplication D output_buffer_size: 512 2024-05-24 16:19:22.817 27252-27252 AudioManager com.mtl.myapplication D input_buffer_size: 2048 2024-05-24 16:19:22.817 27252-27252 JVM com.mtl.myapplication D GlobalRef::ctor@[tid=27252] 2024-05-24 16:19:22.817 27252-27252 AudioManager com.mtl.myapplication D JavaAudioManager::ctor@[tid=27252] 2024-05-24 16:19:22.817 27252-27252 JVM com.mtl.myapplication D AttachCurrentThreadIfNeeded::ctor@[tid=27252] 2024-05-24 16:19:22.818 27252-27252 JVM com.mtl.myapplication D JVM::environment@[tid=27252] 2024-05-24 16:19:22.818 27252-27252 JVM com.mtl.myapplication D JNIEnvironment::ctor@[tid=27252] 2024-05-24 16:19:22.818 27252-27252 AudioTrackJni com.mtl.myapplication D ctor@[tid=27252] 2024-05-24 16:19:22.818 27252-27252 JVM com.mtl.myapplication D JNIEnvironment::RegisterNatives(org/webrtc/voiceengine/WebRtcAudioTrack) 2024-05-24 16:19:22.818 27252-27252 JVM com.mtl.myapplication D NativeRegistration::ctor@[tid=27252] 2024-05-24 16:19:22.818 27252-27252 JVM com.mtl.myapplication D NativeRegistration::NewObject@[tid=27252] 2024-05-24 16:19:22.818 27252-27252 org.webrtc.Logging com.mtl.myapplication I WebRtcAudioTrack: ctor@[name=main, id=1] 2024-05-24 16:19:22.818 27252-27252 JVM com.mtl.myapplication D GlobalRef::ctor@[tid=27252] 2024-05-24 16:19:22.818 27252-27252 JVM com.mtl.myapplication D AttachCurrentThreadIfNeeded::ctor@[tid=27252] 2024-05-24 16:19:22.818 27252-27252 JVM com.mtl.myapplication D JVM::environment@[tid=27252] 2024-05-24 16:19:22.818 27252-27252 JVM com.mtl.myapplication D JNIEnvironment::ctor@[tid=27252] 2024-05-24 16:19:22.818 27252-27252 AudioRecordJni com.mtl.myapplication D ctor@[tid=27252] 2024-05-24 16:19:22.818 27252-27252 JVM com.mtl.myapplication D JNIEnvironment::RegisterNatives(org/webrtc/voiceengine/WebRtcAudioRecord) 2024-05-24 16:19:22.818 27252-27252 JVM com.mtl.myapplication D NativeRegistration::ctor@[tid=27252] 2024-05-24 16:19:22.818 27252-27252 JVM com.mtl.myapplication D NativeRegistration::NewObject@[tid=27252] 2024-05-24 16:19:22.818 27252-27252 org.webrtc.Logging com.mtl.myapplication I WebRtcAudioRecord: ctor@[name=main, id=1] 2024-05-24 16:19:22.819 27252-27252 org.webrtc.Logging com.mtl.myapplication I WebRtcAudioEffects: ctor@[name=main, id=1] 2024-05-24 16:19:22.819 27252-27252 JVM com.mtl.myapplication D GlobalRef::ctor@[tid=27252] 2024-05-24 16:19:22.819 27252-27252 AudioManager com.mtl.myapplication D SetActiveAudioLayer(5)@[tid=27252] 2024-05-24 16:19:22.819 27252-27252 AudioManager com.mtl.myapplication D delay_estimate_in_milliseconds: 150 2024-05-24 16:19:22.819 27252-27252 AudioTrackJni com.mtl.myapplication D AttachAudioBuffer@[tid=27252] 2024-05-24 16:19:22.819 27252-27252 AudioTrackJni com.mtl.myapplication D SetPlayoutSampleRate(44100) 2024-05-24 16:19:22.819 27252-27252 AudioTrackJni com.mtl.myapplication D SetPlayoutChannels(1) 2024-05-24 16:19:22.819 27252-27252 AudioRecordJni com.mtl.myapplication D AttachAudioBuffer 2024-05-24 16:19:22.819 27252-27252 AudioRecordJni com.mtl.myapplication D SetRecordingSampleRate(44100) 2024-05-24 16:19:22.819 27252-27252 AudioRecordJni com.mtl.myapplication D SetRecordingChannels(1) 2024-05-24 16:19:22.819 27252-27252 AudioRecordJni com.mtl.myapplication D total_delay_in_milliseconds: 150 2024-05-24 16:19:22.819 27252-27252 AudioManager com.mtl.myapplication D Init@[tid=27252] 2024-05-24 16:19:22.819 27252-27252 org.webrtc.Logging com.mtl.myapplication I WebRtcAudioManager: init@[name=main, id=1] 2024-05-24 16:19:22.822 27252-27252 org.webrtc.Logging com.mtl.myapplication I WebRtcAudioManager: audio mode is: MODE_NORMAL 2024-05-24 16:19:22.822 27252-27252 AudioTrackJni com.mtl.myapplication D Init@[tid=27252] 2024-05-24 16:19:22.822 27252-27252 AudioRecordJni com.mtl.myapplication D Init@[tid=27252] 2024-05-24 16:19:22.822 27252-27252 AudioTrackJni com.mtl.myapplication D InitPlayout@[tid=27252] 2024-05-24 16:19:22.823 27252-27252 org.webrtc.Logging com.mtl.myapplication I WebRtcAudioTrack: initPlayout(sampleRate=44100, channels=1) 2024-05-24 16:19:22.823 27252-27252 org.webrtc.Logging com.mtl.myapplication I WebRtcAudioTrack: byteBuffer.capacity: 882 2024-05-24 16:19:22.823 27252-27252 AudioTrackJni com.mtl.myapplication D OnCacheDirectBufferAddress 2024-05-24 16:19:22.823 27252-27252 AudioTrackJni com.mtl.myapplication D direct buffer capacity: 882 2024-05-24 16:19:22.823 27252-27252 AudioTrackJni com.mtl.myapplication D frames_per_buffer: 441 2024-05-24 16:19:22.824 27252-27252 org.webrtc.Logging com.mtl.myapplication I WebRtcAudioTrack: AudioTrack.getMinBufferSize: 10260 2024-05-24 16:19:22.827 27252-27252 AudioTrack com.mtl.myapplication D Client defaulted notificationFrames to 2565 for frameCount 5130 2024-05-24 16:19:22.828 27252-27252 AudioManager com.mtl.myapplication D IsCommunicationModeEnabled() 2024-05-24 16:19:22.828 27252-27252 AudioTrackJni com.mtl.myapplication D StartPlayout@[tid=27252] 2024-05-24 16:19:22.829 27252-27252 org.webrtc.Logging com.mtl.myapplication I WebRtcAudioTrack: startPlayout 2024-05-24 16:19:22.829 27252-27252 SDMedia com.mtl.myapplication I SDSetVolume set volume to:2.0 2024-05-24 16:19:22.829 27252-27311 org.webrtc.Logging com.mtl.myapplication I WebRtcAudioTrack: AudioTrackThread@[name=AudioTrackJavaThread, id=334] 2024-05-24 16:19:22.830 229-295 AudioFlinger audioserver E no wake lock to update, but system ready! 2024-05-24 16:19:22.902 27252-27307 SDMedia com.mtl.myapplication I onSysStatus() with type=0 2024-05-24 16:19:22.905 27252-27307 libc com.mtl.myapplication A Fatal signal 11 (SIGSEGV), code 1, fault addr 0x4 in tid 27307 (Thread-2) 2024-05-24 16:19:22.908 200-200 <no-tag> debuggerd W debuggerd: handling request: pid=27252 uid=10059 gid=10059 tid=27307 2024-05-24 16:19:22.979 27315-27315 DEBUG pid-27315 A *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 2024-05-24 16:19:22.980 27315-27315 DEBUG pid-27315 A Build fingerprint: 'Android/rk3288/rk3288:7.1.2/NHG47K/server10311743:userdebug/test-keys' 2024-05-24 16:19:22.980 27315-27315 DEBUG pid-27315 A Revision: '0' 2024-05-24 16:19:22.981 27315-27315 DEBUG pid-27315 A ABI: 'arm' 2024-05-24 16:19:22.982 27315-27315 DEBUG pid-27315 A pid: 27252, tid: 27307, name: Thread-2 >>> com.mtl.myapplication <<< 2024-05-24 16:19:22.983 27315-27315 DEBUG pid-27315 A signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4 2024-05-24 16:19:22.983 27315-27315 DEBUG pid-27315 A r0 00000000 r1 00000004 r2 00000003 r3 9ea36c00 2024-05-24 16:19:22.983 27315-27315 DEBUG pid-27315 A r4 00000000 r5 83600834 r6 91193d25 r7 83600810 2024-05-24 16:19:22.984 27315-27315 DEBUG pid-27315 A r8 ad161008 r9 83600834 sl 9ea37e18 fp 9ea37e14 2024-05-24 16:19:22.984 27315-27315 DEBUG pid-27315 A ip 914d43d8 sp 83600808 lr 911bbdbf pc 91142554 cpsr 40010030 2024-05-24 16:19:23.017 27315-27315 DEBUG pid-27315 A backtrace: 2024-05-24 16:19:23.017 27315-27315 DEBUG pid-27315 A #00 pc 00104554 /data/app/com.mtl.myapplication-2/base.apk (offset 0x63c000) 2024-05-24 16:19:23.017 27315-27315 DEBUG pid-27315 A #01 pc 0017ddbb /data/app/com.mtl.myapplication-2/base.apk (offset 0x63c000) 2024-05-24 16:19:23.018 27315-27315 DEBUG pid-27315 A #02 pc 0017e3ff /data/app/com.mtl.myapplication-2/base.apk (offset 0x63c000) 2024-05-24 16:19:23.019 27315-27315 DEBUG pid-27315 A #03 pc 0017e3d1 /data/app/com.mtl.myapplication-2/base.apk (offset 0x63c000) 2024-05-24 16:19:23.019 27315-27315 DEBUG pid-27315 A #04 pc 00155df1 /data/app/com.mtl.myapplication-2/base.apk (offset 0x63c000) 2024-05-24 16:19:23.019 27315-27315 DEBUG pid-27315 A #05 pc 00155b6f /data/app/com.mtl.myapplication-2/base.apk (offset 0x63c000) 2024-05-24 16:19:23.019 27315-27315 DEBUG pid-27315 A #06 pc 0019e7f3 /data/app/com.mtl.myapplication-2/base.apk (offset 0x63c000) 2024-05-24 16:19:23.019 27315-27315 DEBUG pid-27315 A #07 pc 00047323 /system/lib/libc.so (_ZL15__pthread_startPv+22) 2024-05-24 16:19:23.019 27315-27315 DEBUG pid-27315 A #08 pc 00019e5d /system/lib/libc.so (__start_thread+6) 2024-05-24 16:19:23.376 27315-27315 <no-tag> pid-27315 E debuggerd: failed to kill process 27252: No such process 2024-05-24 16:19:23.376 467-27324 ActivityManager system_server W Force finishing activity com.mtl.myapplication/.MainActivity 2024-05-24 16:19:23.377 200-200 <no-tag> debuggerd W debuggerd: resuming target 27252 2024-05-24 16:19:23.378 467-570 BootReceiver system_server I Copying /data/tombstones/tombstone_07 to DropBox (SYSTEM_TOMBSTONE) 2024-05-24 16:19:23.421 467-677 InputDispatcher system_server W channel 'd820db4 com.mtl.myapplication/com.mtl.myapplication.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9 1970-01-01 08:00:00.000 0-0 <no-tag> I ---------------------------- PROCESS ENDED (27252) for package com.mtl.myapplication ---------------------------- 2024-05-24 16:19:23.421 467-677 InputDispatcher system_server E channel 'd820db4 com.mtl.myapplication/com.mtl.myapplication.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed! 2024-05-24 16:19:23.434 467-21398 GraphicsStats system_server D Buffer count: 3 2024-05-24 16:19:23.434 228-228 Zygote pid-228 I Process 27252 exited due to signal (11)

waterfoxfox commented 5 months ago

1、直接跑原始工程,不做更改,现象是怎样的 2、播放地址能否换一个,比如简单的 rtmp://xxxxx/live/666

waterfoxfox commented 5 months ago

1、直接跑原始工程,不做更改,现象是怎样的 2、播放地址能否换一个,比如简单的 rtmp://xxxxx/live/666