Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/channelrecord'
Browse files Browse the repository at this point in the history
  • Loading branch information
bear101 committed Feb 17, 2020
2 parents 44d4b0f + 74cb5a3 commit 0a7375f
Showing 1 changed file with 36 additions and 5 deletions.
41 changes: 36 additions & 5 deletions Library/TeamTalkJNI/test/dk/bearware/TeamTalkTestCase.java
Expand Up @@ -1026,14 +1026,15 @@ public void test_RecordMultipleChannels() {
makeUserAccount(NICKNAME, USERNAME, PASSWORD, USERRIGHTS);

Vector<TeamTalkBase> clients = new Vector<>();
int[] txintervalsMSec = {40, 100, 250, 500};
for (int i=0;i<4;++i) {

TeamTalkBase ttclient1 = newClientInstance(), ttclient2 = newClientInstance();
clients.add(ttclient1);
clients.add(ttclient2);
assertTrue("tone1", ttclient1.DBG_SetSoundInputTone(StreamType.STREAMTYPE_VOICE, 400));
assertTrue("tone2", ttclient2.DBG_SetSoundInputTone(StreamType.STREAMTYPE_VOICE, 800));

connect(ttclient1);
connect(ttclient2);
initSound(ttclient1);
Expand All @@ -1044,7 +1045,8 @@ public void test_RecordMultipleChannels() {
login(ttclient1, NICKNAME + "#" + ttclient1.getMyUserID(), USERNAME, PASSWORD);
login(ttclient2, NICKNAME + "#" + ttclient2.getMyUserID(), USERNAME, PASSWORD);

Channel chan = buildDefaultChannel(ttclient1, "Opus" + ttclient1.getMyUserID());
Channel chan = buildDefaultChannel(ttclient1, "Opus" + ttclient1.getMyUserID(), Codec.OPUS_CODEC);
chan.audiocodec.opus.nTxIntervalMSec = txintervalsMSec[i];
assertTrue("join1", waitCmdSuccess(ttclient1, ttclient1.doJoinChannel(chan), DEF_WAIT));

assertTrue("join2", waitCmdSuccess(ttclient2, ttclient2.doJoinChannelByID(ttclient1.getMyChannelID(), ""), DEF_WAIT));
Expand All @@ -1059,13 +1061,24 @@ public void test_RecordMultipleChannels() {
assertTrue("Intercept", waitCmdSuccess(ttadmin, ttadmin.doSubscribe(ttclient.getMyUserID(), Subscription.SUBSCRIBE_INTERCEPT_VOICE), DEF_WAIT));
}

Vector<String> filenames = new Vector<>();
Vector<Integer> cbintervalMSec = new Vector<>();
for (int i=0;i<clients.size();i+=2) {
Channel chan = new Channel();
TeamTalkBase ttclient = clients.elementAt(i);
assertTrue("get channel", ttclient.getChannel(ttclient.getMyChannelID(), chan));
assertTrue("Record mux", ttadmin.startRecordingMuxedAudioFile(ttclient.getMyChannelID(), "MuxedRecording-" + chan.szName + ".wav", AudioFileFormat.AFF_WAVE_FORMAT));
String filename = "MuxedRecording-" + chan.szName + ".wav";
filenames.add(filename);
cbintervalMSec.add(chan.audiocodec.opus.nTxIntervalMSec);
assertTrue("Record mux", ttadmin.startRecordingMuxedAudioFile(ttclient.getMyChannelID(), filename, AudioFileFormat.AFF_WAVE_FORMAT));
}

String rootfilename = "MuxedRecording-Root-Channel.wav";
filenames.add(rootfilename);
assertTrue("Record mux", ttadmin.startRecordingMuxedAudioFile(ttadmin.getRootChannelID(), rootfilename, AudioFileFormat.AFF_WAVE_FORMAT));

long starttime = System.currentTimeMillis();

waitForEvent(ttadmin, ClientEvent.CLIENTEVENT_NONE, 1000);

for (int i=0;i<clients.size();i+=2) {
Expand All @@ -1081,19 +1094,37 @@ public void test_RecordMultipleChannels() {
}

waitForEvent(ttadmin, ClientEvent.CLIENTEVENT_NONE, 1000);

for (int i=1;i<clients.size();i+=2) {
TeamTalkBase ttclient = clients.elementAt(i);
assertTrue("enable tone", ttclient.enableVoiceTransmission(true));
}

waitForEvent(ttadmin, ClientEvent.CLIENTEVENT_NONE, 3000);

long duration = System.currentTimeMillis() - starttime;
for (int i=0;i<clients.size();i+=2) {
Channel chan = new Channel();
TeamTalkBase ttclient = clients.elementAt(i);
assertTrue("Stop Record mux", ttadmin.stopRecordingMuxedAudioFile(ttclient.getMyChannelID()));
}

assertTrue("Stop Record root mux", ttadmin.stopRecordingMuxedAudioFile(ttadmin.getRootChannelID()));

int i=0;
for (String filename : filenames) {
MediaFileInfo mfi = new MediaFileInfo();
assertTrue("Open media file " + filename, ttadmin.getMediaFileInfo(filename, mfi));
// callbacks from sound input device may not have
// completed when file was closed, so put in a
// tolerance. This is not a very precise way of testing
// the duration of the files, but at least they should be
// somewhere near the duration of the recording.
int tolerance = cbintervalMSec.elementAt(i) * 2;
assertTrue(String.format("Media file %s duration is %d, must be >= %d, tolerance %d",
filename, mfi.uDurationMSec, duration, tolerance),
mfi.uDurationMSec + tolerance >= duration);
}
}

public void test_AudioBlock() {
Expand Down Expand Up @@ -1514,7 +1545,7 @@ public void testUserEventMuxedStream() {
initSound(rxclient);
login(rxclient, NICKNAME, USERNAME, PASSWORD);
joinRoot(rxclient);

connect(txclient);
initSound(txclient);
login(txclient, NICKNAME, USERNAME, PASSWORD);
Expand Down

0 comments on commit 0a7375f

Please sign in to comment.