1 package com.alivc.live.pusher;
3 import android.content.Context;
4 import android.view.SurfaceView;
5 import android.widget.FrameLayout;
32 private ILivePusher mImpl = null;
34 private static final String BASIC_PUSHER_IMPL_CLASS =
"com.alivc.live.pusher.AlivcLivePusherBasicImpl";
35 private static final String INTERACTIVE_PUSHER_IMPL_CLASS =
"com.alivc.live.pusher.rtc.AlivcRTCLivePusherImpl";
50 throw new IllegalArgumentException(
"Invalid parameter, config is null.");
53 reflectInitPusher(config.getLivePushMode());
59 mImpl.init(context, config);
63 Object playerInstance = null;
66 playerInstance = ReflectUtil.reflectInit(INTERACTIVE_PUSHER_IMPL_CLASS, null, null);
68 playerInstance = ReflectUtil.reflectInit(BASIC_PUSHER_IMPL_CLASS, null, null);
71 if (playerInstance == null) {
72 throw new RuntimeException(
"init live pusher error! now not support mode: " + mode);
75 mImpl = (ILivePusher) playerInstance;
84 public void destroy() throws IllegalStateException {
101 mImpl.setLivePusherReference(livePusher);
112 public void startPreview(SurfaceView surfaceView)
throws IllegalArgumentException, IllegalStateException {
116 mImpl.startPreview(surfaceView);
127 public void startPreviewAsync(SurfaceView surfaceView)
throws IllegalArgumentException, IllegalStateException {
131 mImpl.startPreviewAsync(surfaceView);
145 public void startPreview(Context context, FrameLayout frameLayout,
boolean isAnchor)
throws IllegalArgumentException, IllegalStateException {
149 mImpl.startPreview(context, frameLayout, isAnchor);
173 public void startPush(String url)
throws IllegalArgumentException, IllegalStateException {
177 mImpl.startPush(AlivcLiveURLTools.trimUrl(url));
188 public void startPushAsync(String url)
throws IllegalArgumentException, IllegalStateException {
192 mImpl.startPushAsync(AlivcLiveURLTools.trimUrl(url));
218 mImpl.restartPushAsync();
232 mImpl.reconnectPushAsync(AlivcLiveURLTools.trimUrl(url));
241 public void stopPush() throws IllegalStateException {
254 public void pause() throws IllegalStateException {
267 public void resume() throws IllegalStateException {
297 mImpl.switchCamera();
307 public void setAutoFocus(
boolean autoFocus)
throws IllegalStateException {
311 mImpl.setAutoFocus(autoFocus);
327 mImpl.focusCameraAtAdjustedPoint(x, y, autoFocus);
337 public void setZoom(
int zoom)
throws IllegalArgumentException, IllegalStateException {
355 return mImpl.getMaxZoom();
369 return mImpl.getCurrentZoom();
379 public void setMute(
boolean mute)
throws IllegalStateException {
393 public void setFlash(
boolean flash)
throws IllegalStateException {
397 mImpl.setFlash(flash);
411 mImpl.setPushMirror(mirror);
425 mImpl.setPreviewMirror(mirror);
439 mImpl.setTargetVideoBitrate(targetVideoBitrate);
449 public void setMinVideoBitrate(
int minVideoBitrate)
throws IllegalArgumentException, IllegalStateException {
453 mImpl.setMinVideoBitrate(minVideoBitrate);
466 return mImpl.isCameraSupportAutoFocus();
479 return mImpl.isCameraSupportFlash();
489 public boolean isPushing() throws IllegalStateException {
493 return mImpl.isPushing();
507 return mImpl.isNetworkPushing();
520 mImpl.setCustomDetect(customVideoDetect);
533 mImpl.setCustomFilter(customVideoFilter);
546 mImpl.setCustomAudioFilter(customAudioFilter);
559 return mImpl.getCurrentStatus();
572 mImpl.setLivePushErrorListener(errorListener);
585 mImpl.setLivePushInfoListener(infoListener);
598 mImpl.setLivePushNetworkListener(networkListener);
611 mImpl.setLivePushBGMListener(pushBGMListener);
624 mImpl.setLivePushRenderContextListener(renderCtxListener);
638 return mImpl.getLivePushStatsInfo();
651 return mImpl.getPushUrl();
664 mImpl.setPreviewOrientation(orientation);
680 return mImpl.setAudioEffectVoiceChangeMode(mode);
696 return mImpl.setAudioEffectReverbMode(mode);
710 mImpl.startBGMAsync(path);
723 mImpl.stopBGMAsync();
732 public void pauseBGM() throws IllegalStateException {
759 public void setBGMLoop(
boolean isLoop)
throws IllegalStateException {
763 mImpl.setBGMLoop(isLoop);
777 mImpl.setBGMEarsBack(isOpen);
788 public void setBGMVolume(
int volume)
throws IllegalStateException, IllegalArgumentException {
792 mImpl.setBGMVolume(volume);
803 public void setCaptureVolume(
int volume)
throws IllegalStateException, IllegalArgumentException {
807 mImpl.setCaptureVolume(volume);
820 mImpl.setAudioDenoise(on);
843 return mImpl.startIntelligentDenoise();
857 return mImpl.stopIntelligentDenoise();
871 mImpl.setQualityMode(mode);
885 mImpl.setPreviewMode(mode);
898 mImpl.pauseScreenCapture();
911 mImpl.resumeScreenCapture();
924 return mImpl.getLastError();
937 mImpl.changeResolution(resolution);
954 mImpl.addWaterMark(path, x, y, width);
967 mImpl.setWatermarkVisible(visible);
978 public int startCamera(SurfaceView surfaceView)
throws IllegalStateException {
982 return mImpl.startCamera(surfaceView);
1003 if (mImpl == null) {
1006 mImpl.setScreenOrientation(orientation);
1020 if (mImpl == null) {
1023 return mImpl.startCameraMix(x, y, w, h);
1031 if (mImpl == null) {
1034 mImpl.stopCameraMix();
1046 if (mImpl == null) {
1049 mImpl.snapshot(count, interval, listener);
1065 public void inputStreamVideoPtr(
long dataPtr,
int width,
int height,
int stride,
int size,
long pts,
int rotation) {
1066 if (mImpl == null) {
1069 mImpl.inputStreamVideoPtr(dataPtr, width, height, stride, size, pts, rotation);
1086 public void inputStreamVideoData(byte[] data,
int width,
int height,
int stride,
int size,
long pts,
int rotation) {
1087 if (mImpl == null) {
1090 mImpl.inputStreamVideoData(data, width, height, stride, size, pts, rotation);
1106 if (mImpl == null) {
1109 mImpl.inputStreamAudioPtr(dataPtr, size, sampleRate, channels, pts);
1125 if (mImpl == null) {
1128 mImpl.inputStreamAudioData(data, size, sampleRate, channels, pts);
1143 if (mImpl == null) {
1146 return mImpl.addDynamicsAddons(path, x, y, w, h);
1156 if (mImpl == null) {
1159 mImpl.removeDynamicsAddons(
id);
1169 if (mImpl == null) {
1172 mImpl.setExposure(exposure);
1182 if (mImpl == null) {
1185 return mImpl.getCurrentExposure();
1195 if (mImpl == null) {
1198 return mImpl.getSupportedMinExposure();
1208 if (mImpl == null) {
1211 return mImpl.getSupportedMaxExposure();
1223 public void sendMessage(String info,
int repeat,
int delay,
boolean isKeyFrame) {
1224 if (mImpl == null) {
1227 mImpl.sendMessage(info, repeat, delay, isKeyFrame);
1246 if (mImpl == null) {
1249 return mImpl.setLiveMixTranscodingConfig(config);
1264 if (mImpl == null) {
1267 return mImpl.muteLocalCamera(mute);
1279 if (mImpl == null) {
1282 return mImpl.enableSpeakerphone(enable);
1293 if (mImpl == null) {
1296 return mImpl.isSpeakerphoneOn();
1307 if (mImpl == null) {
1310 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)