forked from florindumitru/react-native-sip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added video support for iOS and Android, and related fixes
- Loading branch information
Showing
275 changed files
with
2,972 additions
and
676 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
android/src/main/java/com/carusto/ReactNativePjSip/PjSipPreviewVideo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.carusto.ReactNativePjSip; | ||
|
||
import android.content.Context; | ||
import android.util.Log; | ||
import android.view.SurfaceHolder; | ||
|
||
import org.pjsip.pjsua2.VideoPreview; | ||
import org.pjsip.pjsua2.VideoPreviewOpParam; | ||
import org.pjsip.pjsua2.VideoWindow; | ||
import org.pjsip.pjsua2.VideoWindowHandle; | ||
|
||
public class PjSipPreviewVideo extends PjSipVideo { | ||
|
||
private int deviceId = -1; | ||
|
||
public PjSipPreviewVideo(Context context) { | ||
super(context); | ||
} | ||
|
||
public void setDeviceId(int deviceId) { | ||
if (this.deviceId == deviceId) { | ||
return; | ||
} | ||
|
||
final VideoPreview windowPreview = new VideoPreview(deviceId); | ||
|
||
setCallback(new PjSipVideoWindowHandler() { | ||
@Override | ||
public VideoWindow start(SurfaceHolder surfaceHolder) throws Exception { | ||
VideoWindowHandle handle = new VideoWindowHandle(); | ||
handle.getHandle().setWindow(surfaceHolder.getSurface()); | ||
|
||
VideoPreviewOpParam op = new VideoPreviewOpParam(); | ||
op.setWindow(handle); | ||
|
||
windowPreview.start(op); | ||
return windowPreview.getVideoWindow(); | ||
} | ||
}); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
android/src/main/java/com/carusto/ReactNativePjSip/PjSipPreviewVideoViewManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.carusto.ReactNativePjSip; | ||
|
||
import android.graphics.Color; | ||
import android.util.Log; | ||
import android.view.SurfaceView; | ||
import android.view.View; | ||
import android.widget.RelativeLayout; | ||
import android.widget.TextView; | ||
|
||
import com.facebook.react.uimanager.annotations.ReactProp; | ||
import com.facebook.react.uimanager.SimpleViewManager; | ||
import com.facebook.react.uimanager.ThemedReactContext; | ||
import com.facebook.react.uimanager.ViewProps; | ||
|
||
import org.pjsip.pjsua2.MediaFormat; | ||
import org.pjsip.pjsua2.MediaFormatVector; | ||
import org.pjsip.pjsua2.VideoDevInfo; | ||
import org.pjsip.pjsua2.VideoPreview; | ||
import org.pjsip.pjsua2.VideoPreviewOpParam; | ||
import org.pjsip.pjsua2.VideoWindowHandle; | ||
import org.pjsip.pjsua2.WindowHandle; | ||
|
||
public class PjSipPreviewVideoViewManager extends SimpleViewManager<PjSipPreviewVideo> { | ||
|
||
private String LOCAL_VIDEO_CLASS = "PjSipPreviewVideoView"; | ||
|
||
@Override | ||
public String getName() { | ||
return LOCAL_VIDEO_CLASS; | ||
} | ||
|
||
@ReactProp(name = "deviceId") | ||
public void setDeviceId(PjSipPreviewVideo view, int deviceId) { | ||
view.setDeviceId(deviceId); | ||
} | ||
|
||
@ReactProp(name = "objectFit") | ||
public void setObjectFit(PjSipPreviewVideo view, String objectFit) { | ||
view.setObjectFit(objectFit); | ||
} | ||
|
||
@Override | ||
protected PjSipPreviewVideo createViewInstance(ThemedReactContext reactContext) { | ||
return new PjSipPreviewVideo(reactContext); | ||
} | ||
|
||
} |
66 changes: 66 additions & 0 deletions
66
android/src/main/java/com/carusto/ReactNativePjSip/PjSipRemoteVideo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package com.carusto.ReactNativePjSip; | ||
|
||
import android.content.Context; | ||
import android.os.Handler; | ||
import android.util.Log; | ||
import android.view.SurfaceHolder; | ||
|
||
import org.pjsip.pjsua2.VideoWindow; | ||
import org.pjsip.pjsua2.VideoWindowHandle; | ||
import org.pjsip.pjsua2.WindowHandle; | ||
|
||
public class PjSipRemoteVideo extends PjSipVideo implements PjSipVideoMediaChange { | ||
|
||
private static String TAG = "PjSipRemoteVideo"; | ||
|
||
public PjSipRemoteVideo(Context context) { | ||
super(context); | ||
} | ||
|
||
@Override | ||
protected void onAttachedToWindow() { | ||
super.onAttachedToWindow(); | ||
|
||
PjSipCall.mediaListeners.add(this); | ||
} | ||
|
||
@Override | ||
protected void onDetachedFromWindow() { | ||
super.onDetachedFromWindow(); | ||
|
||
PjSipCall.mediaListeners.remove(this); | ||
} | ||
|
||
public void setWindowId(int windowId) { | ||
final VideoWindow videoWindow = new VideoWindow(windowId); | ||
|
||
setCallback(new PjSipVideoWindowHandler() { | ||
@Override | ||
public VideoWindow start(SurfaceHolder surfaceHolder) throws Exception { | ||
WindowHandle winHandle = new WindowHandle(); | ||
winHandle.setWindow(surfaceHolder.getSurface()); | ||
|
||
VideoWindowHandle handle = new VideoWindowHandle(); | ||
handle.setHandle(winHandle); | ||
|
||
videoWindow.setWindow(handle); | ||
return videoWindow; | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void onChange() { | ||
Handler mainHandler = new Handler(getContext().getMainLooper()); | ||
mainHandler.post(new Runnable() { | ||
@Override | ||
public void run() { | ||
try { | ||
doLayout(); | ||
} catch (Exception e) { | ||
Log.e(TAG, "An error occurs while layout a video", e); | ||
} | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.