提交 42a5df48 authored 作者: kongdywang's avatar kongdywang

pigeon refactoring

上级 7137720e
......@@ -29,6 +29,11 @@ android {
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
......
......@@ -3,11 +3,16 @@
package com.tencent.vod.flutter;
import android.os.Bundle;
import com.tencent.rtmp.downloader.TXVodDownloadDataSource;
import com.tencent.rtmp.downloader.TXVodDownloadMediaInfo;
import com.tencent.vod.flutter.messages.FtxMessages.BoolMsg;
import com.tencent.vod.flutter.messages.FtxMessages.DoubleMsg;
import com.tencent.vod.flutter.messages.FtxMessages.IntMsg;
import com.tencent.vod.flutter.messages.FtxMessages.ListMsg;
import com.tencent.vod.flutter.messages.FtxMessages.PlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.StringMsg;
import com.tencent.vod.flutter.messages.FtxMessages.UInt8ListMsg;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -45,4 +50,46 @@ public class CommonUtil {
Integer event = DOWNLOAD_STATE_MAP.get(mediaInfoDownloadState);
return null != event ? event : FTXEvent.EVENT_DOWNLOAD_ERROR;
}
public static PlayerMsg playerMsgWith(Long textureId) {
PlayerMsg msg = new PlayerMsg();
msg.setPlayerId(textureId);
return msg;
}
public static StringMsg stringMsgWith(String str) {
StringMsg msg = new StringMsg();
msg.setValue(str);
return msg;
}
public static DoubleMsg doubleMsgWith(Double value) {
DoubleMsg msg = new DoubleMsg();
msg.setValue(value);
return msg;
}
public static BoolMsg boolMsgWith(Boolean value) {
BoolMsg msg = new BoolMsg();
msg.setValue(value);
return msg;
}
public static IntMsg intMsgWith(Long value) {
IntMsg msg = new IntMsg();
msg.setValue(value);
return msg;
}
public static UInt8ListMsg uInt8ListMsg(byte[] data) {
UInt8ListMsg msg = new UInt8ListMsg();
msg.setValue(data);
return msg;
}
public static ListMsg listMsgWith(List<Object> value) {
ListMsg msg = new ListMsg();
msg.setValue(value);
return msg;
}
}
......@@ -7,6 +7,8 @@ import android.text.TextUtils;
import com.tencent.rtmp.TXLivePlayConfig;
import com.tencent.rtmp.TXVodPlayConfig;
import com.tencent.vod.flutter.messages.FtxMessages.FTXLivePlayConfigPlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.FTXVodPlayConfigPlayerMsg;
import java.util.HashMap;
import java.util.Map;
......@@ -15,6 +17,62 @@ import java.util.Map;
*/
public class FTXTransformation {
/**
* 将msg转换为config
*/
public static TXVodPlayConfig transformToVodConfig(FTXVodPlayConfigPlayerMsg configPlayerMsg) {
TXVodPlayConfig playConfig = new TXVodPlayConfig();
if (null != configPlayerMsg.getConnectRetryCount()) {
playConfig.setConnectRetryCount(configPlayerMsg.getConnectRetryCount().intValue());
}
if (null != configPlayerMsg.getProgressInterval()) {
playConfig.setConnectRetryInterval(configPlayerMsg.getProgressInterval().intValue());
}
if (null != configPlayerMsg.getTimeout()) {
playConfig.setTimeout(configPlayerMsg.getTimeout().intValue());
}
if (null != configPlayerMsg.getPlayerType()) {
playConfig.setPlayerType(configPlayerMsg.getPlayerType().intValue());
}
playConfig.setHeaders(configPlayerMsg.getHeaders());
if (null != configPlayerMsg.getEnableAccurateSeek()) {
playConfig.setEnableAccurateSeek(configPlayerMsg.getEnableAccurateSeek());
}
if (null != configPlayerMsg.getAutoRotate()) {
playConfig.setAutoRotate(configPlayerMsg.getAutoRotate());
}
if (null != configPlayerMsg.getSmoothSwitchBitrate()) {
playConfig.setSmoothSwitchBitrate(configPlayerMsg.getSmoothSwitchBitrate());
}
playConfig.setCacheMp4ExtName(configPlayerMsg.getCacheMp4ExtName());
if (null != configPlayerMsg.getProgressInterval()) {
playConfig.setProgressInterval(configPlayerMsg.getProgressInterval().intValue());
}
if (null != configPlayerMsg.getMaxBufferSize()) {
playConfig.setMaxBufferSize(configPlayerMsg.getMaxBufferSize().intValue());
}
if (null != configPlayerMsg.getMaxPreloadSize()) {
playConfig.setMaxPreloadSize(configPlayerMsg.getMaxPreloadSize().intValue());
}
if (null != configPlayerMsg.getFirstStartPlayBufferTime()) {
playConfig.setFirstStartPlayBufferTime(configPlayerMsg.getFirstStartPlayBufferTime().intValue());
}
if (null != configPlayerMsg.getNextStartPlayBufferTime()) {
playConfig.setNextStartPlayBufferTime(configPlayerMsg.getNextStartPlayBufferTime().intValue());
}
playConfig.setOverlayKey(configPlayerMsg.getOverlayKey());
playConfig.setOverlayIv(configPlayerMsg.getOverlayIv());
playConfig.setExtInfo(configPlayerMsg.getExtInfoMap());
if (null != configPlayerMsg.getEnableRenderProcess()) {
playConfig.setEnableRenderProcess(configPlayerMsg.getEnableRenderProcess());
}
if (null != configPlayerMsg.getPreferredResolution()) {
playConfig.setPreferredResolution(configPlayerMsg.getPreferredResolution());
}
return playConfig;
}
/**
* 将map转换为config
*/
......@@ -105,6 +163,45 @@ public class FTXTransformation {
return playConfig;
}
/**
* msg转config
*/
public static TXLivePlayConfig transformToLiveConfig(FTXLivePlayConfigPlayerMsg config) {
TXLivePlayConfig livePlayConfig = new TXLivePlayConfig();
if (null != config.getCacheTime()) {
livePlayConfig.setCacheTime(config.getCacheTime().floatValue());
}
if (null != config.getMaxAutoAdjustCacheTime()) {
livePlayConfig.setMaxAutoAdjustCacheTime(config.getMaxAutoAdjustCacheTime().floatValue());
}
if (null != config.getMinAutoAdjustCacheTime()) {
livePlayConfig.setMinAutoAdjustCacheTime(config.getMinAutoAdjustCacheTime().floatValue());
}
if (null != config.getVideoBlockThreshold()) {
livePlayConfig.setVideoBlockThreshold(config.getVideoBlockThreshold().intValue());
}
if (null != config.getConnectRetryCount()) {
livePlayConfig.setConnectRetryCount(config.getConnectRetryCount().intValue());
}
if (null != config.getConnectRetryInterval()) {
livePlayConfig.setConnectRetryInterval(config.getConnectRetryInterval().intValue());
}
if (null != config.getAutoAdjustCacheTime()) {
livePlayConfig.setAutoAdjustCacheTime(config.getAutoAdjustCacheTime());
}
if (null != config.getEnableAec()) {
livePlayConfig.setEnableAEC(config.getEnableAec());
}
if (null != config.getEnableMessage()) {
livePlayConfig.setEnableMessage(config.getEnableMessage());
}
if (null != config.getEnableMetaData()) {
livePlayConfig.setEnableMetaData(config.getEnableMetaData());
}
livePlayConfig.setFlvSessionKey(config.getFlvSessionKey());
return livePlayConfig;
}
/**
* map转config
*/
......
// Copyright (c) 2022 Tencent. All rights reserved.
package com.tencent.vod.flutter.messages;
import androidx.annotation.NonNull;
import com.tencent.vod.flutter.FTXBasePlayer;
import com.tencent.vod.flutter.messages.FtxMessages.BoolMsg;
import com.tencent.vod.flutter.messages.FtxMessages.BoolPlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.DoublePlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.FTXLivePlayConfigPlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.IntMsg;
import com.tencent.vod.flutter.messages.FtxMessages.IntPlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.PipParamsPlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.PlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.StringIntPlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.StringPlayerMsg;
import com.tencent.vod.flutter.messages.FtxMessages.TXFlutterLivePlayerApi;
@SuppressWarnings("ConstantConditions")
public class FTXLivePlayerDispatcher implements FtxMessages.TXFlutterLivePlayerApi {
final IPlayersBridge bridge;
public FTXLivePlayerDispatcher(@NonNull IPlayersBridge dataBridge) {
this.bridge = dataBridge;
}
TXFlutterLivePlayerApi getPlayer(Long playerID) {
if (null != playerID) {
FTXBasePlayer ftxBasePlayer = bridge.getPlayers().get(playerID.intValue());
if (ftxBasePlayer instanceof FtxMessages.TXFlutterLivePlayerApi) {
return (TXFlutterLivePlayerApi) ftxBasePlayer;
}
}
return null;
}
@NonNull
@Override
public IntMsg initialize(@NonNull BoolPlayerMsg onlyAudio) {
TXFlutterLivePlayerApi api = getPlayer(onlyAudio.getPlayerId());
if (null != api) {
return api.initialize(onlyAudio);
}
return null;
}
@NonNull
@Override
public BoolMsg startLivePlay(@NonNull StringIntPlayerMsg playerMsg) {
TXFlutterLivePlayerApi api = getPlayer(playerMsg.getPlayerId());
if (null != api) {
return api.startLivePlay(playerMsg);
}
return null;
}
@Override
public void setAutoPlay(@NonNull BoolPlayerMsg isAutoPlay) {
TXFlutterLivePlayerApi api = getPlayer(isAutoPlay.getPlayerId());
if (null != api) {
api.setAutoPlay(isAutoPlay);
}
}
@NonNull
@Override
public BoolMsg stop(@NonNull BoolPlayerMsg isNeedClear) {
TXFlutterLivePlayerApi api = getPlayer(isNeedClear.getPlayerId());
if (null != api) {
return api.stop(isNeedClear);
}
return null;
}
@NonNull
@Override
public BoolMsg isPlaying(@NonNull PlayerMsg playerMsg) {
TXFlutterLivePlayerApi api = getPlayer(playerMsg.getPlayerId());
if (null != api) {
return api.isPlaying(playerMsg);
}
return null;
}
@Override
public void pause(@NonNull PlayerMsg playerMsg) {
TXFlutterLivePlayerApi api = getPlayer(playerMsg.getPlayerId());
if (null != api) {
api.pause(playerMsg);
}
}
@Override
public void resume(@NonNull PlayerMsg playerMsg) {
TXFlutterLivePlayerApi api = getPlayer(playerMsg.getPlayerId());
if (null != api) {
api.resume(playerMsg);
}
}
@Override
public void setLiveMode(@NonNull IntPlayerMsg mode) {
TXFlutterLivePlayerApi api = getPlayer(mode.getPlayerId());
if (null != api) {
api.setLiveMode(mode);
}
}
@Override
public void setVolume(@NonNull IntPlayerMsg volume) {
TXFlutterLivePlayerApi api = getPlayer(volume.getPlayerId());
if (null != api) {
api.setVolume(volume);
}
}
@Override
public void setMute(@NonNull BoolPlayerMsg mute) {
TXFlutterLivePlayerApi api = getPlayer(mute.getPlayerId());
if (null != api) {
api.setMute(mute);
}
}
@NonNull
@Override
public IntMsg switchStream(@NonNull StringPlayerMsg url) {
TXFlutterLivePlayerApi api = getPlayer(url.getPlayerId());
if (null != api) {
return api.switchStream(url);
}
return null;
}
@Override
public void seek(@NonNull DoublePlayerMsg progress) {
TXFlutterLivePlayerApi api = getPlayer(progress.getPlayerId());
if (null != api) {
api.seek(progress);
}
}
@Override
public void setAppID(@NonNull StringPlayerMsg appId) {
TXFlutterLivePlayerApi api = getPlayer(appId.getPlayerId());
if (null != api) {
api.setAppID(appId);
}
}
@Override
public void prepareLiveSeek(@NonNull StringIntPlayerMsg playerMsg) {
TXFlutterLivePlayerApi api = getPlayer(playerMsg.getPlayerId());
if (null != api) {
api.prepareLiveSeek(playerMsg);
}
}
@NonNull
@Override
public IntMsg resumeLive(@NonNull PlayerMsg playerMsg) {
TXFlutterLivePlayerApi api = getPlayer(playerMsg.getPlayerId());
if (null != api) {
return api.resumeLive(playerMsg);
}
return null;
}
@Override
public void setRate(@NonNull DoublePlayerMsg rate) {
TXFlutterLivePlayerApi api = getPlayer(rate.getPlayerId());
if (null != api) {
api.setRate(rate);
}
}
@Override
public void setConfig(@NonNull FTXLivePlayConfigPlayerMsg config) {
TXFlutterLivePlayerApi api = getPlayer(config.getPlayerId());
if (null != api) {
api.setConfig(config);
}
}
@NonNull
@Override
public BoolMsg enableHardwareDecode(@NonNull BoolPlayerMsg enable) {
TXFlutterLivePlayerApi api = getPlayer(enable.getPlayerId());
if (null != api) {
return api.enableHardwareDecode(enable);
}
return null;
}
@NonNull
@Override
public IntMsg enterPictureInPictureMode(@NonNull PipParamsPlayerMsg pipParamsMsg) {
TXFlutterLivePlayerApi api = getPlayer(pipParamsMsg.getPlayerId());
if (null != api) {
return api.enterPictureInPictureMode(pipParamsMsg);
}
return null;
}
@Override
public void exitPictureInPictureMode(@NonNull PlayerMsg playerMsg) {
TXFlutterLivePlayerApi api = getPlayer(playerMsg.getPlayerId());
if (null != api) {
api.exitPictureInPictureMode(playerMsg);
}
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论