1 /* 2 * Copyright (C) 2020 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.media.audiotestharness.client.grpc; 18 19 import com.android.media.audiotestharness.client.core.AudioCaptureStream; 20 import com.android.media.audiotestharness.proto.AudioTestHarnessGrpc; 21 22 import java.io.IOException; 23 24 /** {@link AudioCaptureStream} that utilizes gRPC as its transfer mechanism. */ 25 public class GrpcAudioCaptureStream extends AudioCaptureStream { 26 27 // TODO(b/168817017): Implement this class to utlize gRPC and Piped I/O streams to provide an 28 // InputStream from which the audio samples can be read. 29 30 private final AudioTestHarnessGrpc.AudioTestHarnessStub mAudioTestHarnessStub; 31 GrpcAudioCaptureStream(AudioTestHarnessGrpc.AudioTestHarnessStub audioTestHarnessStub)32 private GrpcAudioCaptureStream(AudioTestHarnessGrpc.AudioTestHarnessStub audioTestHarnessStub) { 33 mAudioTestHarnessStub = audioTestHarnessStub; 34 } 35 create( AudioTestHarnessGrpc.AudioTestHarnessStub audioTestHarnessStub)36 static GrpcAudioCaptureStream create( 37 AudioTestHarnessGrpc.AudioTestHarnessStub audioTestHarnessStub) { 38 return new GrpcAudioCaptureStream(audioTestHarnessStub); 39 } 40 41 @Override read(byte[] b)42 public int read(byte[] b) throws IOException { 43 return super.read(b); 44 } 45 46 @Override read(byte[] b, int off, int len)47 public int read(byte[] b, int off, int len) throws IOException { 48 return super.read(b, off, len); 49 } 50 51 @Override skip(long n)52 public long skip(long n) throws IOException { 53 return super.skip(n); 54 } 55 56 @Override available()57 public int available() throws IOException { 58 return super.available(); 59 } 60 61 @Override close()62 public void close() throws IOException { 63 super.close(); 64 } 65 66 @Override mark(int readlimit)67 public synchronized void mark(int readlimit) { 68 super.mark(readlimit); 69 } 70 71 @Override reset()72 public synchronized void reset() throws IOException { 73 super.reset(); 74 } 75 76 @Override markSupported()77 public boolean markSupported() { 78 return super.markSupported(); 79 } 80 81 @Override read()82 public int read() throws IOException { 83 return 0; 84 } 85 } 86