|
|
@ -3,12 +3,14 @@ package org.easydarwin.push;
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.app.Application;
|
|
|
|
import android.app.Application;
|
|
|
|
import android.app.Service;
|
|
|
|
import android.app.Service;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.lifecycle.Lifecycle;
|
|
|
|
import androidx.lifecycle.Lifecycle;
|
|
|
|
import androidx.lifecycle.LifecycleObserver;
|
|
|
|
import androidx.lifecycle.LifecycleObserver;
|
|
|
|
import androidx.lifecycle.LifecycleOwner;
|
|
|
|
import androidx.lifecycle.LifecycleOwner;
|
|
|
|
import androidx.lifecycle.LiveData;
|
|
|
|
import androidx.lifecycle.LiveData;
|
|
|
|
import androidx.lifecycle.Observer;
|
|
|
|
import androidx.lifecycle.Observer;
|
|
|
|
import androidx.lifecycle.OnLifecycleEvent;
|
|
|
|
import androidx.lifecycle.OnLifecycleEvent;
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.ComponentName;
|
|
|
|
import android.content.ComponentName;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.Intent;
|
|
|
@ -30,9 +32,11 @@ import android.os.HandlerThread;
|
|
|
|
import android.os.IBinder;
|
|
|
|
import android.os.IBinder;
|
|
|
|
import android.os.Process;
|
|
|
|
import android.os.Process;
|
|
|
|
import android.preference.PreferenceManager;
|
|
|
|
import android.preference.PreferenceManager;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.annotation.MainThread;
|
|
|
|
import androidx.annotation.MainThread;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.annotation.Nullable;
|
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
|
import androidx.core.app.ActivityCompat;
|
|
|
|
|
|
|
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.Surface;
|
|
|
|
import android.view.Surface;
|
|
|
@ -186,6 +190,7 @@ public class MediaStream extends Service implements LifecycleObserver {
|
|
|
|
boolean hevcEncode = false;
|
|
|
|
boolean hevcEncode = false;
|
|
|
|
public String mime = "";
|
|
|
|
public String mime = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public CodecInfo info = new CodecInfo();
|
|
|
|
public CodecInfo info = new CodecInfo();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -403,32 +408,30 @@ public class MediaStream extends Service implements LifecycleObserver {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void onPreviewFrame2(byte[] data, Object camera) {
|
|
|
|
public void onPreviewFrame2(byte[] data, Object camera) {
|
|
|
|
|
|
|
|
boolean enableOverlay = PreferenceManager.getDefaultSharedPreferences(mApplicationContext).getBoolean("key_enable_video_overlay", true);
|
|
|
|
if (camera instanceof Camera) {
|
|
|
|
if (camera instanceof Camera) {
|
|
|
|
if (PreferenceManager.getDefaultSharedPreferences(mApplicationContext).getBoolean("key_enable_video_overlay", true)) {
|
|
|
|
|
|
|
|
overlay.javaOverlay(data, "EasyPusher");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mDgree == 0) {
|
|
|
|
|
|
|
|
Camera.CameraInfo camInfo = new Camera.CameraInfo();
|
|
|
|
Camera.CameraInfo camInfo = new Camera.CameraInfo();
|
|
|
|
Camera.getCameraInfo(mCameraId, camInfo);
|
|
|
|
Camera.getCameraInfo(mCameraId, camInfo);
|
|
|
|
int cameraRotationOffset = camInfo.orientation;
|
|
|
|
int cameraRotationOffset = camInfo.orientation;
|
|
|
|
|
|
|
|
if (enableOverlay) {
|
|
|
|
|
|
|
|
overlay.javaOverlay(data, width, height, cameraRotationOffset, "EasyPusher");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mDgree == 0) {
|
|
|
|
if (cameraRotationOffset % 180 != 0) {
|
|
|
|
if (cameraRotationOffset % 180 != 0) {
|
|
|
|
yuvRotate(data, 1, width, height, cameraRotationOffset);
|
|
|
|
yuvRotate(data, 1, width, height, cameraRotationOffset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
save2file(data, String.format("/sdcard/yuv_%d_%d.yuv", height, width));
|
|
|
|
save2file(data, String.format("/sdcard/yuv_%d_%d.yuv", height, width));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (PreferenceManager.getDefaultSharedPreferences(mApplicationContext).getBoolean("key_enable_video_overlay", true)) {
|
|
|
|
if (enableOverlay) {
|
|
|
|
String txt;// = String.format("drawtext=fontfile=" + mApplicationContext.getFileStreamPath("SIMYOU.ttf") + ": text='%s%s':x=(w-text_w)/2:y=H-60 :fontcolor=white :box=1:boxcolor=0x00000000@0.3", "EasyPusher", new SimpleDateFormat("yyyy-MM-ddHHmmss").format(new Date()));
|
|
|
|
String txt = "EasyPusher " + new SimpleDateFormat("yy-MM-dd HH:mm:ss SSS").format(new Date());
|
|
|
|
txt = "EasyPusher " + new SimpleDateFormat("yy-MM-dd HH:mm:ss SSS").format(new Date());
|
|
|
|
|
|
|
|
overlay.overlay(data, txt);
|
|
|
|
overlay.overlay(data, txt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mVC.onVideo(data, NV21);
|
|
|
|
mVC.onVideo(data, NV21);
|
|
|
|
mCamera.addCallbackBuffer(data);
|
|
|
|
mCamera.addCallbackBuffer(data);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (PreferenceManager.getDefaultSharedPreferences(mApplicationContext).getBoolean("key_enable_video_overlay", true)) {
|
|
|
|
if (enableOverlay) {
|
|
|
|
String txt;// = String.format("drawtext=fontfile=" + mApplicationContext.getFileStreamPath("SIMYOU.ttf") + ": text='%s%s':x=(w-text_w)/2:y=H-60 :fontcolor=white :box=1:boxcolor=0x00000000@0.3", "EasyPusher", new SimpleDateFormat("yyyy-MM-ddHHmmss").format(new Date()));
|
|
|
|
String txt = "EasyPusher " + new SimpleDateFormat("yy-MM-dd HH:mm:ss SSS").format(new Date());
|
|
|
|
txt = "EasyPusher " + new SimpleDateFormat("yy-MM-dd HH:mm:ss SSS").format(new Date());
|
|
|
|
overlay.javaOverlay(data, width, height, 0, txt);
|
|
|
|
overlay.javaOverlay(data, txt);
|
|
|
|
|
|
|
|
overlay.overlay(data, txt);
|
|
|
|
overlay.overlay(data, txt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mVC.onVideo(data, NV21);
|
|
|
|
mVC.onVideo(data, NV21);
|
|
|
@ -989,7 +992,6 @@ public class MediaStream extends Service implements LifecycleObserver {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param cameraId 0表示后置,1表示前置,2表示uvc摄像头,-1表示默认切换(比如前后置来回切换.).在非-1的情况下,如果没有ID对应的摄像头,则也会作默认切换.
|
|
|
|
* @param cameraId 0表示后置,1表示前置,2表示uvc摄像头,-1表示默认切换(比如前后置来回切换.).在非-1的情况下,如果没有ID对应的摄像头,则也会作默认切换.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public Publisher<Object> switchCamera(final int cameraId) {
|
|
|
|
public Publisher<Object> switchCamera(final int cameraId) {
|
|
|
@ -1245,7 +1247,6 @@ public class MediaStream extends Service implements LifecycleObserver {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static ArrayList<CodecInfo> listEncoders(String mime) {
|
|
|
|
public static ArrayList<CodecInfo> listEncoders(String mime) {
|
|
|
|
// 可能有多个编码库,都获取一下。。。
|
|
|
|
// 可能有多个编码库,都获取一下。。。
|
|
|
|
ArrayList<CodecInfo> codecInfos = new ArrayList<CodecInfo>();
|
|
|
|
ArrayList<CodecInfo> codecInfos = new ArrayList<CodecInfo>();
|
|
|
|