1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-23 01:13:01 +01:00

Implemented audio calls using new ToxAV API

This commit is contained in:
cnhenry 2015-07-03 14:39:27 -05:00
parent 3241551cfb
commit f2121fae74
12 changed files with 142 additions and 3553 deletions

Binary file not shown.

518
gdb.txt
View File

@ -1,518 +0,0 @@
Reading symbols from /usr/local/bin/toxic...done.
Starting program: /usr/local/bin/toxic
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe8b60700 (LWP 14024)]
[New Thread 0x7fffe7f61700 (LWP 14035)]
[New Thread 0x7fffe7760700 (LWP 14036)]
[New Thread 0x7fffe5dad700 (LWP 14037)]
[Thread 0x7fffe5dad700 (LWP 14037) exited]
[New Thread 0x7fffe5dad700 (LWP 14038)]
[Thread 0x7fffe5dad700 (LWP 14038) exited]
[New Thread 0x7fffe5dad700 (LWP 14039)]
[Thread 0x7fffe5dad700 (LWP 14039) exited]
[New Thread 0x7fffe5dad700 (LWP 14040)]
[Thread 0x7fffe5dad700 (LWP 14040) exited]
[New Thread 0x7fffe5dad700 (LWP 14041)]
[Thread 0x7fffe5dad700 (LWP 14041) exited]
[New Thread 0x7fffe4d03700 (LWP 14042)]
[Thread 0x7fffe4d03700 (LWP 14042) exited]
[New Thread 0x7fffe5dad700 (LWP 14043)]
[Thread 0x7fffe5dad700 (LWP 14043) exited]
[New Thread 0x7fffe5dad700 (LWP 14044)]
[New Thread 0x7fffe4c82700 (LWP 14045)]
[New Thread 0x7fffdfcef700 (LWP 14046)]
[New Thread 0x7fffdf4ee700 (LWP 14076)]
[Thread 0x7fffdf4ee700 (LWP 14076) exited]
[New Thread 0x7fffdf4ee700 (LWP 14077)]
[New Thread 0x7fffdacec700 (LWP 14078)]
[New Thread 0x7fffda4eb700 (LWP 14079)]
Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffe7f61700 (LWP 14035)]
0x00007ffff573d0d5 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#0 0x00007ffff573d0d5 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff574083b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff5735d9e in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007ffff5735e42 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007ffff7020c99 in rtp_new (payload_type=193, m=0x74de60, friend_num=0, cs=0x0,
mcb=0x7ffff7024790 <vc_queue_message>) at ../toxav/rtp.c:84
#5 0x00007ffff7025c67 in call_prepare_transmission (call=0x8e0080) at ../toxav/toxav.c:1283
#6 0x00007ffff7025e54 in toxav_answer (av=0x86e130, friend_number=0, audio_bit_rate=48,
video_bit_rate=0, error=0x7fffe7f5ef58) at ../toxav/toxav.c:410
#7 0x000000000042bc11 in cmd_answer (window=0x7fffe002ab60, self=0x63ff90, m=0x74de60, argc=0,
argv=0x7fffe7f5f000) at /home/cnhenry/Workspace/toxic/src/audio_call.c:645
#8 0x000000000040d4b3 in do_command (w=0x7fffe002ab60, self=0x63ff90, m=0x74de60, num_args=1,
commands=0x63ab40, args=0x7fffe7f5f000) at /home/cnhenry/Workspace/toxic/src/execute.c:151
#9 0x000000000040d592 in execute (w=0x7fffe002ab60, self=0x63ff90, m=0x74de60,
input=0x7fffe7f60620 "/answer", mode=1) at /home/cnhenry/Workspace/toxic/src/execute.c:176
#10 0x0000000000409827 in chat_onKey (self=0x63ff90, m=0x74de60, key=10, ltr=false)
at /home/cnhenry/Workspace/toxic/src/chat.c:889
#11 0x0000000000427e67 in draw_active_window (m=0x74de60)
at /home/cnhenry/Workspace/toxic/src/windows.c:544
#12 0x0000000000424a05 in thread_winref (data=0x74de60)
at /home/cnhenry/Workspace/toxic/src/toxic.c:800
#13 0x00007ffff612ce9a in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#14 0x00007ffff57fa38d in clone () from /lib/x86_64-linux-gnu/libc.so.6
#15 0x0000000000000000 in ?? ()Reading symbols from /usr/local/bin/toxic...done.
Starting program: /usr/local/bin/toxic
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe8b60700 (LWP 16834)]
[New Thread 0x7fffe7f61700 (LWP 16845)]
[New Thread 0x7fffe7760700 (LWP 16846)]
[New Thread 0x7fffe5dad700 (LWP 16847)]
[Thread 0x7fffe5dad700 (LWP 16847) exited]
[New Thread 0x7fffe5dad700 (LWP 16848)]
[Thread 0x7fffe5dad700 (LWP 16848) exited]
[New Thread 0x7fffe5dad700 (LWP 16849)]
[Thread 0x7fffe5dad700 (LWP 16849) exited]
[New Thread 0x7fffe5dad700 (LWP 16850)]
[Thread 0x7fffe5dad700 (LWP 16850) exited]
[New Thread 0x7fffe5dad700 (LWP 16851)]
[Thread 0x7fffe5dad700 (LWP 16851) exited]
[New Thread 0x7fffe4d03700 (LWP 16852)]
[Thread 0x7fffe4d03700 (LWP 16852) exited]
[New Thread 0x7fffe5dad700 (LWP 16853)]
[Thread 0x7fffe5dad700 (LWP 16853) exited]
[New Thread 0x7fffe5dad700 (LWP 16854)]
[New Thread 0x7fffe4c82700 (LWP 16855)]
[New Thread 0x7fffdfcef700 (LWP 16856)]
[New Thread 0x7fffdf4ee700 (LWP 16894)]
[Thread 0x7fffdf4ee700 (LWP 16894) exited]
[New Thread 0x7fffdf4ee700 (LWP 16895)]
[New Thread 0x7fffdacec700 (LWP 16896)]
[New Thread 0x7fffda4eb700 (LWP 16897)]
[Thread 0x7fffdacec700 (LWP 16896) exited]
[Thread 0x7fffdf4ee700 (LWP 16895) exited]
[New Thread 0x7fffdf4ee700 (LWP 16949)]
[New Thread 0x7fffdacec700 (LWP 16950)]
Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffe7f61700 (LWP 16845)]
0x00007ffff573d0d5 in raise () from /lib/x86_64-linux-gnu/libc.so.6
Breakpoint 1 at 0x7ffff7024c34: file ../toxav/video.c, line 61.
Breakpoint 2 at 0x7ffff7024c53: file ../toxav/video.c, line 63.
Breakpoint 3 at 0x7ffff7024c6d: file ../toxav/video.c, line 65.
Breakpoint 4 at 0x7ffff7024c98: file ../toxav/video.c, line 71.
Breakpoint 5 at 0x7ffff7024ca9: file ../toxav/video.c, line 76.
Breakpoint 6 at 0x7ffff7024cbb: file ../toxav/video.c, line 81.
#0 0x00007ffff573d0d5 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff574083b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff5735d9e in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007ffff5735e42 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007ffff7020c99 in rtp_new (payload_type=193, m=0x74de60, friend_num=0, cs=0x0,
mcb=0x7ffff7024790 <vc_queue_message>) at ../toxav/rtp.c:84
#5 0x00007ffff7025c67 in call_prepare_transmission (call=0x8c9db0) at ../toxav/toxav.c:1283
#6 0x00007ffff7025e54 in toxav_answer (av=0x86dce0, friend_number=0, audio_bit_rate=48,
video_bit_rate=0, error=0x7fffe7f5ef58) at ../toxav/toxav.c:410
#7 0x000000000042bc11 in cmd_answer (window=0x7fffe002ab60, self=0x63ff90, m=0x74de60, argc=0,
argv=0x7fffe7f5f000) at /home/cnhenry/Workspace/toxic/src/audio_call.c:645
#8 0x000000000040d4b3 in do_command (w=0x7fffe002ab60, self=0x63ff90, m=0x74de60, num_args=1,
commands=0x63ab40, args=0x7fffe7f5f000) at /home/cnhenry/Workspace/toxic/src/execute.c:151
#9 0x000000000040d592 in execute (w=0x7fffe002ab60, self=0x63ff90, m=0x74de60,
input=0x7fffe7f60620 "/answer", mode=1) at /home/cnhenry/Workspace/toxic/src/execute.c:176
#10 0x0000000000409827 in chat_onKey (self=0x63ff90, m=0x74de60, key=10, ltr=false)
at /home/cnhenry/Workspace/toxic/src/chat.c:889
#11 0x0000000000427e67 in draw_active_window (m=0x74de60)
at /home/cnhenry/Workspace/toxic/src/windows.c:544
#12 0x0000000000424a05 in thread_winref (data=0x74de60)
at /home/cnhenry/Workspace/toxic/src/toxic.c:800
#13 0x00007ffff612ce9a in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#14 0x00007ffff57fa38d in clone () from /lib/x86_64-linux-gnu/libc.so.6
#15 0x0000000000000000 in ?? ()
#5 0x00007ffff7025c67 in call_prepare_transmission (call=0x8c9db0) at ../toxav/toxav.c:1283
1283 call->video.first = rtp_new(rtp_TypeVideo, av->m, call->friend_number, call->video.second, vc_queue_message);
Breakpoint 1, vc_new (av=0x86dce0, friend_number=0, cb=0x42b14c <receive_video_frame_cb>,
cb_data=0x71c260, mvfpsz=500) at ../toxav/video.c:62
62 if ( !(vc->split_video_frame = calloc(VIDEOFRAME_PIECE_SIZE + VIDEOFRAME_HEADER_SIZE, 1)) )
The program being debugged stopped while in a function called from GDB.
Evaluation of the expression containing the function
(vc_new) will be abandoned.
When the function is done executing, GDB will silently stop.
Continuing.
Breakpoint 2, vc_new (av=0x86dce0, friend_number=0, cb=0x42b14c <receive_video_frame_cb>,
cb_data=0x71c260, mvfpsz=500) at ../toxav/video.c:64
64 if ( !(vc->vbuf_raw = rb_new(VIDEO_DECODE_BUFFER_SIZE)) )
Continuing.
Breakpoint 3, vc_new (av=0x86dce0, friend_number=0, cb=0x42b14c <receive_video_frame_cb>,
cb_data=0x71c260, mvfpsz=500) at ../toxav/video.c:67
67 int rc = vpx_codec_dec_init_ver(vc->decoder, VIDEO_CODEC_DECODER_INTERFACE,
Continuing.
Continuing.
[Thread 0x7fffdacec700 (LWP 16950) exited]
[Thread 0x7fffdf4ee700 (LWP 16949) exited]
[Thread 0x7fffe4c82700 (LWP 16855) exited]
[Thread 0x7fffe7f61700 (LWP 16845) exited]
[Thread 0x7fffe5dad700 (LWP 16854) exited]
[Thread 0x7fffe7760700 (LWP 16846) exited]
[Thread 0x7fffdfcef700 (LWP 16856) exited]
[Thread 0x7fffe8b60700 (LWP 16834) exited]
[Thread 0x7ffff7fae940 (LWP 16831) exited]
Program terminated with signal SIGABRT, Aborted.
The program no longer exists.
Quit
Reading symbols from /usr/local/bin/toxic...done.
Starting program: /usr/local/bin/toxic
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe8b60700 (LWP 27196)]
[New Thread 0x7fffe7f61700 (LWP 27207)]
[New Thread 0x7fffe7760700 (LWP 27208)]
[New Thread 0x7fffe5dad700 (LWP 27209)]
[Thread 0x7fffe5dad700 (LWP 27209) exited]
[New Thread 0x7fffe5dad700 (LWP 27210)]
[Thread 0x7fffe5dad700 (LWP 27210) exited]
[New Thread 0x7fffe5dad700 (LWP 27211)]
[Thread 0x7fffe5dad700 (LWP 27211) exited]
[New Thread 0x7fffe5dad700 (LWP 27212)]
[Thread 0x7fffe5dad700 (LWP 27212) exited]
[New Thread 0x7fffe5dad700 (LWP 27213)]
[Thread 0x7fffe5dad700 (LWP 27213) exited]
[New Thread 0x7fffe4d03700 (LWP 27214)]
[Thread 0x7fffe4d03700 (LWP 27214) exited]
[New Thread 0x7fffe5dad700 (LWP 27215)]
[Thread 0x7fffe5dad700 (LWP 27215) exited]
[New Thread 0x7fffe5dad700 (LWP 27216)]
[New Thread 0x7fffe4c82700 (LWP 27217)]
[New Thread 0x7fffdfcef700 (LWP 27218)]
[New Thread 0x7fffdf4ee700 (LWP 27255)]
[Thread 0x7fffdf4ee700 (LWP 27255) exited]
[New Thread 0x7fffdf4ee700 (LWP 27256)]
[New Thread 0x7fffdacec700 (LWP 27258)]
[New Thread 0x7fffda4eb700 (LWP 27261)]
[Thread 0x7fffdacec700 (LWP 27258) exited]
[Thread 0x7fffdf4ee700 (LWP 27256) exited]
[New Thread 0x7fffdf4ee700 (LWP 27279)]
[New Thread 0x7fffdacec700 (LWP 27280)]
Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffe7f61700 (LWP 27207)]
0x00007ffff573d0d5 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#0 0x00007ffff573d0d5 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff574083b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff5735d9e in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007ffff5735e42 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007ffff7024dc4 in vc_new (av=0x86e690, friend_number=0,
cb=0x42b14c <receive_video_frame_cb>, cb_data=0x71c260, mvfpsz=500) at ../toxav/video.c:71
#5 0x00007ffff7025ce5 in call_prepare_transmission (call=0x90a5a0) at ../toxav/toxav.c:1282
#6 0x00007ffff7025ef4 in toxav_answer (av=0x86e690, friend_number=0, audio_bit_rate=48,
video_bit_rate=0, error=0x7fffe7f5ef58) at ../toxav/toxav.c:410
#7 0x000000000042bc11 in cmd_answer (window=0x7fffe002ab60, self=0x63ff90, m=0x74de60, argc=0,
argv=0x7fffe7f5f000) at /home/cnhenry/Workspace/toxic/src/audio_call.c:645
#8 0x000000000040d4b3 in do_command (w=0x7fffe002ab60, self=0x63ff90, m=0x74de60, num_args=1,
commands=0x63ab40, args=0x7fffe7f5f000) at /home/cnhenry/Workspace/toxic/src/execute.c:151
#9 0x000000000040d592 in execute (w=0x7fffe002ab60, self=0x63ff90, m=0x74de60,
input=0x7fffe7f60620 "/answer", mode=1) at /home/cnhenry/Workspace/toxic/src/execute.c:176
#10 0x0000000000409827 in chat_onKey (self=0x63ff90, m=0x74de60, key=10, ltr=false)
at /home/cnhenry/Workspace/toxic/src/chat.c:889
#11 0x0000000000427e67 in draw_active_window (m=0x74de60)
at /home/cnhenry/Workspace/toxic/src/windows.c:544
#12 0x0000000000424a05 in thread_winref (data=0x74de60)
at /home/cnhenry/Workspace/toxic/src/toxic.c:800
#13 0x00007ffff612ce9a in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#14 0x00007ffff57fa38d in clone () from /lib/x86_64-linux-gnu/libc.so.6
#15 0x0000000000000000 in ?? ()
#5 0x00007ffff7025ce5 in call_prepare_transmission (call=0x90a5a0) at ../toxav/toxav.c:1282
1282 call->video.second = vc_new(av, call->friend_number, av->vcb.first, av->vcb.second, call->msi_call->peer_vfpsz);
Breakpoint 1 at 0x7ffff7024d2c: file ../toxav/video.c, line 61.
Breakpoint 2 at 0x7ffff7024de3: file ../toxav/video.c, line 63.
Breakpoint 3 at 0x7ffff7024dc4: file ../toxav/video.c, line 65.
Breakpoint 4 at 0x7ffff7024da5: file ../toxav/video.c, line 71.
Breakpoint 5 at 0x7ffff7024d86: file ../toxav/video.c, line 76.
Breakpoint 6 at 0x7ffff7024d5d: file ../toxav/video.c, line 81.
#5 0x00007ffff7025ce5 in call_prepare_transmission (call=0x90a5a0) at ../toxav/toxav.c:1282
1282 call->video.second = vc_new(av, call->friend_number, av->vcb.first, av->vcb.second, call->msi_call->peer_vfpsz);
Breakpoint 4, vc_new (av=0x86e690, friend_number=0, cb=0x42b14c <receive_video_frame_cb>,
cb_data=0x71c260, mvfpsz=500) at ../toxav/video.c:71
71 assert(0);//goto BASE_CLEANUP;
The program being debugged stopped while in a function called from GDB.
Evaluation of the expression containing the function
(vc_new) will be abandoned.
When the function is done executing, GDB will silently stop.
Continuing.
Program received signal SIGABRT, Aborted.
0x00007ffff573d0d5 in raise () from /lib/x86_64-linux-gnu/libc.so.6
Continuing.
[Thread 0x7fffdacec700 (LWP 27280) exited]
[Thread 0x7fffda4eb700 (LWP 27261) exited]
[Thread 0x7fffdfcef700 (LWP 27218) exited]
[Thread 0x7fffdf4ee700 (LWP 27279) exited]
[Thread 0x7fffe4c82700 (LWP 27217) exited]
[Thread 0x7fffe5dad700 (LWP 27216) exited]
[Thread 0x7fffe7760700 (LWP 27208) exited]
[Thread 0x7fffe8b60700 (LWP 27196) exited]
[Thread 0x7ffff7fae940 (LWP 27193) exited]
Program terminated with signal SIGABRT, Aborted.
The program no longer exists.
Reading symbols from /usr/local/bin/toxic...done.
Starting program: /usr/local/bin/toxic
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe8b60700 (LWP 27641)]
[New Thread 0x7fffe7f61700 (LWP 27652)]
[New Thread 0x7fffe7760700 (LWP 27653)]
[New Thread 0x7fffe5dad700 (LWP 27654)]
[Thread 0x7fffe5dad700 (LWP 27654) exited]
[New Thread 0x7fffe5dad700 (LWP 27655)]
[Thread 0x7fffe5dad700 (LWP 27655) exited]
[New Thread 0x7fffe5dad700 (LWP 27656)]
[Thread 0x7fffe5dad700 (LWP 27656) exited]
[New Thread 0x7fffe5dad700 (LWP 27657)]
[Thread 0x7fffe5dad700 (LWP 27657) exited]
[New Thread 0x7fffe5dad700 (LWP 27658)]
[Thread 0x7fffe5dad700 (LWP 27658) exited]
[New Thread 0x7fffe4d03700 (LWP 27659)]
[Thread 0x7fffe4d03700 (LWP 27659) exited]
[New Thread 0x7fffe5dad700 (LWP 27660)]
[Thread 0x7fffe5dad700 (LWP 27660) exited]
[New Thread 0x7fffe5dad700 (LWP 27661)]
[New Thread 0x7fffe4c82700 (LWP 27662)]
[New Thread 0x7fffdfcef700 (LWP 27663)]
[New Thread 0x7fffdf4ee700 (LWP 27679)]
[Thread 0x7fffdf4ee700 (LWP 27679) exited]
[New Thread 0x7fffdf4ee700 (LWP 27680)]
[New Thread 0x7fffdacec700 (LWP 27681)]
[New Thread 0x7fffda4eb700 (LWP 27682)]
[Thread 0x7fffdacec700 (LWP 27681) exited]
[Thread 0x7fffdf4ee700 (LWP 27680) exited]
[New Thread 0x7fffdf4ee700 (LWP 27703)]
[New Thread 0x7fffdacec700 (LWP 27704)]
Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffe7f61700 (LWP 27652)]
0x00007ffff573d0d5 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#0 0x00007ffff573d0d5 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff574083b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff5735d9e in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007ffff5735e42 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007ffff7024dc4 in vc_new (av=0x86d900, friend_number=0,
cb=0x42b14c <receive_video_frame_cb>, cb_data=0x71c260, mvfpsz=500) at ../toxav/video.c:71
#5 0x00007ffff7025ce5 in call_prepare_transmission (call=0x8f4190) at ../toxav/toxav.c:1282
#6 0x00007ffff7025ef4 in toxav_answer (av=0x86d900, friend_number=0, audio_bit_rate=48,
video_bit_rate=0, error=0x7fffe7f5ef58) at ../toxav/toxav.c:410
#7 0x000000000042bc11 in cmd_answer (window=0x7fffe002ab60, self=0x63ff90, m=0x74de60, argc=0,
argv=0x7fffe7f5f000) at /home/cnhenry/Workspace/toxic/src/audio_call.c:645
#8 0x000000000040d4b3 in do_command (w=0x7fffe002ab60, self=0x63ff90, m=0x74de60, num_args=1,
commands=0x63ab40, args=0x7fffe7f5f000) at /home/cnhenry/Workspace/toxic/src/execute.c:151
#9 0x000000000040d592 in execute (w=0x7fffe002ab60, self=0x63ff90, m=0x74de60,
input=0x7fffe7f60620 "/answer", mode=1) at /home/cnhenry/Workspace/toxic/src/execute.c:176
#10 0x0000000000409827 in chat_onKey (self=0x63ff90, m=0x74de60, key=10, ltr=false)
at /home/cnhenry/Workspace/toxic/src/chat.c:889
#11 0x0000000000427e67 in draw_active_window (m=0x74de60)
at /home/cnhenry/Workspace/toxic/src/windows.c:544
#12 0x0000000000424a05 in thread_winref (data=0x74de60)
at /home/cnhenry/Workspace/toxic/src/toxic.c:800
#13 0x00007ffff612ce9a in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
#14 0x00007ffff57fa38d in clone () from /lib/x86_64-linux-gnu/libc.so.6
#15 0x0000000000000000 in ?? ()
#5 0x00007ffff7025ce5 in call_prepare_transmission (call=0x8f4190) at ../toxav/toxav.c:1282
1282 call->video.second = vc_new(av, call->friend_number, av->vcb.first, av->vcb.second, call->msi_call->peer_vfpsz);
Program received signal SIGABRT, Aborted.
0x00007ffff573d0d5 in raise () from /lib/x86_64-linux-gnu/libc.so.6
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on".
Evaluation of the expression containing the function
(vc_new) will be abandoned.
When the function is done executing, GDB will silently stop.
Continuing.
[Thread 0x7fffe7760700 (LWP 27653) exited]
[Thread 0x7fffdacec700 (LWP 27704) exited]
[Thread 0x7fffdf4ee700 (LWP 27703) exited]
[Thread 0x7fffda4eb700 (LWP 27682) exited]
[Thread 0x7fffdfcef700 (LWP 27663) exited]
[Thread 0x7fffe4c82700 (LWP 27662) exited]
[Thread 0x7fffe5dad700 (LWP 27661) exited]
[Thread 0x7fffe7f61700 (LWP 27652) exited]
[Thread 0x7fffe8b60700 (LWP 27641) exited]
Program terminated with signal SIGABRT, Aborted.
The program no longer exists.Reading symbols from /usr/local/bin/toxic...done.
Starting program: /usr/local/bin/toxic
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe8b60700 (LWP 32161)]
[New Thread 0x7fffe7f61700 (LWP 32172)]
[New Thread 0x7fffe7760700 (LWP 32173)]
[New Thread 0x7fffe5dad700 (LWP 32174)]
[Thread 0x7fffe5dad700 (LWP 32174) exited]
[New Thread 0x7fffe5dad700 (LWP 32175)]
[Thread 0x7fffe5dad700 (LWP 32175) exited]
[New Thread 0x7fffe5dad700 (LWP 32176)]
[Thread 0x7fffe5dad700 (LWP 32176) exited]
[New Thread 0x7fffe5dad700 (LWP 32177)]
[Thread 0x7fffe5dad700 (LWP 32177) exited]
[New Thread 0x7fffe5dad700 (LWP 32178)]
[Thread 0x7fffe5dad700 (LWP 32178) exited]
[New Thread 0x7fffe4d03700 (LWP 32179)]
[Thread 0x7fffe4d03700 (LWP 32179) exited]
[New Thread 0x7fffe5dad700 (LWP 32180)]
[Thread 0x7fffe5dad700 (LWP 32180) exited]
[New Thread 0x7fffe5dad700 (LWP 32181)]
[New Thread 0x7fffe4c82700 (LWP 32182)]
[New Thread 0x7fffdfcef700 (LWP 32183)]
[New Thread 0x7fffdf4ee700 (LWP 32661)]
[Thread 0x7fffdf4ee700 (LWP 32661) exited]
[New Thread 0x7fffdf4ee700 (LWP 32663)]
[New Thread 0x7fffdacec700 (LWP 32664)]
[New Thread 0x7fffda4eb700 (LWP 32666)]
[Thread 0x7fffdacec700 (LWP 32664) exited]
[Thread 0x7fffdf4ee700 (LWP 32663) exited]
[New Thread 0x7fffdf4ee700 (LWP 32677)]
[New Thread 0x7fffdacec700 (LWP 32679)]
Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffe7f61700 (LWP 32172)]
0x00007ffff573d0d5 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#0 0x00007ffff573d0d5 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff574083b in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff5735d9e in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007ffff5735e42 in __assert_fail ()
from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007ffff7024dc4 in vc_new (av=0x7e1fc0, friend_number=0,
cb=0x42b14c <receive_video_frame_cb>, cb_data=0x71c260, mvfpsz=500)
at ../toxav/video.c:71
#5 0x00007ffff7025ce5 in call_prepare_transmission (call=0x84e2c0)
at ../toxav/toxav.c:1282
#6 0x00007ffff7025ef4 in toxav_answer (av=0x7e1fc0, friend_number=0,
audio_bit_rate=48, video_bit_rate=0, error=0x7fffe7f5ef58)
at ../toxav/toxav.c:410
#7 0x000000000042bc11 in cmd_answer (window=0x7fffe000dc90, self=0x63ff90,
m=0x74de60, argc=0, argv=0x7fffe7f5f000)
at /home/cnhenry/Workspace/toxic/src/audio_call.c:645
#8 0x000000000040d4b3 in do_command (w=0x7fffe000dc90, self=0x63ff90,
m=0x74de60, num_args=1, commands=0x63ab40, args=0x7fffe7f5f000)
at /home/cnhenry/Workspace/toxic/src/execute.c:151
#9 0x000000000040d592 in execute (w=0x7fffe000dc90, self=0x63ff90,
m=0x74de60, input=0x7fffe7f60620 "/answer", mode=1)
at /home/cnhenry/Workspace/toxic/src/execute.c:176
#10 0x0000000000409827 in chat_onKey (self=0x63ff90, m=0x74de60, key=10,
ltr=false) at /home/cnhenry/Workspace/toxic/src/chat.c:889
#11 0x0000000000427e67 in draw_active_window (m=0x74de60)
at /home/cnhenry/Workspace/toxic/src/windows.c:544
#12 0x0000000000424a05 in thread_winref (data=0x74de60)
at /home/cnhenry/Workspace/toxic/src/toxic.c:800
#13 0x00007ffff612ce9a in start_thread ()
from /lib/x86_64-linux-gnu/libpthread.so.0
#14 0x00007ffff57fa38d in clone () from /lib/x86_64-linux-gnu/libc.so.6
#15 0x0000000000000000 in ?? ()
#5 0x00007ffff7025ce5 in call_prepare_transmission (call=0x84e2c0)
at ../toxav/toxav.c:1282
1282 call->video.second = vc_new(av, call->friend_number, av->vcb.first, av->vcb.second, call->msi_call->peer_vfpsz);
#5 0x00007ffff7025ce5 in call_prepare_transmission (call=0x84e2c0)
at ../toxav/toxav.c:1282
1282 call->video.second = vc_new(av, call->friend_number, av->vcb.first, av->vcb.second, call->msi_call->peer_vfpsz);
The history is empty.
Invalid character ';' in expression.
Invalid character ';' in expression.
Program received signal SIGABRT, Aborted.
0x00007ffff573d0d5 in raise () from /lib/x86_64-linux-gnu/libc.so.6
The program being debugged was signaled while in a function called from GDB.
GDB remains in the frame where the signal was received.
To change this behavior use "set unwindonsignal on".
Evaluation of the expression containing the function
(vc_new) will be abandoned.
When the function is done executing, GDB will silently stop.
Continuing.
[Thread 0x7fffda4eb700 (LWP 32666) exited]
[Thread 0x7fffdacec700 (LWP 32679) exited]
[Thread 0x7fffe4c82700 (LWP 32182) exited]
[Thread 0x7fffdf4ee700 (LWP 32677) exited]
[Thread 0x7fffdfcef700 (LWP 32183) exited]
[Thread 0x7fffe5dad700 (LWP 32181) exited]
[Thread 0x7fffe7f61700 (LWP 32172) exited]
[Thread 0x7fffe8b60700 (LWP 32161) exited]
[Thread 0x7ffff7fae940 (LWP 32158) exited]
Program terminated with signal SIGABRT, Aborted.
The program no longer exists.
No stack.
No registers.
Reading symbols from /usr/local/bin/toxic...done.
Starting program: /usr/local/bin/toxic
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe8b60700 (LWP 4878)]
[New Thread 0x7fffe7f61700 (LWP 5333)]
[New Thread 0x7fffe7760700 (LWP 5334)]
[New Thread 0x7fffe5dad700 (LWP 5335)]
[Thread 0x7fffe5dad700 (LWP 5335) exited]
[New Thread 0x7fffe5dad700 (LWP 5336)]
[Thread 0x7fffe5dad700 (LWP 5336) exited]
[New Thread 0x7fffe5dad700 (LWP 5337)]
[Thread 0x7fffe5dad700 (LWP 5337) exited]
[New Thread 0x7fffe5dad700 (LWP 5338)]
[Thread 0x7fffe5dad700 (LWP 5338) exited]
[New Thread 0x7fffe5dad700 (LWP 5339)]
[Thread 0x7fffe5dad700 (LWP 5339) exited]
[New Thread 0x7fffe4d03700 (LWP 5340)]
[Thread 0x7fffe4d03700 (LWP 5340) exited]
[New Thread 0x7fffe5dad700 (LWP 5341)]
[Thread 0x7fffe5dad700 (LWP 5341) exited]
[New Thread 0x7fffe5dad700 (LWP 5342)]
[New Thread 0x7fffe4c82700 (LWP 5343)]
[New Thread 0x7fffdfcef700 (LWP 5344)]
[New Thread 0x7fffdf4ee700 (LWP 5738)]
[Thread 0x7fffdf4ee700 (LWP 5738) exited]
[New Thread 0x7fffdf4ee700 (LWP 5739)]
[New Thread 0x7fffdacec700 (LWP 5740)]
[New Thread 0x7fffda4eb700 (LWP 5741)]
[Thread 0x7fffdacec700 (LWP 5740) exited]
[Thread 0x7fffdf4ee700 (LWP 5739) exited]
Program received signal SIGINT, Interrupt.
0x00007ffff57c60ad in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6
A debugging session is active.
Inferior 1 [process 4875] will be killed.
Quit anyway? (y or n) Reading symbols from /usr/local/bin/toxic...done.
Starting program: /usr/local/bin/toxic
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffe8b60700 (LWP 20862)]
[New Thread 0x7fffe7eb2700 (LWP 20876)]
[New Thread 0x7fffe76b1700 (LWP 20877)]
[New Thread 0x7fffe5cdb700 (LWP 20878)]
[Thread 0x7fffe5cdb700 (LWP 20878) exited]
[New Thread 0x7fffe5cdb700 (LWP 20879)]
[Thread 0x7fffe5cdb700 (LWP 20879) exited]
[New Thread 0x7fffe5cdb700 (LWP 20880)]
[Thread 0x7fffe5cdb700 (LWP 20880) exited]
[New Thread 0x7fffe5cdb700 (LWP 20881)]
[Thread 0x7fffe5cdb700 (LWP 20881) exited]
[New Thread 0x7fffe5cdb700 (LWP 20882)]
[Thread 0x7fffe5cdb700 (LWP 20882) exited]
[New Thread 0x7fffe4c31700 (LWP 20883)]
[Thread 0x7fffe4c31700 (LWP 20883) exited]
[New Thread 0x7fffe5cdb700 (LWP 20884)]
[Thread 0x7fffe5cdb700 (LWP 20884) exited]
[New Thread 0x7fffe5cdb700 (LWP 20885)]
[New Thread 0x7fffe4bb0700 (LWP 20886)]
[New Thread 0x7fffdfcef700 (LWP 20887)]
[New Thread 0x7fffdf4ee700 (LWP 21416)]
[Thread 0x7fffdf4ee700 (LWP 21416) exited]
[New Thread 0x7fffdf4ee700 (LWP 21417)]
[New Thread 0x7fffdacec700 (LWP 21418)]
[New Thread 0x7fffda4eb700 (LWP 21419)]
[Thread 0x7fffdacec700 (LWP 21418) exited]
[Thread 0x7fffdf4ee700 (LWP 21417) exited]
Program received signal SIGINT, Interrupt.
0x00007ffff57c60ad in nanosleep () from /lib/x86_64-linux-gnu/libc.so.6
Quit
A debugging session is active.
Inferior 1 [process 20859] will be killed.
Quit anyway? (y or n)

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@ -53,7 +53,7 @@
#define MAX_CALLS 10 #define MAX_CALLS 10
#define frame_size (CallContrl.audio_bit_rate * CallContrl.audio_frame_duration / 1000) #define frame_size (CallContrl.audio_sample_rate * CallContrl.audio_frame_duration / 1000)
static int set_call(Call* call, bool start) static int set_call(Call* call, bool start)
{ {
@ -63,12 +63,12 @@ static int set_call(Call* call, bool start)
if ( start ) { if ( start ) {
call->ttas = true; call->ttas = true;
if (pthread_mutex_init(&call->mutex, NULL) != 0) if ( pthread_mutex_init(&call->mutex, NULL) != 0 )
return -1; return -1;
} }
else { else {
call->ttid = 0; call->ttid = 0;
if (pthread_mutex_destroy(&call->mutex) != 0) if ( pthread_mutex_destroy(&call->mutex) != 0 )
return -1; return -1;
} }
@ -87,12 +87,10 @@ typedef struct CallControl {
bool audio_enabled; bool audio_enabled;
bool video_enabled; bool video_enabled;
uint32_t audio_bit_rate; uint32_t audio_bit_rate;
uint32_t video_bit_rate; uint32_t video_bit_rate;
uint32_t audio_sample_rate; uint32_t audio_sample_rate;
uint32_t video_sample_rate;
int32_t audio_frame_duration; int32_t audio_frame_duration;
int32_t video_frame_duration; int32_t video_frame_duration;
@ -102,16 +100,19 @@ typedef struct CallControl {
CallControl CallContrl; CallControl CallContrl;
void call_cb(ToxAV *av, uint32_t friend_number, bool audio_enabled, bool video_enabled, void *user_data); void call_cb( ToxAV *av, uint32_t friend_number, bool audio_enabled, bool video_enabled, void *user_data );
void callstate_cb(ToxAV *av, uint32_t friend_number, uint32_t state, void *user_data); void callstate_cb( ToxAV *av, uint32_t friend_number, uint32_t state, void *user_data );
void receive_audio_frame_cb(ToxAV *av, uint32_t friend_number, int16_t const *pcm, size_t sample_count, uint8_t channels, uint32_t sampling_rate, void *user_data); void receive_audio_frame_cb( ToxAV *av, uint32_t friend_number,
void audio_bit_rate_status_cb(ToxAV *av, uint32_t friend_number, bool stable, uint32_t bit_rate, void *user_data); int16_t const *pcm, size_t sample_count,
void receive_video_frame_cb(ToxAV *av, uint32_t friend_number, uint8_t channels, uint32_t sampling_rate, void *user_data );
void audio_bit_rate_status_cb( ToxAV *av, uint32_t friend_number,
bool stable, uint32_t bit_rate, void *user_data );
void receive_video_frame_cb( ToxAV *av, uint32_t friend_number,
uint16_t width, uint16_t height, uint16_t width, uint16_t height,
uint8_t const *y, uint8_t const *u, uint8_t const *v, uint8_t const *a, uint8_t const *y, uint8_t const *u, uint8_t const *v, uint8_t const *a,
int32_t ystride, int32_t ustride, int32_t vstride, int32_t astride, int32_t ystride, int32_t ustride, int32_t vstride, int32_t astride,
void *user_data); void *user_data );
void video_bit_rate_status_cb(ToxAV *av, uint32_t friend_number, void video_bit_rate_status_cb( ToxAV *av, uint32_t friend_number,
bool stable, uint32_t bit_rate, void *user_data); bool stable, uint32_t bit_rate, void *user_data);
void callback_recv_invite ( void* av, uint32_t friend_number, void *arg ); void callback_recv_invite ( void* av, uint32_t friend_number, void *arg );
@ -140,9 +141,13 @@ ToxAV *init_audio(ToxWindow *self, Tox *tox)
CallContrl.window = self; CallContrl.window = self;
CallContrl.audio_enabled = true; CallContrl.audio_enabled = true;
CallContrl.video_enabled = false;
CallContrl.audio_bit_rate = 48; CallContrl.audio_bit_rate = 48;
CallContrl.video_bit_rate = 0;
CallContrl.audio_sample_rate = 48000; CallContrl.audio_sample_rate = 48000;
CallContrl.video_sample_rate = 0;
CallContrl.audio_frame_duration = 10; CallContrl.audio_frame_duration = 10;
CallContrl.video_frame_duration = 0;
CallContrl.audio_channels = 1; CallContrl.audio_channels = 1;
CallContrl.errors = ae_None; CallContrl.errors = ae_None;
@ -153,13 +158,6 @@ ToxAV *init_audio(ToxWindow *self, Tox *tox)
CallContrl.av = toxav_new(tox, &error); CallContrl.av = toxav_new(tox, &error);
if( error == TOXAV_ERR_NEW_OK) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "TOXAV_ERR_NEW_OK");
}
if(tox == toxav_get_tox(CallContrl.av)) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Tox instance matches");
}
if ( !CallContrl.av ) { if ( !CallContrl.av ) {
CallContrl.errors |= ae_StartingCoreAudio; CallContrl.errors |= ae_StartingCoreAudio;
@ -173,24 +171,6 @@ ToxAV *init_audio(ToxWindow *self, Tox *tox)
return CallContrl.av = NULL; return CallContrl.av = NULL;
} }
/*toxav_register_callstate_callback(CallContrl.av, callback_call_started, av_OnStart, self);
toxav_register_callstate_callback(CallContrl.av, callback_call_canceled, av_OnCancel, self);
toxav_register_callstate_callback(CallContrl.av, callback_call_rejected, av_OnReject, self);
toxav_register_callstate_callback(CallContrl.av, callback_call_ended, av_OnEnd, self);
toxav_register_callstate_callback(CallContrl.av, callback_recv_invite, av_OnInvite, self);
toxav_register_callstate_callback(CallContrl.av, callback_recv_ringing, av_OnRinging, self);
toxav_register_callstate_callback(CallContrl.av, callback_recv_starting, av_OnStart, self);
toxav_register_callstate_callback(CallContrl.av, callback_recv_ending, av_OnEnd, self);
toxav_register_callstate_callback(CallContrl.av, callback_requ_timeout, av_OnRequestTimeout, self);
toxav_register_callstate_callback(CallContrl.av, callback_peer_timeout, av_OnPeerTimeout, self);
//toxav_register_callstate_callback(CallContrl.av, callback_media_change, av_OnMediaChange, self);
toxav_register_audio_callback(CallContrl.av, write_device_callback, NULL);
*/
toxav_callback_call(CallContrl.av, call_cb, &CallContrl); toxav_callback_call(CallContrl.av, call_cb, &CallContrl);
toxav_callback_call_state(CallContrl.av, callstate_cb, &CallContrl); toxav_callback_call_state(CallContrl.av, callstate_cb, &CallContrl);
toxav_callback_audio_receive_frame(CallContrl.av, receive_audio_frame_cb, &CallContrl); toxav_callback_audio_receive_frame(CallContrl.av, receive_audio_frame_cb, &CallContrl);
@ -215,13 +195,15 @@ void terminate_audio()
void read_device_callback (const int16_t* captured, uint32_t size, void* data) void read_device_callback (const int16_t* captured, uint32_t size, void* data)
{ {
TOXAV_ERR_SEND_FRAME error;
int32_t friend_number = *((int32_t*)data); /* TODO: Or pass an array of call_idx's */ int32_t friend_number = *((int32_t*)data); /* TODO: Or pass an array of call_idx's */
int64_t sample_count = CallContrl.audio_sample_rate * CallContrl.audio_frame_duration / 1000;
//uint8_t encoded_payload[RTP_PAYLOAD_SIZE]; if ( sample_count <= 0 || toxav_audio_send_frame(CallContrl.av, friend_number,
//int32_t payload_size = toxav_prepare_audio_frame(CallContrl.av, friend_number, encoded_payload, RTP_PAYLOAD_SIZE, captured, size); captured, sample_count,
//if ( payload_size <= 0 || toxav_send_audio(CallContrl.av, friend_number, encoded_payload, payload_size) < 0 ) { CallContrl.audio_channels,
// /*fprintf(stderr, "Could not encode audio packet\n");*/ CallContrl.audio_sample_rate, &error) == false )
//} {}
} }
void write_device_callback(void *agent, int32_t friend_number, const int16_t* PCM, uint16_t size, void* arg) void write_device_callback(void *agent, int32_t friend_number, const int16_t* PCM, uint16_t size, void* arg)
@ -229,48 +211,29 @@ void write_device_callback(void *agent, int32_t friend_number, const int16_t* PC
(void)arg; (void)arg;
(void)agent; (void)agent;
if (friend_number >= 0 && CallContrl.calls[friend_number].ttas)
if (friend_number >= 0 && CallContrl.calls[friend_number].ttas) {
//ToxAvCSettings csettings = CallContrl.cs;
//toxav_get_peer_csettings(CallContrl.av, friend_number, 0, &csettings);
write_out(CallContrl.calls[friend_number].out_idx, PCM, size, CallContrl.audio_channels); write_out(CallContrl.calls[friend_number].out_idx, PCM, size, CallContrl.audio_channels);
}
} }
int start_transmission(ToxWindow *self, Call *call) int start_transmission(ToxWindow *self, Call *call)
{ {
if ( !self || !CallContrl.av || self->num == -1 ) { if ( !self || !CallContrl.av) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Could not prepare transmission"); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Could not prepare transmission");
return -1; return -1;
} }
/* Don't provide support for video */
/*
if ( 0 != toxav_prepare_transmission(CallContrl.av, self->num, 0) ) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Could not prepare transmission");
return -1;
}
if ( !toxav_capability_supported(CallContrl.av, self->num, av_AudioDecoding) ||
!toxav_capability_supported(CallContrl.av, self->num, av_AudioEncoding) )
return -1;
*/
if (set_call(call, true) == -1) if (set_call(call, true) == -1)
return -1; return -1;
//ToxAvCSettings csettings; DeviceError error = open_primary_device(input, &call->in_idx, CallContrl.audio_sample_rate, CallContrl.audio_frame_duration, CallContrl.audio_channels);
//toxav_get_peer_csettings(CallContrl.av, self->call_idx, 0, &csettings);
DeviceError test = open_primary_device(input, &call->in_idx, CallContrl.audio_bit_rate, CallContrl.audio_frame_duration, CallContrl.audio_channels); if ( error == de_FailedStart)
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to start input device");
if ( test == de_FailedStart) if ( error == de_InternalError )
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed Start"); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Internal error with opening input device");
if ( test == de_InternalError ) if ( error != de_None )
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Internal Error");
if ( test != de_None )
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to open input device!"); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to open input device!");
if ( register_device_callback(self->num, call->in_idx, if ( register_device_callback(self->num, call->in_idx,
@ -279,7 +242,7 @@ int start_transmission(ToxWindow *self, Call *call)
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to register input handler!"); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to register input handler!");
if ( open_primary_device(output, &call->out_idx, if ( open_primary_device(output, &call->out_idx,
CallContrl.audio_bit_rate, CallContrl.audio_frame_duration, CallContrl.audio_channels) != de_None ) { CallContrl.audio_sample_rate, CallContrl.audio_frame_duration, CallContrl.audio_channels) != de_None ) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to open output device!"); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to open output device!");
call->has_output = 0; call->has_output = 0;
} }
@ -290,10 +253,11 @@ int start_transmission(ToxWindow *self, Call *call)
int stop_transmission(Call *call, int32_t friend_number) int stop_transmission(Call *call, int32_t friend_number)
{ {
if ( call->ttas ) { if ( call->ttas ) {
TOXAV_ERR_CALL_CONTROL error; TOXAV_ERR_CALL_CONTROL error = TOXAV_ERR_CALL_CONTROL_OK;
bool call_running = toxav_call_control(CallContrl.av, friend_number, TOXAV_CALL_CONTROL_CANCEL, &error); if ( CallContrl.call_state != TOXAV_FRIEND_CALL_STATE_FINISHED )
//toxav_kill_transmission(CallContrl.av, friend_number); toxav_call_control(CallContrl.av, friend_number, TOXAV_CALL_CONTROL_CANCEL, &error);
if(error == TOXAV_ERR_CALL_CONTROL_OK) {
if ( error == TOXAV_ERR_CALL_CONTROL_OK ) {
call->ttas = false; call->ttas = false;
if ( call->in_idx != -1 ) if ( call->in_idx != -1 )
@ -331,12 +295,11 @@ void call_cb(ToxAV *av, uint32_t friend_number, bool audio_enabled, bool video_e
TOXAV_ERR_ANSWER error; TOXAV_ERR_ANSWER error;
CallControl* cc = user_data; CallControl* cc = user_data;
ToxWindow* window = cc->window; ToxWindow* window = cc->window;
cc->audio_enabled = audio_enabled;
cc->video_enabled = video_enabled;
cc->pending_call = true; cc->pending_call = true;
line_info_add(window, NULL, NULL, NULL, SYS_MSG, 0, 0, "Incoming call callback! Friend number: %d", friend_number);
callback_recv_invite(av, friend_number, user_data); callback_recv_invite(av, friend_number, user_data);
//toxav_answer(CallContrl.av, friend_number, 48, 0, &error);
} }
void callstate_cb(ToxAV *av, uint32_t friend_number, uint32_t state, void *user_data) void callstate_cb(ToxAV *av, uint32_t friend_number, uint32_t state, void *user_data)
@ -345,54 +308,40 @@ void callstate_cb(ToxAV *av, uint32_t friend_number, uint32_t state, void *user_
ToxWindow* window = cc->window; ToxWindow* window = cc->window;
cc->call_state = state; cc->call_state = state;
line_info_add(window, NULL, NULL, NULL, SYS_MSG, 0, 0, "Callstate callback! Friend number: %d", friend_number); if( state == TOXAV_FRIEND_CALL_STATE_FINISHED ) {
if ( CallContrl.pending_call ) {
switch(state) {
case TOXAV_CALL_STATE_ERROR:
line_info_add(window, NULL, NULL, NULL, SYS_MSG, 0, 0, "TOXAV_CALL_STATE_ERROR");
break;
case TOXAV_CALL_STATE_FINISHED:
line_info_add(window, NULL, NULL, NULL, SYS_MSG, 0, 0, "TOXAV_CALL_STATE_FINISHED");
if(CallContrl.pending_call) {
line_info_add(window, NULL, NULL, NULL, SYS_MSG, 0, 0, "Pending Call Rejected");
CallContrl.pending_call = false; CallContrl.pending_call = false;
callback_call_rejected(CallContrl.av, window->num, &CallContrl); callback_call_rejected(CallContrl.av, friend_number, &CallContrl);
} else { } else {
line_info_add(window, NULL, NULL, NULL, SYS_MSG, 0, 0, "Existing Call Cancelled"); callback_call_ended(CallContrl.av, friend_number, &CallContrl);
callback_call_canceled(CallContrl.av, window->num, &CallContrl); }
} else {
if( state == TOXAV_FRIEND_CALL_STATE_ERROR ) {
line_info_add(window, NULL, NULL, NULL, SYS_MSG, 0, 0, "ToxAV callstate error!");
CallContrl.pending_call = false;
callback_call_ended(CallContrl.av, friend_number, &CallContrl);
} else {
CallContrl.pending_call = false;
callback_call_started(CallContrl.av, friend_number, &CallContrl);
} }
break;
case TOXAV_CALL_STATE_SENDING_A:
line_info_add(window, NULL, NULL, NULL, SYS_MSG, 0, 0, "TOXAV_CALL_STATE_SENDING_A");
break;
case TOXAV_CALL_STATE_SENDING_V:
line_info_add(window, NULL, NULL, NULL, SYS_MSG, 0, 0, "TOXAV_CALL_STATE_SENDING_V");
break;
case TOXAV_CALL_STATE_RECEIVING_A:
line_info_add(window, NULL, NULL, NULL, SYS_MSG, 0, 0, "TOXAV_CALL_STATE_RECEIVING_A");
break;
case TOXAV_CALL_STATE_RECEIVING_V:
line_info_add(window, NULL, NULL, NULL, SYS_MSG, 0, 0, "TOXAV_CALL_STATE_RECEIVING_V");
break;
default:
break;
} }
} }
void receive_audio_frame_cb(ToxAV *av, uint32_t friend_number, int16_t const *pcm, size_t sample_count, uint8_t channels, uint32_t sampling_rate, void *user_data) void receive_audio_frame_cb(ToxAV *av, uint32_t friend_number,
int16_t const *pcm, size_t sample_count,
uint8_t channels, uint32_t sampling_rate, void *user_data)
{ {
CallControl* cc = user_data; CallControl* cc = user_data;
write_device_callback(CallContrl.calls[friend_number].out_idx, friend_number, pcm, frame_size, cc); write_device_callback(CallContrl.calls[friend_number].out_idx, friend_number, pcm, frame_size, cc);
} }
void audio_bit_rate_status_cb(ToxAV *av, uint32_t friend_number, bool stable, uint32_t bit_rate, void *user_data) void audio_bit_rate_status_cb(ToxAV *av, uint32_t friend_number,
bool stable, uint32_t bit_rate, void *user_data)
{ {
CallControl* cc = user_data; CallControl* cc = user_data;
if (stable) if ( stable )
cc->audio_bit_rate = bit_rate; cc->audio_bit_rate = bit_rate;
} }
@ -401,21 +350,21 @@ void receive_video_frame_cb(ToxAV *av, uint32_t friend_number,
uint8_t const *y, uint8_t const *u, uint8_t const *v, uint8_t const *a, uint8_t const *y, uint8_t const *u, uint8_t const *v, uint8_t const *a,
int32_t ystride, int32_t ustride, int32_t vstride, int32_t astride, int32_t ystride, int32_t ustride, int32_t vstride, int32_t astride,
void *user_data) void *user_data)
{ {}
}
void video_bit_rate_status_cb(ToxAV *av, uint32_t friend_number, void video_bit_rate_status_cb(ToxAV *av, uint32_t friend_number,
bool stable, uint32_t bit_rate, void *user_data) bool stable, uint32_t bit_rate, void *user_data)
{ {
CallControl* cc = user_data; CallControl* cc = user_data;
if (stable) if ( stable )
cc->video_bit_rate = bit_rate; cc->video_bit_rate = bit_rate;
} }
#define CB_BODY(friend_number, Arg, onFunc) do { ToxWindow* windows = (Arg); int i;\ #define CB_BODY(friend_number, Arg, onFunc) do { ToxWindow* windows = (Arg); int i;\
for (i = 0; i < MAX_WINDOWS_NUM; ++i) if (windows[i].onFunc != NULL) windows[i].onFunc(&windows[i], CallContrl.av, friend_number); } while (0) for (i = 0; i < MAX_WINDOWS_NUM; ++i) if (windows[i].onFunc != NULL) windows[i].onFunc(&windows[i], CallContrl.av, friend_number); } while (0)
@ -430,9 +379,6 @@ void callback_recv_invite ( void* av, uint32_t friend_number, void* arg )
for (i = 0; i < MAX_WINDOWS_NUM; ++i) for (i = 0; i < MAX_WINDOWS_NUM; ++i)
if (windows[i].onInvite != NULL && windows[i].num == friend_number) { if (windows[i].onInvite != NULL && windows[i].num == friend_number) {
windows[i].onInvite(&windows[i], cc->av, friend_number, cc->call_state); windows[i].onInvite(&windows[i], cc->av, friend_number, cc->call_state);
} else {
//if(windows[i].num != friend_number)
//line_info_add(&windows, NULL, NULL, NULL, SYS_MSG, 0, 0, "Non-matching friend number");
} }
} }
@ -441,9 +387,10 @@ void callback_recv_ringing ( void* av, uint32_t friend_number, void* arg )
//CB_BODY(friend_number, arg, onRinging); //CB_BODY(friend_number, arg, onRinging);
CallControl* cc = arg; CallControl* cc = arg;
ToxWindow* windows = cc->window; ToxWindow* windows = cc->window;
int i; int i;
for (i = 0; i < MAX_WINDOWS_NUM; ++i) for (i = 0; i < MAX_WINDOWS_NUM; ++i)
if (windows[i].onRinging != NULL && windows[i].num == friend_number) { if (windows[i].onRinging != NULL && windows[i].is_call && windows[i].num == friend_number) {
windows[i].onRinging(&windows[i], cc->av, friend_number, cc->call_state); windows[i].onRinging(&windows[i], cc->av, friend_number, cc->call_state);
} }
} }
@ -451,9 +398,10 @@ void callback_recv_starting ( void* av, uint32_t friend_number, void* arg )
{ {
CallControl* cc = arg; CallControl* cc = arg;
ToxWindow* windows = cc->window; ToxWindow* windows = cc->window;
int i; int i;
for (i = 0; i < MAX_WINDOWS_NUM; ++i) for (i = 0; i < MAX_WINDOWS_NUM; ++i)
if (windows[i].onStarting != NULL && windows[i].num == friend_number) { if (windows[i].onStarting != NULL && windows[i].is_call && windows[i].num == friend_number) {
windows[i].onStarting(&windows[i], cc->av, friend_number, cc->call_state); windows[i].onStarting(&windows[i], cc->av, friend_number, cc->call_state);
if ( 0 != start_transmission(&windows[i], &CallContrl.calls[friend_number])) {/* YEAH! */ if ( 0 != start_transmission(&windows[i], &CallContrl.calls[friend_number])) {/* YEAH! */
line_info_add(&windows[i], NULL, NULL, NULL, SYS_MSG, 0, 0 , "Error starting transmission!"); line_info_add(&windows[i], NULL, NULL, NULL, SYS_MSG, 0, 0 , "Error starting transmission!");
@ -464,12 +412,12 @@ void callback_recv_starting ( void* av, uint32_t friend_number, void* arg )
void callback_recv_ending ( void* av, uint32_t friend_number, void* arg ) void callback_recv_ending ( void* av, uint32_t friend_number, void* arg )
{ {
//CB_BODY(friend_number, arg, onEnding); //CB_BODY(friend_number, arg, onEnding);
CallControl* cc = arg; CallControl* cc = arg;
ToxWindow* windows = cc->window; ToxWindow* windows = cc->window;
int i; int i;
for (i = 0; i < MAX_WINDOWS_NUM; ++i) for (i = 0; i < MAX_WINDOWS_NUM; ++i)
if (windows[i].onEnding != NULL && windows[i].num == friend_number) { if (windows[i].onEnding != NULL && windows[i].is_call && windows[i].num == friend_number) {
windows[i].onEnding(&windows[i], cc->av, friend_number, cc->call_state); windows[i].onEnding(&windows[i], cc->av, friend_number, cc->call_state);
} }
@ -480,9 +428,10 @@ void callback_call_started ( void* av, uint32_t friend_number, void* arg )
{ {
CallControl* cc = arg; CallControl* cc = arg;
ToxWindow* windows = cc->window; ToxWindow* windows = cc->window;
int i; int i;
for (i = 0; i < MAX_WINDOWS_NUM; ++i) for (i = 0; i < MAX_WINDOWS_NUM; ++i)
if (windows[i].onStart != NULL && windows[i].num == friend_number) { if (windows[i].onStart != NULL && windows[i].is_call && windows[i].num == friend_number) {
windows[i].onStart(&windows[i], cc->av, friend_number, cc->call_state); windows[i].onStart(&windows[i], cc->av, friend_number, cc->call_state);
if ( 0 != start_transmission(&windows[i], &CallContrl.calls[friend_number]) ) {/* YEAH! */ if ( 0 != start_transmission(&windows[i], &CallContrl.calls[friend_number]) ) {/* YEAH! */
line_info_add(&windows[i], NULL, NULL, NULL, SYS_MSG, 0, 0, "Error starting transmission!"); line_info_add(&windows[i], NULL, NULL, NULL, SYS_MSG, 0, 0, "Error starting transmission!");
@ -498,7 +447,7 @@ void callback_call_canceled ( void* av, uint32_t friend_number, void* arg )
int i; int i;
for (i = 0; i < MAX_WINDOWS_NUM; ++i) for (i = 0; i < MAX_WINDOWS_NUM; ++i)
if (windows[i].onCancel != NULL && windows[i].num == friend_number) { if (windows[i].onCancel != NULL && windows[i].is_call && windows[i].num == friend_number) {
windows[i].onCancel(&windows[i], cc->av, friend_number, cc->call_state); windows[i].onCancel(&windows[i], cc->av, friend_number, cc->call_state);
} }
@ -514,7 +463,7 @@ void callback_call_rejected ( void* av, uint32_t friend_number, void* arg )
int i; int i;
for (i = 0; i < MAX_WINDOWS_NUM; ++i) for (i = 0; i < MAX_WINDOWS_NUM; ++i)
if (windows[i].onReject != NULL && windows[i].num == friend_number) { if (windows[i].onReject != NULL && windows[i].is_call && windows[i].num == friend_number) {
windows[i].onReject(&windows[i], cc->av, friend_number, cc->call_state); windows[i].onReject(&windows[i], cc->av, friend_number, cc->call_state);
} }
@ -527,7 +476,7 @@ void callback_call_ended ( void* av, uint32_t friend_number, void* arg )
int i; int i;
for (i = 0; i < MAX_WINDOWS_NUM; ++i) for (i = 0; i < MAX_WINDOWS_NUM; ++i)
if (windows[i].onEnd != NULL && windows[i].num == friend_number) { if (windows[i].onEnd != NULL && windows[i].is_call && windows[i].num == friend_number) {
windows[i].onEnd(&windows[i], cc->av, friend_number, cc->call_state); windows[i].onEnd(&windows[i], cc->av, friend_number, cc->call_state);
} }
@ -542,7 +491,7 @@ void callback_requ_timeout ( void* av, uint32_t friend_number, void* arg )
int i; int i;
for (i = 0; i < MAX_WINDOWS_NUM; ++i) for (i = 0; i < MAX_WINDOWS_NUM; ++i)
if (windows[i].onRequestTimeout != NULL && windows[i].num == friend_number) { if (windows[i].onRequestTimeout != NULL && windows[i].is_call && windows[i].num == friend_number) {
windows[i].onRequestTimeout(&windows[i], cc->av, friend_number, cc->call_state); windows[i].onRequestTimeout(&windows[i], cc->av, friend_number, cc->call_state);
} }
} }
@ -554,7 +503,7 @@ void callback_peer_timeout ( void* av, uint32_t friend_number, void* arg )
int i; int i;
for (i = 0; i < MAX_WINDOWS_NUM; ++i) for (i = 0; i < MAX_WINDOWS_NUM; ++i)
if (windows[i].onPeerTimeout != NULL && windows[i].num == friend_number) { if (windows[i].onPeerTimeout != NULL && windows[i].is_call && windows[i].num == friend_number) {
windows[i].onPeerTimeout(&windows[i], cc->av, friend_number, cc->call_state); windows[i].onPeerTimeout(&windows[i], cc->av, friend_number, cc->call_state);
} }
@ -584,7 +533,7 @@ void cmd_call(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
TOXAV_ERR_CALL error; TOXAV_ERR_CALL error;
const char *error_str; const char *error_str;
if (argc != 0) { if ( argc != 0 ) {
error_str = "Unknown arguments."; error_str = "Unknown arguments.";
goto on_error; goto on_error;
} }
@ -594,7 +543,7 @@ void cmd_call(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
goto on_error; goto on_error;
} }
if (!self->stb->connection) { if ( !self->stb->connection ) {
error_str = "Friend is offline."; error_str = "Friend is offline.";
goto on_error; goto on_error;
} }
@ -604,7 +553,7 @@ void cmd_call(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
if ( !call_running ) { if ( !call_running ) {
if ( error == TOXAV_ERR_CALL_FRIEND_ALREADY_IN_CALL ) error_str = "Already in a call!"; if ( error == TOXAV_ERR_CALL_FRIEND_ALREADY_IN_CALL ) error_str = "Already in a call!";
else if ( error == TOXAV_ERR_CALL_MALLOC ) error_str = "Resource allocation issue"; else if ( error == TOXAV_ERR_CALL_MALLOC ) error_str = "Memory allocation issue";
else if ( error == TOXAV_ERR_CALL_FRIEND_NOT_FOUND) error_str = "Friend number invalid"; else if ( error == TOXAV_ERR_CALL_FRIEND_NOT_FOUND) error_str = "Friend number invalid";
else if ( error == TOXAV_ERR_CALL_FRIEND_NOT_CONNECTED) error_str = "Friend is valid but not currently connected"; else if ( error == TOXAV_ERR_CALL_FRIEND_NOT_CONNECTED) error_str = "Friend is valid but not currently connected";
else error_str = "Internal error!"; else error_str = "Internal error!";
@ -612,7 +561,7 @@ void cmd_call(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
goto on_error; goto on_error;
} }
CallContrl.pending_call = true; self->is_call = call_running;
callback_recv_ringing(CallContrl.av, self->num, &CallContrl); callback_recv_ringing(CallContrl.av, self->num, &CallContrl);
return; return;
@ -625,7 +574,7 @@ void cmd_answer(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
TOXAV_ERR_ANSWER error; TOXAV_ERR_ANSWER error;
const char *error_str; const char *error_str;
if (argc != 0) { if ( argc != 0 ) {
error_str = "Unknown arguments."; error_str = "Unknown arguments.";
goto on_error; goto on_error;
} }
@ -638,11 +587,10 @@ void cmd_answer(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
bool call_running = toxav_answer(CallContrl.av, self->num, 48, 0, &error); bool call_running = toxav_answer(CallContrl.av, self->num, 48, 0, &error);
if ( !call_running ) { if ( !call_running ) {
//if ( error != TOXAV_ERR_ANSWER_OK ) error_str = "Cannot answer in invalid state!";
if ( error == TOXAV_ERR_ANSWER_FRIEND_NOT_CALLING ) error_str = "No incoming call!"; if ( error == TOXAV_ERR_ANSWER_FRIEND_NOT_CALLING ) error_str = "No incoming call!";
else if ( error == TOXAV_ERR_ANSWER_CODEC_INITIALIZATION ) error_str = "Failed to initialize codecs"; else if ( error == TOXAV_ERR_ANSWER_CODEC_INITIALIZATION ) error_str = "Failed to initialize codecs!";
else if ( error == TOXAV_ERR_ANSWER_FRIEND_NOT_FOUND ) error_str = "Friend not found"; else if ( error == TOXAV_ERR_ANSWER_FRIEND_NOT_FOUND ) error_str = "Friend not found!";
else if ( error == TOXAV_ERR_ANSWER_INVALID_BIT_RATE ) error_str = "Invalid bit rate"; else if ( error == TOXAV_ERR_ANSWER_INVALID_BIT_RATE ) error_str = "Invalid bit rate!";
else error_str = "Internal error!"; else error_str = "Internal error!";
goto on_error; goto on_error;
@ -650,7 +598,7 @@ void cmd_answer(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
/* Callback will print status... */ /* Callback will print status... */
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Starting call"); self->is_call = call_running;
CallContrl.pending_call = false; CallContrl.pending_call = false;
callback_recv_starting(CallContrl.av, self->num, &CallContrl); callback_recv_starting(CallContrl.av, self->num, &CallContrl);
@ -664,7 +612,7 @@ void cmd_reject(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
TOXAV_ERR_CALL_CONTROL error; TOXAV_ERR_CALL_CONTROL error;
const char *error_str; const char *error_str;
if (argc != 0) { if ( argc != 0 ) {
error_str = "Unknown arguments."; error_str = "Unknown arguments.";
goto on_error; goto on_error;
} }
@ -676,7 +624,6 @@ void cmd_reject(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
bool call_running; bool call_running;
call_running = toxav_call_control(CallContrl.av, self->num, TOXAV_CALL_CONTROL_CANCEL, &error); call_running = toxav_call_control(CallContrl.av, self->num, TOXAV_CALL_CONTROL_CANCEL, &error);
//ToxAvError error = toxav_reject(CallContrl.av, self->call_idx, "Why not?");
if ( error != TOXAV_ERR_CALL_CONTROL_OK ) { if ( error != TOXAV_ERR_CALL_CONTROL_OK ) {
if ( error == TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION ) error_str = "Cannot reject in invalid state!"; if ( error == TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION ) error_str = "Cannot reject in invalid state!";
@ -688,8 +635,10 @@ void cmd_reject(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
/* Callback will print status... */ /* Callback will print status... */
self->is_call = call_running;
CallContrl.pending_call = false; CallContrl.pending_call = false;
callback_call_rejected(CallContrl.av, self->num, &CallContrl); callback_call_rejected(CallContrl.av, self->num, &CallContrl);
return; return;
on_error: on_error:
print_err (self, error_str); print_err (self, error_str);
@ -700,7 +649,7 @@ void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
TOXAV_ERR_CALL_CONTROL error; TOXAV_ERR_CALL_CONTROL error;
const char *error_str; const char *error_str;
if (argc != 0) { if ( argc != 0 ) {
error_str = "Unknown arguments."; error_str = "Unknown arguments.";
goto on_error; goto on_error;
} }
@ -711,21 +660,23 @@ void cmd_hangup(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[
} }
bool call_running; bool call_running;
if( CallContrl.call_state != TOXAV_CALL_STATE_SENDING_A | TOXAV_CALL_STATE_RECEIVING_A | TOXAV_CALL_STATE_SENDING_V | TOXAV_CALL_STATE_RECEIVING_V ) { if( CallContrl.pending_call && CallContrl.call_state != TOXAV_FRIEND_CALL_STATE_FINISHED ) {
call_running = toxav_call_control(CallContrl.av, self->num, TOXAV_CALL_CONTROL_CANCEL, &error); call_running = toxav_call_control(CallContrl.av, self->num, TOXAV_CALL_CONTROL_CANCEL, &error);
#ifdef SOUND_NOTIFY #ifdef SOUND_NOTIFY
stop_sound(self->ringing_sound); stop_sound(self->ringing_sound);
#endif #endif
CallContrl.pending_call = false; CallContrl.pending_call = false;
callback_call_canceled(CallContrl.av, self->num, &CallContrl); callback_call_ended(CallContrl.av, self->num, &CallContrl);
} else { } else {
call_running = toxav_call_control(CallContrl.av, &self->num, TOXAV_CALL_CONTROL_CANCEL, &error); call_running = toxav_call_control(CallContrl.av, self->num, TOXAV_CALL_CONTROL_CANCEL, &error);
callback_call_ended(CallContrl.av, self->num, &CallContrl); callback_call_ended(CallContrl.av, self->num, &CallContrl);
} }
self->is_call = call_running;
if ( error != TOXAV_ERR_CALL_CONTROL_OK ) { if ( error != TOXAV_ERR_CALL_CONTROL_OK ) {
if ( error == TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION ) error_str = "Cannot hangup in invalid state!"; if ( error == TOXAV_ERR_CALL_CONTROL_INVALID_TRANSITION ) error_str = "Cannot hangup in invalid state!";
else if ( error == TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_IN_CALL ) error_str = "No call!"; else if ( error == TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_IN_CALL ) error_str = "No call!";
else if ( error == TOXAV_ERR_CALL_CONTROL_FRIEND_NOT_FOUND ) error_str = "Invalid friend!";
else error_str = "Internal error!"; else error_str = "Internal error!";
goto on_error; goto on_error;
@ -852,25 +803,23 @@ void cmd_ccur_device(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*a
} }
/* If call is active, change device */ /* If call is active, change device */
if ( self->num > -1) { if ( self->is_call ) {
Call* this_call = &CallContrl.calls[self->num]; Call* this_call = &CallContrl.calls[self->num];
if (this_call->ttas) { if (this_call->ttas) {
//ToxAvCSettings csettings;
//toxav_get_peer_csettings(CallContrl.av, self->num, 0, &csettings);
if (type == output) { if (type == output) {
pthread_mutex_lock(&this_call->mutex); pthread_mutex_lock(&this_call->mutex);
close_device(output, this_call->out_idx); close_device(output, this_call->out_idx);
this_call->has_output = open_device(output, selection, &this_call->out_idx, this_call->has_output = open_device(output, selection, &this_call->out_idx,
CallContrl.audio_bit_rate, CallContrl.audio_frame_duration, CallContrl.audio_channels) CallContrl.audio_sample_rate, CallContrl.audio_frame_duration, CallContrl.audio_channels)
== de_None ? 1 : 0; == de_None ? 1 : 0;
pthread_mutex_unlock(&this_call->mutex); pthread_mutex_unlock(&this_call->mutex);
} }
else { else {
/* TODO: check for failure */ /* TODO: check for failure */
close_device(input, this_call->in_idx); close_device(input, this_call->in_idx);
open_device(input, selection, &this_call->in_idx, CallContrl.audio_bit_rate, open_device(input, selection, &this_call->in_idx, CallContrl.audio_sample_rate,
CallContrl.audio_frame_duration, CallContrl.audio_channels); CallContrl.audio_frame_duration, CallContrl.audio_channels);
/* Set VAD as true for all; TODO: Make it more dynamic */ /* Set VAD as true for all; TODO: Make it more dynamic */
register_device_callback(self->num, this_call->in_idx, read_device_callback, &self->num, true); register_device_callback(self->num, this_call->in_idx, read_device_callback, &self->num, true);
@ -911,7 +860,7 @@ void cmd_mute(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MA
/* If call is active, use this_call values */ /* If call is active, use this_call values */
if ( self->num > -1) { if ( self->is_call ) {
Call* this_call = &CallContrl.calls[self->num]; Call* this_call = &CallContrl.calls[self->num];
pthread_mutex_lock(&this_call->mutex); pthread_mutex_lock(&this_call->mutex);
@ -951,7 +900,7 @@ void cmd_sense(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[M
} }
/* Call must be active */ /* Call must be active */
if ( self->num > -1) { if ( self->is_call ) {
device_set_VAD_treshold(CallContrl.calls[self->num].in_idx, value); device_set_VAD_treshold(CallContrl.calls[self->num].in_idx, value);
self->chatwin->infobox.vad_lvl = value; self->chatwin->infobox.vad_lvl = value;
} }
@ -967,29 +916,5 @@ void stop_current_call(ToxWindow* self)
{ {
TOXAV_ERR_CALL_CONTROL error; TOXAV_ERR_CALL_CONTROL error;
bool call_running = toxav_call_control(CallContrl.av, &self->num, TOXAV_CALL_CONTROL_CANCEL, &error); bool call_running = toxav_call_control(CallContrl.av, &self->num, TOXAV_CALL_CONTROL_CANCEL, &error);
self->is_call = call_running;
/*
ToxAvCallState callstate;
if ( CallContrl.av != NULL && self->num != -1 &&
CallContrl.call_state != TOXAV_CALL_STATE_SENDING_A | TOXAV_CALL_STATE_RECEIVING_A | TOXAV_CALL_STATE_SENDING_V | TOXAV_CALL_STATE_RECEIVING_V) {
switch (callstate)
{
case av_CallActive:
case av_CallHold:
//toxav_hangup(CallContrl.av, self->num);
toxav_call_control(CallContrl.av, &self->num, TOXAV_CALL_CONTROL_CANCEL, &error);
break;
case av_CallInviting:
//toxav_cancel(CallContrl.av, self->num, 0, "Not interested anymore");
toxav_call_control(CallContrl.av, &self->num, TOXAV_CALL_CONTROL_CANCEL, &error);
break;
case av_CallStarting:
//toxav_reject(CallContrl.av, self->num, "Not interested");
toxav_call_control(CallContrl.av, &self->num, TOXAV_CALL_CONTROL_CANCEL, &error);
break;
default:
break;
}
}
*/
} }

View File

@ -549,16 +549,17 @@ static void chat_onGroupInvite(ToxWindow *self, Tox *m, int32_t friendnumber, ui
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Type \"/join\" to join the chat."); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Type \"/join\" to join the chat.");
} }
/* Av Stuff */ /* AV Stuff */
#ifdef AUDIO #ifdef AUDIO
void chat_onInvite (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state) void chat_onInvite (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
{ {
if (!self || self->num != friend_number) if (!self || self->is_call || self->num != friend_number)
return; return;
/* friend_number is set here and reset on call end */ /* call is flagged active here */
self->num = (int)friend_number; self->is_call = true;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Incoming audio call! Type: \"/answer\" or \"/reject\""); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Incoming audio call! Type: \"/answer\" or \"/reject\"");
if (self->ringing_sound == -1) if (self->ringing_sound == -1)
@ -572,7 +573,7 @@ void chat_onInvite (ToxWindow *self, ToxAV *av, uint32_t friend_number, int stat
void chat_onRinging (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state) void chat_onRinging (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
{ {
if (!self || self->num != friend_number) if (!self || !self->is_call || self->num != friend_number)
return; return;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Ringing...type \"/hangup\" to cancel it."); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Ringing...type \"/hangup\" to cancel it.");
@ -585,11 +586,13 @@ void chat_onRinging (ToxWindow *self, ToxAV *av, uint32_t friend_number, int sta
void chat_onStarting (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state) void chat_onStarting (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
{ {
if (!self || self->num != friend_number) if (!self || !self->is_call || self->num != friend_number)
return; return;
init_infobox(self); /* call is flagged active here */
self->is_call = true;
init_infobox(self);
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call started! Type: \"/hangup\" to end it."); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call started! Type: \"/hangup\" to end it.");
#ifdef SOUND_NOTIFY #ifdef SOUND_NOTIFY
@ -599,11 +602,11 @@ void chat_onStarting (ToxWindow *self, ToxAV *av, uint32_t friend_number, int st
void chat_onEnding (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state) void chat_onEnding (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
{ {
if (!self || self->num != friend_number) if (!self || !self->is_call || self->num != friend_number)
return; return;
self->is_call = false;
kill_infobox(self); kill_infobox(self);
//self->num = -1;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!"); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!");
#ifdef SOUND_NOTIFY #ifdef SOUND_NOTIFY
@ -613,10 +616,10 @@ void chat_onEnding (ToxWindow *self, ToxAV *av, uint32_t friend_number, int stat
void chat_onError (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state) void chat_onError (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
{ {
if (!self || self->num != friend_number) if (!self || !self->is_call || self->num != friend_number)
return; return;
//self->num = -1; self->is_call = false;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Error!"); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Error!");
#ifdef SOUND_NOTIFY #ifdef SOUND_NOTIFY
@ -626,11 +629,13 @@ void chat_onError (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state
void chat_onStart (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state) void chat_onStart (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
{ {
if (!self || self->num != friend_number) if (!self || !self->is_call || self->num != friend_number)
return; return;
init_infobox(self); /* call is flagged active here */
self->is_call = true;
init_infobox(self);
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call started! Type: \"/hangup\" to end it."); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call started! Type: \"/hangup\" to end it.");
#ifdef SOUND_NOTIFY #ifdef SOUND_NOTIFY
@ -640,11 +645,11 @@ void chat_onStart (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state
void chat_onCancel (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state) void chat_onCancel (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
{ {
if (!self || self->num != friend_number) if (!self || !self->is_call || self->num != friend_number)
return; return;
self->is_call = false;
kill_infobox(self); kill_infobox(self);
//self->num = -1;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call canceled!"); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call canceled!");
#ifdef SOUND_NOTIFY #ifdef SOUND_NOTIFY
@ -654,10 +659,10 @@ void chat_onCancel (ToxWindow *self, ToxAV *av, uint32_t friend_number, int stat
void chat_onReject (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state) void chat_onReject (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
{ {
if (!self || self->num != friend_number) if (!self || !self->is_call || self->num != friend_number)
return; return;
//self->num = -1; self->is_call = false;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Rejected!"); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Rejected!");
#ifdef SOUND_NOTIFY #ifdef SOUND_NOTIFY
@ -667,11 +672,11 @@ void chat_onReject (ToxWindow *self, ToxAV *av, uint32_t friend_number, int stat
void chat_onEnd (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state) void chat_onEnd (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
{ {
if (!self || self->num != friend_number) if (!self || !self->is_call || self->num != friend_number)
return; return;
self->is_call = false;
kill_infobox(self); kill_infobox(self);
//self->num = -1;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!"); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Call ended!");
#ifdef SOUND_NOTIFY #ifdef SOUND_NOTIFY
@ -681,10 +686,10 @@ void chat_onEnd (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
void chat_onRequestTimeout (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state) void chat_onRequestTimeout (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
{ {
if (!self || self->num != friend_number) if (!self || !self->is_call || self->num != friend_number)
return; return;
//self->num = -1; self->is_call = false;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No answer!"); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "No answer!");
#ifdef SOUND_NOTIFY #ifdef SOUND_NOTIFY
@ -694,11 +699,11 @@ void chat_onRequestTimeout (ToxWindow *self, ToxAV *av, uint32_t friend_number,
void chat_onPeerTimeout (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state) void chat_onPeerTimeout (ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
{ {
if (!self || self->num != friend_number) if (!self || !self->is_call || self->num != friend_number)
return; return;
self->is_call = false;
kill_infobox(self); kill_infobox(self);
//self->num = -1;
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Peer disconnected; call ended!"); line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Peer disconnected; call ended!");
#ifdef SOUND_NOTIFY #ifdef SOUND_NOTIFY
@ -1128,7 +1133,7 @@ ToxWindow new_chat(Tox *m, uint32_t friendnum)
ret.onRequestTimeout = &chat_onRequestTimeout; ret.onRequestTimeout = &chat_onRequestTimeout;
ret.onPeerTimeout = &chat_onPeerTimeout; ret.onPeerTimeout = &chat_onPeerTimeout;
ret.num = -1; ret.is_call = false;
ret.device_selection[0] = ret.device_selection[1] = -1; ret.device_selection[0] = ret.device_selection[1] = -1;
ret.ringing_sound = -1; ret.ringing_sound = -1;
#endif /* AUDIO */ #endif /* AUDIO */

View File

@ -77,10 +77,10 @@ static struct cmd_func chat_commands[] = {
{ "/hangup", cmd_hangup }, { "/hangup", cmd_hangup },
{ "/mute", cmd_mute }, { "/mute", cmd_mute },
{ "/sense", cmd_sense }, { "/sense", cmd_sense },
#ifdef VIDEO //#ifdef VIDEO
{ "/enablevid", cmd_enablevid }, //{ "/enablevid", cmd_enablevid },
{ "/disablevid",cmd_disablevid }, //{ "/disablevid",cmd_disablevid },
#endif /* VIDEO */ //#endif /* VIDEO */
#endif /* AUDIO */ #endif /* AUDIO */
{ NULL, NULL }, { NULL, NULL },
}; };

View File

@ -1050,17 +1050,15 @@ void disable_chatwin(uint32_t f_num)
#ifdef AUDIO #ifdef AUDIO
static void friendlist_onAV(ToxWindow *self, ToxAV *av, uint32_t friend_number, int state) static void friendlist_onAV(ToxWindow *self, ToxAV *av, uint32_t friend_number, int state)
{ {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "friendlist_onAV fired");
if( friend_number >= Friends.max_idx) if( friend_number >= Friends.max_idx)
return; return;
Tox *m = toxav_get_tox(av); Tox *m = toxav_get_tox(av);
if (Friends.list[friend_number].chatwin == -1) { if (Friends.list[friend_number].chatwin == -1) {
if (get_num_active_windows() < MAX_WINDOWS_NUM) { if (get_num_active_windows() < MAX_WINDOWS_NUM) {
//line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, "List number %d", Friends.list[friend_number].num); //line_info_add(prompt, NULL, NULL, NULL, SYS_MSG, 0, 0, "List number %d", Friends.list[friend_number].num);
if(state != TOXAV_CALL_STATE_FINISHED) { if(state != TOXAV_FRIEND_CALL_STATE_FINISHED) {
Friends.list[friend_number].chatwin = add_window(m, new_chat(m, Friends.list[friend_number].num)); Friends.list[friend_number].chatwin = add_window(m, new_chat(m, Friends.list[friend_number].num));
set_active_window(Friends.list[friend_number].chatwin); set_active_window(Friends.list[friend_number].chatwin);
} }
@ -1110,7 +1108,8 @@ ToxWindow new_friendlist(void)
ret.onRequestTimeout = &friendlist_onAV; ret.onRequestTimeout = &friendlist_onAV;
ret.onPeerTimeout = &friendlist_onAV; ret.onPeerTimeout = &friendlist_onAV;
ret.num = -1; //ret.num = -1;
ret.is_call = false;
ret.device_selection[0] = ret.device_selection[1] = -1; ret.device_selection[0] = ret.device_selection[1] = -1;
#endif /* AUDIO */ #endif /* AUDIO */

View File

@ -68,12 +68,10 @@ int stop_video_transmission(Call *call, int friend_number)
*/ */
void cmd_enablevid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) void cmd_enablevid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{ {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Video Enabled");
return; return;
} }
void cmd_disablevid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE]) void cmd_disablevid(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[MAX_STR_SIZE])
{ {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Video Disabled");
return; return;
} }

View File

@ -124,58 +124,6 @@ VideoDeviceError init_video_devices()
} }
#endif /* __linux__ */ #endif /* __linux__ */
#ifdef __WIN32
/* Enumerate video capture devices using win32 api */
HRESULT hr;
CoInitialize(NULL);
ICreateDevEnum *pSysDevEnum = NULL;
hr = CoCreateInstance(&CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, &IID_ICreateDevEnum, (void**)&pSysDevEnum);
if(FAILED(hr)) {
printf("CoCreateInstance failed()\n");
}
// Obtain a class enumerator for the video compressor category.
IEnumMoniker *pEnumCat = NULL;
hr = pSysDevEnum->lpVtbl->CreateClassEnumerator(pSysDevEnum, &CLSID_VideoInputDeviceCategory, &pEnumCat, 0);
if(hr != S_OK) {
pSysDevEnum->lpVtbl->Release(pSysDevEnum);
printf("CreateClassEnumerator failed()\n");
}
IMoniker *pMoniker = NULL;
ULONG cFetched;
i = 0;
while( pEnumCat->lpVtbl->Next(pEnumCat, 1, &pMoniker, &cFetched) == S_OK && i <= MAX_DEVICES ) {
IPropertyBag *pPropBag;
hr = pMoniker->lpVtbl->BindToStorage(pMoniker, 0, 0, &IID_IPropertyBag, (void **)&pPropBag);
if(SUCCEEDED(hr)) {
/* To retrieve the filter's friendly name, do the following: */
VARIANT varName;
VariantInit(&varName);
hr = pPropBag->lpVtbl->Read(pPropBag, L"FriendlyName", &varName, 0);
if (SUCCEEDED(hr)) {
if(varName.vt == VT_BSTR) {
int name_length = wcslen(varName.bstrVal);
char* name = (char*)malloc(name_length + 1);
wcstombs(name, varName.bstrVal, name_length + 1);
video_device_names[input][i] = name;
} else {
video_device_names[input][i] = "Unknown Device";
}
++i;
}
VariantClear(&varName);
pPropBag->lpVtbl->Release(pPropBag);
}
pMoniker->lpVtbl->Release(pMoniker);
}
video_device_size[input] = i-1;
pEnumCat->lpVtbl->Release(pEnumCat);
pSysDevEnum->lpVtbl->Release(pSysDevEnum);
#endif /* __WIN32 */
/* Start poll thread */ /* Start poll thread */
if (pthread_mutex_init(&video_mutex, NULL) != 0) if (pthread_mutex_init(&video_mutex, NULL) != 0)
return vde_InternalError; return vde_InternalError;

View File

@ -147,14 +147,14 @@ struct ToxWindow {
void(*onWriteDevice)(ToxWindow *, Tox *, uint32_t, int, const int16_t *, unsigned int, uint8_t, unsigned int); void(*onWriteDevice)(ToxWindow *, Tox *, uint32_t, int, const int16_t *, unsigned int, uint8_t, unsigned int);
int device_selection[2]; /* -1 if not set, if set uses these selections instead of primary device */ int device_selection[2]; /* -1 if not set, if set uses these selections instead of primary device */
bool is_call;
int ringing_sound; int ringing_sound;
#endif /* AUDIO */ #endif /* AUDIO */
int active_box; /* For box notify */ int active_box; /* For box notify */
char name[TOXIC_MAX_NAME_LENGTH + 1]; char name[TOXIC_MAX_NAME_LENGTH + 1];
int num; /* corresponds to friendnumber in chat windows */ uint32_t num; /* corresponds to friendnumber in chat windows */
bool active; bool active;
int x; int x;