0

ortp_init(); ms_init(); MSSndCard *card_capture = ms_snd_card_manager_get_default_capture_card(ms_snd_card_manager_get()); MSSndCard card_playback = ms_snd_card_manager_get_default_playback_card(ms_snd_card_manager_get()); /音频捕获过滤器 */ MSFilter *soundread = ms_snd_card_create_reader(card_capture); MSFilter *soundwrite = ms_snd_card_create_writer(card_playback);

MSFilter *encoder = ms_filter_create_encoder("PCMU");
MSFilter *decoder = ms_filter_create_decoder("PCMU");
MSFilter *rtpsend = ms_filter_new(MS_RTP_SEND_ID);
MSFilter *rtprecv = ms_filter_new(MS_RTP_RECV_ID);

MSFactory* factory = ms_factory_new_with_voip(); 
RtpProfile* profile = rtp_profile_clone_full(&av_profile);
AudioStream *audio= audio_stream_start(factory, profile, 6666, "127.0.0.1", 6666, 0, 0, 0);
if (audio)
{


    qDebug() << "ok!";

    RtpSession *rtp_session = audio_stream_get_rtp_session(audio);
    OrtpEvQueue* q = ortp_ev_queue_new();
    rtp_session_register_event_queue(rtp_session, q);

    ms_filter_call_method(rtpsend, MS_RTP_SEND_SET_SESSION, rtp_session);
    ms_filter_call_method(rtprecv, MS_RTP_RECV_SET_SESSION, rtp_session);

    int sr = 8000;
    int chan = 1;
    ms_filter_call_method(soundread, MS_FILTER_SET_SAMPLE_RATE, &sr);
    ms_filter_call_method(soundread, MS_FILTER_SET_NCHANNELS, &chan);

    ms_filter_call_method(soundwrite, MS_FILTER_SET_SAMPLE_RATE, &sr);
    ms_filter_call_method(soundwrite, MS_FILTER_SET_NCHANNELS, &chan);

    ms_filter_call_method(encoder, MS_FILTER_SET_SAMPLE_RATE, &sr);

    ms_filter_call_method(decoder, MS_FILTER_SET_SAMPLE_RATE, &sr);

    //link
    ms_filter_link(soundread, 0, encoder, 0);
    ms_filter_link(encoder, 0, rtpsend, 0);

    ms_filter_link(rtprecv, 0, decoder, 0);
    ms_filter_link(decoder, 0, soundwrite, 0);
    //ms_filter_link(stream->dtmfgen, 0, stream->soundwrite, 0);

      /* create ticker */
    MSTicker *ticker = ms_ticker_new();
    ms_ticker_attach(ticker, soundread);
    ms_ticker_attach(ticker, rtprecv);

听到我的声音错误,豪改变它,认为

4

0 回答 0