1 package com.alivc.live.pusher;
3 import android.content.Context;
4 import android.view.SurfaceView;
5 import android.widget.FrameLayout;
29 private ILivePusher mImpl = null;
31 private static final String BASIC_PUSHER_IMPL_CLASS =
"com.alivc.live.pusher.AlivcLivePusherBasicImpl";
32 private static final String INTERACTIVE_PUSHER_IMPL_CLASS =
"com.alivc.live.pusher.rtc.AlivcRTCLivePusherImpl";
47 throw new IllegalArgumentException(
"Invalid parameter, config is null.");
50 reflectInitPusher(config.getLivePushMode());
56 mImpl.init(context, config);
60 Object playerInstance = null;
63 playerInstance = ReflectUtil.reflectInit(INTERACTIVE_PUSHER_IMPL_CLASS, null, null);
65 playerInstance = ReflectUtil.reflectInit(BASIC_PUSHER_IMPL_CLASS, null, null);
68 if (playerInstance == null) {
69 throw new RuntimeException(
"init live pusher error! now not support mode: " + mode);
72 mImpl = (ILivePusher) playerInstance;
81 public void destroy() throws IllegalStateException {
98 mImpl.setLivePusherReference(livePusher);
109 public void startPreview(SurfaceView surfaceView)
throws IllegalArgumentException, IllegalStateException {
113 mImpl.startPreview(surfaceView);
124 public void startPreviewAsync(SurfaceView surfaceView)
throws IllegalArgumentException, IllegalStateException {
128 mImpl.startPreviewAsync(surfaceView);
142 public void startPreview(Context context, FrameLayout frameLayout,
boolean isAnchor)
throws IllegalArgumentException, IllegalStateException {
146 mImpl.startPreview(context, frameLayout, isAnchor);
170 public void startPush(String url)
throws IllegalArgumentException, IllegalStateException {
174 mImpl.startPush(AlivcLiveURLTools.trimUrl(url));
185 public void startPushAsync(String url)
throws IllegalArgumentException, IllegalStateException {
189 mImpl.startPushAsync(AlivcLiveURLTools.trimUrl(url));
215 mImpl.restartPushAsync();
229 mImpl.reconnectPushAsync(AlivcLiveURLTools.trimUrl(url));
238 public void stopPush() throws IllegalStateException {
251 public void pause() throws IllegalStateException {
264 public void resume() throws IllegalStateException {
294 mImpl.switchCamera();
304 public void setAutoFocus(
boolean autoFocus)
throws IllegalStateException {
308 mImpl.setAutoFocus(autoFocus);
324 mImpl.focusCameraAtAdjustedPoint(x, y, autoFocus);
334 public void setZoom(
int zoom)
throws IllegalArgumentException, IllegalStateException {
352 return mImpl.getMaxZoom();
366 return mImpl.getCurrentZoom();
376 public void setMute(
boolean mute)
throws IllegalStateException {
390 public void setFlash(
boolean flash)
throws IllegalStateException {
394 mImpl.setFlash(flash);
408 mImpl.setPushMirror(mirror);
422 mImpl.setPreviewMirror(mirror);
436 mImpl.setTargetVideoBitrate(targetVideoBitrate);
446 public void setMinVideoBitrate(
int minVideoBitrate)
throws IllegalArgumentException, IllegalStateException {
450 mImpl.setMinVideoBitrate(minVideoBitrate);
463 return mImpl.isCameraSupportAutoFocus();
476 return mImpl.isCameraSupportFlash();
486 public boolean isPushing() throws IllegalStateException {
490 return mImpl.isPushing();
504 return mImpl.isNetworkPushing();
517 mImpl.setCustomDetect(customVideoDetect);
530 mImpl.setCustomFilter(customVideoFilter);
543 mImpl.setCustomAudioFilter(customAudioFilter);
556 return mImpl.getCurrentStatus();
569 mImpl.setLivePushErrorListener(errorListener);
582 mImpl.setLivePushInfoListener(infoListener);
595 mImpl.setLivePushNetworkListener(networkListener);
608 mImpl.setLivePushBGMListener(pushBGMListener);
621 mImpl.setLivePushRenderContextListener(renderCtxListener);
635 return mImpl.getLivePushStatsInfo();
648 return mImpl.getPushUrl();
661 mImpl.setPreviewOrientation(orientation);
677 return mImpl.setAudioEffectVoiceChangeMode(mode);
693 return mImpl.setAudioEffectReverbMode(mode);
707 mImpl.startBGMAsync(path);
720 mImpl.stopBGMAsync();
729 public void pauseBGM() throws IllegalStateException {
756 public void setBGMLoop(
boolean isLoop)
throws IllegalStateException {
760 mImpl.setBGMLoop(isLoop);
774 mImpl.setBGMEarsBack(isOpen);
785 public void setBGMVolume(
int volume)
throws IllegalStateException, IllegalArgumentException {
789 mImpl.setBGMVolume(volume);
800 public void setCaptureVolume(
int volume)
throws IllegalStateException, IllegalArgumentException {
804 mImpl.setCaptureVolume(volume);
817 mImpl.setAudioDenoise(on);
840 return mImpl.startIntelligentDenoise();
854 return mImpl.stopIntelligentDenoise();
868 mImpl.setQualityMode(mode);
882 mImpl.setPreviewMode(mode);
895 mImpl.pauseScreenCapture();
908 mImpl.resumeScreenCapture();
921 return mImpl.getLastError();
934 mImpl.changeResolution(resolution);
951 mImpl.addWaterMark(path, x, y, width);
964 mImpl.setWatermarkVisible(visible);
975 public int startCamera(SurfaceView surfaceView)
throws IllegalStateException {
979 return mImpl.startCamera(surfaceView);
1000 if (mImpl == null) {
1003 mImpl.setScreenOrientation(orientation);
1017 if (mImpl == null) {
1020 return mImpl.startCameraMix(x, y, w, h);
1028 if (mImpl == null) {
1031 mImpl.stopCameraMix();
1043 if (mImpl == null) {
1046 mImpl.snapshot(count, interval, listener);
1063 public void inputStreamVideoPtr(
long dataPtr,
int width,
int height,
int stride,
int size,
long pts,
int rotation) {
1064 if (mImpl == null) {
1067 mImpl.inputStreamVideoPtr(dataPtr, width, height, stride, size, pts, rotation);
1084 public void inputStreamVideoData(byte[] data,
int width,
int height,
int stride,
int size,
long pts,
int rotation) {
1085 if (mImpl == null) {
1088 mImpl.inputStreamVideoData(data, width, height, stride, size, pts, rotation);
1104 if (mImpl == null) {
1107 mImpl.inputStreamAudioPtr(dataPtr, size, sampleRate, channels, pts);
1123 if (mImpl == null) {
1126 mImpl.inputStreamAudioData(data, size, sampleRate, channels, pts);
1141 if (mImpl == null) {
1144 return mImpl.addDynamicsAddons(path, x, y, w, h);
1154 if (mImpl == null) {
1157 mImpl.removeDynamicsAddons(
id);
1167 if (mImpl == null) {
1170 mImpl.setExposure(exposure);
1180 if (mImpl == null) {
1183 return mImpl.getCurrentExposure();
1193 if (mImpl == null) {
1196 return mImpl.getSupportedMinExposure();
1206 if (mImpl == null) {
1209 return mImpl.getSupportedMaxExposure();
1221 public void sendMessage(String info,
int repeat,
int delay,
boolean isKeyFrame) {
1222 if (mImpl == null) {
1225 mImpl.sendMessage(info, repeat, delay, isKeyFrame);
1244 if (mImpl == null) {
1247 return mImpl.setLiveMixTranscodingConfig(config);
1262 if (mImpl == null) {
1265 return mImpl.muteLocalCamera(mute);
1277 if (mImpl == null) {
1280 return mImpl.enableSpeakerphone(enable);
1291 if (mImpl == null) {
1294 return mImpl.isSpeakerphoneOn();
1305 if (mImpl == null) {
1308 return mImpl.getLiveTraceId();
Live push snapshot async callback.
void startPreviewAsync(SurfaceView surfaceView)
int getSupportedMaxExposure()
int setAudioEffectReverbMode(AlivcLivePushAudioEffectReverbMode mode)
void startPush(String url)
Live push mix transcoding config.
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)
Live pusher abstract class.
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)
Live push network listener.
Live push error listener.
void setCustomAudioFilter(AlivcLivePushCustomAudioFilter customAudioFilter)
int startIntelligentDenoise()
int stopIntelligentDenoise()
void setBGMLoop(boolean isLoop)
void focusCameraAtAdjustedPoint(float x, float y, boolean autoFocus)
Enumeration of streaming audio effect reverb mode.
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)
Customizing the filter interface.
void setTargetVideoBitrate(int targetVideoBitrate)
void setAutoFocus(boolean autoFocus)
Live push video quality mode.
Used to load sdk common instance,.
int setLiveMixTranscodingConfig(AlivcLiveTranscodingConfig config)
void setFlash(boolean flash)
void setLivePushRenderContextListener(AlivcLivePusherRenderContextListener renderCtxListener)
int muteLocalCamera(boolean mute)
Live push video resolution.
void setPreviewMirror(boolean mirror)
Customizing the audio filter interface.
int getSupportedMinExposure()
User defined video custom detect callback.
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)
Live push preview orientation.
void startPushAsync(String url)
Live push preview display mode.
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)
Enumeration of streaming audio effect voice change mode.
Live push statistics info.