<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello everyone,<br>
<br>
I'm trying to start a stream on Wowza programmaticaly by feeding the
stream myself with packets comming from GStreamer.<br>
Wowza provides an API called "Publisher API" :
(<a class="moz-txt-link-freetext" href="http://www.wowza.com/resources/serverapi/4.5.0/com/wowza/wms/stream/publish/Publisher.html">http://www.wowza.com/resources/serverapi/4.5.0/com/wowza/wms/stream/publish/Publisher.html</a>)<br>
it enables you to publish a stream on Wowza with Java Code by
feeding the stream with byte[] (packets).<br>
What I'm trying to do is to read a mkv file on disk with gstreamer
and send packets to Wowza using this API.<br>
My Problem is that Wowza seems to doesn't recognize what's inside
the packet I'm sending, see logs : <br>
<br>
Audio codec:PCM_BE isCompatible:false<br>
Video codec:UNKNOWN[0] isCompatible:false<br>
<br>
For information my video and audio packets are in h264 and aac
codecs. it is 2 format that Wowza knows to read.<br>
I Think, maybe the packets coming from GStreamer can't be sent to
Wowza directly without some king of transformation or adaptation.<br>
On the Publisher API page, there is the format of the packets for
aac and h264 that is described. I don't know if GStreamer is already
sending me the video and audio packets<br>
respecting this format or if I have to do something myself with
gstreamer packets before giving it to Wowza.<br>
<br>
For more detail, this is the GStreamer Pipeline I'm using :<br>
<br>
<img alt="" src="cid:part1.44996BAA.DF1FA9D4@gmail.com" height="394"
width="238"><br>
<br>
<br>
I've tryed with and without h264parse & aacparse and it is the
same result.<br>
<br>
This is my code that read gstreamer video/audio buffer and transmit
it to Wowza using the Publisher API. I think there is something to
work here to make this works :<br>
<br>
private class VIDEO_BUFFER_LISTENER implements AppSink.NEW_BUFFER{<br>
<br>
@Override<br>
public void newBuffer(AppSink elem) {<br>
<br>
Buffer buffer = elem.pullBuffer();<br>
<br>
ByteBuffer bb =buffer.getByteBuffer();<br>
<br>
byte[] bytes = toArray(bb);<br>
<br>
AMFPacket amfPacket = new
AMFPacket(IVHost.CONTENTTYPE_VIDEO,1,bytes);<br>
<br>
publisher.addVideoData(amfPacket.getData(), amfPacket.getSize(),
amfPacket.getTimecode()); <br>
<br>
buffer.dispose();<br>
}<br>
<br>
}<br>
<br>
private class AUDIO_BUFFER_LISTENER implements AppSink.NEW_BUFFER{<br>
<br>
@Override<br>
public void newBuffer(AppSink elem) {<br>
<br>
Buffer buffer = elem.pullBuffer();<br>
<br>
ByteBuffer bb =buffer.getByteBuffer();<br>
<br>
<br>
byte[] bytes = toArray(bb);<br>
<br>
AMFPacket amfPacket = new
AMFPacket(IVHost.CONTENTTYPE_AUDIO,1,bytes);<br>
<br>
publisher.addAudioData(amfPacket.getData(), amfPacket.getSize(),
amfPacket.getTimecode());<br>
<br>
buffer.dispose();<br>
}<br>
<br>
}<br>
<br>
private byte[] toArray(ByteBuffer bb){<br>
byte[] b = new byte[bb.remaining()];<br>
bb.get(b);<br>
return b;<br>
}<br>
<br>
This is the format described by wowza on the page
<a class="moz-txt-link-freetext" href="http://www.wowza.com/resources/serverapi/4.5.0/com/wowza/wms/stream/publish/Publisher.html">http://www.wowza.com/resources/serverapi/4.5.0/com/wowza/wms/stream/publish/Publisher.html</a>:<br>
<br>
_____________________________________________________________________________________________________________________________________________<br>
Basic packet format:<br>
<br>
Audio:<br>
<br>
AAC<br>
[1-byte header]<br>
[1-byte codec config indicator (1 - audio data, 0 - codec config
packet)]<br>
[n-bytes audio content or codec config data]<br>
<br>
All others<br>
[1-byte header]<br>
[n-bytes audio content]<br>
<br>
Below is the bit <br>
layout of the header byte of data (table goes from least significant
bit to most significant bit):<br>
<br>
1 bit Number of channels: <br>
0 mono <br>
1 stereo <br>
<br>
1 bit Sample size: <br>
0 8 bits per sample <br>
1 16 bits per sample <br>
<br>
2 bits Sample rate: <br>
0 special or 8KHz <br>
1 11KHz <br>
2 22KHz <br>
3 44KHz <br>
<br>
4 bits Audio type: <br>
0 PCM (big endian) <br>
1 PCM (swf - ADPCM) <br>
2 MP3 <br>
3 PCM (little endian) <br>
4 Nelly Moser ASAO 16KHz Mono <br>
5 Nelly Moser ASAO 8KHz Mono <br>
6 Nelly Moser ASAO <br>
7 G.711 ALaw <br>
8 G.711 MULaw <br>
9 Reserved <br>
a AAC <br>
b Speex <br>
f MP3 8Khz <br>
<br>
Note: For AAC the codec config data is generally a two byte packet
that describes the stream. It must<br>
be published first. Here is the basic code to fill in the codec
config data.<br>
<br>
AACFrame frame = new AACFrame();<br>
int sampleRate = 22100;<br>
int channels = 2;<br>
frame.setSampleRate(sampleRate);<br>
frame.setRateIndex(AACUtils.sampleRateToIndex(sampleRate));<br>
frame.setChannels(channels);<br>
frame.setChannelIndex(AACUtils.channelCountToIndex(sampleRate));<br>
byte[] codecConfig = new byte[2];<br>
AACUtils.encodeAACCodecConfig(frame, codecConfig, 0);<br>
<br>
Note: For AAC the header byte is always 0xaf<br>
<br>
Note: For Speex the audio data must be encoded as 16000Hz wide band<br>
<br>
Video:<br>
<br>
H.264<br>
[1-byte header]<br>
[1-byte codec config indicator (1 - video data, 0 - codec config
packet)]<br>
[3-byte time difference between dts and pts in milliseconds]<br>
[n-bytes video content or codec config data]<br>
<br>
All others<br>
[1-byte header]<br>
[n-bytes audio content]<br>
<br>
Below is the bit layout of the header byte of data (table goes from
least significant bit to most significant bit):<br>
<br>
4 bits Video type: <br>
2 Sorenson Spark (H.263) <br>
3 Screen <br>
4 On2 VP6 <br>
5 On2 VP6A <br>
6 Screen2 <br>
7 H.264 <br>
<br>
2 bit Frame type: <br>
1 K frame (key frame) <br>
2 P frame <br>
3 B frame <br>
<br>
Note: H.264 codec config data is the same as the AVCc packet in a
QuickTime container.<br>
<br>
Note: All timecode data is in milliseconds<br>
_____________________________________________________________________________________________________________________________________________<br>
<br>
Do you know what is the problem in my code and what do I have to do
to make this work ?<br>
<br>
</body>
</html>