mirror of
https://github.com/mpv-player/mpv
synced 2025-01-16 12:02:39 +00:00
support for AMR; it works inserting in the first byte of the demux_packet
a 1-byte header that live555 seems to be stripping for some reason, although according to the specs it should be there. Patch by Carl Eugen Hoyos. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22481 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
5de53fffeb
commit
f1c7edfaa6
@ -362,6 +362,7 @@ static void afterReading(void* clientData, unsigned frameSize,
|
||||
unsigned /*numTruncatedBytes*/,
|
||||
struct timeval presentationTime,
|
||||
unsigned /*durationInMicroseconds*/) {
|
||||
int headersize = 0;
|
||||
if (frameSize >= MAX_RTP_FRAME_SIZE) {
|
||||
fprintf(stderr, "Saw an input frame too large (>=%d). Increase MAX_RTP_FRAME_SIZE in \"demux_rtp.cpp\".\n",
|
||||
MAX_RTP_FRAME_SIZE);
|
||||
@ -372,8 +373,11 @@ static void afterReading(void* clientData, unsigned frameSize,
|
||||
|
||||
if (frameSize > 0) demuxer->stream->eof = 0;
|
||||
|
||||
if (bufferQueue->readSource()->isAMRAudioSource())
|
||||
headersize = 1;
|
||||
|
||||
demux_packet_t* dp = bufferQueue->dp;
|
||||
resize_demux_packet(dp, frameSize);
|
||||
resize_demux_packet(dp, frameSize + headersize);
|
||||
|
||||
// Set the packet's presentation time stamp, depending on whether or
|
||||
// not our RTP source's timestamps have been synchronized yet:
|
||||
@ -432,10 +436,13 @@ static demux_packet_t* getBuffer(demuxer_t* demuxer, demux_stream_t* ds,
|
||||
// the demuxer's 'priv' field)
|
||||
RTPState* rtpState = (RTPState*)(demuxer->priv);
|
||||
ReadBufferQueue* bufferQueue = NULL;
|
||||
int amr = 0;
|
||||
if (ds == demuxer->video) {
|
||||
bufferQueue = rtpState->videoBufferQueue;
|
||||
} else if (ds == demuxer->audio) {
|
||||
bufferQueue = rtpState->audioBufferQueue;
|
||||
if (bufferQueue->readSource()->isAMRAudioSource())
|
||||
amr = 1;
|
||||
} else {
|
||||
fprintf(stderr, "(demux_rtp)getBuffer: internal error: unknown stream\n");
|
||||
return NULL;
|
||||
@ -463,7 +470,7 @@ static demux_packet_t* getBuffer(demuxer_t* demuxer, demux_stream_t* ds,
|
||||
|
||||
// Schedule the read operation:
|
||||
bufferQueue->blockingFlag = 0;
|
||||
bufferQueue->readSource()->getNextFrame(dp->buffer, MAX_RTP_FRAME_SIZE,
|
||||
bufferQueue->readSource()->getNextFrame(&dp->buffer[amr], MAX_RTP_FRAME_SIZE - amr,
|
||||
afterReading, bufferQueue,
|
||||
onSourceClosure, bufferQueue);
|
||||
// Block ourselves until data becomes available:
|
||||
@ -471,6 +478,10 @@ static demux_packet_t* getBuffer(demuxer_t* demuxer, demux_stream_t* ds,
|
||||
= bufferQueue->readSource()->envir().taskScheduler();
|
||||
scheduler.doEventLoop(&bufferQueue->blockingFlag);
|
||||
|
||||
if (amr)
|
||||
dp->buffer[0] =
|
||||
((AMRAudioSource*)bufferQueue->readSource())->lastFrameHeader();
|
||||
|
||||
// Set the "ptsBehind" result parameter:
|
||||
if (bufferQueue->prevPacketPTS != 0.0
|
||||
&& bufferQueue->prevPacketWasSynchronized
|
||||
|
@ -184,6 +184,10 @@ void rtpCodecInitialize_audio(demuxer_t* demuxer,
|
||||
wf->nBlockAlign = 1;
|
||||
wf->wBitsPerSample = 8;
|
||||
wf->cbSize = 0;
|
||||
} else if (strcmp(subsession->codecName(), "AMR") == 0) {
|
||||
wf->wFormatTag = sh_audio->format = mmioFOURCC('s','a','m','r');
|
||||
} else if (strcmp(subsession->codecName(), "AMR-WB") == 0) {
|
||||
wf->wFormatTag = sh_audio->format = mmioFOURCC('s','a','w','b');
|
||||
} else if (strcmp(subsession->codecName(), "GSM") == 0) {
|
||||
wf->wFormatTag = sh_audio->format = mmioFOURCC('a','g','s','m');
|
||||
wf->nAvgBytesPerSec = 1650;
|
||||
|
Loading…
Reference in New Issue
Block a user