[+] Camera2拍照

This commit is contained in:
acgist
2023-04-15 01:16:08 +08:00
parent ce0afef889
commit 24d849cde0
17 changed files with 565 additions and 364 deletions

View File

@@ -121,12 +121,11 @@ public class MainActivity extends AppCompatActivity implements Serializable {
final Resources resources = this.getResources();
MediaManager.getInstance().initContext(
this.mainHandler, this.getApplicationContext(),
resources.getBoolean(R.bool.playAudio),
resources.getBoolean(R.bool.playVideo),
resources.getBoolean(R.bool.audioConsume),
resources.getBoolean(R.bool.videoConsume),
resources.getBoolean(R.bool.audioProduce),
resources.getBoolean(R.bool.videoProduce),
resources.getInteger(R.integer.imageQuantity),
resources.getString(R.string.audioQuantity),
resources.getString(R.string.videoQuantity),
resources.getInteger(R.integer.channelCount),
resources.getInteger(R.integer.iFrameInterval),
resources.getString(R.string.storagePathImage),
resources.getString(R.string.storagePathVideo),
TransportType.valueOf(resources.getString(R.string.transportType))

View File

@@ -1,8 +1,7 @@
package com.acgist.taoyao.client.signal;
import android.Manifest;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.location.Criteria;
import android.location.Location;
@@ -16,8 +15,6 @@ import android.os.PowerManager;
import android.os.Process;
import android.util.Log;
import androidx.core.app.ActivityCompat;
import com.acgist.taoyao.boot.model.Header;
import com.acgist.taoyao.boot.model.Message;
import com.acgist.taoyao.boot.utils.CloseableUtils;
@@ -728,12 +725,15 @@ public final class Taoyao implements ITaoyao {
key, password,
this, this.mainHandler,
resources.getBoolean(R.bool.preview),
resources.getBoolean(R.bool.playAudio),
resources.getBoolean(R.bool.playVideo),
resources.getBoolean(R.bool.dataConsume),
resources.getBoolean(R.bool.audioConsume),
resources.getBoolean(R.bool.videoConsume),
resources.getBoolean(R.bool.audioProduce),
resources.getBoolean(R.bool.dataProduce),
resources.getBoolean(R.bool.videoProduce)
resources.getBoolean(R.bool.videoProduce),
this.mediaManager.getMediaProperties()
)
);
final boolean success = room.enter();
@@ -783,7 +783,20 @@ public final class Taoyao implements ITaoyao {
final String name = MapUtils.get(body, "name");
final String clientId = MapUtils.get(body, "clientId");
final String sessionId = MapUtils.get(body, "sessionId");
final SessionClient sessionClient = new SessionClient(sessionId, name, clientId, this, this.mainHandler);
final Resources resources = this.context.getResources();
final SessionClient sessionClient = new SessionClient(
sessionId, name, clientId, this, this.mainHandler,
resources.getBoolean(R.bool.preview),
resources.getBoolean(R.bool.playAudio),
resources.getBoolean(R.bool.playVideo),
resources.getBoolean(R.bool.dataConsume),
resources.getBoolean(R.bool.audioConsume),
resources.getBoolean(R.bool.videoConsume),
resources.getBoolean(R.bool.audioProduce),
resources.getBoolean(R.bool.dataProduce),
resources.getBoolean(R.bool.videoProduce),
this.mediaManager.getMediaProperties()
);
this.sessionClients.put(sessionId, sessionClient);
sessionClient.init();
sessionClient.offer();
@@ -884,16 +897,11 @@ public final class Taoyao implements ITaoyao {
/**
* @return 位置
*/
@SuppressLint("MissingPermission")
private Location location() {
if (this.locationManager == null) {
return null;
}
if (
ActivityCompat.checkSelfPermission(this.context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(this.context, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED
) {
return null;
}
final Criteria criteria = new Criteria();
criteria.setCostAllowed(false);
criteria.setBearingRequired(false);

View File

@@ -34,5 +34,8 @@
<!-- 媒体配置:是否生产视频 -->
<bool name="videoProduce">true</bool>
<integer name="imageQuantity">100</integer>
<string name="audioQuantity">fd-audio</string>
<string name="videoQuantity">fd-video</string>
<integer name="channelCount">1</integer>
<integer name="iFrameInterval">1</integer>
</resources>