1 package com.alivc.live.pusher;
3 import android.content.Context;
4 import android.view.SurfaceView;
5 import android.widget.FrameLayout;
34 private ILivePusher mImpl = null;
36 private static final String BASIC_PUSHER_IMPL_CLASS =
"com.alivc.live.pusher.AlivcLivePusherBasicImpl";
37 private static final String INTERACTIVE_PUSHER_IMPL_CLASS =
"com.alivc.live.pusher.rtc.AlivcRTCLivePusherImpl";
52 throw new IllegalArgumentException(
"Invalid parameter, config is null.");
55 reflectInitPusher(config.getLivePushMode());
61 mImpl.init(context, config);
65 Object playerInstance = null;
68 playerInstance = ReflectUtil.reflectInit(INTERACTIVE_PUSHER_IMPL_CLASS, null, null);
70 playerInstance = ReflectUtil.reflectInit(BASIC_PUSHER_IMPL_CLASS, null, null);
73 if (playerInstance == null) {
74 throw new RuntimeException(
"init live pusher error! now not support mode: " + mode);
77 mImpl = (ILivePusher) playerInstance;
86 public void destroy() throws IllegalStateException {
103 mImpl.setLivePusherReference(livePusher);
115 public void startPreview(SurfaceView surfaceView)
throws IllegalArgumentException, IllegalStateException {
119 mImpl.startPreview(surfaceView);
131 public void startPreviewAsync(SurfaceView surfaceView)
throws IllegalArgumentException, IllegalStateException {
135 mImpl.startPreviewAsync(surfaceView);
149 public void startPreview(Context context, FrameLayout frameLayout,
boolean isAnchor)
throws IllegalArgumentException, IllegalStateException {
153 mImpl.startPreview(context, frameLayout, isAnchor);
177 public void startPush(String url)
throws IllegalArgumentException, IllegalStateException {
181 mImpl.startPush(AlivcLiveURLTools.trimUrl(url));
192 public void startPushAsync(String url)
throws IllegalArgumentException, IllegalStateException {
196 mImpl.startPushAsync(AlivcLiveURLTools.trimUrl(url));
222 mImpl.restartPushAsync();
236 mImpl.reconnectPushAsync(AlivcLiveURLTools.trimUrl(url));
245 public void stopPush() throws IllegalStateException {
258 public void pause() throws IllegalStateException {
271 public void resume() throws IllegalStateException {
301 mImpl.switchCamera();
311 public void setAutoFocus(
boolean autoFocus)
throws IllegalStateException {
315 mImpl.setAutoFocus(autoFocus);
331 mImpl.focusCameraAtAdjustedPoint(x, y, autoFocus);
341 public void setZoom(
int zoom)
throws IllegalArgumentException, IllegalStateException {
359 return mImpl.getMaxZoom();
373 return mImpl.getCurrentZoom();
383 public void setMute(
boolean mute)
throws IllegalStateException {
397 public void setFlash(
boolean flash)
throws IllegalStateException {
401 mImpl.setFlash(flash);
415 mImpl.setPushMirror(mirror);
429 mImpl.setPreviewMirror(mirror);
443 mImpl.setTargetVideoBitrate(targetVideoBitrate);
453 public void setMinVideoBitrate(
int minVideoBitrate)
throws IllegalArgumentException, IllegalStateException {
457 mImpl.setMinVideoBitrate(minVideoBitrate);
473 mImpl.refreshPushURLToken(url);
486 return mImpl.isCameraSupportAutoFocus();
499 return mImpl.isCameraSupportFlash();
509 public boolean isPushing() throws IllegalStateException {
513 return mImpl.isPushing();
527 return mImpl.isNetworkPushing();
540 mImpl.setCustomDetect(customVideoDetect);
553 mImpl.setCustomFilter(customVideoFilter);
566 mImpl.setCustomAudioFilter(customAudioFilter);
579 return mImpl.getCurrentStatus();
592 mImpl.setLivePushErrorListener(errorListener);
605 mImpl.setLivePushInfoListener(infoListener);
618 mImpl.setLivePushNetworkListener(networkListener);
631 mImpl.setLivePushBGMListener(pushBGMListener);
644 mImpl.setLivePushRenderContextListener(renderCtxListener);
658 return mImpl.getLivePushStatsInfo();
671 return mImpl.getPushUrl();
684 mImpl.setPreviewOrientation(orientation);
700 return mImpl.setAudioEffectVoiceChangeMode(mode);
716 return mImpl.setAudioEffectReverbMode(mode);
730 mImpl.startBGMAsync(path);
743 mImpl.stopBGMAsync();
752 public void pauseBGM() throws IllegalStateException {
779 public void setBGMLoop(
boolean isLoop)
throws IllegalStateException {
783 mImpl.setBGMLoop(isLoop);
797 mImpl.setBGMEarsBack(isOpen);
808 public void setBGMVolume(
int volume)
throws IllegalStateException, IllegalArgumentException {
812 mImpl.setBGMVolume(volume);
823 public void setCaptureVolume(
int volume)
throws IllegalStateException, IllegalArgumentException {
827 mImpl.setCaptureVolume(volume);
840 mImpl.setAudioDenoise(on);
863 return mImpl.startIntelligentDenoise();
877 return mImpl.stopIntelligentDenoise();
891 mImpl.setQualityMode(mode);
905 mImpl.setPreviewMode(mode);
918 mImpl.pauseScreenCapture();
931 mImpl.resumeScreenCapture();
944 return mImpl.getLastError();
957 mImpl.changeResolution(resolution);
974 mImpl.addWaterMark(path, x, y, width);
987 mImpl.setWatermarkVisible(visible);
998 public int startCamera(SurfaceView surfaceView)
throws IllegalStateException {
1002 return mImpl.startCamera(surfaceView);
1010 if (mImpl == null) {
1023 if (mImpl == null) {
1026 mImpl.setScreenOrientation(orientation);
1040 if (mImpl == null) {
1043 return mImpl.startCameraMix(x, y, w, h);
1051 if (mImpl == null) {
1054 mImpl.stopCameraMix();
1066 if (mImpl == null) {
1069 mImpl.snapshot(count, interval, listener);
1085 public void inputStreamVideoPtr(
long dataPtr,
int width,
int height,
int stride,
int size,
long pts,
int rotation) {
1086 if (mImpl == null) {
1089 mImpl.inputStreamVideoPtr(dataPtr, width, height, stride, size, pts, rotation);
1106 public void inputStreamVideoData(byte[] data,
int width,
int height,
int stride,
int size,
long pts,
int rotation) {
1107 if (mImpl == null) {
1110 mImpl.inputStreamVideoData(data, width, height, stride, size, pts, rotation);
1126 if (mImpl == null) {
1129 mImpl.inputStreamAudioPtr(dataPtr, size, sampleRate, channels, pts);
1145 if (mImpl == null) {
1148 mImpl.inputStreamAudioData(data, size, sampleRate, channels, pts);
1163 if (mImpl == null) {
1166 return mImpl.addDynamicsAddons(path, x, y, w, h);
1176 if (mImpl == null) {
1179 mImpl.removeDynamicsAddons(
id);
1189 if (mImpl == null) {
1192 mImpl.setExposure(exposure);
1202 if (mImpl == null) {
1205 return mImpl.getCurrentExposure();
1215 if (mImpl == null) {
1218 return mImpl.getSupportedMinExposure();
1228 if (mImpl == null) {
1231 return mImpl.getSupportedMaxExposure();
1243 public void sendMessage(String info,
int repeat,
int delay,
boolean isKeyFrame) {
1244 if (mImpl == null) {
1247 mImpl.sendMessage(info, repeat, delay, isKeyFrame);
1266 if (mImpl == null) {
1269 return mImpl.setLiveMixTranscodingConfig(config);
1284 if (mImpl == null) {
1287 return mImpl.muteLocalCamera(mute);
1299 if (mImpl == null) {
1302 return mImpl.enableSpeakerphone(enable);
1313 if (mImpl == null) {
1316 return mImpl.isSpeakerphoneOn();
1330 if (mImpl == null) {
1333 return mImpl.enableAudioVolumeIndication(interval, smooth, reportVad);
1344 if (mImpl == null) {
1347 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)
int enableAudioVolumeIndication(int interval, int smooth, int reportVad)
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 refreshPushURLToken(String url)
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)