大佬教程收集整理的这篇文章主要介绍了公开共享自定义图像 FAMILY,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我可以从文档中看到如何Sharing custom images publicly,但似乎不可能授予公众访问所有图像或按家庭访问权限。
看起来应该可以,但没有用:
gcloud projects add-iam-policy-binding project-ID \
--member 'allAuthenticatedUsers' --role 'roles/compute.imageUser'
就我而言,我想专门为我们的客户创建一个跨 GCP 平台共享图像的项目,而无需添加每个人。
您问题中的命令正在尝试向项目授予
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaFormat;
import android.util.Log;
import java.io.IOException;
import java.nio.byteBuffer;
import java.util.LinkedList;
import java.util.Queue;
import java.util.UUID;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
public class AACDecoder {
private static final String TAG = "AACDecoder";
privatE int KEY_CHAnnEL_COUNT = 2;
privatE int KEY_SAMPLE_RATE = 16000;
privatE int KEY_BIT_RATE = 64000;
private MediaCodec mDecoder;
private AtomicReference<AudioMixPlayer> m_mixPlayer = new AtomicReference<>(null);
/**
* set android audio player
*/
public void setAudioMixPlayer(AudioMixPlayer audioMixPlayer) {
Log.d(tag,"AACDecoder setAudioMixPlayer: " + audioMixPlayer);
this.m_mixPlayer.set(audioMixPlayer);
}
privatE int freqIdx = 0xb;
private Queue<byte[]> m_aacDataQueue = new ConcurrentLinkedQueue<>();
private Queue<Object> m_sourceQueue = new LinkedList<>();
private AtomicBoolean m_threadRunning = new AtomicBoolean(false);
private AACThread m_aacDecodeThread;
private String name;
public AACDecoder() {
this.name = UUID.randomUUID().toString().replace("-","");
}
/**
* Init API
*/
public void initCodec() {
this.initCodec(16000,1,256000);
}
protected void initCodec(int sampleRate,int chAnnelCount,int bitRatE) {
KEY_CHAnnEL_COUNT = chAnnelCount;
KEY_SAMPLE_RATE = sampleRate;
KEY_BIT_RATE = bitRate;
switch (sampleRatE) {
case 96000:
freqIdx = 0x00;
break;
case 88200:
freqIdx = 0x01;
break;
case 64000:
freqIdx = 0x02;
break;
case 48000:
freqIdx = 0x03;
break;
case 44100:
freqIdx = 0x04;
break;
case 32000:
freqIdx = 0x05;
break;
case 24000:
freqIdx = 0x06;
break;
case 22050:
freqIdx = 0x07;
break;
case 16000:
freqIdx = 0x08;
break;
case 12000:
freqIdx = 0x09;
break;
case 11025:
freqIdx = 0x0a;
break;
case 8000:
freqIdx = 0x0b;
break;
case 7350:
freqIdx = 0x0c;
break;
}
prepare();
m_aacDecodeThread = new AACThread();
m_threadRunning.set(true);
m_aacDecodeThread.start();
}
private Boolean prepare() {
try {
String mine = "audio/mp4a-latm";
mDecoder = MediaCodec.createDecoderByType(minE);
MediaFormat mediaFormat = new MediaFormat();
mediaFormat.setString(MediaFormat.KEY_MIME,minE);
mediaFormat.setInteger(MediaFormat.KEY_CHAnnEL_COUNT,KEY_CHAnnEL_COUNT);
mediaFormat.setInteger(MediaFormat.KEY_SAMPLE_RATE,KEY_SAMPLE_RATE);
mediaFormat.setInteger(MediaFormat.KEY_BIT_RATE,KEY_BIT_RATE);
mediaFormat.setInteger(MediaFormat.KEY_IS_ADTS,1);
mediaFormat.setInteger(MediaFormat.KEY_AAC_PROFILE,MediaCodecInfo.CodecProfileLevel.AACObjectLC);
ByteBuffer csd = ByteBuffer.allocate(2);
csd.put(0,(bytE) (MediaCodecInfo.CodecProfileLevel.AACObjectLC << 3 | freqIdx >> 1));
csd.put(1,(bytE) ((freqIdx & 0x01) << 7 | KEY_CHAnnEL_COUNT << 3));
mediaFormat.setByteBuffer("csd-0",csd);
mDecoder.configure(mediaFormat,null,0);
Log.d(tag,"initCodec: " + mDecoder.getName());
} catch (IOException E) {
Log.e(tag,"Audio decode init error ",E);
return false;
}
if (mDecoder == null) {
return false;
}
mDecoder.start();
return true;
}
/**
* Decode API
*/
public void decode(int source,byte[] buf,int offset,int length) {
m_sourceQueue.add(sourcE);
m_aacDataQueue.add(buf);
Log.d(tag,"enqueue m_sourceQueue.size:" + m_sourceQueue.size() + " m_aacDataQueue.size:" + m_aacDataQueue.size() + " m_sourceQueue++ m_aacDataQueue++");
}
private void decodeAAC(byte[] buf,int length) {
long kTimeOutUs = 0;
try {
Boolean in = false;
for (int triedTime = 1; triedTime <= 3; triedTime++) {
int inputBufIndex = mDecoder.dequeueInputBuffer(kTimeOutUs);
if (inputBufIndex >= 0) {
ByteBuffer dstBuf = mDecoder.geTinputBuffer(inputBufIndeX);//codecInputBuffers[inputBufIndex];
if (dstBuf != null) {
dstBuf.clear();
dstBuf.put(buf,offset,length);
mDecoder.queueInputBuffer(inputBufIndex,length,0);
in = true;
Log.d(tag,name + "》 Input success m_sourceQueue.size:" + m_sourceQueue.size() + " m_aacDataQueue.size" + m_aacDataQueue.size() + " inputBufIndex:" + inputBufIndeX);
break;
}
}
}
if (!in) {
m_sourceQueue.poll();
Log.d(tag,name + "》 try 3 time but failed. poll one source. m_source m_sourceQueue.size:" + m_sourceQueue.size() + " m_aacDataQueue.size" + m_aacDataQueue.size() + " m_sourceQueue--");
}
} catch (Exception E) {
Log.e(tag,"Audio decode error ",E);
}
}
private void pollDecoderResult() {
long kTimeOutUs = 0;
MediaCodec.bufferInfo info = new MediaCodec.bufferInfo();
int outputBufferIndex = mDecoder.dequeueOutputBuffer(info,kTimeOutUs);
Log.d(tag,name + "》 m_sourceQueue.size:" + m_sourceQueue.size() + " m_aacDataQueue.size" + m_aacDataQueue.size() + " try to pollDecoderResult " + info.size + " " + info.offset + " " + info.presentationTimeUs + " " + info.flags + " outputBufferIndex" + outputBufferIndeX);
while (outputBufferIndex >= 0) {
ByteBuffer outputBuffer = mDecoder.getOutputBuffer(outputBufferIndeX);
byte[] outData = new byte[info.size];
if (outputBuffer != null) {
outputBuffer.get(outData);
Object source = m_sourceQueue.poll();
Log.d(tag,name + "》after pollDecoderResult m_sourceQueue.size:" + m_sourceQueue.size() + " m_aacDataQueue.size:" + m_aacDataQueue.size() + " outputBuffer.remaining:" + outputBuffer.remaining() + " m_sourceQueue--");
AudioMixPlayer mixPlayer = this.m_mixPlayer.get();
Log.d(tag,name + "》to addPcmFrame" + source + " length:" + outData.length);
// play sound
if (mixPlayer != null) {
mixPlayer.addPcmFrame(source,outData);
}
mDecoder.releaseOutputBuffer(outputBufferIndex,falsE);
outputBuffer.clear();
}
info = new MediaCodec.bufferInfo();
outputBufferIndex = mDecoder.dequeueOutputBuffer(info,kTimeOutUs);
}
}
/**
* release API
*/
public void release() {
try {
m_threadRunning.set(false);
m_aacDecodeThread.join();
if (mDecoder != null) {
mDecoder.stop();
mDecoder.release();
}
m_mixPlayer.set(null);
} catch (Exception E) {
Log.d(tag,"release error",E);
}
}
private class AACThread extends Thread {
//继承Thread类,并改写其run方法
private final static String TAG = "AACDecodeThread";
private ThreadSleeper sleeper = new ThreadSleeper(32,TAG); // sleep 32 millis
public void run() {
Log.d(tag,"AAC decode thread start");
while (m_threadRunning.get()) {
try {
sleeper.sleep(); // sleep 32 millis
byte[] aacData = null;
if (!m_aacDataQueue.isEmpty()) {
aacData = m_aacDataQueue.poll();
Log.d(tag,name + "》m_sourceQueue.size:" + m_sourceQueue.size() + " m_aacDataQueue.size:" + m_aacDataQueue.size() + " m_aacDataQueue--");
}
if (aacData != null) {
decodeAAC(aacData,aacData.length);
}
pollDecoderResult();
} catch (InterruptedException E) {
Log.e(tag,"AAC decode thread error",E);
sleeper.reset();
}
}
Log.d(tag,"AAC decode thread stop");
}
}
}
的权限 roles/compute.imageUser
。不支持该特定授权。
改为授予对资源的权限。使用以下命令:
allAuthenticatedUsers
gcloud compute images add-iam-policy-binding
以上是大佬教程为你收集整理的公开共享自定义图像 FAMILY全部内容,希望文章能够帮你解决公开共享自定义图像 FAMILY所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。