Hello,<br><br>I'm trying to implement streaming Speex encoded audio data (RTP Speex payload) from a microphone. I've read FAQ and checked mailing list so I had point of start but now I can not go further.<br>I've decided to start first with streaming WAV file transcoded to Speex.<br>
I created SpeexAudioFileServerMediaSubsession which was based on WAVAudioFileServerMediaSubsession but when playing the stream VLC I get only messages (with no audio):<br>....<br>live555 debug: tk->rtpSource->hasBeenSynchronizedUsingRTCP()<br>
main error: ES_OUT_RESET_PCR called<br>main debug: Buffering 0%<br>main debug: Buffering 17%<br>main debug: Buffering 34%<br>main debug: Buffering 51%<br>main debug: Buffering 68%<br>main debug: Buffering 85%<br>main debug: Stream buffering done (1238 ms in 1238 ms)<br>
main debug: Decoder buffering done in 0 ms<br>main debug: End of audio preroll<br>main warning: PTS is out of range (15713989), dropping buffer<br>main warning: PTS is out of range (15900246), dropping buffer<br>main warning: PTS is out of range (16089345), dropping buffer<br>
main warning: PTS is out of range (16271773), dropping buffer<br>main warning: PTS is out of range (16458644), dropping buffer<br>main warning: PTS is out of range (16646190), dropping buffer<br>main warning: PTS is out of range (16832643), dropping buffer<br>
main warning: PTS is out of range (17018080), dropping buffer<br><br><br>I wonder if I have to change fPresentationTime? Original time comes from WAVAudioFileSource but after encoding frames with Speex should I do any changes to it?<br>
<br>BTW Is there any reliable player for RTP/Speex? Maybe my problem is a player that doesn't support the protocol and codec (I tested with VLC and mplayer)<br><br><br>Thanks in advance for help.<br><br>regards,<br>ternyk<br>
<br><br><br>Some snippets from my code:<br><br>*********************************************************<br>WAVAudioFileServerMediaSubsession:<br><br>--------------<br>createNewStreamSource:<br>WAVAudioFileSource* wavSource<br>
= WAVAudioFileSource::createNew(envir(), fFileName);<br>...<br>//add if needed<br>resultSource = uLawFromPCMAudioSource::createNew(envir(), wavSource);<br>resultSource = EndianSwap16::createNew(envir(), wavSource);<br>
...<br>fSamplingFrequency = 8000;<br>fNumChannels = 1;<br>unsigned bitsPerSecond<br> = fSamplingFrequency*fBitsPerSample*fNumChannels;<br>SpeexTranscoder* speexFilter = SpeexTranscoder::createNew(envir(), SPEEX_MODE_NARROWBAND, bitsPerSecond, resultSource);<br>
resultSource = speexFilter;<br><br> return resultSource;<br><br>----------------<br>createNewRTPSink:<br><br>return SimpleRTPSink::createNew(envir(), rtpGroupsock,<br>        96, fSamplingFrequency,<br>        "audio", "speex", fNumChannels);<br>
<br>*****************************************************************<br>in SpeexTranscoder:<br>-----------<br><br>SpeexInit:<br><br>encoder_state = speex_encoder_init( speex_mode );<br> <br> int tmp; <br><br> tmp=0;<br>
speex_encoder_ctl(encoder_state, SPEEX_SET_VBR, &tmp); <br> int quality = 8;<br> speex_encoder_ctl(encoder_state, SPEEX_SET_QUALITY, &quality); // 8: 27,800[bps]<br> tmp=3;<br> speex_encoder_ctl(encoder_state, SPEEX_SET_COMPLEXITY, &tmp);<br>
speex_encoder_ctl( encoder_state, SPEEX_GET_FRAME_SIZE, &speex_frame_size );<br> speex_bits_init( &encoder_bits );<br><br> resampler = speex_resampler_init(1, 44100, 8000, quality, &tmp);<br><br><br>
---------------<br>afterGettingFrame1:<br><br>fFrameSize = TranscodeSpeex(fOrigADU, numBytesRead, fOutBitrate,<br>                         fTo, fMaxSize, fAvailableBytesForBackpointer);<br><br> if (fFrameSize == 0) { // internal error - bad ADU data?<br>
handleClosure(this);<br> return;<br> }<br><br> // Complete delivery to the client:<br>fNumTruncatedBytes = numTruncatedBytes;<br> fPresentationTime = presentationTime;<br> fDurationInMicroseconds = durationInMicroseconds;<br>
afterGetting(this);<br><br>-----------<br>TranscodeSpeex:<br><br>unsigned SpeexTranscoder::TranscodeSpeex(unsigned char const* fromPtr, unsigned fromSize, unsigned toBitrate, unsigned char* toPtr, unsigned toMaxSize, unsigned& availableBytesForBackpointer) { <br>
<br> int err;<br> char tmp[MAX_MP3_FRAME_SIZE];<br> const spx_int16_t *in = (spx_int16_t*)fromPtr; <br> unsigned in_len = fromSize; <br> spx_int16_t* out = (spx_int16_t*)tmp;<br> unsigned out_len;<br> err = speex_resampler_process_int(resampler, 0, in, &in_len, out, &out_len);<br>
<br> speex_bits_reset( &encoder_bits );<br> speex_encode_int( encoder_state, out, &encoder_bits );<br> speex_packet_size = speex_bits_write( &encoder_bits, (char*)fTo, toMaxSize);<br> return speex_packet_size;<br>
<br clear="all"><br>