Stefan Sayer pisze:
o Wojciech Wrona [12/22/08 21:46]:
Stefan Sayer wrote:
you can use AmAudioQueue (AmAdvancedAudio.h) to write audio to two
AmAudio devices.
put both the audio_connector and the AmAudioFile in the write queue,
and it will write to both. You don't even have to modify the
AmAudioConnector, you just catch the b2abconnectaudio event, and
after it is connected, you get the output with getOutput() and put
it in the queue, like
MySession::onB2ABEvent(ev) {
AmB2ABCallerSession::onB2ABEvent(ev);
if (ev-event-id==B2ABConnectAudio) {
lockAudio();
audio_queue.pushAudio(getOutput(), AmAudioQueue::OutputQueue,
AmAudioQueue::Back, true, false);
audio_queue.pushAudio(my_audio_file, AmAudioQueue::OutputQueue,
AmAudioQueue::Back, true, false);
setOutput(audio_queue);
unlockAudio();
}
Now, with r1203 you can use the AmAudioMixIn to mix the audio from
two AmAudios by using AUDIO_MIXIN_IMMEDIATE_START | AUDIO_MIXIN_ONCE
as flags. Additionally, you can use AmAudioBridge to connect read
and write (input and output), this way by using getInput() and with
an extra AmAudioQueue you can do the whole thing in the caller
session easily I guess.
I'm not sure that i get it well. So in Your solution both legs of the
b2abua call all recorded to diffrent files ? So, there is now way to
write contents from one AmAudio to another ?
Can You explain a little more that idea with AmAudioMixIn ? I guess
that it was intented to mix AmAudio with a static file. An
AmAudioFile object is especially AmAudio so i can mix two files, but
what then ? I get another AmAudio object which i don't know how to
write to disk :(
well, AmAudioMixIn mixes on the output side (get()/read()), thus you'd
have to tweak audio queues a bit more for it to work. note that the
second AmAudio in AmAudioMixIn is AmAudioFile only because of my
lazyness - for rewind() it could also be dynamic_cast'ed.
i figured for li the audio is not mixed, and the audio queue is
already there...so i added AmAudioMixer, which mixes on input from a
number of sources and writes to a number of sinks. it is not as
elegant a solution as the AudioPumps Raphael proposed some time back,
but together with AmAudioQueue it should suffice for most, if not all
applications. you can use it like this
if (ev->event_id == B2ABConnectAudio) {
// delayed processing of first INVITE request
AmSession::onInvite(invite_req);
+ AmB2ABCallerSession::onB2ABEvent(ev);
+ my_audio_file.open(fname, AmAudioFile::Write);
+
+ src1 = mixer.addSource();
+ src2 = mixer.addSource();
+ mixer.addSink(&my_audio_file);
+
+ lockAudio();
+ audio_queue.pushAudio(getOutput(), AmAudioQueue::OutputQueue,
AmAudioQueue::Back, false, true);
+ audio_queue.pushAudio(src1, AmAudioQueue::OutputQueue,
AmAudioQueue::Back, true, false);
+
+ audio_queue.pushAudio(getInput(), AmAudioQueue::InputQueue,
AmAudioQueue::Back, true, false);
+ audio_queue.pushAudio(src2, AmAudioQueue::InputQueue,
AmAudioQueue::Back, true, false);
+
+ unlockAudio();
+ setInOut(&audio_queue,&audio_queue);
+ return;
}
don't forget to popAndGetAudio the things from the queues otherwise it
will think it owns it and try to delete them twice in the dtor.
happy hacking
Stefan
Looked very well and works even better. Just implemented and learned a
lot while having fun with this code ;)
You're my god Stefan :)
I've done something like alternative serviceline application. So it goes
like this:
1. Incomming connection
2. Prompt with menu
3. After picking up the direction, call is placed in CallQueue - so if
direction is busy, call will keep trying holding its proper place in
queue (FIFO).
4. After connection is started (in B2ABUA) application starts recording,
which is stopped on call end.
Additionally i'm having a lot of fun with ringtones and music while
waiting :) Now, a lot of things is hardcoded (for example different call
queues to each direction), but when i clean it a little i might post it :)
Thanks a lot once again :)
--
Wojciech Wrona
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev