~singpolyma/ccd

57179f05380092f58716b89d6b3bcc5eae5b5da3 — Stephen Paul Weber 4 months ago 004c612 master
Switch to higher-level DTMF API

We can get a DTMF sender from the session or even the chat, rather than
manually wrapping the track.
1 files changed, 2 insertions(+), 4 deletions(-)

M main.c
M main.c => main.c +2 -4
@@ 12,7 12,6 @@

// Globals, ew
static void *chat = NULL;
static void *dtmf = NULL;
static pa_simple *pulse = NULL;
static pa_sample_spec ss_rec;
static pa_simple *pulse_rec = NULL;


@@ 118,9 117,6 @@ void on_call_media(void* session, bool audio, bool video, void* dummy) {
	streams[cstreams++] = snikket_jingle_media_stream_make_audio();
	size_t ctracks = snikket_jingle_media_stream_get_tracks(streams[cstreams-1], &tracks);
	for (size_t i = 0; i < ctracks; i++) {
		if (!dtmf) {
			dtmf = snikket_jingle_dtmf_sender_new(tracks[i]);
		}
		snikket_jingle_media_stream_track_add_pcm_listener(tracks[i], &on_pcm, NULL);
		snikket_jingle_media_stream_track_add_ready_for_pcm_listener(tracks[i], &on_ready_for_pcm, tracks[i]);
		snikket_release(tracks[i]);


@@ 235,8 231,10 @@ int main(int argc, const char **argv) {
		return 1;
	}

	void *dtmf = NULL;
	char tone[2] = " ";
	while ((tone[0] = fgetc(stdin)) != EOF && tone[0] != 4) {
		if (!dtmf && chat) dtmf = snikket_chat_dtmf(chat);
		if (dtmf) snikket_jingle_dtmf_sender_insert_dtmf(dtmf, tone);
	}