Skip to content

Commit

Permalink
Merge pull request #131 from lgcast-dev/master
Browse files Browse the repository at this point in the history
Disabled ScreenMirroring support for 32bit devices
  • Loading branch information
jonghenhan authored Jul 4, 2022
2 parents dd1e1f0 + 68c766e commit 3e608e7
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
Binary file removed jniLibs/armeabi-v7a/libc++_shared.so
Binary file not shown.
Binary file removed jniLibs/armeabi-v7a/libgstreamer-appcast.so
Binary file not shown.
Binary file removed jniLibs/armeabi-v7a/libgstreamer_android.so
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ public static class Video {
public static final String CODEC = "H264";
public static final int CLOCK_RATE = 90000;
public static final int FRAMERATE = 60;
public static final int BITRATE = 6 * 1024 * 1024;
public static final int BITRATE_1MB = 1500000; // 1.5 * 1024 * 1024 (1,572,864)
public static final int BITRATE_4MB = 4000000; // 4.0 * 1024 * 1024 (4,194,304)
public static final int BITRATE_6MB = 6000000; // 6.0 * 1024 * 1024 (6,291,456)

public static final int DEFAULT_WIDTH = 1920;
public static final int DEFAULT_HEIGHT = 1080;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@
import android.content.Context;
import android.content.Intent;
import android.hardware.display.DisplayManager;
import android.os.Build;
import android.view.Display;
import com.connectsdk.service.capability.ScreenMirroringControl;
import com.connectsdk.service.capability.ScreenMirroringControl.ScreenMirroringError;
import com.connectsdk.service.capability.ScreenMirroringControl.ScreenMirroringErrorListener;
import com.connectsdk.service.capability.ScreenMirroringControl.ScreenMirroringStartListener;
import com.connectsdk.service.capability.ScreenMirroringControl.ScreenMirroringStopListener;
import com.connectsdk.service.webos.lgcast.common.utils.DeviceUtil;
import com.connectsdk.service.webos.lgcast.common.utils.LocalBroadcastEx;
import com.connectsdk.service.webos.lgcast.common.utils.Logger;
import com.connectsdk.service.webos.lgcast.screenmirroring.ScreenMirroringConfig;
Expand Down Expand Up @@ -58,6 +60,7 @@ public void startMirroring(Context context, Intent projectionData, String device
if (context == null || projectionData == null || deviceIpAddress == null) throw new Exception("Invalid arguments");
if (ScreenMirroringControl.isCompatibleOsVersion() == false) throw new Exception("Incompatible OS version");
if (ScreenMirroringControl.isRunning(context) == true) throw new Exception("Screen Mirroring is ALREADY running");
if (DeviceUtil.getProcessorBits() != 64) throw new Exception("Invalid Application Binary Interface");

mLocalBroadcastEx.registerOnce(context, MirroringServiceIF.ACTION_NOTIFY_PAIRING, intent -> {
if (startListener != null) startListener.onPairing();
Expand All @@ -76,6 +79,7 @@ public void startMirroring(Context context, Intent projectionData, String device
Logger.debug("Request start");
MirroringServiceIF.requestStart(context, projectionData, deviceIpAddress, secondScreenClass != null);
} catch (Exception e) {
Logger.error(e);
if (startListener != null) startListener.onStart(false, null);
}
}
Expand All @@ -102,6 +106,7 @@ public void stopMirroring(Context context, ScreenMirroringStopListener stopListe
Logger.debug("Request stop");
MirroringServiceIF.requestStop(context);
} catch (Exception e) {
Logger.error(e);
if (stopListener != null) stopListener.onStop(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.connectsdk.service.webos.lgcast.common.connection.MobileDescription;
import com.connectsdk.service.webos.lgcast.common.streaming.RTPStreaming;
import com.connectsdk.service.webos.lgcast.common.utils.AppUtil;
import com.connectsdk.service.webos.lgcast.common.utils.DeviceUtil;
import com.connectsdk.service.webos.lgcast.common.utils.HandlerThreadEx;
import com.connectsdk.service.webos.lgcast.common.utils.IOUtil;
import com.connectsdk.service.webos.lgcast.common.utils.Logger;
Expand All @@ -33,8 +34,8 @@
import com.connectsdk.service.webos.lgcast.screenmirroring.uibc.UibcAccessibilityService;
import com.lge.lib.lgcast.iface.AudioCaptureIF;
import com.lge.lib.lgcast.iface.CaptureStatus;
import com.lge.lib.lgcast.iface.VideoCaptureIF;
import com.lge.lib.lgcast.iface.MasterKeyFactoryIF;
import com.lge.lib.lgcast.iface.VideoCaptureIF;
import org.json.JSONObject;

public class MirroringService extends Service {
Expand Down Expand Up @@ -327,11 +328,21 @@ private boolean startCaptureAndStreaming(Intent intent) {
Logger.print("startCaptureAndStreaming");

try {
Point captureSizeInLandscape = MirroringServiceFunc.getCaptureSizeInLandscape(this);
int width = captureSizeInLandscape.x;
int height = captureSizeInLandscape.y;
int bitrate = ScreenMirroringConfig.Video.BITRATE_6MB;

float totalMemoryGB = DeviceUtil.getTotalMemorySpace(this) / 1024F / 1024F / 1024F;
if (totalMemoryGB <= 3.0) bitrate = ScreenMirroringConfig.Video.BITRATE_1MB;
else if (totalMemoryGB <= 4.0) bitrate = ScreenMirroringConfig.Video.BITRATE_4MB;
Logger.error("### width=%d, height=%d, totalMemory=%f, bitrate=%d ###", width, height, totalMemoryGB, bitrate);

mMediaProjection = MirroringServiceFunc.getMediaProjection(this, intent);
if (mMediaProjection == null) throw new Exception("Invalid projection");

mRTPStreaming = new RTPStreaming();
mRTPStreaming.setStreamingConfig(MirroringServiceFunc.createRtpVideoConfig(ScreenMirroringConfig.Video.BITRATE), MirroringServiceFunc.createRtpAudioConfig(), MirroringServiceFunc.createRtpSecurityConfig(mMirroringSourceCapability.masterKeys));
mRTPStreaming.setStreamingConfig(MirroringServiceFunc.createRtpVideoConfig(bitrate), MirroringServiceFunc.createRtpAudioConfig(), MirroringServiceFunc.createRtpSecurityConfig(mMirroringSourceCapability.masterKeys));
mRTPStreaming.open(this, ScreenMirroringConfig.RTP.SSRC, mMirroringSinkCapability.ipAddress, mMirroringSinkCapability.videoUdpPort, mMirroringSinkCapability.audioUdpPort);

if (ScreenMirroringConfig.Test.testMkiUpdate == true) {
Expand All @@ -345,19 +356,16 @@ private boolean startCaptureAndStreaming(Intent intent) {
mAudioCapture.setErrorListener(this::stop);
mAudioCapture.startCapture(mMediaProjection, mRTPStreaming.getAudioStreamHandler());

Point captureSizeInLandscape = MirroringServiceFunc.getCaptureSizeInLandscape(this);
Logger.debug("captureSizeInLandscape.x=%d, captureSizeInLandscape.y=%d", captureSizeInLandscape.x, captureSizeInLandscape.y);

mLandscapeVideoCapture = new VideoCaptureIF("land");
mLandscapeVideoCapture.setErrorListener(this::stop);
mLandscapeVideoCapture.prepare(captureSizeInLandscape.x, captureSizeInLandscape.y, ScreenMirroringConfig.Video.BITRATE, mMediaProjection, mRTPStreaming.getVideoStreamHandler());
mLandscapeVideoCapture.prepare(width, height, bitrate, mMediaProjection, mRTPStreaming.getVideoStreamHandler());

mPortraitVideoCapture = new VideoCaptureIF("port");
mPortraitVideoCapture.setErrorListener(this::stop);

if (MirroringServiceFunc.isDualScreen(intent) == false) {
Logger.debug("Prepare portrait capture");
mPortraitVideoCapture.prepare(captureSizeInLandscape.y, captureSizeInLandscape.x, ScreenMirroringConfig.Video.BITRATE, mMediaProjection, mRTPStreaming.getVideoStreamHandler());
mPortraitVideoCapture.prepare(height, width, bitrate, mMediaProjection, mRTPStreaming.getVideoStreamHandler());
}

if (mMirroringSinkCapability.isDisplayPortrait() == true) mPortraitVideoCapture.start();
Expand Down

0 comments on commit 3e608e7

Please sign in to comment.