我的应用程序使用ffmpeg 将 mms 流解析到缓冲区,并使用音频队列播放缓冲数据。现在我可以确认缓冲的数据是好的,但我不能播放它。播放结构基于AudioFileStreamExample demo的客户端,可以播放http流(AudioFileStreamExample demo的服务器)。我在回调函数中注意到:
void MyPacketsProc(void *inClientData, UInt32 inNumberBytes,
UInt32 inNumberPackets, const void *inInputData,
AudioStreamPacketDescription *inPacketDescriptions),
当我直接播放AudioFileStreamExample demo的http流时,paraminNumberPackets
大多时候大于1;当我播放 mms 流时,inNumberPackets
总是 1。audioQueue 只播放第一个数据包,所有最后一个数据包都丢失了。
AudioFileStreamExample demo的http流使用日志:
*AudioStreamBasicDescription info ----*
SampleRate :44100.000000
FormatID :778924083
FormatFlags :0
BytesPerPacket :0
FramesPerPacket :1152
BytesPerFrame :0
ChannelsPerFrame :2
BitsPerChannel :0
got data. bytes: 1253 packets: 2
packetSize:626
kAQBufSize:24576
bytesFilled:0
packetSize:627
kAQBufSize:24576
bytesFilled:626
got data. bytes: 627 packets: 1
packetSize:627
kAQBufSize:24576
bytesFilled:1253
使用解析的mms流的日志:
*AudioStreamBasicDescription info ----*
SampleRate :48000.000000
FormatID :1819304813
FormatFlags :12
BytesPerPacket :4
FramesPerPacket :1
BytesPerFrame :4
ChannelsPerFrame :2
BitsPerChannel :16
got data. bytes: 4498 packets: 1
packetSize:216
kAQBufSize:24576
bytesFilled:0
got data. bytes: 1090 packets: 1
packetSize:576
kAQBufSize:24576
bytesFilled:216
got data. bytes: 3064 packets: 1
packetSize:576
kAQBufSize:24576
bytesFilled:792
got data. bytes: 3978 packets: 1
packetSize:252
kAQBufSize:24576
bytesFilled:1368
我不知道如何解决这个问题。似乎该MyPacketsProc
函数的参数错误,但是如何修复它?
非常感谢。