1 package com.alivc.live.pusher;
3 import android.content.Context;
4 import android.view.SurfaceView;
5 import android.widget.FrameLayout;
33 private ILivePusher mImpl = null;
35 private static final String BASIC_PUSHER_IMPL_CLASS =
"com.alivc.live.pusher.AlivcLivePusherBasicImpl";
36 private static final String INTERACTIVE_PUSHER_IMPL_CLASS =
"com.alivc.live.pusher.rtc.AlivcRTCLivePusherImpl";
51 throw new IllegalArgumentException(
"Invalid parameter, config is null.");
54 reflectInitPusher(config.getLivePushMode());
60 mImpl.init(context, config);
64 Object playerInstance = null;
67 playerInstance = ReflectUtil.reflectInit(INTERACTIVE_PUSHER_IMPL_CLASS, null, null);
69 playerInstance = ReflectUtil.reflectInit(BASIC_PUSHER_IMPL_CLASS, null, null);
72 if (playerInstance == null) {
73 throw new RuntimeException(
"init live pusher error! now not support mode: " + mode);
76 mImpl = (ILivePusher) playerInstance;
85 public void destroy() throws IllegalStateException {
102 mImpl.setLivePusherReference(livePusher);
113 public void startPreview(SurfaceView surfaceView)
throws IllegalArgumentException, IllegalStateException {
117 mImpl.startPreview(surfaceView);
128 public void startPreviewAsync(SurfaceView surfaceView)
throws IllegalArgumentException, IllegalStateException {
132 mImpl.startPreviewAsync(surfaceView);
146 public void startPreview(Context context, FrameLayout frameLayout,
boolean isAnchor)
throws IllegalArgumentException, IllegalStateException {
150 mImpl.startPreview(context, frameLayout, isAnchor);
174 public void startPush(String url)
throws IllegalArgumentException, IllegalStateException {
178 mImpl.startPush(AlivcLiveURLTools.trimUrl(url));
189 public void startPushAsync(String url)
throws IllegalArgumentException, IllegalStateException {
193 mImpl.startPushAsync(AlivcLiveURLTools.trimUrl(url));
219 mImpl.restartPushAsync();
233 mImpl.reconnectPushAsync(AlivcLiveURLTools.trimUrl(url));
242 public void stopPush() throws IllegalStateException {
255 public void pause() throws IllegalStateException {
268 public void resume() throws IllegalStateException {
298 mImpl.switchCamera();
308 public void setAutoFocus(
boolean autoFocus)
throws IllegalStateException {
312 mImpl.setAutoFocus(autoFocus);
328 mImpl.focusCameraAtAdjustedPoint(x, y, autoFocus);
338 public void setZoom(
int zoom)
throws IllegalArgumentException, IllegalStateException {
356 return mImpl.getMaxZoom();
370 return mImpl.getCurrentZoom();
380 public void setMute(
boolean mute)
throws IllegalStateException {
394 public void setFlash(
boolean flash)
throws IllegalStateException {
398 mImpl.setFlash(flash);
412 mImpl.setPushMirror(mirror);
426 mImpl.setPreviewMirror(mirror);
440 mImpl.setTargetVideoBitrate(targetVideoBitrate);
450 public void setMinVideoBitrate(
int minVideoBitrate)
throws IllegalArgumentException, IllegalStateException {
454 mImpl.setMinVideoBitrate(minVideoBitrate);
467 return mImpl.isCameraSupportAutoFocus();
480 return mImpl.isCameraSupportFlash();
490 public boolean isPushing() throws IllegalStateException {
494 return mImpl.isPushing();
508 return mImpl.isNetworkPushing();
521 mImpl.setCustomDetect(customVideoDetect);
534 mImpl.setCustomFilter(customVideoFilter);
547 mImpl.setCustomAudioFilter(customAudioFilter);
560 return mImpl.getCurrentStatus();
573 mImpl.setLivePushErrorListener(errorListener);
586 mImpl.setLivePushInfoListener(infoListener);
599 mImpl.setLivePushNetworkListener(networkListener);
612 mImpl.setLivePushBGMListener(pushBGMListener);
625 mImpl.setLivePushRenderContextListener(renderCtxListener);
639 return mImpl.getLivePushStatsInfo();
652 return mImpl.getPushUrl();
665 mImpl.setPreviewOrientation(orientation);
681 return mImpl.setAudioEffectVoiceChangeMode(mode);
697 return mImpl.setAudioEffectReverbMode(mode);
711 mImpl.startBGMAsync(path);
724 mImpl.stopBGMAsync();
733 public void pauseBGM() throws IllegalStateException {
760 public void setBGMLoop(
boolean isLoop)
throws IllegalStateException {
764 mImpl.setBGMLoop(isLoop);
778 mImpl.setBGMEarsBack(isOpen);
789 public void setBGMVolume(
int volume)
throws IllegalStateException, IllegalArgumentException {
793 mImpl.setBGMVolume(volume);
804 public void setCaptureVolume(
int volume)
throws IllegalStateException, IllegalArgumentException {
808 mImpl.setCaptureVolume(volume);
821 mImpl.setAudioDenoise(on);
844 return mImpl.startIntelligentDenoise();
858 return mImpl.stopIntelligentDenoise();
872 mImpl.setQualityMode(mode);
886 mImpl.setPreviewMode(mode);
899 mImpl.pauseScreenCapture();
912 mImpl.resumeScreenCapture();
925 return mImpl.getLastError();
938 mImpl.changeResolution(resolution);
955 mImpl.addWaterMark(path, x, y, width);
968 mImpl.setWatermarkVisible(visible);
979 public int startCamera(SurfaceView surfaceView)
throws IllegalStateException {
983 return mImpl.startCamera(surfaceView);
1004 if (mImpl == null) {
1007 mImpl.setScreenOrientation(orientation);
1021 if (mImpl == null) {
1024 return mImpl.startCameraMix(x, y, w, h);
1032 if (mImpl == null) {
1035 mImpl.stopCameraMix();
1047 if (mImpl == null) {
1050 mImpl.snapshot(count, interval, listener);
1066 public void inputStreamVideoPtr(
long dataPtr,
int width,
int height,
int stride,
int size,
long pts,
int rotation) {
1067 if (mImpl == null) {
1070 mImpl.inputStreamVideoPtr(dataPtr, width, height, stride, size, pts, rotation);
1087 public void inputStreamVideoData(byte[] data,
int width,
int height,
int stride,
int size,
long pts,
int rotation) {
1088 if (mImpl == null) {
1091 mImpl.inputStreamVideoData(data, width, height, stride, size, pts, rotation);
1107 if (mImpl == null) {
1110 mImpl.inputStreamAudioPtr(dataPtr, size, sampleRate, channels, pts);
1126 if (mImpl == null) {
1129 mImpl.inputStreamAudioData(data, size, sampleRate, channels, pts);
1144 if (mImpl == null) {
1147 return mImpl.addDynamicsAddons(path, x, y, w, h);
1157 if (mImpl == null) {
1160 mImpl.removeDynamicsAddons(
id);
1170 if (mImpl == null) {
1173 mImpl.setExposure(exposure);
1183 if (mImpl == null) {
1186 return mImpl.getCurrentExposure();
1196 if (mImpl == null) {
1199 return mImpl.getSupportedMinExposure();
1209 if (mImpl == null) {
1212 return mImpl.getSupportedMaxExposure();
1224 public void sendMessage(String info,
int repeat,
int delay,
boolean isKeyFrame) {
1225 if (mImpl == null) {
1228 mImpl.sendMessage(info, repeat, delay, isKeyFrame);
1247 if (mImpl == null) {
1250 return mImpl.setLiveMixTranscodingConfig(config);
1265 if (mImpl == null) {
1268 return mImpl.muteLocalCamera(mute);
1280 if (mImpl == null) {
1283 return mImpl.enableSpeakerphone(enable);
1294 if (mImpl == null) {
1297 return mImpl.isSpeakerphoneOn();
1308 if (mImpl == null) {
1311 return mImpl.getLiveTraceId();
void startPreviewAsync(SurfaceView surfaceView)
int getSupportedMaxExposure()
int setAudioEffectReverbMode(AlivcLivePushAudioEffectReverbMode mode)
void startPush(String url)
void inputStreamVideoData(byte[] data, int width, int height, int stride, int size, long pts, int rotation)
void snapshot(int count, int interval, AlivcSnapshotListener listener)
boolean isCameraSupportAutoFocus()
void setBGMEarsBack(boolean isOpen)
void setCaptureVolume(int volume)
void startPreview(SurfaceView surfaceView)
void changeResolution(AlivcResolutionEnum resolution)
void resumeScreenCapture()
void setLivePushNetworkListener(AlivcLivePushNetworkListener networkListener)
void init(Context context, AlivcLivePushConfig config)
void sendMessage(String info, int repeat, int delay, boolean isKeyFrame)
void startPreview(Context context, FrameLayout frameLayout, boolean isAnchor)
void setMinVideoBitrate(int minVideoBitrate)
void removeDynamicsAddons(int id)
void setLivePushBGMListener(AlivcLivePushBGMListener pushBGMListener)
void setScreenOrientation(int orientation)
void setCustomDetect(AlivcLivePushCustomDetect customVideoDetect)
void pauseScreenCapture()
void setPreviewOrientation(AlivcPreviewOrientationEnum orientation)
void setMute(boolean mute)
void reconnectPushAsync(String url)
void inputStreamAudioPtr(long dataPtr, int size, int sampleRate, int channels, long pts)
void inputStreamAudioData(byte[] data, int size, int sampleRate, int channels, long pts)
AlivcLivePushError getLastError()
void setBGMVolume(int volume)
void setWatermarkVisible(boolean visible)
int addDynamicsAddons(String path, float x, float y, float w, float h)
void setPushMirror(boolean mirror)
void setCustomAudioFilter(AlivcLivePushCustomAudioFilter customAudioFilter)
int startIntelligentDenoise()
int stopIntelligentDenoise()
void setBGMLoop(boolean isLoop)
void focusCameraAtAdjustedPoint(float x, float y, boolean autoFocus)
int startCamera(SurfaceView surfaceView)
void setAudioDenoise(boolean on)
int enableSpeakerphone(boolean enable)
boolean isSpeakerphoneOn()
int startCameraMix(float x, float y, float w, float h)
void setExposure(int exposure)
void setLivePushErrorListener(AlivcLivePushErrorListener errorListener)
int setAudioEffectVoiceChangeMode(AlivcLivePushAudioEffectVoiceChangeMode mode)
void setLivePushInfoListener(AlivcLivePushInfoListener infoListener)
void setTargetVideoBitrate(int targetVideoBitrate)
void setAutoFocus(boolean autoFocus)
int setLiveMixTranscodingConfig(AlivcLiveTranscodingConfig config)
void setFlash(boolean flash)
void setLivePushRenderContextListener(AlivcLivePusherRenderContextListener renderCtxListener)
int muteLocalCamera(boolean mute)
void setPreviewMirror(boolean mirror)
int getSupportedMinExposure()
AlivcLivePushStatsInfo getLivePushStatsInfo()
void setPreviewMode(AlivcPreviewDisplayMode mode)
void setCustomFilter(AlivcLivePushCustomFilter customVideoFilter)
void inputStreamVideoPtr(long dataPtr, int width, int height, int stride, int size, long pts, int rotation)
void startPushAsync(String url)
boolean isCameraSupportFlash()
void addWaterMark(String path, float x, float y, float width)
void startBGMAsync(String path)
boolean isNetworkPushing()
void setLivePusherReference(AlivcLivePusher livePusher)
AlivcLivePushStats getCurrentStatus()
void setQualityMode(AlivcQualityModeEnum mode)
static void loadInstance(Context context)