[Live-devel] ASIO input device -> RTP stream
James Heliker
james.heliker at gmail.com
Mon Sep 22 13:19:47 PDT 2014
Hi Ross -
Thanks for getting back to me. I've copied in my doGetNextFrame because I'm
not seeing anything that is particularly wrong here from your last email...
would you possibly be willing to shed any light on my mistakes? I would so
appreciate it!!!
Kind Regards,
- James
void AudioBufferSource::doGetNextFrame() {
fFrameSize = 0; // until it's set later
if (fPreferredFrameSize < fMaxSize) {
fMaxSize = fPreferredFrameSize;
}
unsigned bytesPerSample = (fNumChannels*fBitsPerSample) / 8;
if (bytesPerSample == 0) bytesPerSample = 1; // because we can't read
less than a byte at a time
unsigned samplesToRead = fMaxSize / bytesPerSample;
unsigned numSamplesRead;
numSamplesRead = fBufferManager->getFrames((int16_t*)fTo, samplesToRead);
unsigned numBytesRead = numSamplesRead * bytesPerSample;
fFrameSize += numBytesRead;
fTo += numBytesRead; //TODO - eval - is this line necessary
fMaxSize -= numBytesRead;
fNumBytesToStream -= numBytesRead;
// Set the 'presentation time' and 'duration' of this frame:
if (fPresentationTime.tv_sec == 0 && fPresentationTime.tv_usec == 0) {
// This is the first frame, so use the current time:
gettimeofday(&fPresentationTime, NULL);
}
else {
// Increment by the play time of the previous data:
unsigned uSeconds = fPresentationTime.tv_usec + fLastPlayTime;
fPresentationTime.tv_sec += uSeconds / 1000000;
fPresentationTime.tv_usec = uSeconds % 1000000;
}
// Remember the play time of this data:
fDurationInMicroseconds = fLastPlayTime =
(unsigned)((fPlayTimePerSample*fFrameSize) / bytesPerSample);
// Inform the reader that he has data:
// To avoid possible infinite recursion, we need to return to the event
loop to do this:
nextTask() = envir().taskScheduler().scheduleDelayedTask(0,
(TaskFunc*)FramedSource::afterGetting, this);
}
On Fri, Sep 19, 2014 at 10:52 PM, Ross Finlayson <finlayson at live555.com>
wrote:
> Audio is getting on to the network but in a bad state with many pops ticks
> and glitches, and a lot of variable latency.
>
>
> This suggests that you're probably not packing PCM audio samples into
> outgoing RTP packets properly. Make sure that your source's
> "doGetNextFrame()" implementation is packing an appropriate number of
> complete PCM audio samples (remember that you'll have 2x as many bytes if
> the audio is stereo) before calling "FramedSource::afterGetting()". Also
> make sure that you're setting "fPresentationTime" properly (it must be
> aligned with 'wall clock' time: the time that you'd get by calling
> "gettimeofday()".) You also need to set "fDurationInMicroseconds"
> appropriately each time.
>
> Ross Finlayson
> Live Networks, Inc.
> http://www.live555.com/
>
>
> _______________________________________________
> live-devel mailing list
> live-devel at lists.live555.com
> http://lists.live555.com/mailman/listinfo/live-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20140922/9dbb7d4d/attachment-0001.html>
More information about the live-devel
mailing list