미디어 파일을 읽는 대신 사용자 지정 입력 버퍼에서 읽는 IContainer 개체를 열려고합니다. 이 사용자 정의 입력 버퍼의 구현은 다음과 같습니다.IContainer.open()에서 사용자 ByteChannel을 사용하여 읽을 때 오류가 발생합니다.
컨테이너를 만들고 여는 코드는 다음과 같습니다.
// Open up the container for READING
mInputCStore = new CStore();
IContainerFormat format = IContainerFormat.make();
if (format.setInputFormat("flv") < 0) {
throw new IllegalArgumentException("Failed to initialize the input format");
}
// Open up the container
mInputContainer = IContainer.make();
int retval = mInputContainer.open(mPlaybackContainerStore, IContainer.Type.READ, format);
if (retval < 0) {
// This little trick converts the non friendly integer return value into
// a slightly more friendly object to get a human-readable error name
IError error = IError.make(retval);
throw new IllegalArgumentException("could not open input container: " + mPlaybackContainerStore + "; Error: " + error.getDescription());
}
그 말을 예외를 던지는 위의 코드는 - 컨테이너에 쓰기가 성공적으로 작동하는 동안
Exception in thread "main" java.lang.IllegalArgumentException: could not open input container: [email protected]; Error: Operation not permitted
같은 맞춤 버퍼 사용하는 경우. 누군가가 내가 READ 모드에서 그것을 사용하는 한 맞춤 버퍼 구현에서 누락 된 부분을 이해하는 데 도움을 줄 수 있으며 왜 실패 이유가 무엇입니까?
package test;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.ByteChannel;
import java.util.concurrent.ConcurrentLinkedQueue;
public class CStore implements ByteChannel {
private ConcurrentLinkedQueue<DataChunk> mChunkQueue = null;
private int mQueueSize = 0;
// constructor
public CStore(String type) {
mQueueSize = 0;
mChunkQueue = new ConcurrentLinkedQueue<DataChunk>();
mChunkQueue.clear();
}
@Override
public void close() throws IOException {
return;
}
@Override
public boolean isOpen() {
return false;
}
@Override
public int write(ByteBuffer buffer) throws IOException {
DataChunk chunk = new DataChunk(buffer);
mChunkQueue.add(chunk);
mQueueSize += chunk.getLength();
return 0;
}
public int read(ByteBuffer buffer) throws IOException {
int result = 0;
DataChunk chunk = mChunkQueue.poll();
if (chunk != null) {
buffer = chunk.getBuffer();
if (buffer != null) {
result = 0;
} else {
result = 1;
}
}
return result;
}
}
누군가이 문제를 해결할 수 있도록 도와 줄 수 있습니까? 이 접근법이 맞습니까? – AnilJ