提交 c8398b4f 编写于 作者: G guoshuyu

#2922 deprecated SkipSSLChain ,support api custom dataSoucre

上级 d3a382b2
......@@ -134,8 +134,8 @@ public class DetailPlayer extends AppCompatActivity {
.setRotateViewAuto(false)
//仅仅横屏旋转,不变直
//.setOnlyRotateLand(true)
.setLockLand(false)
.setAutoFullWithSize(false)
.setLockLand(true)
.setAutoFullWithSize(true)
.setShowFullAnimation(false)
.setNeedLockFull(true)
.setUrl(url)
......@@ -317,7 +317,7 @@ public class DetailPlayer extends AppCompatActivity {
//String url = "http://video.7k.cn/app_video/20171202/6c8cf3ea/v.m3u8.mp4";
//String url = "http://devimages.apple.com.edgekey.net/streaming/examples/bipbop_4x3/bipbop_4x3_variant.m3u8";
//String url = "rtmp://ctc-zhenjiang04.rt1.gensee.com/5324e855b28b453db7b0ec226598b76c_171391_0_8801038305_1591077225_205d01b8/video";
String url = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4";
String url = "http://video1.dgtle.com/backend%2F2020%2F3%2F0%2F%E6%88%91%E6%B2%A1%E6%9C%89%E7%BB%99%E4%B8%80%E5%8A%A08Pro%E5%81%9A%E8%AF%84%E6%B5%8B_%E5%8D%B4%E5%B8%A6%E7%9D%80%E5%AE%83%E6%BC%82%E6%B5%81.mp4_1080.mp4";
//String url = "http://yongtaizx.xyz/20191230/t2Axgh3k/index.m3u8";
//String url = "https://pointshow.oss-cn-hangzhou.aliyuncs.com/McTk51586843620689.mp4";
//String url = "http://pointshow.oss-cn-hangzhou.aliyuncs.com/transcode/ORIGINAL/Mnbc61586842828593.mp4";
......
package com.example.gsyvideoplayer;
import androidx.annotation.Nullable;
import androidx.multidex.MultiDexApplication;
import tv.danmaku.ijk.media.exo2.Exo2PlayerManager;
import tv.danmaku.ijk.media.exo2.ExoMediaSourceInterceptListener;
import tv.danmaku.ijk.media.exo2.ExoSourceManager;
import tv.danmaku.ijk.media.exo2.IjkExo2MediaPlayer;
import tv.danmaku.ijk.media.player.IMediaPlayer;
import com.example.gsyvideoplayer.source.GSYExoHttpDataSourceFactory;
import com.google.android.exoplayer2.DefaultLoadControl;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.hls.HlsMediaSource;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.upstream.TransferListener;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.shuyu.gsyvideoplayer.model.GSYModel;
import com.shuyu.gsyvideoplayer.player.BasePlayerManager;
......@@ -18,6 +26,8 @@ import com.shuyu.gsyvideoplayer.utils.Debuger;
import com.shuyu.gsyvideoplayer.utils.GSYVideoType;
import com.squareup.leakcanary.LeakCanary;
import java.io.File;
import static com.google.android.exoplayer2.util.Util.inferContentType;
/**
......@@ -61,18 +71,25 @@ public class GSYApplication extends MultiDexApplication {
//IjkPlayerManager.setLogLevel(IjkMediaPlayer.IJK_LOG_SILENT);
/*ExoSourceManager.setExoMediaSourceInterceptListener(new ExoMediaSourceInterceptListener() {
ExoSourceManager.setExoMediaSourceInterceptListener(new ExoMediaSourceInterceptListener() {
@Override
public MediaSource getMediaSource(String dataSource, boolean preview, boolean cacheEnable, boolean isLooping, File cacheDir) {
Uri contentUri = Uri.parse(dataSource);
int contentType = inferContentType(dataSource);
switch (contentType) {
case C.TYPE_HLS:
return new HlsMediaSource.Factory(CustomSourceTag.getDataSourceFactory(GSYApplication.this.getApplicationContext(), preview)).createMediaSource(contentUri);
}
//如果返回 null,就使用默认的
return null;
}
});*/
/**
* 通过自定义的 HttpDataSource ,可以设置自签证书或者忽略证书
* demo 里的 GSYExoHttpDataSourceFactory 使用的是忽略证书
* */
@Override
public HttpDataSource.BaseFactory getHttpDataSourceFactory(String userAgent, @Nullable TransferListener listener, int connectTimeoutMillis, int readTimeoutMillis, boolean allowCrossProtocolRedirects) {
//如果返回 null,就使用默认的
return new GSYExoHttpDataSourceFactory(userAgent, listener,
connectTimeoutMillis,
readTimeoutMillis, allowCrossProtocolRedirects);
}
});
/*GSYVideoManager.instance().setPlayerInitSuccessListener(new IPlayerInitSuccessListener() {
///播放器初始化成果回调
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package tv.danmaku.ijk.media.exo2.source;
package com.example.gsyvideoplayer.source;
import android.net.Uri;
import android.text.TextUtils;
......
......@@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package tv.danmaku.ijk.media.exo2.source;
package com.example.gsyvideoplayer.source;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;
import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.upstream.HttpDataSource.BaseFactory;
import com.google.android.exoplayer2.upstream.HttpDataSource.Factory;
......
package tv.danmaku.ijk.media.exo2;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.upstream.TransferListener;
import java.io.File;
......@@ -19,4 +23,15 @@ public interface ExoMediaSourceInterceptListener {
* @return 返回不为空时,使用返回的自定义mediaSource
*/
MediaSource getMediaSource(String dataSource, boolean preview, boolean cacheEnable, boolean isLooping, File cacheDir);
/**
* @return 返回不为空时,使用返回的自定义 HttpDataSource
*/
HttpDataSource.BaseFactory getHttpDataSourceFactory(
String userAgent,
@Nullable TransferListener listener,
int connectTimeoutMillis,
int readTimeoutMillis,
boolean allowCrossProtocolRedirects);
}
......@@ -6,9 +6,6 @@ import android.net.Uri;
import androidx.annotation.Nullable;
import tv.danmaku.ijk.media.exo2.source.GSYDefaultHttpDataSource;
import tv.danmaku.ijk.media.exo2.source.GSYExoHttpDataSourceFactory;
import android.text.TextUtils;
import com.google.android.exoplayer2.C;
......@@ -26,7 +23,9 @@ import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
import com.google.android.exoplayer2.upstream.HttpDataSource;
import com.google.android.exoplayer2.upstream.RawResourceDataSource;
import com.google.android.exoplayer2.upstream.cache.Cache;
import com.google.android.exoplayer2.upstream.cache.CacheDataSource;
......@@ -57,7 +56,9 @@ public class ExoSourceManager {
private static Cache mCache;
/**
* 忽律Https证书校验
* @deprecated 如果需要忽略证书,请直接使用 ExoMediaSourceInterceptListener 的 getHttpDataSourceFactory
*/
@Deprecated
private static boolean sSkipSSLChain = false;
private static int sHttpReadTimeout = -1;
......@@ -259,7 +260,11 @@ public class ExoSourceManager {
return isCached;
}
/**
* 忽律Https证书校验
* @deprecated 如果需要忽略证书,请直接使用 ExoMediaSourceInterceptListener 的 getHttpDataSourceFactory
*/
@Deprecated
public static boolean isSkipSSLChain() {
return sSkipSSLChain;
}
......@@ -268,7 +273,9 @@ public class ExoSourceManager {
* 设置https忽略证书
*
* @param skipSSLChain true时是hulve
* @deprecated 如果需要忽略证书,请直接使用 ExoMediaSourceInterceptListener 的 getHttpDataSourceFactory
*/
@Deprecated
public static void setSkipSSLChain(boolean skipSSLChain) {
sSkipSSLChain = skipSSLChain;
}
......@@ -322,8 +329,8 @@ public class ExoSourceManager {
if (uerAgent == null) {
uerAgent = Util.getUserAgent(context, TAG);
}
int connectTimeout = GSYDefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS;
int readTimeout = GSYDefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS;
int connectTimeout = DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS;
int readTimeout = DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS;
if (sHttpConnectTimeout > 0) {
connectTimeout = sHttpConnectTimeout;
}
......@@ -334,20 +341,16 @@ public class ExoSourceManager {
if (mMapHeadData != null && mMapHeadData.size() > 0) {
allowCrossProtocolRedirects = "true".equals(mMapHeadData.get("allowCrossProtocolRedirects"));
}
if (sSkipSSLChain) {
GSYExoHttpDataSourceFactory dataSourceFactory = new GSYExoHttpDataSourceFactory(uerAgent, preview ? null : new DefaultBandwidthMeter.Builder(mAppContext).build(),
HttpDataSource.BaseFactory dataSourceFactory;
if (sExoMediaSourceInterceptListener != null) {
dataSourceFactory = sExoMediaSourceInterceptListener.getHttpDataSourceFactory(uerAgent, preview ? null : new DefaultBandwidthMeter.Builder(mAppContext).build(),
connectTimeout,
readTimeout, allowCrossProtocolRedirects);
} else {
dataSourceFactory = new DefaultHttpDataSourceFactory(uerAgent, preview ? null : new DefaultBandwidthMeter.Builder(mAppContext).build(),
connectTimeout,
readTimeout, allowCrossProtocolRedirects);
if (mMapHeadData != null && mMapHeadData.size() > 0) {
for (Map.Entry<String, String> header : mMapHeadData.entrySet()) {
dataSourceFactory.getDefaultRequestProperties().set(header.getKey(), header.getValue());
}
}
return dataSourceFactory;
}
DefaultHttpDataSourceFactory dataSourceFactory = new DefaultHttpDataSourceFactory(uerAgent, preview ? null : new DefaultBandwidthMeter.Builder(mAppContext).build(),
connectTimeout,
readTimeout, allowCrossProtocolRedirects);
if (mMapHeadData != null && mMapHeadData.size() > 0) {
for (Map.Entry<String, String> header : mMapHeadData.entrySet()) {
dataSourceFactory.getDefaultRequestProperties().set(header.getKey(), header.getValue());
......
......@@ -50,11 +50,11 @@ dependencies {
//api "com.shuyu:gsyVideoPlayer-java:$gsyVideoVersion"
//api "com.shuyu:GSYVideoPlayer-exo2:$gsyVideoVersion"
// api "com.shuyu:gsyVideoPlayer-armv5:$gsyVideoVersion"
//api "com.shuyu:gsyVideoPlayer-armv5:$gsyVideoVersion"
//api "com.shuyu:gsyVideoPlayer-armv7a:$gsyVideoVersion"
//api "com.shuyu:gsyVideoPlayer-arm64:$gsyVideoVersion"
// api "com.shuyu:gsyVideoPlayer-x64:$gsyVideoVersion"
// api "com.shuyu:gsyVideoPlayer-x86:$gsyVideoVersion"
//api "com.shuyu:gsyVideoPlayer-x64:$gsyVideoVersion"
//api "com.shuyu:gsyVideoPlayer-x86:$gsyVideoVersion"
//更多配置版so,增加了concat,rtsp,mpeg,crypto
//api "com.shuyu:gsyVideoPlayer-ex_so:$gsyVideoVersion"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册