1 package com.alivc.live.pusher;
57 import static com.
alivc.
live.utils.ParameterUtil.getInteger;
58 import static com.
alivc.
live.utils.ParameterUtil.getLong;
60 import android.app.Application;
61 import android.content.BroadcastReceiver;
62 import android.content.Context;
63 import android.content.Intent;
64 import android.content.IntentFilter;
65 import android.graphics.Bitmap;
66 import android.graphics.BitmapFactory;
67 import android.media.AudioManager;
68 import android.os.Handler;
69 import android.os.Looper;
70 import android.os.Message;
71 import android.text.TextUtils;
72 import android.view.Surface;
73 import android.view.SurfaceHolder;
74 import android.view.SurfaceView;
75 import android.widget.FrameLayout;
130 import org.json.JSONException;
131 import org.json.JSONObject;
132 import org.webrtc.utils.AlivcLog;
133 import org.webrtc.utils.telephony.TelephonyListener;
134 import org.webrtc.utils.telephony.TelephonyUtil;
136 import java.lang.ref.WeakReference;
137 import java.util.ArrayList;
138 import java.util.HashMap;
139 import java.util.Iterator;
140 import java.util.Map;
141 import java.util.StringTokenizer;
142 import java.util.concurrent.Executors;
143 import java.util.concurrent.LinkedBlockingQueue;
144 import java.util.concurrent.ScheduledExecutorService;
145 import java.util.concurrent.ScheduledThreadPoolExecutor;
146 import java.util.concurrent.ThreadFactory;
147 import java.util.concurrent.ThreadPoolExecutor;
148 import java.util.concurrent.TimeUnit;
149 import java.util.concurrent.atomic.AtomicInteger;
286 class AlivcLivePusherBasicImpl
implements ILivePusher {
287 private static final String TAG =
"AlivcLivePusherBasicImpl";
291 SCREEN_RECORD_NORMAL,
292 SCREEN_RECORD_CAMERA_START,
293 SCREEN_RECORD_CAMERA_MIX_START,
296 private static LivePusherJNI mNativeAlivcLivePusher = null;
297 private WeakReference<AlivcLivePusher> mWeakAlivcLivePusher = null;
300 private AlivcLivePlayStats mPlayStats = AlivcLivePlayStats.IDLE;
307 private AlivcLivePusherRenderContextListener mRenderContextListener = null;
311 private SurfaceView mPreviewView = null;
313 private AudioManager mAudioManager = null;
315 private Context mContext = null;
317 private static final int NTP_TIME_OUT_MILLISECOND = 1000;
318 private static final String AUTH_KEY =
"auth_key=";
319 private static final int MAX_CHATS = 4000;
320 private static final float TEXTURE_RANGE_MIN = 0.0f;
321 private static final float TEXTURE_RANGE_MAX = 1.0f;
322 private static final int MAX_DYNAMIC_ADDSON_COUNT = 3;
323 private static final int AlivcLiveMaxWatermarkCount = 3;
324 private static final long SCHEDULED_EXECUTOR_SERVICE_PERIOD = 2 * 1000L;
326 private Map<Integer, AlivcLivePushError> mErrorMap =
new HashMap<>();
327 private String mPushUrl = null;
329 private int mBGMVolume = 50;
330 private int mCaptureVolume = 50;
331 private boolean mMute =
false;
333 private TelephonyUtil mTelephonyUtil = null;
335 private static final int MESSAGE_RECONNECT_SUCCESS = 0x12;
336 private boolean registeredCallback =
false;
337 protected BluetoothHeadsetUtils mBluetoothHelper;
338 private boolean isReconnect =
false;
339 private LiveEventReporter mLiveEventReporter = null;
340 private long mTimeStamp = -1;
341 private int mExpiryTime = -1;
343 private int mDynamicAddsonCount = 0;
345 private int mTimeCount = 0;
347 private int mWatermarkCount = 0;
349 private ScheduledExecutorService mScheduledExecutorService = null;
358 private AppFrontBackHelper mAppFrontBackHelper;
360 private ThreadPoolExecutor mThreadPoolExecutor =
new ThreadPoolExecutor(3, 5, 1, TimeUnit.SECONDS,
361 new LinkedBlockingQueue<Runnable>(100));
363 private Handler mHandler =
new Handler(Looper.getMainLooper()) {
365 public void handleMessage(Message msg) {
366 AlivcLog.i(TAG,
"[Callback-PushNetwork] onReconnectSucceed");
368 if (mPushNetworkListener != null) {
369 mThreadPoolExecutor.execute(
new Runnable() {
379 private SurfaceHolder.Callback mPreviewCallback =
new SurfaceHolder.Callback() {
381 public void surfaceCreated(SurfaceHolder holder) {
382 AlivcLog.d(TAG,
"Preview surface created");
383 if (mPreviewView == null) {
387 if (mSurfaceStatus == SurfaceStatus.
UNINITED) {
388 mSurfaceStatus = SurfaceStatus.
CREATED;
389 }
else if (mSurfaceStatus == SurfaceStatus.
DESTROYED) {
390 mSurfaceStatus = SurfaceStatus.
RECREATED;
391 if (mNativeAlivcLivePusher != null) {
392 mNativeAlivcLivePusher.notifySurfaceReCreate(mPreviewView.getHolder().getSurface());
398 public void surfaceChanged(SurfaceHolder holder,
int format,
int width,
int height) {
399 AlivcLog.d(TAG,
"Preview surface changed");
400 if (mPreviewView == null) {
403 mSurfaceStatus = SurfaceStatus.
CHANGED;
404 if (mNativeAlivcLivePusher != null) {
405 mNativeAlivcLivePusher.notifySurfaceChange(holder.getSurface(), mAlivcLivePushConfig.
getPreviewOrientation());
410 public void surfaceDestroyed(SurfaceHolder holder) {
411 AlivcLog.d(TAG,
"Preview surface destroyed");
412 if (mPreviewView == null) {
415 if (mNativeAlivcLivePusher != null) {
416 mNativeAlivcLivePusher.notifySurfaceDestroy();
418 mSurfaceStatus = SurfaceStatus.
DESTROYED;
422 public AlivcLivePusherBasicImpl() {
427 public void init(
final Context context,
final AlivcLivePushConfig config)
throws IllegalArgumentException, IllegalStateException {
428 AlivcLog.i(TAG,
"[API-Pusher] init");
429 AlivcLog.i(TAG, AlivcLivePushInstance.getSdkBuildInfo());
431 mAlivcLivePushConfig = config;
432 mLiveEventReporter =
new LiveEventReporter(mContext,
this, mAlivcLivePushConfig);
434 if (!AlivcLiveLicenseManager.isLicenseRegistered()) {
435 String errorMessage =
"License not registered! Get HELP from https://help.aliyun.com/document_detail/431730.htm";
436 AlivcLog.e(TAG, errorMessage);
437 throw new IllegalStateException(errorMessage);
440 boolean isLicenseVerified = AlivcLiveLicenseManager.verifyLicense();
442 AlivcLiveLicenseManager.AlivcLiveLicenseResult licenseResult = AlivcLiveLicenseManager.getLatestLicenseResult();
443 if (licenseResult != null) {
444 PusherLicenseEvent.Args args =
new PusherLicenseEvent.Args();
445 args.result = licenseResult.result;
446 args.reason = licenseResult.msg;
447 args.key = licenseResult.licenseKey;
448 mLiveEventReporter.sendEvent(PusherLicenseEvent.kTopicType, PusherLicenseEvent.kTopicValue, PusherLicenseEvent.getArgsStr(args));
451 if (!isLicenseVerified) {
452 String errorMessage =
"License not verified! Get HELP from https://help.aliyun.com/document_detail/431730.htm";
453 AlivcLog.e(TAG, errorMessage);
454 throw new IllegalStateException(errorMessage);
457 if (mPushStatus != AlivcLivePushStats.
IDLE && mPushStatus != AlivcLivePushStats.
INIT) {
458 throw new IllegalStateException(
"init state error, current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
460 mAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
461 mAudioManager.setMode(AudioManager.STREAM_VOICE_CALL);
462 mAudioManager.setSpeakerphoneOn(
true);
464 registerHeadsetPlugReceiver();
467 LogWhenGoBackOrFront((Application) context.getApplicationContext(),
true);
469 AliLiveInfoUtils.setSDKContext(mContext);
471 mBluetoothHelper =
new BluetoothHeadsetUtils(mContext);
472 mBluetoothHelper.start(
new BluetoothHeadsetUtils.BlueToothListener() {
474 public void onBlueTooth(
boolean on) {
475 LivePusherJNI.headSetOn = on;
477 mAudioManager.setMode(AudioManager.STREAM_VOICE_CALL);
478 mAudioManager.setSpeakerphoneOn(
true);
480 mAudioManager.setSpeakerphoneOn(
false);
482 if (mNativeAlivcLivePusher != null) {
483 mNativeAlivcLivePusher.setHeadSet(on);
490 for (AlivcLivePushError error : AlivcLivePushError.values()) {
491 mErrorMap.put(error.getCode(), error);
493 mLiveEventReporter =
new LiveEventReporter(mContext,
this, mAlivcLivePushConfig);
494 mNativeAlivcLivePusher =
new LivePusherJNI(mContext, config,
new LivePusherJNI.LivePusherListener() {
496 public void onNotify(
final int what, String msg,
final int param1,
final int param2,
int param3,
int param4,
int param5,
long arg6, String arg7, String arg8) {
498 if (what == ALIVC_PUSHER_ERROR_SDK_LIVE_PUSH_NETWORK_TOO_POOR.getCode()) {
499 AlivcLog.w(TAG,
"[Callback-PushNetwork] onNetworkPoor");
500 if (mPushNetworkListener != null) {
501 mThreadPoolExecutor.execute(
new Runnable() {
504 mPushNetworkListener.
onNetworkPoor(getLivePusherReference());
509 PusherNetworkPoorEvent.Args args = null;
510 mLiveEventReporter.sendEvent(PusherNetworkPoorEvent.kTopicType, PusherNetworkPoorEvent.kTopicValue, PusherNetworkPoorEvent.getArgsStr(args));
511 }
else if (what == ALIVC_PUSHER_EVENT_PUSH_NETWORK_RECOVERY.getCode()) {
512 AlivcLog.i(TAG,
"[Callback-PushNetwork] onNetworkRecovery");
513 if (mPushNetworkListener != null) {
514 mThreadPoolExecutor.execute(
new Runnable() {
522 PusherNetworkRecoveryEvent.Args args = null;
523 mLiveEventReporter.sendEvent(PusherNetworkRecoveryEvent.kTopicType, PusherNetworkRecoveryEvent.kTopicValue, PusherNetworkRecoveryEvent.getArgsStr(args));
524 }
else if (what == ALIVC_PUSHER_EVENT_PUSH_RECONNECT_START.getCode()) {
525 AlivcLog.i(TAG,
"[Callback-PushNetwork] onReconnectStart");
528 if (mPushNetworkListener != null) {
529 mThreadPoolExecutor.execute(
new Runnable() {
538 PusherReconnectStartEvent.Args args =
new PusherReconnectStartEvent.Args();
539 mLiveEventReporter.sendEvent(PusherReconnectStartEvent.kTopicType, PusherReconnectStartEvent.kTopicValue, PusherReconnectStartEvent.getArgsStr(args));
540 }
else if (what == ALIVC_PUSHER_EVENT_PUSH_RECONNECT_SUCCESS.getCode()) {
541 AlivcLog.i(TAG,
"[Callback-PushNetwork] Reconnect Success");
542 if (mHandler != null) {
543 mHandler.removeMessages(MESSAGE_RECONNECT_SUCCESS);
544 mHandler.sendEmptyMessageDelayed(MESSAGE_RECONNECT_SUCCESS, 500);
547 if (mPushStatus != AlivcLivePushStats.
PAUSED) {
548 mPushStatus = AlivcLivePushStats.
PUSHED;
551 PusherReconnectSuccessEvent.Args args = null;
552 mLiveEventReporter.sendEvent(PusherReconnectSuccessEvent.kTopicType, PusherReconnectSuccessEvent.kTopicValue, PusherReconnectSuccessEvent.getArgsStr(args));
553 }
else if (what == ALIVC_PUSHER_EVENT_PUSH_CONNECTION_LOST.getCode()) {
554 AlivcLog.e(TAG,
"[Callback-PushNetwork] onConnectionLost");
555 if (mPushNetworkListener != null) {
556 mThreadPoolExecutor.execute(
new Runnable() {
564 PusherConnectionLostEvent.Args args =
new PusherConnectionLostEvent.Args();
566 args.reason =
"rtmp_";
567 }
else if (param1 == 1) {
568 args.reason =
"artc_";
570 args.reason += String.valueOf(param2);
571 mLiveEventReporter.sendEvent(PusherConnectionLostEvent.kTopicType, PusherConnectionLostEvent.kTopicValue, PusherConnectionLostEvent.getArgsStr(args));
572 }
else if (what == ALIVC_PUSHER_ERROR_SDK_PUSH_RECONNECT_FAIL.getCode()) {
573 AlivcLog.e(TAG,
"[Callback-PushNetwork] onReconnectFail");
575 if (mHandler != null) {
576 mHandler.removeMessages(MESSAGE_RECONNECT_SUCCESS);
578 if (mPushNetworkListener != null) {
579 mThreadPoolExecutor.execute(
new Runnable() {
586 mPushStatus = AlivcLivePushStats.
ERROR;
587 mLastError = ALIVC_PUSHER_ERROR_SDK_PUSH_RECONNECT_FAIL;
589 PusherReconnectFailedEvent.Args args =
new PusherReconnectFailedEvent.Args();
592 mLiveEventReporter.sendEvent(PusherReconnectFailedEvent.kTopicType, PusherReconnectFailedEvent.kTopicValue, PusherReconnectFailedEvent.getArgsStr(args));
593 }
else if (what == ALIVC_PUSHER_ERROR_SDK_PUSH_SEND_DATA_TIMEOUT.getCode()) {
594 AlivcLog.w(TAG,
"[Callback-PushNetwork] onSendDataTimeout");
595 if (mPushNetworkListener != null) {
596 mThreadPoolExecutor.execute(
new Runnable() {
604 PusherSendDataTimeoutEvent.Args args = null;
605 mLiveEventReporter.sendEvent(PusherSendDataTimeoutEvent.kTopicType, PusherSendDataTimeoutEvent.kTopicValue, PusherSendDataTimeoutEvent.getArgsStr(args));
606 }
else if (what == ALIVC_PUSHER_ERROR_SDK_PUSH_CONNECT.getCode()
607 || what == ALIVC_LIVE_ERROR_SYSTEM_RTMP_OOM.getCode()
608 || what == ALIVC_PUSHER_ERROR_SDK_PUSH_SETUPURL.getCode()
609 || what == ALIVC_PUSHER_ERROR_SDK_PUSH_CONNECT_STREAM.getCode()
610 || what == ALIVC_PUSHER_ERROR_SDK_PUSH_START_PUSH_TIMEOUT.getCode()) {
611 AlivcLog.e(TAG,
"[Callback-PushNetwork] onConnectFail");
612 if (mPushNetworkListener != null) {
613 mThreadPoolExecutor.execute(
new Runnable() {
616 mPushNetworkListener.
onConnectFail(getLivePusherReference());
620 mPushStatus = AlivcLivePushStats.
ERROR;
621 mLastError = getErrorByCode(what);
623 PusherStartPushFailedEvent.Args args =
new PusherStartPushFailedEvent.Args();
626 mLiveEventReporter.sendEvent(PusherStartPushFailedEvent.kTopicType, PusherStartPushFailedEvent.kTopicValue, PusherStartPushFailedEvent.getArgsStr(args));
627 }
else if (what == ALIVC_PUSHER_EVENT_NATIVE_LIVE_PUSH_INIT_SUCCESS.getCode()) {
629 }
else if (what == ALIVC_PUSHER_EVENT_NATIVE_LIVE_PUSH_PREVIEW_STARTED.getCode()) {
630 AlivcLog.i(TAG,
"[Callback-PushInfo] onPreviewStarted");
631 if (mPushInfoListener != null) {
632 mThreadPoolExecutor.execute(
new Runnable() {
639 mPushStatus = AlivcLivePushStats.
PREVIEWED;
641 }
else if (what == ALIVC_PUSHER_EVENT_NATIVE_LIVE_PUSH_PREVIEW_STOPED.getCode()) {
642 AlivcLog.i(TAG,
"[Callback-PushInfo] onPreviewStopped");
643 if (mPushInfoListener != null) {
644 mThreadPoolExecutor.execute(
new Runnable() {
647 if (mPushInfoListener != null) {
653 mPushStatus = AlivcLivePushStats.
INIT;
654 }
else if (what == ALIVC_PUSHER_EVENT_PUSH_STARTED.getCode()) {
655 AlivcLog.i(TAG,
"[Callback-PushInfo] onPushStarted");
656 mPushStatus = AlivcLivePushStats.
PUSHED;
657 if (mPushInfoListener != null) {
658 mThreadPoolExecutor.execute(
new Runnable() {
666 PusherStartPushSuccessEvent.Args args =
new PusherStartPushSuccessEvent.Args();
668 mLiveEventReporter.sendEvent(PusherStartPushSuccessEvent.kTopicType, PusherStartPushSuccessEvent.kTopicValue, PusherStartPushSuccessEvent.getArgsStr(args));
669 }
else if (what == ALIVC_PUSHER_EVENT_PUSH_STOPED.getCode()) {
670 AlivcLog.i(TAG,
"[Callback-PushInfo] onPushStopped");
671 if (mPushInfoListener != null) {
672 mThreadPoolExecutor.execute(
new Runnable() {
675 if (mPushInfoListener != null) {
681 PusherStopPushSuccessEvent.Args args =
new PusherStopPushSuccessEvent.Args();
683 mLiveEventReporter.sendEvent(PusherStopPushSuccessEvent.kTopicType, PusherStopPushSuccessEvent.kTopicValue, PusherStopPushSuccessEvent.getArgsStr(args));
684 }
else if(what == ALIVC_PUSHER_EVENT_PUSH_CRASH.getCode()){
685 AlivcLog.i(TAG,
"found SDK crashed!");
686 mLiveEventReporter.sendEvent(PusherSDKCrashEvent.kTopicType, PusherSDKCrashEvent.kTopicValue, PusherSDKCrashEvent.getArgsStr(arg7, arg8));
687 }
else if(what == ALIVC_PUSHER_EVENT_GENERAL_MONITOR.getCode()) {
688 AlivcLivePushConstants.Topic topicType = AlivcLivePushConstants.Topic.event;
690 int topicTypeId = (int)arg6;
691 switch (topicTypeId) {
692 case 0: topicType = AlivcLivePushConstants.Topic.action;
break;
693 case 1: topicType = AlivcLivePushConstants.Topic.event;
break;
694 case 2: topicType = AlivcLivePushConstants.Topic.error;
break;
695 case 3: topicType = AlivcLivePushConstants.Topic.biz;
break;
696 default: assert(
false);
699 assert(!arg7.isEmpty());
700 String topicValue = arg7;
701 String argJsonStr = arg8;
702 Map<String, String> param =
new HashMap<String, String>();
704 JSONObject obj =
new JSONObject(argJsonStr);
705 Iterator it = obj.keys();
706 while (it.hasNext()) {
707 String key = it.next().toString();
708 String value = (String)obj.get(key).toString();
709 param.put(key, value);
711 }
catch(JSONException e) {
712 AlivcLog.e(TAG,
"Invalid json object: " + arg8);
713 }
catch(Exception e) {
714 AlivcLog.e(TAG,
"Unknown exception: " + e.getMessage());
716 mLiveEventReporter.sendEvent(topicType, topicValue, param);
717 }
else if(what == ALIVC_PUSHER_EVENT_PUSH_MEDIAINFO.getCode()) {
719 }
else if(what == ALIVC_PUSHER_EVENT_PUSH_DELAY_INFO.getCode()) {
721 PusherDelayInfoEvent.Args args =
new PusherDelayInfoEvent.Args();
722 args.totalDelay = param1;
723 args.captureDelay = param2;
724 args.encoderDelay = param3;
725 args.sendDelay = param4;
727 AlivcLog.d(TAG,
"AlivcLivePusher push delay");
729 mLiveEventReporter.sendEvent(PusherDelayInfoEvent.kTopicType, PusherDelayInfoEvent.kTopicValue, PusherDelayInfoEvent.getArgsStr(args));
732 JSONObject gDelayObject =
new JSONObject();
735 gDelayObject.put(
"gdelay", param1);
737 sendMessageInternal(gDelayObject.toString(),10,0,
false,
true);
739 }
catch (Exception e) {
744 }
else if (what == ALIVC_PUSHER_EVENT_NATIVE_LIVE_PUSH_PUSH_PAUSED.getCode()) {
745 AlivcLog.i(TAG,
"[Callback-PushInfo] onPushPaused");
746 if (mPushInfoListener != null) {
747 mThreadPoolExecutor.execute(
new Runnable() {
750 mPushInfoListener.
onPushPaused(getLivePusherReference());
755 PusherOnPauseEvent.Args args = null;
756 mLiveEventReporter.sendEvent(PusherOnPauseEvent.kTopicType, PusherOnPauseEvent.kTopicValue, PusherOnPauseEvent.getArgsStr(args));
757 }
else if (what == ALIVC_PUSHER_EVENT_NATIVE_LIVE_PUSH_PUSH_RESUMED.getCode()) {
758 AlivcLog.i(TAG,
"[Callback-PushInfo] onPushResumed");
759 if (mNativeAlivcLivePusher.isPushing()) {
760 mPushStatus = AlivcLivePushStats.
PUSHED;
762 mPushStatus = AlivcLivePushStats.
PREVIEWED;
764 if (mPushInfoListener != null) {
765 mThreadPoolExecutor.execute(
new Runnable() {
773 PusherOnResumeEvent.Args args = null;
774 mLiveEventReporter.sendEvent(PusherOnResumeEvent.kTopicType, PusherOnResumeEvent.kTopicValue, PusherOnResumeEvent.getArgsStr(args));
775 }
else if (what == ALIVC_FRAMEWORK_RENDER_FIRST_FRAME_PREVIEWED.getCode()) {
776 AlivcLog.i(TAG,
"[Callback-PushInfo] onFirstFramePreviewed");
777 if (mPushInfoListener != null) {
778 mThreadPoolExecutor.execute(
new Runnable() {
785 }
else if (what == ALIVC_PUSHER_EVENT_NATIVE_LIVE_PUSH_PUSH_RESTARTED.getCode()) {
786 AlivcLog.i(TAG,
"[Callback-PushInfo] onPushRestarted");
787 mPushStatus = AlivcLivePushStats.
PUSHED;
788 if (mPushInfoListener != null) {
789 mThreadPoolExecutor.execute(
new Runnable() {
797 PusherOnRestartEvent.Args args = null;
798 mLiveEventReporter.sendEvent(PusherOnRestartEvent.kTopicType, PusherOnRestartEvent.kTopicValue, PusherOnRestartEvent.getArgsStr(args));
799 }
else if (what == ALIVC_PUSHER_EVENT_PUSH_DROP_FRAME.getCode()) {
800 AlivcLog.w(TAG,
"[Callback-PushInfo] onDropFrame");
801 AlivcLog.w(TAG,
"[Callback-PushNetwork] onPacketsLost");
802 PusherDropFrameEvent.PusherDropFrameArgs args =
new PusherDropFrameEvent.PusherDropFrameArgs();
803 args.vpiubbd = param1;
804 args.vpiubad = param2;
805 args.apiubbd = param3;
806 args.apiubad = param4;
807 mLiveEventReporter.sendEvent(PusherDropFrameEvent.kTopicType, PusherDropFrameEvent.kTopicValue, PusherDropFrameEvent.getArgsStr(args));
808 if (mPushInfoListener != null) {
809 mThreadPoolExecutor.execute(
new Runnable() {
812 mPushInfoListener.
onDropFrame(getLivePusherReference(), param1, param2);
814 if (mPushNetworkListener != null) {
815 mPushNetworkListener.
onPacketsLost(getLivePusherReference());
821 }
else if (what == ALIVC_PUSHER_EVENT_NATIVE_LIVE_PUSH_ADJUST_BITRATE.getCode()) {
822 PusherAdjustBitrateEvent.Args args =
new PusherAdjustBitrateEvent.Args();
823 args.oeb = param1 / 1000;
824 args.neb = param2 / 1000;
825 Map map = getPerformanceMap();
827 args.ceb = getInteger(map,
"mVideoEncodeBitrate") + getInteger(map,
"mAudioEncodeBitrate");
828 args.cub = getInteger(map,
"mAudioUploadBitrate") + getInteger(map,
"mVideoUploadBitrate");
830 AlivcLog.i(TAG,
"[Callback-PushInfo] onAdjustBitrate: " + args.oeb +
", " + args.neb);
831 mLiveEventReporter.sendEventWithLevel(PusherAdjustBitrateEvent.kTopicType, PusherAdjustBitrateEvent.kTopicValue, PusherAdjustBitrateEvent.getArgsStr(args), AlivcLivePushMonitorLevel.CUT);
832 if (mPushInfoListener != null) {
833 mThreadPoolExecutor.execute(
new Runnable() {
836 mPushInfoListener.
onAdjustBitrate(getLivePusherReference(), param1 / 1000, param2 / 1000);
840 }
else if (what == ALIVC_PUSHER_EVENT_NATIVE_LIVE_PUSH_CHANGE_FPS.getCode()) {
841 AlivcLog.i(TAG,
"[Callback-PushInfo] onAdjustFps: " + param1 +
", " + param2);
842 PusherAdjustFpsEvent.Args args =
new PusherAdjustFpsEvent.Args();
843 args.oldFps = param1;
844 args.newFps = param2;
845 mLiveEventReporter.sendEvent(PusherAdjustFpsEvent.kTopicType, PusherAdjustFpsEvent.kTopicValue, PusherAdjustFpsEvent.getArgsStr(args));
846 if (mPushInfoListener != null) {
847 mThreadPoolExecutor.execute(
new Runnable() {
850 mPushInfoListener.
onAdjustFps(getLivePusherReference(), param1, param2);
854 }
else if (what == ALIVC_PUSHER_EVENT_NATIVE_LIVE_PUSH_CHANGE_RESOLUTION.getCode()) {
856 }
else if (what == ALIVC_PUSHER_ERROR_SDK_PUSH_RTS_DOWN_TO_RTMP.getCode()) {
859 }
else if (what == ALIVC_PUSHER_EVENT_PUSH_SENDED_FIRST_AV.getCode()) {
861 PusherFirstFrameSentEvent.Args args =
new PusherFirstFrameSentEvent.Args();
864 args.resolution = mAlivcLivePushConfig.
getResolution().toString().substring(11);
869 args.wc = mAlivcLivePushConfig.getWaterMarkInfos().size();
871 args.fps = mAlivcLivePushConfig.
getFps();
878 args.flash = mAlivcLivePushConfig.
isFlash();
884 mLiveEventReporter.sendEvent(PusherFirstFrameSentEvent.kTopicType, PusherFirstFrameSentEvent.kTopicValue, PusherFirstFrameSentEvent.getArgsStr(args));
885 AlivcLog.i(TAG,
"[Callback-PushInfo] onFirstFramePushed");
886 if (mPushInfoListener != null) {
887 mThreadPoolExecutor.execute(
new Runnable() {
894 }
else if (what == ALIVC_PUSHER_EVENT_CAPTURE_OPEN_CAMERA_SUCCESS.getCode()) {
896 }
else if (what == ALIVC_PUSHER_EVENT_CAPTURE_OPEN_MIC_SUCCESS.getCode()) {
898 }
else if (what == ALIVC_PUSHER_EVENT_CAPTURE_CLOSE_CAMERA_SUCCESS.getCode()) {
900 }
else if (what == ALIVC_PUSHER_EVENT_NATIVE_LIVE_PUSH_OPEN_VIDEO_ENCODER_SUCCESS.getCode()) {
902 }
else if (what == ALIVC_PUSHER_EVENT_NATIVE_LIVE_PUSH_CAPTURE_VIDEO_SAMPLES_OVERFLOW.getCode()) {
904 }
else if (what == ALIVC_PUSHER_EVENT_PUSH_SENDED_SEI.getCode()) {
905 AlivcLog.i(TAG,
"[Callback-PushNetwork] onSendMessage");
906 if (mPushNetworkListener != null) {
907 mThreadPoolExecutor.execute(
new Runnable() {
910 mPushNetworkListener.
onSendMessage(getLivePusherReference());
917 else if (what == ALIVC_PUSHER_ERROR_BGM_OPEN_FAILED.getCode()) {
918 AlivcLog.e(TAG,
"[Callback-PushBGM] onOpenFailed");
919 mPlayStats = AlivcLivePlayStats.IDLE;
920 if (mPushBGMListener != null) {
923 if (mNativeAlivcLivePusher != null) {
924 mNativeAlivcLivePusher.stopBGM();
926 }
else if (what == ALIVC_PUSHER_ERROR_BGM_TIMEOUT.getCode()) {
927 AlivcLog.e(TAG,
"[Callback-PushBGM] onDownloadTimeout");
928 mPlayStats = AlivcLivePlayStats.IDLE;
929 if (mPushBGMListener != null) {
932 }
else if (what == ALIVC_PUSHER_EVENT_BGM_OPEN_SUCCESS.getCode()) {
933 AlivcLog.i(TAG,
"[Callback-PushBGM] onStarted");
934 mPlayStats = AlivcLivePlayStats.STARTED;
935 if (mPushBGMListener != null) {
938 }
else if (what == ALIVC_PUSHER_EVENT_BGM_STOP_SUCCESS.getCode()) {
939 AlivcLog.i(TAG,
"[Callback-PushBGM] onStopped");
940 mPlayStats = AlivcLivePlayStats.STOPPED;
941 if (mPushBGMListener != null) {
944 }
else if (what == ALIVC_PUSHER_EVENT_BGM_PAUSE_SUCCESS.getCode()) {
945 AlivcLog.i(TAG,
"[Callback-PushBGM] onPaused");
946 mPlayStats = AlivcLivePlayStats.PAUSED;
947 if (mPushBGMListener != null) {
950 }
else if (what == ALIVC_PUSHER_EVENT_BGM_RESUME_SUCCESS.getCode()) {
951 AlivcLog.i(TAG,
"[Callback-PushBGM] onResumed");
952 mPlayStats = AlivcLivePlayStats.STARTED;
953 if (mPushBGMListener != null) {
956 }
else if (what == ALIVC_PUSHER_EVENT_BGM_COMPLETED.getCode()) {
957 AlivcLog.i(TAG,
"[Callback-PushBGM] onCompleted");
958 if (mPushBGMListener != null) {
961 mPlayStats = AlivcLivePlayStats.IDLE;
962 }
else if (what == ALIVC_PUSHER_EVENT_BGM_PROGRESS.getCode()) {
963 if (mPushBGMListener != null) {
964 mPushBGMListener.
onProgress((
long) param1, (
long) param2);
966 }
else if (what == ALIVC_PUSHER_EVENT_CAPTURE_OPEN_SCREENCAPTURE_SUCCESS.getCode()) {
968 }
else if (what == ALIVC_PUSHER_EVENT_CAPTURE_CLOSE_SCREENCAPTURE_SUCCESS.getCode()) {
970 }
else if (what == ALIVC_PUSHER_EVENT_NATIVE_LIVE_PUSH_GL_CONTEXT_CREATED.getCode()) {
971 AlivcLog.i(TAG,
"[Callback-PusherRenderContext] onSharedContextCreated");
972 if (mRenderContextListener != null) {
973 mRenderContextListener.onSharedContextCreated(arg6);
975 }
else if (what == ALIVC_PUSHER_EVENT_NATIVE_LIVE_PUSH_GL_CONTEXT_DESTROYED.getCode()) {
976 AlivcLog.i(TAG,
"[Callback-PusherRenderContext] onSharedContextDestroyed");
977 if (mRenderContextListener != null) {
978 mRenderContextListener.onSharedContextDestroyed(arg6);
982 else if (what > 0x30010000 && what < 0x30020000) {
983 if (mErrorMap.get(what) != null) {
984 mErrorMap.get(what).setMsg(msg);
986 AlivcLog.e(TAG,
"[Callback-PushError] onSystemError:" + mErrorMap.get(what));
987 if (mPushErrorListener != null) {
988 mThreadPoolExecutor.execute(
new Runnable() {
991 mPushErrorListener.
onSystemError(getLivePusherReference(), mErrorMap.get(what));
996 PusherSystemErrorEvent.Args args =
new PusherSystemErrorEvent.Args();
997 Map map = getPerformanceMap();
999 args.totalUploadSize = getLong(map,
"mTotalSizeOfUploadedPackets");
1000 args.totalTime = getLong(map,
"mTotalTimeOfPublishing");
1001 args.error_code = what;
1002 if (mErrorMap.get(what) != null) {
1003 args.error_msg = msg;
1005 mLiveEventReporter.sendEvent(PusherSystemErrorEvent.kTopicType, PusherSystemErrorEvent.kTopicValue, PusherSystemErrorEvent.getArgsStr(args));
1007 mPushStatus = AlivcLivePushStats.
ERROR;
1008 mLastError = getErrorByCode(what);
1010 else if (what == ALIVC_PUSHER_ERROR_SDK_LIVE_PUSH_LOW_PERFORMANCE.getCode()) {
1012 if (mErrorMap.get(what) != null) {
1013 mErrorMap.get(what).setMsg(msg);
1015 AlivcLog.w(TAG,
"low performance warning:" + mErrorMap.get(what));
1016 PusherSdkErrorEvent.Args args =
new PusherSdkErrorEvent.Args();
1017 Map map = getPerformanceMap();
1019 args.totalUploadSize = ParameterUtil.getLong(map,
"mTotalSizeOfUploadedPackets");
1020 args.totalTime = ParameterUtil.getLong(map,
"mTotalTimeOfPublishing");
1021 args.error_code = what;
1022 if (mErrorMap.get(what) != null) {
1023 args.error_msg = msg;
1025 mLiveEventReporter.sendEvent(PusherSdkErrorEvent.kTopicType, PusherSdkErrorEvent.kTopicValue, PusherSdkErrorEvent.getArgsStr(args));
1030 if (mErrorMap.get(what) != null) {
1031 mErrorMap.get(what).setMsg(msg);
1033 AlivcLog.e(TAG,
"[Callback-PushError] onSDKError:" + mErrorMap.get(what));
1034 if (mPushErrorListener != null) {
1035 mThreadPoolExecutor.execute(
new Runnable() {
1038 mPushErrorListener.
onSDKError(getLivePusherReference(), mErrorMap.get(what));
1043 PusherSdkErrorEvent.Args args =
new PusherSdkErrorEvent.Args();
1044 Map map = getPerformanceMap();
1046 args.totalUploadSize = getLong(map,
"mTotalSizeOfUploadedPackets");
1047 args.totalTime = getLong(map,
"mTotalTimeOfPublishing");
1048 args.error_code = what;
1049 if (mErrorMap.get(what) != null) {
1050 args.error_msg = msg;
1052 mLiveEventReporter.sendEvent(PusherSdkErrorEvent.kTopicType, PusherSdkErrorEvent.kTopicValue, PusherSdkErrorEvent.getArgsStr(args));
1054 mPushStatus = AlivcLivePushStats.
ERROR;
1055 mLastError = getErrorByCode(what);
1059 mNativeAlivcLivePusher.init();
1060 BGMPlayerJNI.setContext(mContext);
1061 mPushStatus = AlivcLivePushStats.
INIT;
1065 public void setCustomDetect(AlivcLivePushCustomDetect customVideoDetect) {
1066 AlivcLog.i(TAG,
"[API-Pusher] setCustomDetect");
1067 if (mNativeAlivcLivePusher == null) {
1070 mNativeAlivcLivePusher.setCustomDetect(customVideoDetect);
1074 public void setCustomFilter(AlivcLivePushCustomFilter customVideoFilter) {
1075 AlivcLog.i(TAG,
"[API-Pusher] setCustomFilter");
1076 if (mNativeAlivcLivePusher == null) {
1079 mNativeAlivcLivePusher.setCustomFilter(customVideoFilter);
1083 public void setCustomAudioFilter(AlivcLivePushCustomAudioFilter customAudioFilter) {
1084 AlivcLog.i(TAG,
"[API-Pusher] setCustomAudioFilter: " + customAudioFilter);
1085 if (mNativeAlivcLivePusher == null) {
1088 mNativeAlivcLivePusher.setCustomAudioFilter(customAudioFilter);
1092 public void destroy() throws IllegalStateException {
1093 AlivcLog.i(TAG,
"[API-Pusher] destroy");
1094 LogWhenGoBackOrFront((Application) mContext.getApplicationContext(),
false);
1096 if (mNativeAlivcLivePusher != null) {
1097 mNativeAlivcLivePusher.release();
1100 mDynamicAddsonCount = 0;
1102 if (registeredCallback) {
1104 mContext.unregisterReceiver(mHeadsetPlugReceiver);
1105 }
catch (Exception e) {
1106 AlivcLog.e(TAG,
"unregisterReceiver exception");
1108 registeredCallback =
false;
1110 if (mBluetoothHelper != null) {
1111 mBluetoothHelper.stop();
1113 unregisterTelephony();
1114 mPushStatus = AlivcLivePushStats.
IDLE;
1116 stopScheduleExecutor();
1118 if (mThreadPoolExecutor != null && !mThreadPoolExecutor.isShutdown()) {
1119 mThreadPoolExecutor.shutdown();
1121 mThreadPoolExecutor = null;
1123 mNativeAlivcLivePusher = null;
1124 mPushInfoListener = null;
1125 mPushErrorListener = null;
1126 mPushNetworkListener = null;
1127 mPushBGMListener = null;
1129 mPreviewView = null;
1131 mAlivcLivePushConfig = null;
1134 mPreviewCallback = null;
1135 if (mHandler != null) {
1136 mHandler.removeMessages(MESSAGE_RECONNECT_SUCCESS);
1140 if (mWeakAlivcLivePusher != null) {
1141 mWeakAlivcLivePusher.clear();
1142 mWeakAlivcLivePusher = null;
1144 BGMPlayerJNI.setContext(null);
1148 public void setLivePusherReference(AlivcLivePusher livePusher) {
1149 mWeakAlivcLivePusher =
new WeakReference<>(livePusher);
1152 private AlivcLivePusher getLivePusherReference() {
1153 return (mWeakAlivcLivePusher != null) ? mWeakAlivcLivePusher.get() : null;
1157 public void startPreview(SurfaceView surfaceView)
throws IllegalArgumentException, IllegalStateException {
1158 AlivcLog.i(TAG,
"[API-Pusher] startPreview");
1159 PusherStartPreviewEvent.Args args =
new PusherStartPreviewEvent.Args();
1161 if (mLiveEventReporter != null) {
1162 mLiveEventReporter.sendEvent(PusherStartPreviewEvent.kTopicType, PusherStartPreviewEvent.kTopicValue, PusherStartPreviewEvent.getArgsStr(args));
1165 if (mNativeAlivcLivePusher == null) {
1166 AlivcLog.e(TAG,
"Illegal State, you should init first");
1169 if (mPushStatus != AlivcLivePushStats.
INIT && mPushStatus != AlivcLivePushStats.
PREVIEWED) {
1170 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1174 this.mPreviewView = surfaceView;
1176 if (surfaceView == null) {
1177 result = mNativeAlivcLivePusher.startPreview(null,
true);
1179 mPushStatus = AlivcLivePushStats.
PREVIEWED;
1181 AlivcLog.e(TAG,
"start preview error");
1185 result = mNativeAlivcLivePusher.startPreview(surfaceView.getHolder().getSurface(),
true);
1187 surfaceView.getHolder().addCallback(mPreviewCallback);
1188 mPushStatus = AlivcLivePushStats.
PREVIEWED;
1190 AlivcLog.e(TAG,
"start preview error");
1196 public void startPreviewAsync(SurfaceView surfaceView)
throws IllegalArgumentException, IllegalStateException {
1197 AlivcLog.i(TAG,
"[API-Pusher] startPreviewAsync");
1199 PusherStartPreviewEvent.Args args =
new PusherStartPreviewEvent.Args();
1201 if (mLiveEventReporter != null) {
1202 mLiveEventReporter.sendEvent(PusherStartPreviewEvent.kTopicType, PusherStartPreviewEvent.kTopicValue, PusherStartPreviewEvent.getArgsStr(args));
1205 if (mNativeAlivcLivePusher == null) {
1206 AlivcLog.e(TAG,
"Illegal State, you should init first");
1210 if (mPushStatus != AlivcLivePushStats.
INIT && mPushStatus != AlivcLivePushStats.
PREVIEWED) {
1211 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1216 this.mPreviewView = surfaceView;
1218 if (surfaceView == null) {
1219 result = mNativeAlivcLivePusher.startPreview(null,
false);
1221 mPushStatus = AlivcLivePushStats.
PREVIEWED;
1223 AlivcLog.e(TAG,
"start preview async error");
1226 result = mNativeAlivcLivePusher.startPreview(surfaceView.getHolder().getSurface(),
false);
1228 surfaceView.getHolder().addCallback(mPreviewCallback);
1229 mPushStatus = AlivcLivePushStats.
PREVIEWED;
1231 AlivcLog.e(TAG,
"start preview async error");
1237 public void startPreview(Context context, FrameLayout frameLayout,
boolean isAnchor)
throws IllegalArgumentException, IllegalStateException {
1242 public void stopPreview() throws IllegalStateException {
1243 AlivcLog.i(TAG,
"[API-Pusher] stopPreview");
1244 PusherStopPreviewEvent.Args args = null;
1245 if (mLiveEventReporter != null) {
1246 mLiveEventReporter.sendEvent(PusherStopPreviewEvent.kTopicType, PusherStopPreviewEvent.kTopicValue, PusherStopPreviewEvent.getArgsStr(args));
1249 if (mNativeAlivcLivePusher == null) {
1250 AlivcLog.e(TAG,
"Illegal State, you should init first");
1254 mDynamicAddsonCount = 0;
1256 if (mPushStatus != AlivcLivePushStats.
INIT && mPushStatus != AlivcLivePushStats.
PREVIEWED) {
1257 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1261 int result = mNativeAlivcLivePusher.stopPreview();
1263 mPushStatus = AlivcLivePushStats.
INIT;
1265 AlivcLog.e(TAG,
"stop preview error");
1270 public void startPush(String url)
throws IllegalArgumentException, IllegalStateException {
1271 AlivcLog.i(TAG,
"[API-Pusher] startPush: " + url);
1272 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
1273 AlivcLog.e(TAG,
"Illegal State, you should init first");
1277 url = AlivcLiveURLTools.trimUrl(url);
1278 if (!AlivcLiveURLTools.checkPushUrl(url)) {
1279 AlivcLog.e(TAG,
"Illegal argument, push url error!");
1283 if ((mAlivcLivePushConfig.
isAudioOnly() || mAlivcLivePushConfig.
isVideoOnly()) && url.startsWith(AlivcLiveStreamType.EnumType.AlivcLiveStreamRts.getPrefix())) {
1284 AlivcLog.e(TAG,
"RTC protocol don't support audio/video only stream");
1288 if ((mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
INIT)
1289 && mPushStatus != AlivcLivePushStats.
PUSHED) {
1290 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1294 if (mPushStatus.equals(AlivcLivePushStats.INIT)) {
1295 mPreviewView = null;
1296 int result = mNativeAlivcLivePusher.startPreview(null,
true);
1298 AlivcLog.e(TAG,
"start push error : create gl resource failed");
1303 if (mPushUrl.contains(AUTH_KEY)) {
1307 mLiveEventReporter.refreshPushId();
1308 int result = mNativeAlivcLivePusher.startPush(url,
true);
1310 if (mPushStatus != AlivcLivePushStats.
PUSHED) {
1311 mPushStatus = AlivcLivePushStats.
PUSHED;
1313 mScreenStatus = ScreenRecordStatus.SCREEN_RECORD_NORMAL;
1317 AlivcLog.e(TAG,
"start push error");
1321 reportStartPushEvent(
false,
true);
1325 mNativeAlivcLivePusher.addPushImage(pauseImage, networkImage);
1326 startScheduleExecutor();
1330 public void startPushAsync(String url)
throws IllegalArgumentException, IllegalStateException {
1331 AlivcLog.i(TAG,
"[API-Pusher] startPushAsync: " + url);
1332 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
1333 AlivcLog.e(TAG,
"Illegal State, you should init first");
1337 url = AlivcLiveURLTools.trimUrl(url);
1338 if (!AlivcLiveURLTools.checkPushUrl(url)) {
1339 AlivcLog.e(TAG,
"Illegal argument, push url error!");
1343 if ((mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
INIT)
1344 && mPushStatus != AlivcLivePushStats.
PUSHED) {
1345 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1349 if ((mAlivcLivePushConfig.
isAudioOnly() || mAlivcLivePushConfig.
isVideoOnly()) && url.startsWith(AlivcLiveStreamType.EnumType.AlivcLiveStreamRts.getPrefix())) {
1350 AlivcLog.e(TAG,
"RTC protocol don't support audio/video only stream");
1354 if (mPushStatus.equals(AlivcLivePushStats.INIT)) {
1355 mPreviewView = null;
1356 int result = mNativeAlivcLivePusher.startPreview(null,
true);
1358 AlivcLog.e(TAG,
"start push error : create gl resource failed");
1364 if (mPushUrl.contains(AUTH_KEY)) {
1368 mLiveEventReporter.refreshPushId();
1369 int result = mNativeAlivcLivePusher.startPush(url,
false);
1371 if (mPushStatus != AlivcLivePushStats.
PUSHED) {
1372 mPushStatus = AlivcLivePushStats.
PUSHED;
1374 mScreenStatus = ScreenRecordStatus.SCREEN_RECORD_NORMAL;
1378 AlivcLog.e(TAG,
"start push async error");
1382 reportStartPushEvent(
false,
false);
1386 mNativeAlivcLivePusher.addPushImage(pauseImage, networkImage);
1387 startScheduleExecutor();
1391 public void restartPush() throws IllegalStateException {
1392 AlivcLog.i(TAG,
"[API-Pusher] restartPush");
1393 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
1394 AlivcLog.e(TAG,
"Illegal State, you should init first");
1400 AlivcLog.e(TAG,
"illegal argument");
1405 && (!TextUtils.isEmpty(mPushUrl) && mPushUrl.startsWith(AlivcLiveStreamType.EnumType.AlivcLiveStreamRts.getPrefix()))) {
1406 AlivcLog.e(TAG,
"RTC protocol don't support audio/video only stream");
1410 if (mPushStatus != AlivcLivePushStats.
PUSHED && mPushStatus != AlivcLivePushStats.
ERROR) {
1411 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1415 mDynamicAddsonCount = 0;
1417 stopScheduleExecutor();
1419 Surface surface = mPreviewView != null ? mPreviewView.getHolder().getSurface() : null;
1420 int result = mNativeAlivcLivePusher.restartPush(surface,
true, 1000);
1422 mPushStatus = AlivcLivePushStats.
PUSHED;
1424 mScreenStatus = ScreenRecordStatus.SCREEN_RECORD_NORMAL;
1427 AlivcLog.e(TAG,
"restart push error");
1432 mNativeAlivcLivePusher.addPushImage(pauseImage, networkImage);
1434 reportStartPushEvent(
true,
true);
1436 startScheduleExecutor();
1441 public void restartPushAsync() throws IllegalStateException {
1442 AlivcLog.i(TAG,
"[API-Pusher] restartPushAsync");
1443 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
1444 AlivcLog.e(TAG,
"Illegal State, you should init first");
1450 AlivcLog.e(TAG,
"illegal argument");
1455 && (!TextUtils.isEmpty(mPushUrl) && mPushUrl.startsWith(AlivcLiveStreamType.EnumType.AlivcLiveStreamRts.getPrefix()))) {
1456 AlivcLog.e(TAG,
"RTC protocol don't support audio/video only stream");
1460 if (mPushStatus != AlivcLivePushStats.
PUSHED && mPushStatus != AlivcLivePushStats.
ERROR) {
1461 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1465 Surface surface = mPreviewView != null ? mPreviewView.getHolder().getSurface() : null;
1466 int result = mNativeAlivcLivePusher.restartPush(surface,
false, 1000);
1470 AlivcLog.e(TAG,
"restart push async error");
1475 mNativeAlivcLivePusher.addPushImage(pauseImage, networkImage);
1477 stopScheduleExecutor();
1479 reportStartPushEvent(
true,
false);
1481 startScheduleExecutor();
1485 public void reconnectPushAsync(String url)
throws IllegalStateException {
1486 AlivcLog.i(TAG,
"[API-Pusher] reconnectPushAsync");
1487 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
1488 AlivcLog.e(TAG,
"Illegal State, you should init first");
1492 url = AlivcLiveURLTools.trimUrl(url);
1493 if (!AlivcLiveURLTools.checkPushUrl(url)) {
1497 if (mPushStatus != AlivcLivePushStats.
PUSHED && mPushStatus != AlivcLivePushStats.
PAUSED &&
1498 mPushStatus != AlivcLivePushStats.
ERROR) {
1499 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1503 if (isNetworkPushing()) {
1509 int result = mNativeAlivcLivePusher.reconnect(url,
false);
1511 isReconnect =
false;
1512 if (mHandler != null) {
1513 mHandler.removeMessages(MESSAGE_RECONNECT_SUCCESS);
1515 mPushStatus = AlivcLivePushStats.
PUSHED;
1517 mScreenStatus = ScreenRecordStatus.SCREEN_RECORD_NORMAL;
1520 AlivcLog.e(TAG,
"reconnect push async error");
1525 PusherReconnectEvent.Args args =
new PusherReconnectEvent.Args();
1526 Map map = getPerformanceMap();
1528 args.vutMs = getLong(map,
"mVideoDurationFromeCaptureToUpload");
1529 args.autMs = getLong(map,
"mAudioDurationFromeCaptureToUpload");
1530 if (mLiveEventReporter != null) {
1531 mLiveEventReporter.sendEvent(PusherReconnectEvent.kTopicType, PusherReconnectEvent.kTopicValue, PusherReconnectEvent.getArgsStr(args));
1537 public void stopPush() throws IllegalStateException {
1538 AlivcLog.i(TAG,
"[API-Pusher] stopPush");
1539 PusherStopPushEvent.Args args =
new PusherStopPushEvent.Args();
1540 Map map = getPerformanceMap();
1542 args.totalUploadSize = ParameterUtil.getLong(map,
"mTotalSizeOfUploadedPackets");
1543 args.totalTime = ParameterUtil.getLong(map,
"mTotalTimeOfPublishing");
1544 if (mLiveEventReporter != null) {
1545 mLiveEventReporter.sendEvent(PusherStopPushEvent.kTopicType, PusherStopPushEvent.kTopicValue, PusherStopPushEvent.getArgsStr(args));
1549 if (mNativeAlivcLivePusher == null) {
1550 AlivcLog.e(TAG,
"Illegal State, you should init first");
1553 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED
1554 && mPushStatus != AlivcLivePushStats.
PAUSED && mPushStatus != AlivcLivePushStats.
ERROR) {
1555 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1559 int result = mNativeAlivcLivePusher.stopPush();
1561 mPushStatus = AlivcLivePushStats.
PREVIEWED;
1563 AlivcLog.e(TAG,
"stop push error");
1566 if (mPreviewView == null) {
1567 mNativeAlivcLivePusher.stopPreview();
1568 mPushStatus = AlivcLivePushStats.
INIT;
1570 stopScheduleExecutor();
1574 public void pause() throws IllegalStateException {
1575 AlivcLog.i(TAG,
"[API-Pusher] pause");
1576 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
1577 AlivcLog.e(TAG,
"Illegal State, you should init first");
1583 if (mPushStatus != AlivcLivePushStats.
PUSHED && mPushStatus != AlivcLivePushStats.
PAUSED
1584 && mPushStatus != AlivcLivePushStats.
PREVIEWED) {
1585 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1588 mPushStatus = AlivcLivePushStats.
PAUSED;
1590 mNativeAlivcLivePusher.pause();
1593 PusherPauseEvent.mLastPauseTime = System.currentTimeMillis();
1594 PusherPauseEvent.Args args =
new PusherPauseEvent.Args();
1595 Map map = getPerformanceMap();
1597 args.isPauseScreen =
false;
1598 args.totalUploadSize = ParameterUtil.getLong(map,
"mTotalSizeOfUploadedPackets");
1599 args.totalTime = ParameterUtil.getLong(map,
"mTotalTimeOfPublishing");
1600 if (mLiveEventReporter != null) {
1601 mLiveEventReporter.sendEvent(PusherPauseEvent.kTopicType, PusherPauseEvent.kTopicValue, PusherPauseEvent.getArgsStr(args));
1607 public void resume() throws IllegalStateException {
1608 AlivcLog.i(TAG,
"[API-Pusher] resume");
1609 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
1610 AlivcLog.e(TAG,
"Illegal State, you should init first");
1616 if (mPushStatus != AlivcLivePushStats.
PAUSED && mPushStatus != AlivcLivePushStats.
ERROR) {
1617 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1621 mNativeAlivcLivePusher.resume(
true);
1622 PusherResumeEvent.Args args =
new PusherResumeEvent.Args();
1623 Map map = getPerformanceMap();
1626 args.isResumeScreen =
false;
1627 args.totalUploadSize = ParameterUtil.getLong(map,
"mTotalSizeOfUploadedPackets");
1628 args.totalTime = ParameterUtil.getLong(map,
"mTotalTimeOfPublishing");
1629 if (PusherPauseEvent.mLastPauseTime == 0) {
1632 args.cost = System.currentTimeMillis() - PusherPauseEvent.mLastPauseTime;
1634 if (mLiveEventReporter != null) {
1635 mLiveEventReporter.sendEvent(PusherResumeEvent.kTopicType, PusherResumeEvent.kTopicValue, PusherResumeEvent.getArgsStr(args));
1639 PusherPauseEvent.mLastPauseTime = 0;
1641 if (mNativeAlivcLivePusher.isPushing()) {
1642 mPushStatus = AlivcLivePushStats.
PUSHED;
1644 mPushStatus = AlivcLivePushStats.
PREVIEWED;
1649 public void resumeAsync() throws IllegalStateException {
1650 AlivcLog.i(TAG,
"[API-Pusher] resumeAsync");
1651 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
1652 AlivcLog.e(TAG,
"Illegal State, you should init first");
1658 if (mPushStatus != AlivcLivePushStats.
PAUSED && mPushStatus != AlivcLivePushStats.
ERROR) {
1659 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1662 mPushStatus = AlivcLivePushStats.
RESUMING;
1663 mNativeAlivcLivePusher.resume(
false);
1664 PusherResumeEvent.Args args =
new PusherResumeEvent.Args();
1665 Map map = getPerformanceMap();
1668 args.isResumeScreen =
false;
1669 args.totalUploadSize = ParameterUtil.getLong(map,
"mTotalSizeOfUploadedPackets");
1670 args.totalTime = ParameterUtil.getLong(map,
"mTotalTimeOfPublishing");
1671 if (PusherPauseEvent.mLastPauseTime == 0) {
1674 args.cost = System.currentTimeMillis() - PusherPauseEvent.mLastPauseTime;
1676 if (mLiveEventReporter != null) {
1677 mLiveEventReporter.sendEvent(PusherResumeEvent.kTopicType, PusherResumeEvent.kTopicValue, PusherResumeEvent.getArgsStr(args));
1681 PusherPauseEvent.mLastPauseTime = 0;
1685 public void pauseScreenCapture() throws IllegalStateException {
1686 AlivcLog.i(TAG,
"[API-Pusher] pauseScreenCapture");
1687 if (mNativeAlivcLivePusher == null) {
1688 AlivcLog.e(TAG,
"Illegal State, you should init first");
1691 if (mPushStatus != AlivcLivePushStats.
PUSHED && mPushStatus != AlivcLivePushStats.
PAUSED
1692 && mPushStatus != AlivcLivePushStats.
PREVIEWED) {
1693 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1696 mPushStatus = AlivcLivePushStats.
PAUSED;
1699 PusherPauseEvent.mLastPauseTime = System.currentTimeMillis();
1701 mNativeAlivcLivePusher.pauseScreenCapture();
1702 PusherPauseEvent.Args args =
new PusherPauseEvent.Args();
1703 Map map = getPerformanceMap();
1705 args.isPauseScreen =
true;
1706 args.totalUploadSize = ParameterUtil.getLong(map,
"mTotalSizeOfUploadedPackets");
1707 args.totalTime = ParameterUtil.getLong(map,
"mTotalTimeOfPublishing");
1708 if (mLiveEventReporter != null) {
1709 mLiveEventReporter.sendEvent(PusherPauseEvent.kTopicType, PusherPauseEvent.kTopicValue, PusherPauseEvent.getArgsStr(args));
1715 public void resumeScreenCapture() throws IllegalStateException {
1716 AlivcLog.i(TAG,
"[API-Pusher] resumeScreenCapture");
1717 if (mNativeAlivcLivePusher == null) {
1718 AlivcLog.e(TAG,
"Illegal State, you should init first");
1721 if (mPushStatus != AlivcLivePushStats.
PAUSED) {
1722 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1726 mNativeAlivcLivePusher.resumeScreenCapture();
1727 PusherResumeEvent.Args args =
new PusherResumeEvent.Args();
1728 Map map = getPerformanceMap();
1731 args.isResumeScreen =
true;
1732 args.totalUploadSize = ParameterUtil.getLong(map,
"mTotalSizeOfUploadedPackets");
1733 args.totalTime = ParameterUtil.getLong(map,
"mTotalTimeOfPublishing");
1734 args.cost = System.currentTimeMillis() - PusherPauseEvent.mLastPauseTime;
1735 if (mLiveEventReporter != null) {
1736 mLiveEventReporter.sendEvent(PusherResumeEvent.kTopicType, PusherResumeEvent.kTopicValue, PusherResumeEvent.getArgsStr(args));
1740 PusherPauseEvent.mLastPauseTime = 0;
1742 if (mNativeAlivcLivePusher.isPushing()) {
1743 mPushStatus = AlivcLivePushStats.
PUSHED;
1745 mPushStatus = AlivcLivePushStats.
PREVIEWED;
1750 public void switchCamera() throws IllegalStateException {
1751 AlivcLog.i(TAG,
"[API-Pusher] switchCamera");
1752 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
1753 AlivcLog.e(TAG,
"Illegal State, you should init first");
1756 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
1757 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1760 mNativeAlivcLivePusher.switchCamera();
1762 if (mAlivcLivePushConfig.
getCameraType() == CAMERA_TYPE_FRONT.getCameraId()) {
1769 PusherSwitchCameraEvent.Args args =
new PusherSwitchCameraEvent.Args();
1770 args.isFrontCamera = mAlivcLivePushConfig.
getCameraType() == CAMERA_TYPE_FRONT.getCameraId();
1771 if (mLiveEventReporter != null) {
1772 mLiveEventReporter.sendEvent(PusherSwitchCameraEvent.kTopicType, PusherSwitchCameraEvent.kTopicValue, PusherSwitchCameraEvent.getArgsStr(args));
1777 public void setAutoFocus(
boolean autoFocus)
throws IllegalStateException {
1778 AlivcLog.i(TAG,
"[API-Pusher] setAutoFocus: " + autoFocus);
1779 if (mNativeAlivcLivePusher == null) {
1780 AlivcLog.e(TAG,
"Illegal State, you should init first");
1783 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
1784 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1787 mNativeAlivcLivePusher.setCameraFocus(autoFocus, 0, 0);
1791 public void focusCameraAtAdjustedPoint(
float x,
float y,
boolean autoFocus)
throws IllegalStateException {
1792 AlivcLog.i(TAG,
"[API-Pusher] focusCameraAtAdjustedPoint: x=" + x +
", y=" + y +
", autoFocus=" + autoFocus);
1793 if (mNativeAlivcLivePusher == null) {
1794 AlivcLog.e(TAG,
"Illegal State, you should init first");
1797 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
1798 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1801 mNativeAlivcLivePusher.setCameraFocus(autoFocus, x, y);
1805 public void setExposure(
int exposure) {
1806 AlivcLog.i(TAG,
"[API-Pusher] setExposure: " + exposure);
1807 if (mNativeAlivcLivePusher == null) {
1808 AlivcLog.e(TAG,
"Illegal State, you should init first");
1811 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
1812 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1815 mNativeAlivcLivePusher.setExposureCompensation(exposure);
1819 public int getCurrentExposure() {
1820 AlivcLog.i(TAG,
"[API-Pusher] getCurrentExposure");
1821 if (mNativeAlivcLivePusher == null) {
1822 AlivcLog.e(TAG,
"Illegal State, you should init first");
1825 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
1826 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1829 return mNativeAlivcLivePusher.getCurrentExposureCompensation();
1833 public int getSupportedMinExposure() {
1834 AlivcLog.i(TAG,
"[API-Pusher] getSupportedMinExposure");
1835 if (mNativeAlivcLivePusher == null) {
1836 AlivcLog.e(TAG,
"Illegal State, you should init first");
1839 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
1840 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1843 return mNativeAlivcLivePusher.getMinExposureCompensation();
1847 public int getSupportedMaxExposure() {
1848 AlivcLog.i(TAG,
"[API-Pusher] getSupportedMaxExposure");
1849 if (mNativeAlivcLivePusher == null) {
1850 AlivcLog.e(TAG,
"Illegal State, you should init first");
1853 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
1854 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1857 return mNativeAlivcLivePusher.getMaxExposureCompensation();
1861 public int setLiveMixTranscodingConfig(AlivcLiveTranscodingConfig config) {
1866 public int muteLocalCamera(
boolean mute) {
1872 public int enableSpeakerphone(
boolean enable) {
1878 public boolean isSpeakerphoneOn() {
1884 public void setZoom(
int zoom)
throws IllegalStateException {
1885 AlivcLog.i(TAG,
"[API-Pusher] setZoom: " + zoom);
1886 if (mNativeAlivcLivePusher == null) {
1887 AlivcLog.e(TAG,
"Illegal State, you should init first");
1890 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
1891 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1894 mNativeAlivcLivePusher.setCameraZoom(zoom);
1898 public int getMaxZoom() throws IllegalStateException {
1899 AlivcLog.i(TAG,
"[API-Pusher] getMaxZoom");
1900 if (mNativeAlivcLivePusher == null) {
1901 AlivcLog.e(TAG,
"Illegal State, you should init first");
1904 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
1905 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1908 return mNativeAlivcLivePusher.getCameraMaxZoom();
1912 public int getCurrentZoom() throws IllegalStateException {
1913 AlivcLog.i(TAG,
"[API-Pusher] getCurrentZoom");
1914 if (mNativeAlivcLivePusher == null) {
1915 AlivcLog.e(TAG,
"Illegal State, you should init first");
1918 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
1919 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1923 return mNativeAlivcLivePusher.getCameraCurrentZoom();
1927 public void setMute(
boolean mute)
throws IllegalStateException {
1928 AlivcLog.i(TAG,
"[API-Pusher] setMute: " + mute);
1929 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
1930 AlivcLog.e(TAG,
"Illegal State, you should init first");
1933 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED && mPushStatus != AlivcLivePushStats.
PAUSED) {
1934 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1937 mNativeAlivcLivePusher.setMute(mute);
1941 if (mLiveEventReporter != null) {
1943 PusherMuteOnEvent.Args args =
new PusherMuteOnEvent.Args();
1944 mLiveEventReporter.sendEvent(PusherMuteOffEvent.kTopicType, PusherMuteOffEvent.kTopicValue, PusherMuteOnEvent.getArgsStr(args));
1946 PusherMuteOffEvent.Args args =
new PusherMuteOffEvent.Args();
1947 mLiveEventReporter.sendEvent(PusherMuteOffEvent.kTopicType, PusherMuteOffEvent.kTopicValue, PusherMuteOffEvent.getArgsStr(args));
1953 public void setFlash(
boolean flash)
throws IllegalStateException {
1954 AlivcLog.i(TAG,
"[API-Pusher] setFlash: " + flash);
1955 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
1956 AlivcLog.e(TAG,
"Illegal State, you should init first");
1959 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
1960 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1963 mNativeAlivcLivePusher.setFlash(flash);
1964 mAlivcLivePushConfig.
setFlash(flash);
1966 PusherSetFlashEvent.Args args =
new PusherSetFlashEvent.Args();
1967 args.isOpen = flash;
1968 if (mLiveEventReporter != null) {
1969 mLiveEventReporter.sendEvent(PusherSetFlashEvent.kTopicType, PusherSetFlashEvent.kTopicValue, PusherSetFlashEvent.getArgsStr(args));
1974 public void setPushMirror(
boolean mirror)
throws IllegalStateException {
1975 AlivcLog.i(TAG,
"[API-Pusher] setPushMirror: " + mirror);
1976 if (mNativeAlivcLivePusher == null) {
1977 AlivcLog.e(TAG,
"Illegal State, you should init first");
1980 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
1981 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1984 mNativeAlivcLivePusher.setPusherMirror(mirror);
1988 public void setPreviewMirror(
boolean mirror)
throws IllegalStateException {
1989 AlivcLog.i(TAG,
"[API-Pusher] setPreviewMirror: " + mirror);
1990 if (mNativeAlivcLivePusher == null) {
1991 AlivcLog.e(TAG,
"Illegal State, you should init first");
1994 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
1995 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
1998 mNativeAlivcLivePusher.setPreviewMirror(mirror);
2002 public void setTargetVideoBitrate(
int targetVideoBitrate)
throws IllegalArgumentException, IllegalStateException {
2003 AlivcLog.i(TAG,
"[API-Pusher] setTargetVideoBitrate: " + targetVideoBitrate);
2004 if (mNativeAlivcLivePusher == null) {
2005 AlivcLog.e(TAG,
"Illegal State, you should init first");
2008 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
2009 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
2012 mNativeAlivcLivePusher.setVideoBitrateRange(0, targetVideoBitrate, targetVideoBitrate);
2016 public void setMinVideoBitrate(
int minVideoBitrate)
throws IllegalArgumentException, IllegalStateException {
2017 AlivcLog.i(TAG,
"[API-Pusher] setMinVideoBitrate: " + minVideoBitrate);
2018 if (mNativeAlivcLivePusher == null) {
2019 AlivcLog.e(TAG,
"Illegal State, you should init first");
2022 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
2023 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
2026 mNativeAlivcLivePusher.setVideoBitrateRange(minVideoBitrate, 0, 0);
2030 public boolean isCameraSupportAutoFocus() {
2031 AlivcLog.i(TAG,
"[API-Pusher] isCameraSupportAutoFocus");
2032 if (mNativeAlivcLivePusher == null) {
2033 AlivcLog.e(TAG,
"Illegal State, you should init first");
2036 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
2037 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
2040 return mNativeAlivcLivePusher.isCameraSupportAutoFocus();
2044 public boolean isCameraSupportFlash() {
2045 AlivcLog.i(TAG,
"[API-Pusher] isCameraSupportFlash");
2047 if (mNativeAlivcLivePusher == null) {
2048 AlivcLog.e(TAG,
"Illegal State, you should init first");
2051 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
2052 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
2055 return mNativeAlivcLivePusher.isCameraSupportFlash();
2059 public boolean isPushing() throws IllegalStateException {
2060 if (mNativeAlivcLivePusher != null) {
2061 return mNativeAlivcLivePusher.isPushing();
2067 public AlivcLivePushStats getCurrentStatus() {
2072 public AlivcLivePushError getLastError() {
2077 public void snapshot(
int count,
int interval, AlivcSnapshotListener listener) {
2078 AlivcLog.i(TAG,
"[API-Pusher] snapshot");
2079 mSnapshotListener = listener;
2080 if (mNativeAlivcLivePusher != null) {
2081 mNativeAlivcLivePusher.snapshot(count, interval, mInnerSnapshotListener);
2086 public boolean isNetworkPushing() throws IllegalStateException {
2087 if (mNativeAlivcLivePusher != null) {
2088 return mNativeAlivcLivePusher.isNetworkPushing();
2094 public void setLivePushErrorListener(AlivcLivePushErrorListener errorListener) {
2095 AlivcLog.i(TAG,
"[API-Pusher] setLivePushErrorListener");
2096 this.mPushErrorListener = errorListener;
2100 public void setLivePushInfoListener(AlivcLivePushInfoListener infoListener) {
2101 AlivcLog.i(TAG,
"[API-Pusher] setLivePushInfoListener");
2102 this.mPushInfoListener = infoListener;
2106 public void setLivePushNetworkListener(AlivcLivePushNetworkListener networkListener) {
2107 AlivcLog.i(TAG,
"[API-Pusher] setLivePushNetworkListener");
2108 this.mPushNetworkListener = networkListener;
2112 public void setLivePushBGMListener(AlivcLivePushBGMListener pushBGMListener) {
2113 AlivcLog.i(TAG,
"[API-Pusher] setLivePushBGMListener");
2114 this.mPushBGMListener = pushBGMListener;
2118 public void setLivePushRenderContextListener(AlivcLivePusherRenderContextListener renderCtxListener) {
2119 AlivcLog.i(TAG,
"[API-Pusher] setLivePushRenderContextListener");
2120 this.mRenderContextListener = renderCtxListener;
2124 public AlivcLivePushStatsInfo getLivePushStatsInfo() throws IllegalStateException {
2125 if (mNativeAlivcLivePusher == null) {
2128 AlivcLivePushStatsInfo info =
new AlivcLivePushStatsInfo();
2129 String mapStr = mNativeAlivcLivePusher.getPerformanceInfo();
2130 if (mapStr == null ||
"".equals(mapStr)) {
2133 Map map =
new HashMap<String, String>();
2134 StringTokenizer items;
2135 for (StringTokenizer entries =
new StringTokenizer(mapStr,
"|"); entries.hasMoreTokens();
2136 map.put(items.nextToken(), items.hasMoreTokens() ? ((String) (items.nextToken())) : null)) {
2137 items =
new StringTokenizer(entries.nextToken(),
":");
2140 info.setVideoCaptureFps(getInteger(map,
"mVideoCaptureFps"));
2141 info.setAudioEncodeBitrate(getInteger(map,
"mAudioEncodeBitrate"));
2142 info.setVideoRenderFps(getInteger(map,
"mVideoRenderingFPS"));
2143 info.setAudioEncodeFps(getInteger(map,
"mAudioEncodeFps"));
2144 info.setVideoEncodeMode(AlivcEncodeModeEnum.values()[getInteger(map,
"mPresetVideoEncoderMode")]);
2145 info.setVideoEncodeBitrate(getInteger(map,
"mVideoEncodeBitrate"));
2146 info.setVideoEncodeFps(getInteger(map,
"mVideoEncodedFps"));
2147 info.setTotalFramesOfEncodedVideo(getLong(map,
"mTotalFramesOfEncodedVideo"));
2148 info.setTotalTimeOfEncodedVideo(getLong(map,
"mTotalTimeOfEncodedVideo"));
2149 info.setVideoEncodeParam(getInteger(map,
"mPresetVideoEncoderBitrate"));
2150 info.setAudioUploadBitrate(getInteger(map,
"mAudioUploadBitrate"));
2151 info.setVideoUploadBitrate(getInteger(map,
"mVideoUploadBitrate"));
2152 info.setAudioPacketsInUploadBuffer(getInteger(map,
"mAudioPacketsInBuffer"));
2153 info.setVideoPacketsInUploadBuffer(getInteger(map,
"mVideoPacketsInBuffer"));
2154 info.setVideoUploadeFps(getInteger(map,
"mVideoUploadedFps"));
2155 info.setAudioUploadFps(getInteger(map,
"mAudioUploadingPacketsPerSecond"));
2156 info.setCurrentlyUploadedVideoFramePts(getLong(map,
"mCurrentlyUploadedVideoFramePts"));
2157 info.setCurrentlyUploadedAudioFramePts(getLong(map,
"mCurrentlyUploadedAudioFramePts"));
2158 info.setPreviousVideoKeyFramePts(getLong(map,
"mPreviousKeyFramePts"));
2159 info.setLastVideoPtsInBuffer(getLong(map,
"mLastVideoFramePTSInQueue"));
2160 info.setLastAudioPtsInBuffer(getLong(map,
"mLastAudioFramePTSInQueue"));
2161 info.setTotalSizeOfUploadedPackets(getLong(map,
"mTotalSizeOfUploadedPackets"));
2162 info.setTotalTimeOfUploading(getLong(map,
"mTotalTimeOfPublishing"));
2163 info.setTotalFramesOfUploadedVideo(getLong(map,
"mTotalFramesOfVideoUploaded"));
2164 info.setTotalDurationOfDropingVideoFrames(getLong(map,
"mDropDurationOfVideoFrames"));
2165 info.setTotalTimesOfDropingVideoFrames(getLong(map,
"mTotalDroppedTimes"));
2166 info.setTotalTimesOfDisconnect(getInteger(map,
"mTotalNetworkDisconnectedTimes"));
2167 info.setTotalTimesOfReconnect(getInteger(map,
"mTotalNetworkReconnectedTimes"));
2168 info.setVideoDurationFromeCaptureToUpload(getInteger(map,
"mVideoDurationFromeCaptureToUpload"));
2169 info.setAudioDurationFromeCaptureToUpload(getInteger(map,
"mAudioDurationFromeCaptureToUpload"));
2170 info.setCurrentUploadPacketSize(getInteger(map,
"mCurrentUploadingPacketSize"));
2171 info.setMaxSizeOfVideoPacketsInBuffer(getInteger(map,
"mMaxVideoPacketSize"));
2172 info.setMaxSizeOfAudioPacketsInBuffer(getInteger(map,
"mMaxAudioPacketSize"));
2173 info.setLastVideoFramePTSInQueue(getLong(map,
"mLastVideoFramePTSInQueue"));
2174 info.setLastAudioFramePTSInQueue(getLong(map,
"mLastAudioFramePTSInQueue"));
2175 info.setAvPTSInterval(getLong(map,
"mAvPTSInterval"));
2176 info.setAudioFrameInEncodeBuffer(getInteger(map,
"mAudioFramesInEncoderQueue"));
2177 info.setVideoFramesInEncodeBuffer(getInteger(map,
"mVideoFramesInEncoderQueue"));
2178 info.setVideoFramesInRenderBuffer(getInteger(map,
"mVideoFramesInRenderQueue"));
2179 info.setVideoRenderConsumingTimePerFrame(getInteger(map,
"mVideoRenderConsumingTimePerFrame"));
2180 info.setTotalDroppedAudioFrames(getInteger(map,
"mTotalDroppedAudioFrames"));
2181 info.setRtt(getInteger(map,
"mRtt"));
2182 info.setVideoLostRate(getInteger(map,
"mVideoLostRate"));
2183 info.setAudioLostRate(getInteger(map,
"mAudioLostRate"));
2184 info.setVideoReSendBitRate(getInteger(map,
"mVideoReSendBitRate"));
2185 info.setAudioReSendBitRate(getInteger(map,
"mAudioReSendBitRate"));
2186 info.setVideoEncodingWidth(getInteger(map,
"mVideoEncodingWidth"));
2187 info.setVideoEncodingHeight(getInteger(map,
"mVideoEncodingHeight"));
2188 info.setVideoEncodingGopSize(getInteger(map,
"mVideoEncodingGopSize"));
2189 info.setAudioCapturingSampleRate(getInteger(map,
"mAudioCapturingSampleRate"));
2190 info.setAudioCaptureVolume(getInteger(map,
"mAudioCaptureVolume"));
2192 info.setCpu((
float)AliLiveInfoUtils.getCPUUsageRatio());
2193 info.setMemory(ParameterUtil.getRunningAppProcessInfo(mContext));
2194 if (!TextUtils.isEmpty(mPushUrl)) {
2195 if (mPushUrl.startsWith(AlivcLiveStreamType.EnumType.AlivcLiveStreamRtmp.getPrefix())) {
2196 info.setAlivcLivePushPublishType(AlivcLiveStreamType.EnumType.AlivcLiveStreamRtmp.getValue());
2197 }
else if (mPushUrl.startsWith(AlivcLiveStreamType.EnumType.AlivcLiveStreamRts.getPrefix())) {
2198 info.setAlivcLivePushPublishType(AlivcLiveStreamType.EnumType.AlivcLiveStreamRts.getValue());
2201 }
catch (IllegalStateException e) {
2202 e.printStackTrace();
2203 }
catch (Exception e) {
2204 e.printStackTrace();
2210 public String getPushUrl() {
2211 return AlivcLiveURLTools.getUrlWithoutParameters(mPushUrl);
2214 private void checkConfig(AlivcLivePushConfig livePushConfig)
throws IllegalStateException {
2215 if (livePushConfig == null) {
2216 throw new IllegalArgumentException(
"Invalid parameter, config is null.");
2219 if (livePushConfig.isVideoOnly() && livePushConfig.isAudioOnly()) {
2220 throw new IllegalStateException(
"cannot set video only and audio only simultaneously");
2223 if (livePushConfig.getTargetVideoBitrate() < 100 || livePushConfig.getTargetVideoBitrate() > 5000) {
2224 throw new IllegalStateException(
"video target bitrate error, Range:[100 5000]");
2226 if (livePushConfig.getMinVideoBitrate() < 100 || livePushConfig.getMinVideoBitrate() > 5000) {
2227 throw new IllegalStateException(
"video min bitrate error, Range:[100 5000]");
2229 if (livePushConfig.getInitialVideoBitrate() < livePushConfig.getMinVideoBitrate() || livePushConfig.getInitialVideoBitrate() < 100
2230 || livePushConfig.getInitialVideoBitrate() > 5000) {
2231 throw new IllegalStateException(
"init bitrate error");
2233 if (livePushConfig.getConnectRetryCount() <= 0 || livePushConfig.getConnectRetryCount() > 100) {
2234 throw new IllegalStateException(
"connect retry count error, Range:[0 100]");
2236 if (livePushConfig.getConnectRetryInterval() <= 0 || livePushConfig.getConnectRetryInterval() > 10000) {
2237 throw new IllegalStateException(
"connect retry interval error, Range:[0 10000]");
2240 if (livePushConfig.getMinFps() <= 0 || livePushConfig.getMinFps() > livePushConfig.getFps()) {
2241 throw new IllegalStateException(
"fps error");
2244 for (
int i = 0; i < livePushConfig.getWaterMarkInfos().size(); i++) {
2246 if (livePushConfig.getWaterMarkInfos().get(i).mWaterMarkCoordX > 1 || livePushConfig.getWaterMarkInfos().get(i).mWaterMarkWidth > 1
2247 || livePushConfig.getWaterMarkInfos().get(i).mWaterMarkCoordY > 1 || livePushConfig.getWaterMarkInfos().get(i).mWaterMarkHeight > 1) {
2248 throw new IllegalStateException(
"watermark param error");
2251 if (livePushConfig.getWaterMarkInfos().get(i).mWaterMarkCoordX < 0 || livePushConfig.getWaterMarkInfos().get(i).mWaterMarkWidth <= 0
2252 || livePushConfig.getWaterMarkInfos().get(i).mWaterMarkCoordY < 0 || livePushConfig.getWaterMarkInfos().get(i).mWaterMarkHeight <= 0) {
2253 throw new IllegalStateException(
"watermark param error");
2259 public void setPreviewOrientation(AlivcPreviewOrientationEnum orientation) {
2260 AlivcLog.i(TAG,
"[API-Pusher] setPreviewOrientation: " + orientation);
2261 if (mNativeAlivcLivePusher == null) {
2262 AlivcLog.e(TAG,
"Illegal State, you should init first");
2265 if (mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
PUSHED) {
2266 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
2270 mNativeAlivcLivePusher.setOrientaion(orientation.getOrientation());
2274 public int setAudioEffectVoiceChangeMode(AlivcLivePushAudioEffectVoiceChangeMode mode) {
2275 AlivcLog.i(TAG,
"[API-Pusher] setAudioEffectVoiceChangeMode: " + mode);
2277 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
2278 AlivcLog.e(TAG,
"Illegal State, you should init first");
2283 AlivcLog.e(TAG,
"Sound effect can not be used on the video only mode!");
2287 return mNativeAlivcLivePusher.setNativeAudioEffectVoiceMode(mode.getValue());
2291 public int setAudioEffectReverbMode(AlivcLivePushAudioEffectReverbMode mode) {
2292 AlivcLog.i(TAG,
"[API-Pusher] setAudioEffectReverbMode: " + mode);
2294 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
2295 AlivcLog.e(TAG,
"Illegal State, you should init first");
2300 AlivcLog.e(TAG,
"Sound effect can not be used on the video only mode!");
2304 return mNativeAlivcLivePusher.setNativeAudioEffectReverbMode(mode.getValue());
2307 private Map<String, String> getPerformanceMap() {
2308 if (mNativeAlivcLivePusher == null) {
2311 String mapStr = mNativeAlivcLivePusher.getPerformanceInfo();
2312 if (mapStr == null ||
"".equals(mapStr)) {
2315 Map map =
new HashMap<String, String>();
2316 StringTokenizer items;
2317 for (StringTokenizer entries =
new StringTokenizer(mapStr,
"|"); entries.hasMoreTokens(); map
2318 .put(items.nextToken(), items.hasMoreTokens() ? ((String) (items.nextToken())) : null)) {
2319 items =
new StringTokenizer(entries.nextToken(),
":");
2324 private String getHeartBeatInfo() {
2325 if (mNativeAlivcLivePusher == null) {
2329 String heartBeatInfo = mNativeAlivcLivePusher.getPusherInfo();
2330 heartBeatInfo +=
",cpu:" + AliLiveInfoUtils.getCPUUsageRatio();
2331 heartBeatInfo +=
",mem:" + AliLiveInfoUtils.getMemoryUsageRatio();
2333 return heartBeatInfo;
2337 public String getLiveTraceId() {
2338 if (mNativeAlivcLivePusher == null) {
2341 return mNativeAlivcLivePusher.getPusherTraceId();
2345 public void sendMessage(String info,
int repeat,
int delay,
boolean isKeyFrame) {
2346 AlivcLog.i(TAG,
"[API-Pusher] sendMessage: " + info +
", repeat=" + repeat +
", delay=" + delay +
", isKeyFrame=" + isKeyFrame);
2348 sendMessageInternal(info, repeat, delay, isKeyFrame,
false);
2349 }
catch (Exception e) {
2350 e.printStackTrace();
2354 private void sendMessageInternal(String info,
int repeat,
int delay,
boolean isKeyFrame,
boolean isGDelayInfo)
throws IllegalStateException, IllegalArgumentException {
2355 if (mNativeAlivcLivePusher == null) {
2356 AlivcLog.e(TAG,
"Illegal State, you should init first");
2359 if (!mNativeAlivcLivePusher.isPushing()) {
2360 AlivcLog.e(TAG,
"Status error, status should be PUSHED");
2363 if (TextUtils.isEmpty(info) || info.length() > MAX_CHATS) {
2364 AlivcLog.e(TAG,
"The maximum length is 4000");
2367 mNativeAlivcLivePusher.addSeiInfo(info, repeat, delay, isKeyFrame, isGDelayInfo);
2370 private int getBGMVolume() {
2377 private int getCaptureVolume() {
2381 return mCaptureVolume;
2384 private boolean getHeadSetPlugOn() {
2385 return LivePusherJNI.headSetOn;
2388 private boolean getBlueToothHeadSetOn() {
2389 if (mBluetoothHelper != null) {
2390 return mBluetoothHelper.isOnHeadsetSco();
2396 public void startBGMAsync(String path)
throws IllegalStateException {
2397 AlivcLog.i(TAG,
"[API-Pusher] startBGMAsync");
2398 if (mNativeAlivcLivePusher == null) {
2399 AlivcLog.e(TAG,
"Illegal State, you should init first");
2402 if (mPushStatus == AlivcLivePushStats.
IDLE || mPushStatus == AlivcLivePushStats.
ERROR) {
2403 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
2407 if (mPlayStats == AlivcLivePlayStats.IDLE || mPlayStats == AlivcLivePlayStats.STOPPED) {
2408 PusherSetBGMEvent.Args args =
new PusherSetBGMEvent.Args();
2410 args.music = getBGMVolume();
2411 args.voice = getCaptureVolume();
2412 if (mLiveEventReporter != null) {
2413 mLiveEventReporter.sendEvent(PusherSetBGMEvent.kTopicType, PusherSetBGMEvent.kTopicValue, PusherSetBGMEvent.getArgsStr(args));
2418 mNativeAlivcLivePusher.stopBGM();
2419 mNativeAlivcLivePusher.startBGMAsync(path);
2423 public void stopBGMAsync() throws IllegalStateException {
2424 AlivcLog.i(TAG,
"[API-Pusher] stopBGMAsync");
2425 if (mNativeAlivcLivePusher == null) {
2426 AlivcLog.e(TAG,
"Illegal State, you should init first");
2429 if (mPlayStats == AlivcLivePlayStats.IDLE) {
2430 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePlayStats.values()[mPlayStats.ordinal()]);
2434 mNativeAlivcLivePusher.stopBGM();
2435 PusherSetBGMEvent.Args args =
new PusherSetBGMEvent.Args();
2436 args.isOpen =
false;
2437 args.music = getBGMVolume();
2438 args.voice = getCaptureVolume();
2439 if (mLiveEventReporter != null) {
2440 mLiveEventReporter.sendEvent(PusherSetBGMEvent.kTopicType, PusherSetBGMEvent.kTopicValue, PusherSetBGMEvent.getArgsStr(args));
2445 public void pauseBGM() throws IllegalStateException {
2446 AlivcLog.i(TAG,
"[API-Pusher] pauseBGM");
2447 if (mNativeAlivcLivePusher == null) {
2448 AlivcLog.e(TAG,
"Illegal State, you should init first");
2451 if (mPlayStats != AlivcLivePlayStats.STARTED) {
2452 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePlayStats.values()[mPlayStats.ordinal()]);
2456 mNativeAlivcLivePusher.pauseBGM();
2460 public void resumeBGM() throws IllegalStateException {
2461 AlivcLog.i(TAG,
"[API-Pusher] resumeBGM");
2462 if (mNativeAlivcLivePusher == null) {
2463 AlivcLog.e(TAG,
"Illegal State, you should init first");
2466 if (mPlayStats != AlivcLivePlayStats.PAUSED) {
2467 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePlayStats.values()[mPlayStats.ordinal()]);
2471 mNativeAlivcLivePusher.resumeBGM();
2475 public void setBGMLoop(
boolean isLoop)
throws IllegalStateException {
2476 AlivcLog.i(TAG,
"[API-Pusher] setBGMLoop: " + isLoop);
2477 if (mNativeAlivcLivePusher != null) {
2478 mNativeAlivcLivePusher.setBGMLoop(isLoop);
2480 PusherSetBGMLoopEvent.Args args =
new PusherSetBGMLoopEvent.Args();
2481 args.value = isLoop;
2482 if (mLiveEventReporter != null) {
2483 mLiveEventReporter.sendEvent(PusherSetBGMLoopEvent.kTopicType, PusherSetBGMLoopEvent.kTopicValue, PusherSetBGMLoopEvent.getArgsStr(args));
2488 public void setBGMEarsBack(
boolean isOpen)
throws IllegalStateException {
2489 AlivcLog.i(TAG,
"[API-Pusher] setBGMEarsBack: " + isOpen);
2490 if (mNativeAlivcLivePusher != null) {
2491 mNativeAlivcLivePusher.setEarsBack(isOpen);
2493 PusherSetBGMEarsBackEvent.Args args =
new PusherSetBGMEarsBackEvent.Args();
2494 args.value = isOpen;
2495 args.bh = getBlueToothHeadSetOn() ? 1 : 0;
2496 args.eh = getHeadSetPlugOn() ? 1 : 0;
2497 if (mLiveEventReporter != null) {
2498 mLiveEventReporter.sendEvent(PusherSetBGMEarsBackEvent.kTopicType, PusherSetBGMEarsBackEvent.kTopicValue, PusherSetBGMEarsBackEvent.getArgsStr(args));
2503 public void setBGMVolume(
int volume)
throws IllegalStateException, IllegalArgumentException {
2504 AlivcLog.i(TAG,
"[API-Pusher] setBGMVolume: " + volume);
2505 if (mNativeAlivcLivePusher == null) {
2506 AlivcLog.e(TAG,
"Illegal State, you should init first");
2509 mBGMVolume = (volume > 0 && volume < 10) ? 10 : volume;
2510 mNativeAlivcLivePusher.setBackgroundMusicVolume(mBGMVolume / 10);
2514 public void setCaptureVolume(
int volume)
throws IllegalStateException, IllegalArgumentException {
2515 AlivcLog.i(TAG,
"[API-Pusher] setCaptureVolume: " + volume);
2516 if (mNativeAlivcLivePusher == null) {
2517 AlivcLog.e(TAG,
"Illegal State, you should init first");
2520 mCaptureVolume = (volume > 0 && volume < 10) ? 10 : volume;
2521 mNativeAlivcLivePusher.setAudioVolume(mCaptureVolume / 10);
2525 public void setAudioDenoise(
boolean on) {
2526 AlivcLog.i(TAG,
"[API-Pusher] setAudioDenoise: " + on);
2528 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
2529 AlivcLog.e(TAG,
"Illegal State, you should init first");
2534 AlivcLog.e(TAG,
"Audio denoise can not be used on the video only mode!");
2538 mNativeAlivcLivePusher.setAudioDenoise(on);
2542 public int startIntelligentDenoise() {
2543 AlivcLog.i(TAG,
"[API-Pusher] startIntelligentDenoise");
2544 return setIntelligentDenoiseInternal(
true);
2548 public int stopIntelligentDenoise() {
2549 AlivcLog.i(TAG,
"[API-Pusher] stopIntelligentDenoise");
2550 return setIntelligentDenoiseInternal(
false);
2553 private int setIntelligentDenoiseInternal(
boolean flag) {
2554 if (!AlivcLivePushIntelligentDenoiseManager.isFeatureWorked(mContext)) {
2555 AlivcLog.e(TAG,
"Intelligent denoise feature not worked due to the lack of native library file! " +
2556 "You can try to read the API doc to find the solution!");
2560 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
2561 AlivcLog.e(TAG,
"Illegal State, you should init first");
2566 AlivcLog.e(TAG,
"Audio denoise can not be used on the video only mode!");
2572 result = mNativeAlivcLivePusher.startNativeIntelligentDenoise();
2574 result = mNativeAlivcLivePusher.stopNativeIntelligentDenoise();
2577 AlivcLog.i(TAG,
"setIntelligentDenoiseInternal " + flag +
", return " + result);
2582 public void setQualityMode(AlivcQualityModeEnum mode)
throws IllegalStateException {
2583 AlivcLog.i(TAG,
"[API-Pusher] setQualityMode: " + mode);
2584 if (mNativeAlivcLivePusher == null) {
2585 AlivcLog.e(TAG,
"Illegal State, you should init first");
2588 if (AlivcQualityModeEnum.QM_CUSTOM.equals(mode)) {
2589 AlivcLog.e(TAG,
"Cannot set QM_CUSTOM dynamically");
2592 mNativeAlivcLivePusher.setQualityMode(mode.getQualityMode());
2596 public void setPreviewMode(AlivcPreviewDisplayMode mode)
throws IllegalStateException {
2597 AlivcLog.i(TAG,
"[API-Pusher] setPreviewMode: " + mode);
2598 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
2599 AlivcLog.e(TAG,
"Illegal State, you should init first");
2603 mNativeAlivcLivePusher.setDisplayMode(mode.getPreviewDisplayMode());
2607 private void startScheduleExecutor() {
2608 if (mScheduledExecutorService != null) {
2611 mScheduledExecutorService = Executors.newScheduledThreadPool(2);
2612 mScheduledExecutorService.scheduleAtFixedRate(
new Runnable() {
2615 mTimeCount = mTimeCount + 1;
2616 if(mTimeCount == 5) {
2617 if (mTimeStamp != -1) {
2618 if (mExpiryTime < 60) {
2619 AlivcLog.w(TAG,
"[Callback-PushNetwork] onPushURLAuthenticationOverdue");
2620 if (mPushNetworkListener != null) {
2622 if (!TextUtils.isEmpty(url) && !url.equals(mPushUrl)) {
2623 reconnectPushAsync(url);
2627 mExpiryTime = mExpiryTime - 5;
2631 PusherHeartBeatEvent.Args args =
new PusherHeartBeatEvent.Args();
2632 args.mediaInfo = getHeartBeatInfo();
2633 mLiveEventReporter.sendEvent(PusherHeartBeatEvent.kTopicType, PusherHeartBeatEvent.kTopicValue, PusherHeartBeatEvent.getArgsStr(args));
2637 if (mPushInfoListener != null) {
2638 AlivcLivePushStatsInfo statsInfo = getLivePushStatsInfo();
2643 }, 0, SCHEDULED_EXECUTOR_SERVICE_PERIOD, TimeUnit.MILLISECONDS);
2646 private void stopScheduleExecutor() {
2648 if (mScheduledExecutorService != null) {
2649 mScheduledExecutorService.shutdown();
2650 if (!mScheduledExecutorService.awaitTermination(1000, TimeUnit.MICROSECONDS)) {
2651 mScheduledExecutorService.shutdownNow();
2653 mScheduledExecutorService = null;
2655 }
catch (InterruptedException e) {
2656 if (mScheduledExecutorService != null) {
2657 mScheduledExecutorService.shutdownNow();
2659 mScheduledExecutorService = null;
2660 e.printStackTrace();
2664 private int[] getImageWidthHeight(String path) {
2665 BitmapFactory.Options options =
new BitmapFactory.Options();
2667 options.inJustDecodeBounds =
true;
2669 Bitmap bitmap = BitmapFactory.decodeFile(path, options);
2670 }
catch (Exception e) {
2671 return new int[]{0, 0};
2674 return new int[]{options.outWidth, options.outHeight};
2677 private void addWaterMark() {
2678 if (mAlivcLivePushConfig == null) {
2679 AlivcLog.e(TAG,
"Illegal State, you should init first");
2682 ArrayList<WaterMarkInfo> waterMarkInfos = mAlivcLivePushConfig.getWaterMarkInfos();
2683 int size = waterMarkInfos.size();
2684 for (
int i = 0; i < size; i++) {
2685 addWaterMark(waterMarkInfos.get(i).mWaterMarkPath, waterMarkInfos.get(i).mWaterMarkCoordX, waterMarkInfos.get(i).mWaterMarkCoordY,
2686 waterMarkInfos.get(i).mWaterMarkWidth);
2691 private void rtsDownToRtmp() {
2692 AlivcLog.w(TAG,
"rts downgrade to rtmp");
2693 if (TextUtils.isEmpty(mPushUrl) || !mPushUrl.startsWith(AlivcLiveStreamType.EnumType.AlivcLiveStreamRts.getPrefix())) {
2697 AlivcLog.w(TAG,
"pre url: " + mPushUrl);
2698 mPushUrl = mPushUrl.replaceFirst(AlivcLiveStreamType.EnumType.AlivcLiveStreamRts.getPrefix(), AlivcLiveStreamType.EnumType.AlivcLiveStreamRtmp.getPrefix());
2699 AlivcLog.w(TAG,
"after url: " + mPushUrl);
2700 mPushStatus = AlivcLivePushStats.
ERROR;
2703 if (mNativeAlivcLivePusher != null) {
2704 mNativeAlivcLivePusher.release();
2705 mNativeAlivcLivePusher.init();
2708 startPushAsync(mPushUrl);
2711 private void reportStartPushEvent(
boolean isRestart,
boolean isSync) {
2712 PusherStartPushEvent.Args args =
new PusherStartPushEvent.Args();
2713 Map map = getPerformanceMap();
2716 args.vutMs = getInteger(map,
"mVideoDurationFromeCaptureToUpload");
2717 args.autMs = getInteger(map,
"mAudioDurationFromeCaptureToUpload");
2718 args.resolution = mAlivcLivePushConfig.
getResolution().toString().substring(11);
2719 args.st = mAlivcLivePushConfig.
getAudioChannels() == 1 ?
"single" :
"dual";
2723 args.wc = mAlivcLivePushConfig.getWaterMarkInfos().size();
2725 args.fps = mAlivcLivePushConfig.
getFps();
2732 args.flash = mAlivcLivePushConfig.
isFlash();
2740 mLiveEventReporter.sendEvent(PusherRestartPushEvent.kTopicType, PusherRestartPushEvent.kTopicValue, PusherRestartPushEvent.getArgsStr(args));
2742 mLiveEventReporter.sendEvent(PusherStartPushEvent.kTopicType, PusherStartPushEvent.kTopicValue, PusherStartPushEvent.getArgsStr(args));
2747 private BroadcastReceiver mHeadsetPlugReceiver =
new BroadcastReceiver() {
2750 public void onReceive(Context context, Intent intent) {
2752 String action = intent.getAction();
2753 if (AudioManager.ACTION_AUDIO_BECOMING_NOISY.equals(action)) {
2754 AlivcLog.d(
"BluetoothHeadsetUtils",
"ACTION_AUDIO_BECOMING_NOISY headset out");
2756 mAudioManager.setMode(AudioManager.STREAM_VOICE_CALL);
2757 mAudioManager.setSpeakerphoneOn(
true);
2759 LivePusherJNI.headSetOn =
false;
2760 if (mNativeAlivcLivePusher != null) {
2761 mNativeAlivcLivePusher.setHeadSet(
false);
2763 }
else if (
"android.intent.action.HEADSET_PLUG".equals(action)) {
2764 if (intent.hasExtra(
"state")) {
2765 if (intent.getIntExtra(
"state", 0) == 0) {
2766 AlivcLog.d(
"BluetoothHeadsetUtils",
"headset out");
2768 mAudioManager.setMode(AudioManager.STREAM_VOICE_CALL);
2769 mAudioManager.setSpeakerphoneOn(
true);
2771 if (LivePusherJNI.headSetOn) {
2772 LivePusherJNI.headSetOn =
false;
2773 if (mNativeAlivcLivePusher != null) {
2774 mNativeAlivcLivePusher.setHeadSet(
false);
2777 }
else if (intent.getIntExtra(
"state", 0) == 1) {
2779 AlivcLog.d(
"BluetoothHeadsetUtils",
"headset in");
2780 mAudioManager.setSpeakerphoneOn(
false);
2781 LivePusherJNI.headSetOn =
true;
2782 if (mNativeAlivcLivePusher != null) {
2783 mNativeAlivcLivePusher.setHeadSet(
true);
2792 private void registerHeadsetPlugReceiver() {
2794 IntentFilter intentFilter =
new IntentFilter();
2795 intentFilter.addAction(
"android.intent.action.HEADSET_PLUG");
2796 mContext.registerReceiver(mHeadsetPlugReceiver, intentFilter);
2798 IntentFilter intentFilter1 =
new IntentFilter(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
2799 mContext.registerReceiver(mHeadsetPlugReceiver, intentFilter1);
2801 registeredCallback =
true;
2804 private void registerTelephony() {
2805 mTelephonyUtil =
new TelephonyUtil();
2806 mTelephonyUtil.register(mContext,
new TelephonyListener() {
2808 public void onCallStateIdle() {
2809 AlivcLog.i(TAG,
"onCallStateIdle");
2810 if (mNativeAlivcLivePusher != null) {
2811 mNativeAlivcLivePusher.setMute(
false);
2816 public void onCallStateRinging() {
2817 AlivcLog.i(TAG,
"onCallStateRinging");
2818 if (mNativeAlivcLivePusher != null) {
2819 mNativeAlivcLivePusher.setMute(
true);
2824 public void onCallStateOffHook() {
2825 AlivcLog.i(TAG,
"onCallStateOffHook");
2826 if (mNativeAlivcLivePusher != null) {
2827 mNativeAlivcLivePusher.setMute(
true);
2833 private void unregisterTelephony() {
2834 if (mTelephonyUtil != null) {
2835 mTelephonyUtil.unregister();
2837 mTelephonyUtil = null;
2840 private void LogWhenGoBackOrFront(Application app,
boolean bind) {
2842 mAppFrontBackHelper =
new AppFrontBackHelper();
2843 mAppFrontBackHelper.bindApplication(app,
new AppFrontBackHelper.OnAppStatusListener() {
2845 public void onFront() {
2846 if (mNativeAlivcLivePusher != null) {
2847 AlivcLog.i(TAG,
"applicationWillBecomeActive");
2848 mNativeAlivcLivePusher.setAppBackgroundState(
false);
2853 public void onBack() {
2854 if (mNativeAlivcLivePusher != null) {
2855 AlivcLog.i(TAG,
"applicationWillResignActive");
2856 mNativeAlivcLivePusher.setAppBackgroundState(
true);
2861 if(mAppFrontBackHelper != null){
2862 mAppFrontBackHelper.unBindApplication(app);
2863 mAppFrontBackHelper = null;
2868 private void getNetworkTime() {
2869 new ScheduledThreadPoolExecutor(1,
new ThreadFactory() {
2870 private AtomicInteger atoInteger =
new AtomicInteger(0);
2873 public Thread newThread(Runnable r) {
2874 Thread t =
new Thread(r);
2875 t.setName(
"LivePusher-NTP-Time-Thread " + atoInteger.getAndIncrement());
2878 }).execute(
new Runnable() {
2881 for (
int i = 0; i < 3; i++) {
2882 mTimeStamp = getTimeFromNtpServer(
"time.pool.aliyun.com");
2883 if (mTimeStamp > 0) {
2884 mTimeStamp = mTimeStamp / 1000;
2888 if (mTimeStamp < 0) {
2889 mTimeStamp = System.currentTimeMillis() / 1000;
2891 if (getTimestamp(mPushUrl) != -1) {
2892 mExpiryTime = (int) ((getTimestamp(mPushUrl) - mTimeStamp));
2898 private long getTimeFromNtpServer(String ntpHost) {
2899 AlivcLog.d(
"",
"get time from " + ntpHost);
2900 SntpClient client =
new SntpClient();
2901 boolean isSuccessful = client.requestTime(ntpHost, NTP_TIME_OUT_MILLISECOND);
2903 return client.getNtpTime();
2909 public void addWaterMark(String path,
float x,
float y,
float width) {
2910 AlivcLog.i(TAG,
"[API-Pusher] addWaterMark: " + path +
", " + x +
", " + y +
", " + width);
2911 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
2912 AlivcLog.e(TAG,
"Illegal State, you should init first");
2915 int[] widthHeight = getImageWidthHeight(path);
2916 if (mWatermarkCount >= AlivcLiveMaxWatermarkCount || widthHeight == null || widthHeight[0] == 0 || widthHeight[1] == 0) {
2921 float h = width * widthHeight[1] / widthHeight[0];
2922 if (mAlivcLivePushConfig.
getPreviewOrientation() == AlivcPreviewOrientationEnum.ORIENTATION_LANDSCAPE_HOME_LEFT.getOrientation() ||
2923 mAlivcLivePushConfig.
getPreviewOrientation() == AlivcPreviewOrientationEnum.ORIENTATION_LANDSCAPE_HOME_RIGHT.getOrientation()) {
2929 mNativeAlivcLivePusher.addWaterMark(path, w, h, x + w / 2, y + h / 2);
2934 public void setWatermarkVisible(
boolean visible) {
2935 AlivcLog.i(TAG,
"[API-Pusher] setWatermarkVisible: " + visible);
2936 if (mNativeAlivcLivePusher == null) {
2937 AlivcLog.e(TAG,
"Illegal State, you should init first");
2940 if (mPushStatus != AlivcLivePushStats.
PREVIEWED) {
2941 AlivcLog.e(TAG,
"status error current state is " + AlivcLivePushStats.values()[mPushStatus.ordinal()]);
2944 if (mWatermarkCount <= 0) {
2947 mNativeAlivcLivePusher.setWaterMarkVisible(visible);
2951 public int startCamera(SurfaceView surfaceView)
throws IllegalStateException {
2952 AlivcLog.i(TAG,
"[API-Pusher] startCamera");
2953 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
2954 AlivcLog.e(TAG,
"Please execute init first ");
2958 AlivcLog.e(TAG,
"Not in ScreenCapture Mode");
2961 if (!ScreenRecordStatus.SCREEN_RECORD_NORMAL.equals(mScreenStatus)) {
2962 AlivcLog.e(TAG,
"you should start push screen first");
2965 Surface surface = null;
2966 if (surfaceView != null) {
2967 surface = surfaceView.getHolder().getSurface();
2969 int ret = mNativeAlivcLivePusher.startCamera(surface);
2970 mScreenStatus = ScreenRecordStatus.SCREEN_RECORD_CAMERA_START;
2975 public void setScreenOrientation(
int orientation) {
2976 AlivcLog.i(TAG,
"[API-Pusher] setScreenOrientation: " + orientation);
2977 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
2978 AlivcLog.e(TAG,
"Please execute init first ");
2982 AlivcLog.e(TAG,
"Not in ScreenCapture Mode");
2985 mNativeAlivcLivePusher.setScreenOrientation(orientation);
2989 public void stopCamera() {
2990 AlivcLog.i(TAG,
"[API-Pusher] stopCamera");
2991 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
2992 AlivcLog.e(TAG,
"Please execute init first ");
2996 AlivcLog.e(TAG,
"Not in ScreenCapture Mode");
2999 mNativeAlivcLivePusher.stopCamera();
3000 mScreenStatus = ScreenRecordStatus.SCREEN_RECORD_NORMAL;
3004 public int startCameraMix(
float x,
float y,
float w,
float h) {
3005 AlivcLog.i(TAG,
"[API-Pusher] startCameraMix: " + x +
", " + y +
", " + w +
", " + h);
3006 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
3007 AlivcLog.e(TAG,
"Please execute init first ");
3011 AlivcLog.e(TAG,
"Not in ScreenCapture Mode");
3014 if (!mScreenStatus.equals(ScreenRecordStatus.SCREEN_RECORD_CAMERA_START)) {
3015 AlivcLog.e(TAG,
"You should start camera first");
3018 int ret = mNativeAlivcLivePusher.startCameraMix(x, y, w, h);
3019 mScreenStatus = ScreenRecordStatus.SCREEN_RECORD_CAMERA_MIX_START;
3024 public void stopCameraMix() {
3025 AlivcLog.i(TAG,
"[API-Pusher] stopCameraMix");
3026 if (mNativeAlivcLivePusher == null || mAlivcLivePushConfig == null) {
3027 AlivcLog.e(TAG,
"Please execute init first ");
3031 AlivcLog.e(TAG,
"Not in ScreenCapture Mode");
3034 mNativeAlivcLivePusher.stopCameraMix();
3035 mScreenStatus = ScreenRecordStatus.SCREEN_RECORD_CAMERA_START;
3039 public void changeResolution(AlivcResolutionEnum resolutionEnum) {
3040 AlivcLog.i(TAG,
"[API-Pusher] changeResolution: " + resolutionEnum);
3041 if (mNativeAlivcLivePusher == null) {
3042 AlivcLog.e(TAG,
"Please execute init first!");
3045 if (mPushStatus != AlivcLivePushStats.
PUSHED && mPushStatus != AlivcLivePushStats.
PREVIEWED && mPushStatus != AlivcLivePushStats.
INIT) {
3046 AlivcLog.e(TAG,
"changeResolution can only be called in inited or previewed status");
3049 mNativeAlivcLivePusher.changeResolution(AlivcResolutionEnum.GetResolutionWidth(resolutionEnum), AlivcResolutionEnum.GetResolutionHeight(resolutionEnum));
3052 public int mixStreamRequireMain(
int vid,
boolean require) {
3053 if (mNativeAlivcLivePusher == null) {
3056 return mNativeAlivcLivePusher.mixStreamRequireMain(vid, require);
3059 public int mixStreamChangePosition(
int vid,
float x,
float y,
float w,
float h) {
3060 if (mNativeAlivcLivePusher == null) {
3063 return mNativeAlivcLivePusher.mixStreamChangePosition(vid, x, y, w, h);
3066 public void mixStreamMirror(
int vid,
boolean mirror) {
3067 if (mNativeAlivcLivePusher == null) {
3070 mNativeAlivcLivePusher.setMixStreamMirror(vid, mirror);
3086 public int addMixVideo(AlivcImageFormat format,
int width,
int height,
int rotation,
float displayX,
float displayY,
float displayW,
float displayH,
boolean adjustHeight) {
3087 if (mNativeAlivcLivePusher == null) {
3090 return mNativeAlivcLivePusher.addMixVideo(format.getAlivcImageFormat(), width, height, rotation, displayX, displayY, displayW, displayH, adjustHeight);
3098 public void removeMixVideo(
int handler) {
3099 if (mNativeAlivcLivePusher == null) {
3102 mNativeAlivcLivePusher.removeMixVideo(handler);
3117 public void inputMixTexture(
int handler,
int texture,
int width,
int height,
long pts,
int rotation) {
3118 if (mNativeAlivcLivePusher == null) {
3121 mNativeAlivcLivePusher.inputMixTexture(handler, texture, width, height, pts, rotation);
3137 public void inputMixVideoPtr(
int handler,
long dataptr,
int width,
int height,
int stride,
int size,
long pts,
int rotation) {
3138 if (mNativeAlivcLivePusher == null) {
3141 mNativeAlivcLivePusher.inputMixVideoPtr(handler, dataptr, width, height, stride, size, pts, rotation);
3157 public void inputMixVideoData(
int handler, byte[] data,
int width,
int height,
int stride,
int size,
long pts,
int rotation) {
3158 if (mNativeAlivcLivePusher == null) {
3161 mNativeAlivcLivePusher.inputMixVideoData(handler, data, width, height, stride, size, pts, rotation);
3172 public int addMixAudio(
int channels, AlivcSoundFormat format,
int audioSample) {
3173 if (mNativeAlivcLivePusher == null) {
3176 return mNativeAlivcLivePusher.addMixAudio(channels, format.getAlivcSoundFormat(), audioSample);
3184 public void removeMixAudio(
int handler) {
3185 if (mNativeAlivcLivePusher == null) {
3188 mNativeAlivcLivePusher.removeMixAudio(handler);
3201 public boolean inputMixAudioPtr(
int handler,
long dataptr,
int size,
long pts) {
3202 if (mNativeAlivcLivePusher == null) {
3205 return mNativeAlivcLivePusher.inputMixAudioPtr(handler, dataptr, size, pts);
3217 public boolean inputMixAudioData(
int handler, byte[] data,
int size,
long pts) {
3218 if (mNativeAlivcLivePusher == null) {
3221 return mNativeAlivcLivePusher.inputMixAudioData(handler, data, size, pts);
3225 public void inputStreamVideoPtr(
long dataptr,
int width,
int height,
int stride,
int size,
long pts,
int rotation) {
3226 if (mNativeAlivcLivePusher == null) {
3229 mNativeAlivcLivePusher.inputStreamVideoPtr(dataptr, width, height, stride, size, pts, rotation);
3244 public void inputStreamTexture(
int textureId,
int width,
int height,
int stride,
long pts,
int rotation,
long extra) {
3245 if (mNativeAlivcLivePusher == null) {
3248 mNativeAlivcLivePusher.inputStreamTexture(textureId, width, height, stride, pts, rotation, extra);
3252 public void inputStreamVideoData(byte[] data,
int width,
int height,
int stride,
int size,
long pts,
int rotation) {
3253 if (mNativeAlivcLivePusher == null) {
3256 mNativeAlivcLivePusher.inputStreamVideoData(data, width, height, stride, size, pts, rotation);
3260 public void inputStreamAudioPtr(
long dataPtr,
int size,
int sampleRate,
int channels,
long pts) {
3261 if (mNativeAlivcLivePusher == null) {
3264 mNativeAlivcLivePusher.inputStreamAudioPtr(dataPtr, size, sampleRate, channels, pts);
3268 public void inputStreamAudioData(byte[] data,
int size,
int sampleRate,
int channels,
long pts) {
3269 if (mNativeAlivcLivePusher == null) {
3272 mNativeAlivcLivePusher.inputStreamAudioData(data, size, sampleRate, channels, pts);
3276 public int addDynamicsAddons(String path,
float x,
float y,
float w,
float h)
throws IllegalArgumentException {
3277 AlivcLog.i(TAG,
"[API-Pusher] addDynamicsAddons: " + path +
", " + x +
", " + y +
", " + w +
", " + h);
3278 if (mNativeAlivcLivePusher == null) {
3281 if (x < TEXTURE_RANGE_MIN || x > TEXTURE_RANGE_MAX || y < TEXTURE_RANGE_MIN || y > TEXTURE_RANGE_MAX || w < TEXTURE_RANGE_MIN || w > TEXTURE_RANGE_MAX || h < TEXTURE_RANGE_MIN || h > TEXTURE_RANGE_MAX) {
3282 AlivcLog.e(TAG,
"addDynamicsAddons failed! x, y, w, h should in range [0~1.0f]");
3285 if (mDynamicAddsonCount >= MAX_DYNAMIC_ADDSON_COUNT) {
3288 mDynamicAddsonCount++;
3289 return mNativeAlivcLivePusher.addDynamicsAddons(path, System.currentTimeMillis() * 1000, 0, x, y, w, h, 0,
false);
3293 public void removeDynamicsAddons(
int id) {
3294 AlivcLog.i(TAG,
"[API-Pusher] removeDynamicsAddons: " +
id);
3295 if (mNativeAlivcLivePusher == null) {
3298 mDynamicAddsonCount--;
3299 mNativeAlivcLivePusher.removeDynamicsAddons(
id);
3302 public void setMainStreamPosition(
float startX,
float startY,
float w,
float h) {
3303 if (mNativeAlivcLivePusher == null) {
3306 mNativeAlivcLivePusher.setMainStreamPosition(startX, startY, w, h);
3309 private String getFormatString(String
string) {
3311 int index =
string.indexOf(AUTH_KEY);
3313 String temp =
string.substring(index);
3314 if (temp.indexOf(
"-") > 0) {
3315 result = temp.substring(AUTH_KEY.length(), temp.indexOf(
"-"));
3317 result = temp.substring(AUTH_KEY.length());
3323 private int getTimestamp(String
string) {
3325 String tempStamp = getFormatString(
string);
3326 if (tempStamp.length() < 10) {
3329 if (TextUtils.isDigitsOnly(tempStamp)) {
3330 return new Long(Long.valueOf(tempStamp)).intValue();
3336 private AlivcSnapshotListener mInnerSnapshotListener =
new AlivcSnapshotListener() {
3338 public void onSnapshot(
final Bitmap bmp) {
3339 if (mSnapshotListener != null) {
3340 mThreadPoolExecutor.execute(
new Runnable() {
AlivcResolutionEnum getResolution()
void onNetworkPoor(AlivcLivePusher pusher)
void onReconnectStart(AlivcLivePusher pusher)
int getPreviewOrientation()
void onFirstFramePreviewed(AlivcLivePusher pusher)
String getPausePushImage()
boolean isPreviewMirror()
void onPushPaused(AlivcLivePusher pusher)
String getNetworkPoorPushImage()
void onNetworkRecovery(AlivcLivePusher pusher)
void onConnectFail(AlivcLivePusher pusher)
boolean isExternMainStream()
void onPushStarted(AlivcLivePusher pusher)
void onConnectionLost(AlivcLivePusher pusher)
void onReconnectFail(AlivcLivePusher pusher)
void setFlash(boolean flash)
void onPreviewStarted(AlivcLivePusher pusher)
void onPushRestarted(AlivcLivePusher pusher)
void onDropFrame(AlivcLivePusher pusher, int beforeCount, int afterCount)
String onPushURLAuthenticationOverdue(AlivcLivePusher pusher)
int getTargetVideoBitrate()
void setCameraType(AlivcLivePushCameraTypeEnum cameraType)
void onReconnectSucceed(AlivcLivePusher pusher)
void onPushStopped(AlivcLivePusher pusher)
void onFirstFramePushed(AlivcLivePusher pusher)
int getConnectRetryCount()
void onSDKError(AlivcLivePusher livePusher, AlivcLivePushError error)
void onAdjustFps(AlivcLivePusher pusher, int currentFps, int targetFps)
void onSnapshot(Bitmap bitmap)
int getConnectRetryInterval()
void onSystemError(AlivcLivePusher livePusher, AlivcLivePushError error)
Intent getMediaProjectionPermissionResultData()
void onPushStatistics(AlivcLivePusher pusher, AlivcLivePushStatsInfo statistics)
int getInitialVideoBitrate()
void onSendDataTimeout(AlivcLivePusher pusher)
void onAdjustBitrate(AlivcLivePusher pusher, int currentBitrate, int targetBitrate)
void onPreviewStopped(AlivcLivePusher pusher)
void onPushResumed(AlivcLivePusher pusher)
void onSendMessage(AlivcLivePusher pusher)
AlivcAudioSampleRateEnum getAudioSampleRate()
void onProgress(long progress, long duration)
void onPacketsLost(AlivcLivePusher pusher)
AlivcEncodeModeEnum getVideoEncodeMode()