Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Android/APIExample/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ android {
pickFirst 'lib/x86_64/libbytertc_vp8codec_extension.so'
pickFirst 'lib/x86_64/libh265enc.so'


// 删除重复的 libc++ 共享库
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}


Expand All @@ -92,10 +96,9 @@ dependencies {
implementation files('libs/ByteEffect.aar')
implementation'com.faceunity:core:8.7.0'
implementation'com.faceunity:model:8.7.0'
implementation "com.bytedanceapi:ttsdk-player_premium:1.40.2.8"
implementation 'com.bytedanceapi:ttsdk-player_premium:1.47.1.10'
implementation 'com.bytedanceapi:ttsdk-ttlivepull_rtc:1.47.1.10'

implementation ("com.bytedanceapi:ttsdk-ttlivepull:1.40.2.8") {
}
implementation 'commons-net:commons-net:3.6'

// 日志上报 SDK,用于点播日志上传, 使用 6.14.3 及以上版本
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,19 @@
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.bytedance.vcloud.cacheModule.utils.CmLog;
import com.pandora.common.env.Env;
import com.pandora.common.env.config.Config;
import com.pandora.common.env.config.VodConfig;
import com.pandora.live.player.LivePlayerBuilder;
import com.pandora.ttlicense2.LicenseManager;
import com.ss.mediakit.medialoader.AVMDLLog;
import com.ss.ttvideoengine.utils.TTVideoEngineLog;
import com.ss.videoarch.liveplayer.ILiveListener;
import com.ss.videoarch.liveplayer.INetworkClient;
import com.ss.videoarch.liveplayer.VeLivePlayer;
import com.ss.videoarch.liveplayer.VeLivePlayerAudioFrame;
import com.ss.videoarch.liveplayer.VeLivePlayerConfiguration;
Expand All @@ -32,13 +29,8 @@
import com.ss.videoarch.liveplayer.VeLivePlayerStreamData;
import com.ss.videoarch.liveplayer.VeLivePlayerVideoFrame;
import com.ss.videoarch.liveplayer.VideoLiveManager;
import com.ss.videoarch.liveplayer.log.LiveError;
import com.ss.videoarch.liveplayer.log.VeLivePlayerLog;

import org.json.JSONObject;

import java.io.File;
import java.nio.ByteBuffer;
import java.util.ArrayList;

import rtc.volcengine.apiexample.BaseActivity;
Expand All @@ -58,6 +50,10 @@ public class PullStreamActivity extends BaseActivity {
private TextView seiMsg;
private VeLivePlayer livePlayer;

private VeLivePlayerDef.VeLivePlayerFormat streamFormat; // 选中的是 FLV 拉流还是 RTM 拉流
private VeLivePlayerDef.VeLivePlayerProtocol streamProtocol; // 使用的拉流协议


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -78,9 +74,6 @@ protected void onCreate(Bundle savedInstanceState) {

// 配置播放器回调
livePlayer.setObserver(mLivePlayerObserver);



}

// VeLivePlayerObserver 回调
Expand Down Expand Up @@ -183,6 +176,27 @@ private void initUI() {
surfaceView = findViewById(R.id.video_view);
livePlayer.setSurfaceHolder(surfaceView.getHolder());

RadioGroup radioGroup = findViewById(R.id.streamTypeGroup);

// 默认选择 FLV 拉流
radioGroup.check(R.id.flvStreamType);
streamFormat = VeLivePlayerDef.VeLivePlayerFormat.VeLivePlayerFormatFLV;
streamProtocol = VeLivePlayerDef.VeLivePlayerProtocol.VeLivePlayerProtocolTCP;

// 设置监听器
radioGroup.setOnCheckedChangeListener((group, checkedId) -> {
switch (checkedId) {
case R.id.flvStreamType:
streamFormat = VeLivePlayerDef.VeLivePlayerFormat.VeLivePlayerFormatFLV;
streamProtocol = VeLivePlayerDef.VeLivePlayerProtocol.VeLivePlayerProtocolTCP;
break;
case R.id.rtmStreamType:
streamFormat = VeLivePlayerDef.VeLivePlayerFormat.VeLivePlayerFormatRTM;
streamProtocol = VeLivePlayerDef.VeLivePlayerProtocol.VeLivePlayerProtocolTLS;
break;
}
});

btnStartPull = findViewById(R.id.btn_start_pull);
btnStopPull = findViewById(R.id.btn_stop_pull);
urlInput = findViewById(R.id.url_input);
Expand All @@ -195,32 +209,29 @@ private void initUI() {
return;
}

// 配置 RTM 地址
VeLivePlayerStreamData.VeLivePlayerStream playStreamRTM = new VeLivePlayerStreamData.VeLivePlayerStream();
playStreamRTM.url = url;
playStreamRTM.format = VeLivePlayerDef.VeLivePlayerFormat.VeLivePlayerFormatFLV;
playStreamRTM.resolution = VeLivePlayerDef.VeLivePlayerResolution.VeLivePlayerResolutionOrigin;
playStreamRTM.streamType = VeLivePlayerDef.VeLivePlayerStreamType.VeLivePlayerStreamTypeMain;
// 配置流信息
VeLivePlayerStreamData.VeLivePlayerStream playStream = new VeLivePlayerStreamData.VeLivePlayerStream();
playStream.url = url;
playStream.format = streamFormat;
playStream.resolution = new VeLivePlayerDef.VeLivePlayerResolution(VeLivePlayerDef.VeLivePlayerResolution.VeLivePlayerResolutionOrigin);
playStream.streamType = VeLivePlayerDef.VeLivePlayerStreamType.VeLivePlayerStreamTypeMain;

// 创建 VeLivePlayerStreamData
VeLivePlayerStreamData streamData = new VeLivePlayerStreamData();
streamData.mainStreamList = new ArrayList<>();

// 添加 RTM 流地址
streamData.mainStreamList.add(playStreamRTM);
// 添加流
streamData.mainStreamList.add(playStream);

// 配置默认 format 和 protocol
streamData.defaultFormat = VeLivePlayerDef.VeLivePlayerFormat.VeLivePlayerFormatFLV;
streamData.defaultProtocol = VeLivePlayerDef.VeLivePlayerProtocol.VeLivePlayerProtocolTCP;
streamData.defaultFormat = streamFormat;
streamData.defaultProtocol = streamProtocol;

// 配置播放源
// 配置播放源
livePlayer.setPlayStreamData(streamData);

// 开始播放
// 开始播放
livePlayer.play();

// livePlayer.setPlayUrl(url);
// livePlayer.play();
});
btnStopPull.setOnClickListener(v -> livePlayer.stop());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,36 @@
android:layout_width="match_parent"
android:layout_height="400dp" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="20dp"
android:orientation="vertical">

<RadioGroup
android:id="@+id/streamTypeGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">

<RadioButton
android:id="@+id/flvStreamType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="FLV 拉流" />

<RadioButton
android:id="@+id/rtmStreamType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="RTM 拉流" />
</RadioGroup>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -63,11 +93,4 @@
android:text="SEI:"
/>








</androidx.appcompat.widget.LinearLayoutCompat>
10 changes: 10 additions & 0 deletions Android/APIExample/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ dependencyResolutionManagement {
mavenCentral()
maven { url 'https://artifact.bytedance.com/repository/Volcengine/' }
maven { url 'https://maven.faceunity.com/repository/maven-public/' }
maven {
url "https://artifact.bytedance.com/repository/thrall_base/"
credentials {
username = 'veVOS'
password = 'KUC9TpKrqbryrxHz'
}
authentication {
digest(BasicAuthentication)
}
}
}
}
rootProject.name = "APIExample"
Expand Down
Loading