[Live-devel] wis-streamer can't play raw 16khz PCM sample

Cheng James jemicheng at gmail.com
Sun Jan 16 20:04:45 PST 2011


Hi,

I am doing a little experiment. I record a single channel 16khz raw PCM
sample for 3 seconds as a file and then I modify wis-streamer codes for
playing this raw sample as audio source.

Here is the code which I have modified.

void copypcm(char *to)
{
    int fd;

    printf("copypcm\n");
    char buf[96000];
    fd = open("/tmp/wav", O_RDWR);
  if (fd < 0)
   return ;

  memset(buf,0,96000);
  read(fd, buf, sizeof(buf));
  memcpy(to,buf,96000);

  close(fd);
  printf("copydone\n");

}

void WISAudioOpenFileSource::readFromFile() {
  // Read available audio data:
  int timeinc;
  //int ret = read(fInput.fOurAudioFileNo, fTo, fMaxSize);
 //my modification from here


copypcm(fTo);

  fFrameSize = (unsigned)96000;
  gettimeofday(&fPresentationTime, NULL);



  /* PR#2665 fix from Robin
   * Assuming audio format = AFMT_S16_LE
   * Get the current time
   * Substract the time increment of the audio oss buffer, which is equal to
   * buffer_size / channel_number / sample_rate / sample_size ==> 400+
millisec
   */
  timeinc = fFrameSize * 1000 / audioNumChannels /
(audioSamplingFrequency/1000) / 2;
  while (fPresentationTime.tv_usec < timeinc)
  {
    fPresentationTime.tv_sec -= 1;
    timeinc -= 1000000;
  }
  fPresentationTime.tv_usec -= timeinc;
}


The audio can't be played by VLC and VLC complains about PTS is out of
range. Is there any thing wrong with my modification?
By the way, I saw VLC drops a lot of audio buffers. Here is the RTSP
negotiation detail of my experiment. 192.168.1.168 is the wis-streamer IP.

DESCRIBE rtsp://192.168.1.168:7777/audio RTSP/1.0
CSeq: 3
User-Agent: LibVLC/1.1.5 (LIVE555 Streaming Media v2010.09.25)
Accept: application/sdp



RTSP/1.0 200 OK
CSeq: 3
Date: Sat, Jan 01 2000 02:17:21 GMT
Content-Base: rtsp://192.168.1.168:7777/audio/
Content-Type: application/sdp
Content-Length: 341

v=0
o=- 946692776958225 1 IN IP4 192.168.1.30
s=PCM raw source experiment
i=audio
t=0 0
a=tool:LIVE555 Streaming Media v2011.01.06
a=type:broadcast
a=control:*
a=range:npt=0-
a=x-qt-text-nam:RTSP/RTP stream
a=x-qt-text-inf:audio
m=audio 0 RTP/AVP 96
c=IN IP4 0.0.0.0
b=AS:128
a=rtpmap:96 L16/16000
a=control:track1

SETUP rtsp://192.168.1.168:7777/audio/track1 RTSP/1.0
CSeq: 4
User-Agent: LibVLC/1.1.5 (LIVE555 Streaming Media v2010.09.25)
Transport: RTP/AVP;unicast;client_port=3650-3651



RTSP/1.0 200 OK
CSeq: 4
Date: Sat, Jan 01 2000 02:17:21 GMT
Transport:
RTP/AVP;unicast;destination=192.168.1.99;source=192.168.1.168;client_port=3650-3651;server_port=6970-6971
Session: 04632C22



PLAY rtsp://192.168.1.168:7777/audio/ RTSP/1.0
CSeq: 5
User-Agent: LibVLC/1.1.5 (LIVE555 Streaming Media v2010.09.25)
Session: 04632C22
Range: npt=0.000-



RTSP/1.0 200 OK
CSeq: 5
Date: Sat, Jan 01 2000 02:17:21 GMT
Range: npt=0.000-
Session: 04632C22
RTP-Info: url=rtsp://
192.168.1.168:7777/audio/track1;seq=6548;rtptime=292484997



GET_PARAMETER rtsp://192.168.1.168:7777/audio/ RTSP/1.0
CSeq: 6
User-Agent: LibVLC/1.1.5 (LIVE555 Streaming Media v2010.09.25)
Session: 04632C22



RTSP/1.0 200 OK
CSeq: 6
Date: Sat, Jan 01 2000 02:17:21 GMT
Session: 04632C22
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20110117/a7d959fb/attachment.html>


More information about the live-devel mailing list