public class FrameData {
public byte[] data;
public long timestamp;
public FrameData(byte[] data, long timestamp) {
this.data = data;
this.timestamp = timestamp;
}
}
2)在摄像头的预览回调中添加时间戳:
camera.setPreviewCallback(new Camera.PreviewCallback() {
@Override
public void onPreviewFrame(byte[] data, Camera camera) {
long timestamp = System.nanoTime();
// 处理视频帧数据和时间戳
FrameData frameData = new FrameData(data, timestamp);
// 将 frameData 传递给编码器和传输模块
}
});
3)在 AudioRecord 的录音循环中添加时间戳:
while (isRecording) {
long timestamp = System.nanoTime();
int bytesRead = audioRecord.read(buffer, 0, bufferSize);
// 处理音频帧数据和时间戳
FrameData frameData = new FrameData(Arrays.copyOf(buffer, bytesRead), timestamp);
// 将 frameData 传递给编码器和传输模块
}