-
Notifications
You must be signed in to change notification settings - Fork 155
/
OTPublisherLayout.java
64 lines (52 loc) · 2.38 KB
/
OTPublisherLayout.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.opentokreactnative;
import android.view.Gravity;
import android.widget.FrameLayout;
import android.opengl.GLSurfaceView;
import com.facebook.react.uimanager.ThemedReactContext;
import com.opentok.android.BaseVideoRenderer;
import com.opentok.android.Publisher;
import java.util.concurrent.ConcurrentHashMap;
/**
* Created by manik on 1/10/18.
*/
public class OTPublisherLayout extends FrameLayout{
public OTRN sharedState;
public OTPublisherLayout(ThemedReactContext reactContext) {
super(reactContext);
sharedState = OTRN.getSharedState();
}
public void createPublisherView(String publisherId) {
ConcurrentHashMap<String, Publisher> mPublishers = sharedState.getPublishers();
ConcurrentHashMap<String, String> androidOnTopMap = sharedState.getAndroidOnTopMap();
ConcurrentHashMap<String, String> androidZOrderMap = sharedState.getAndroidZOrderMap();
String pubOrSub = "";
String zOrder = "";
Publisher mPublisher = mPublishers.get(publisherId);
if (mPublisher != null) {
String sessionId = mPublisher.getSession().getSessionId();
if (sessionId != null) {
if (androidOnTopMap.get(sessionId) != null) {
pubOrSub = androidOnTopMap.get(sessionId);
}
if (androidZOrderMap.get(sessionId) != null) {
zOrder = androidZOrderMap.get(sessionId);
}
}
mPublisher.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE,
BaseVideoRenderer.STYLE_VIDEO_FILL);
FrameLayout mPublisherViewContainer = new FrameLayout(getContext());
if (pubOrSub.equals("publisher") && mPublisher.getView() instanceof GLSurfaceView) {
if (zOrder.equals("mediaOverlay")) {
((GLSurfaceView) mPublisher.getView()).setZOrderMediaOverlay(true);
} else {
((GLSurfaceView) mPublisher.getView()).setZOrderOnTop(true);
}
}
ConcurrentHashMap<String, FrameLayout> mPublisherViewContainers = sharedState.getPublisherViewContainers();
mPublisherViewContainers.put(publisherId, mPublisherViewContainer);
addView(mPublisherViewContainer, 0);
mPublisherViewContainer.addView(mPublisher.getView());
requestLayout();
}
}
}