forked from xufuji456/FFmpegAndroid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
增加RTSP低延时直播
- Loading branch information
Showing
54 changed files
with
3,513 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion '26.0.2' | ||
|
||
lintOptions { | ||
abortOnError false | ||
} | ||
defaultConfig { | ||
applicationId "com.frank.living" | ||
minSdkVersion 17 | ||
targetSdkVersion 25 | ||
versionCode 1001 | ||
versionName "1.0.1" | ||
flavorDimensions "800400" | ||
|
||
ndk { | ||
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a' | ||
} | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
productFlavors { | ||
all32 { minSdkVersion 17 } | ||
all64 { minSdkVersion 17 } | ||
} | ||
|
||
sourceSets { | ||
main { | ||
jniLibs.srcDirs = ['libs'] | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(include: ['*.jar'], dir: 'libs') | ||
compile 'com.android.support:appcompat-v7:25.3.1' | ||
compile 'com.android.support:preference-v7:25.4.0' | ||
compile 'com.android.support:support-annotations:26.0.1' | ||
compile 'com.android.support:recyclerview-v7:25.3.1' | ||
|
||
compile 'com.squareup:otto:1.3.8' | ||
|
||
compile 'tv.danmaku.ijk.media:ijkplayer-java:0.8.8' | ||
compile 'tv.danmaku.ijk.media:ijkplayer-exo:0.8.8' | ||
|
||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in /opt/android/ADK/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} |
13 changes: 13 additions & 0 deletions
13
OnLive/src/androidTest/java/tv/frank/living/media/example/ApplicationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package tv.frank.living.media.example; | ||
|
||
import android.app.Application; | ||
import android.test.ApplicationTestCase; | ||
|
||
/** | ||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a> | ||
*/ | ||
public class ApplicationTest extends ApplicationTestCase<Application> { | ||
public ApplicationTest() { | ||
super(Application.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.frank.living"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.WAKE_LOCK" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
|
||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme"> | ||
|
||
<activity | ||
android:name="com.frank.living.activity.RtspLiveActivity" | ||
android:configChanges="orientation|keyboardHidden|screenSize" | ||
android:label="@string/app_name" | ||
android:screenOrientation="landscape" | ||
android:theme="@style/FullscreenTheme"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
</application> | ||
|
||
</manifest> |
80 changes: 80 additions & 0 deletions
80
OnLive/src/main/java/com/frank/living/activity/RtspLiveActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package com.frank.living.activity; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.util.Log; | ||
import android.widget.TableLayout; | ||
import com.frank.living.R; | ||
import com.frank.living.listener.IjkPlayerListener; | ||
import tv.danmaku.ijk.media.player.IjkMediaPlayer; | ||
import com.frank.living.widget.IjkVideoView; | ||
|
||
public class RtspLiveActivity extends AppCompatActivity implements IjkPlayerListener{ | ||
|
||
private final static String TAG = RtspLiveActivity.class.getSimpleName(); | ||
|
||
private IjkMediaPlayer ijkMediaPlayer; | ||
private IjkVideoView mVideoView; | ||
|
||
private final static String url = "rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov"; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_live); | ||
|
||
init(); | ||
|
||
} | ||
|
||
private void init(){ | ||
IjkMediaPlayer.loadLibrariesOnce(null); | ||
IjkMediaPlayer.native_profileBegin("libijkplayer.so"); | ||
|
||
TableLayout mHudView = (TableLayout) findViewById(R.id.hud_view); | ||
mVideoView = (IjkVideoView) findViewById(R.id.video_view); | ||
mVideoView.setHudView(mHudView); | ||
mVideoView.setIjkPlayerListener(this); | ||
mVideoView.setVideoPath(url); | ||
mVideoView.start(); | ||
} | ||
|
||
private void initOptions(){ | ||
if (ijkMediaPlayer == null) | ||
return; | ||
Log.e(TAG, "initOptions"); | ||
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "fast", 1); | ||
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "probesize", 200); | ||
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "flush_packets", 1); | ||
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "packet-buffering", 0); | ||
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "start-on-prepared", 1); | ||
//0:代表关闭 1:代表开启 | ||
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec", 0); | ||
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-auto-rotate", 0); | ||
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-handle-resolution-change", 0); | ||
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max-buffer-size", 0); | ||
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "min-frames", 2); | ||
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max_cached_duration", 30); | ||
//input buffer:don't limit the input buffer size (useful with realtime streams) | ||
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "infbuf", 1); | ||
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "fflags", "nobuffer"); | ||
//ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_transport", "tcp"); | ||
ijkMediaPlayer.setOption(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzedmaxduration", 100); | ||
} | ||
|
||
@Override | ||
public void onIjkPlayer(IjkMediaPlayer ijkMediaPlayer) { | ||
this.ijkMediaPlayer = ijkMediaPlayer; | ||
initOptions(); | ||
} | ||
|
||
@Override | ||
protected void onStop() { | ||
super.onStop(); | ||
|
||
mVideoView.stopPlayback(); | ||
mVideoView.release(true); | ||
IjkMediaPlayer.native_profileEnd(); | ||
} | ||
|
||
} |
108 changes: 108 additions & 0 deletions
108
OnLive/src/main/java/com/frank/living/config/Settings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* Copyright (C) 2015 Bilibili | ||
* Copyright (C) 2015 Zhang Rui <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.frank.living.config; | ||
|
||
import android.content.Context; | ||
import android.content.SharedPreferences; | ||
import android.preference.PreferenceManager; | ||
import com.frank.living.R; | ||
|
||
public class Settings { | ||
private Context mAppContext; | ||
private SharedPreferences mSharedPreferences; | ||
|
||
public static final int PV_PLAYER__Auto = 0; | ||
public static final int PV_PLAYER__AndroidMediaPlayer = 1; | ||
public static final int PV_PLAYER__IjkMediaPlayer = 2; | ||
public static final int PV_PLAYER__IjkExoMediaPlayer = 3; | ||
|
||
public Settings(Context context) { | ||
mAppContext = context.getApplicationContext(); | ||
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(mAppContext); | ||
} | ||
|
||
public int getPlayer() { | ||
String key = mAppContext.getString(R.string.pref_key_player); | ||
String value = mSharedPreferences.getString(key, ""); | ||
try { | ||
return Integer.valueOf(value).intValue(); | ||
} catch (NumberFormatException e) { | ||
return 0; | ||
} | ||
} | ||
|
||
public boolean getUsingMediaCodec() { | ||
String key = mAppContext.getString(R.string.pref_key_using_media_codec); | ||
return mSharedPreferences.getBoolean(key, false); | ||
} | ||
|
||
public boolean getUsingMediaCodecAutoRotate() { | ||
String key = mAppContext.getString(R.string.pref_key_using_media_codec_auto_rotate); | ||
return mSharedPreferences.getBoolean(key, false); | ||
} | ||
|
||
public boolean getMediaCodecHandleResolutionChange() { | ||
String key = mAppContext.getString(R.string.pref_key_media_codec_handle_resolution_change); | ||
return mSharedPreferences.getBoolean(key, false); | ||
} | ||
|
||
public boolean getUsingOpenSLES() { | ||
String key = mAppContext.getString(R.string.pref_key_using_opensl_es); | ||
return mSharedPreferences.getBoolean(key, false); | ||
} | ||
|
||
public String getPixelFormat() { | ||
String key = mAppContext.getString(R.string.pref_key_pixel_format); | ||
return mSharedPreferences.getString(key, ""); | ||
} | ||
|
||
public boolean getEnableNoView() { | ||
String key = mAppContext.getString(R.string.pref_key_enable_no_view); | ||
return mSharedPreferences.getBoolean(key, false); | ||
} | ||
|
||
public boolean getEnableSurfaceView() { | ||
String key = mAppContext.getString(R.string.pref_key_enable_surface_view); | ||
return mSharedPreferences.getBoolean(key, false); | ||
} | ||
|
||
public boolean getEnableTextureView() { | ||
String key = mAppContext.getString(R.string.pref_key_enable_texture_view); | ||
return mSharedPreferences.getBoolean(key, false); | ||
} | ||
|
||
public boolean getEnableDetachedSurfaceTextureView() { | ||
String key = mAppContext.getString(R.string.pref_key_enable_detached_surface_texture); | ||
return mSharedPreferences.getBoolean(key, false); | ||
} | ||
|
||
public boolean getUsingMediaDataSource() { | ||
String key = mAppContext.getString(R.string.pref_key_using_mediadatasource); | ||
return mSharedPreferences.getBoolean(key, false); | ||
} | ||
|
||
public String getLastDirectory() { | ||
String key = mAppContext.getString(R.string.pref_key_last_directory); | ||
return mSharedPreferences.getString(key, "/"); | ||
} | ||
|
||
public void setLastDirectory(String path) { | ||
String key = mAppContext.getString(R.string.pref_key_last_directory); | ||
mSharedPreferences.edit().putString(key, path).apply(); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
OnLive/src/main/java/com/frank/living/listener/IjkPlayerListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.frank.living.listener; | ||
|
||
import tv.danmaku.ijk.media.player.IjkMediaPlayer; | ||
|
||
/** | ||
* | ||
* Created by frank on 2019/1/4. | ||
*/ | ||
|
||
public interface IjkPlayerListener { | ||
|
||
void onIjkPlayer(IjkMediaPlayer ijkMediaPlayer); | ||
|
||
} |
Oops, something went wrong.