static void srtp_protected_text_stream(void) { text_stream_tester_t* marielle = text_stream_tester_new(); text_stream_tester_t* margaux = text_stream_tester_new(); const char* helloworld = "Hello World !"; int i = 0, strcmpresult = -2; int dummy = 0; init_text_streams(marielle, margaux, FALSE, FALSE, NULL, T140_PAYLOAD_TYPE /* ignored */); BC_ASSERT_EQUAL(ms_media_stream_sessions_set_encryption_mandatory(&marielle->ts->ms.sessions, TRUE), 0, int, "%d"); BC_ASSERT_TRUE(ms_srtp_supported()); BC_ASSERT_TRUE(ms_media_stream_sessions_set_srtp_send_key_b64(&(marielle->ts->ms.sessions), MS_AES_128_SHA1_32, "d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj") == 0); BC_ASSERT_TRUE(ms_media_stream_sessions_set_srtp_send_key_b64(&(margaux->ts->ms.sessions), MS_AES_128_SHA1_32, "6jCLmtRkVW9E/BUuJtYj/R2z6+4iEe06/DWohQ9F") == 0); BC_ASSERT_TRUE(ms_media_stream_sessions_set_srtp_recv_key_b64(&(margaux->ts->ms.sessions), MS_AES_128_SHA1_32, "d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj") == 0); BC_ASSERT_TRUE(ms_media_stream_sessions_set_srtp_recv_key_b64(&(marielle->ts->ms.sessions), MS_AES_128_SHA1_32, "6jCLmtRkVW9E/BUuJtYj/R2z6+4iEe06/DWohQ9F") == 0); BC_ASSERT_TRUE(media_stream_secured(&marielle->ts->ms)); BC_ASSERT_TRUE(media_stream_secured(&margaux->ts->ms)); for (; i < strlen(helloworld); i++) { char c = helloworld[i]; text_stream_putchar32(margaux->ts, (uint32_t)c); wait_for_until(&marielle->ts->ms, &margaux->ts->ms, &dummy, 1, 500); } BC_ASSERT_TRUE(wait_for_until(&marielle->ts->ms, &margaux->ts->ms, &marielle->stats.number_of_received_char, strlen(helloworld), 1000)); ms_message("Received message is: %s", marielle->stats.received_chars); strcmpresult = strcmp(marielle->stats.received_chars, helloworld); BC_ASSERT_EQUAL(strcmpresult, 0, int, "%d"); uninit_text_streams(marielle, margaux); text_stream_tester_destroy(marielle); text_stream_tester_destroy(margaux); }
void media_stream_iterate(MediaStream *stream){ time_t curtime=ms_time(NULL); if (stream->ice_check_list) ice_check_list_process(stream->ice_check_list,stream->sessions.rtp_session); /*we choose to update the quality indicator as much as possible, since local statistics can be computed realtime. */ if (stream->state==MSStreamStarted){ if (stream->is_beginning && (curtime-stream->start_time>15)){ rtp_session_set_rtcp_report_interval(stream->sessions.rtp_session,5000); stream->is_beginning=FALSE; } if (stream->qi && curtime>stream->last_iterate_time) ms_quality_indicator_update_local(stream->qi); } stream->last_iterate_time=curtime; if (stream->rc) ms_bitrate_controller_update(stream->rc); if (stream->evd) { ortp_ev_dispatcher_iterate(stream->evd); } if (stream->evq){ OrtpEvent *ev=NULL; while ((ev=ortp_ev_queue_get(stream->evq))!=NULL){ OrtpEventType evt=ortp_event_get_type(ev); if (evt==ORTP_EVENT_RTCP_PACKET_RECEIVED){ mblk_t *m=ortp_event_get_data(ev)->packet; media_stream_process_rtcp(stream,m,curtime); }else if (evt==ORTP_EVENT_RTCP_PACKET_EMITTED){ ms_message("%s_stream_iterate[%p], local statistics available:" "\n\tLocal current jitter buffer size: %5.1fms", media_stream_type_str(stream), stream, rtp_session_get_jitter_stats(stream->sessions.rtp_session)->jitter_buffer_size_ms); } else if (evt==ORTP_EVENT_STUN_PACKET_RECEIVED && stream->ice_check_list){ ice_handle_stun_packet(stream->ice_check_list,stream->sessions.rtp_session,ortp_event_get_data(ev)); } else if ((evt == ORTP_EVENT_ZRTP_ENCRYPTION_CHANGED) || (evt == ORTP_EVENT_DTLS_ENCRYPTION_CHANGED)) { ms_message("%s_stream_iterate[%p]: is %s ",media_stream_type_str(stream) , stream, media_stream_secured(stream) ? "encrypted" : "not encrypted"); } ortp_event_destroy(ev); } } }